blob: 3d07abd6c7300bb4ea1271210e14b5183b39b477 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhb3e376c2017-01-04 15:27:13 +05302 * Copyright (c) 2012-2017 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"
Sushant Kaushik084f6592015-09-10 13:11:56 +053098#include "qwlan_version.h"
c_manjeecfd1efb2015-09-25 19:32:34 +053099#include "wlan_logging_sock_svc.h"
Agrawal Ashishcfe83282016-09-29 13:03:45 +0530100#include "wlan_hdd_misc.h"
Sushant Kaushik084f6592015-09-10 13:11:56 +0530101
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
103#define g_mode_rates_size (12)
104#define a_mode_rates_size (8)
105#define FREQ_BASE_80211G (2407)
106#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700107#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530108#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800110 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700111
112#define HDD2GHZCHAN(freq, chan, flag) { \
113 .band = IEEE80211_BAND_2GHZ, \
114 .center_freq = (freq), \
115 .hw_value = (chan),\
116 .flags = (flag), \
117 .max_antenna_gain = 0 ,\
118 .max_power = 30, \
119}
120
121#define HDD5GHZCHAN(freq, chan, flag) { \
122 .band = IEEE80211_BAND_5GHZ, \
123 .center_freq = (freq), \
124 .hw_value = (chan),\
125 .flags = (flag), \
126 .max_antenna_gain = 0 ,\
127 .max_power = 30, \
128}
129
130#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
131{\
132 .bitrate = rate, \
133 .hw_value = rate_id, \
134 .flags = flag, \
135}
136
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530137#ifdef WLAN_FEATURE_VOWIFI_11R
138#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
139#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
140#endif
141
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530142#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530143#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530144
Sunil Duttc69bccb2014-05-26 21:30:20 +0530145#ifdef WLAN_FEATURE_LINK_LAYER_STATS
146/*
147 * Used to allocate the size of 4096 for the link layer stats.
148 * The size of 4096 is considered assuming that all data per
149 * respective event fit with in the limit.Please take a call
150 * on the limit based on the data requirements on link layer
151 * statistics.
152 */
153#define LL_STATS_EVENT_BUF_SIZE 4096
154#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530155#ifdef WLAN_FEATURE_EXTSCAN
156/*
157 * Used to allocate the size of 4096 for the EXTScan NL data.
158 * The size of 4096 is considered assuming that all data per
159 * respective event fit with in the limit.Please take a call
160 * on the limit based on the data requirements.
161 */
162
163#define EXTSCAN_EVENT_BUF_SIZE 4096
164#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
165#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530166
Atul Mittal115287b2014-07-08 13:26:33 +0530167/*EXT TDLS*/
168/*
169 * Used to allocate the size of 4096 for the TDLS.
170 * The size of 4096 is considered assuming that all data per
171 * respective event fit with in the limit.Please take a call
172 * on the limit based on the data requirements on link layer
173 * statistics.
174 */
175#define EXTTDLS_EVENT_BUF_SIZE 4096
176
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +0530177/*
178 * Values for Mac spoofing feature
179 *
180 */
181#define MAC_ADDR_SPOOFING_FW_HOST_DISABLE 0
182#define MAC_ADDR_SPOOFING_FW_HOST_ENABLE 1
183#define MAC_ADDR_SPOOFING_FW_ENABLE_HOST_DISABLE 2
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +0530184#define MAC_ADDR_SPOOFING_DEFER_INTERVAL 10 //in ms
185
Anurag Chouhan343af7e2016-12-16 13:11:19 +0530186/*
187 * max_sched_scan_plans defined to 10
188 */
189#define MAX_SCHED_SCAN_PLANS 10
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +0530190
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530191static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700192{
193 WLAN_CIPHER_SUITE_WEP40,
194 WLAN_CIPHER_SUITE_WEP104,
195 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800196#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700197#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
198 WLAN_CIPHER_SUITE_KRK,
199 WLAN_CIPHER_SUITE_CCMP,
200#else
201 WLAN_CIPHER_SUITE_CCMP,
202#endif
203#ifdef FEATURE_WLAN_WAPI
204 WLAN_CIPHER_SUITE_SMS4,
205#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700206#ifdef WLAN_FEATURE_11W
207 WLAN_CIPHER_SUITE_AES_CMAC,
208#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700209};
210
211static inline int is_broadcast_ether_addr(const u8 *addr)
212{
213 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
214 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
215}
216
Agrawal Ashish97dec502015-11-26 20:20:58 +0530217const static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530218{
Jeff Johnson295189b2012-06-20 16:38:30 -0700219 HDD2GHZCHAN(2412, 1, 0) ,
220 HDD2GHZCHAN(2417, 2, 0) ,
221 HDD2GHZCHAN(2422, 3, 0) ,
222 HDD2GHZCHAN(2427, 4, 0) ,
223 HDD2GHZCHAN(2432, 5, 0) ,
224 HDD2GHZCHAN(2437, 6, 0) ,
225 HDD2GHZCHAN(2442, 7, 0) ,
226 HDD2GHZCHAN(2447, 8, 0) ,
227 HDD2GHZCHAN(2452, 9, 0) ,
228 HDD2GHZCHAN(2457, 10, 0) ,
229 HDD2GHZCHAN(2462, 11, 0) ,
230 HDD2GHZCHAN(2467, 12, 0) ,
231 HDD2GHZCHAN(2472, 13, 0) ,
232 HDD2GHZCHAN(2484, 14, 0) ,
233};
234
Agrawal Ashish97dec502015-11-26 20:20:58 +0530235const static struct ieee80211_channel hdd_channels_5_GHZ[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700236{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700237 HDD5GHZCHAN(4920, 240, 0) ,
238 HDD5GHZCHAN(4940, 244, 0) ,
239 HDD5GHZCHAN(4960, 248, 0) ,
240 HDD5GHZCHAN(4980, 252, 0) ,
241 HDD5GHZCHAN(5040, 208, 0) ,
242 HDD5GHZCHAN(5060, 212, 0) ,
243 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 HDD5GHZCHAN(5180, 36, 0) ,
245 HDD5GHZCHAN(5200, 40, 0) ,
246 HDD5GHZCHAN(5220, 44, 0) ,
247 HDD5GHZCHAN(5240, 48, 0) ,
248 HDD5GHZCHAN(5260, 52, 0) ,
249 HDD5GHZCHAN(5280, 56, 0) ,
250 HDD5GHZCHAN(5300, 60, 0) ,
251 HDD5GHZCHAN(5320, 64, 0) ,
252 HDD5GHZCHAN(5500,100, 0) ,
253 HDD5GHZCHAN(5520,104, 0) ,
254 HDD5GHZCHAN(5540,108, 0) ,
255 HDD5GHZCHAN(5560,112, 0) ,
256 HDD5GHZCHAN(5580,116, 0) ,
257 HDD5GHZCHAN(5600,120, 0) ,
258 HDD5GHZCHAN(5620,124, 0) ,
259 HDD5GHZCHAN(5640,128, 0) ,
260 HDD5GHZCHAN(5660,132, 0) ,
261 HDD5GHZCHAN(5680,136, 0) ,
262 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800263#ifdef FEATURE_WLAN_CH144
264 HDD5GHZCHAN(5720,144, 0) ,
265#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 HDD5GHZCHAN(5745,149, 0) ,
267 HDD5GHZCHAN(5765,153, 0) ,
268 HDD5GHZCHAN(5785,157, 0) ,
269 HDD5GHZCHAN(5805,161, 0) ,
270 HDD5GHZCHAN(5825,165, 0) ,
271};
272
273static struct ieee80211_rate g_mode_rates[] =
274{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530275 HDD_G_MODE_RATETAB(10, 0x1, 0),
276 HDD_G_MODE_RATETAB(20, 0x2, 0),
277 HDD_G_MODE_RATETAB(55, 0x4, 0),
278 HDD_G_MODE_RATETAB(110, 0x8, 0),
279 HDD_G_MODE_RATETAB(60, 0x10, 0),
280 HDD_G_MODE_RATETAB(90, 0x20, 0),
281 HDD_G_MODE_RATETAB(120, 0x40, 0),
282 HDD_G_MODE_RATETAB(180, 0x80, 0),
283 HDD_G_MODE_RATETAB(240, 0x100, 0),
284 HDD_G_MODE_RATETAB(360, 0x200, 0),
285 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700286 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530287};
Jeff Johnson295189b2012-06-20 16:38:30 -0700288
289static struct ieee80211_rate a_mode_rates[] =
290{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530291 HDD_G_MODE_RATETAB(60, 0x10, 0),
292 HDD_G_MODE_RATETAB(90, 0x20, 0),
293 HDD_G_MODE_RATETAB(120, 0x40, 0),
294 HDD_G_MODE_RATETAB(180, 0x80, 0),
295 HDD_G_MODE_RATETAB(240, 0x100, 0),
296 HDD_G_MODE_RATETAB(360, 0x200, 0),
297 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 HDD_G_MODE_RATETAB(540, 0x800, 0),
299};
300
301static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
302{
Agrawal Ashish97dec502015-11-26 20:20:58 +0530303 .channels = NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
305 .band = IEEE80211_BAND_2GHZ,
306 .bitrates = g_mode_rates,
307 .n_bitrates = g_mode_rates_size,
308 .ht_cap.ht_supported = 1,
309 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
310 | IEEE80211_HT_CAP_GRN_FLD
311 | IEEE80211_HT_CAP_DSSSCCK40
312 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
313 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
314 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
315 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
316 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
317 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
318};
319
Jeff Johnson295189b2012-06-20 16:38:30 -0700320static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
321{
Agrawal Ashish97dec502015-11-26 20:20:58 +0530322 .channels = NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
324 .band = IEEE80211_BAND_5GHZ,
325 .bitrates = a_mode_rates,
326 .n_bitrates = a_mode_rates_size,
327 .ht_cap.ht_supported = 1,
328 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
329 | IEEE80211_HT_CAP_GRN_FLD
330 | IEEE80211_HT_CAP_DSSSCCK40
331 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
332 | IEEE80211_HT_CAP_SGI_40
333 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
334 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
335 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
336 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
337 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
338 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
339};
340
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530341/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700342 TX/RX direction for each kind of interface */
343static const struct ieee80211_txrx_stypes
344wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
345 [NL80211_IFTYPE_STATION] = {
346 .tx = 0xffff,
347 .rx = BIT(SIR_MAC_MGMT_ACTION) |
348 BIT(SIR_MAC_MGMT_PROBE_REQ),
349 },
350 [NL80211_IFTYPE_AP] = {
351 .tx = 0xffff,
352 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
353 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
354 BIT(SIR_MAC_MGMT_PROBE_REQ) |
355 BIT(SIR_MAC_MGMT_DISASSOC) |
356 BIT(SIR_MAC_MGMT_AUTH) |
357 BIT(SIR_MAC_MGMT_DEAUTH) |
358 BIT(SIR_MAC_MGMT_ACTION),
359 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700360 [NL80211_IFTYPE_ADHOC] = {
361 .tx = 0xffff,
362 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
363 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
364 BIT(SIR_MAC_MGMT_PROBE_REQ) |
365 BIT(SIR_MAC_MGMT_DISASSOC) |
366 BIT(SIR_MAC_MGMT_AUTH) |
367 BIT(SIR_MAC_MGMT_DEAUTH) |
368 BIT(SIR_MAC_MGMT_ACTION),
369 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700370 [NL80211_IFTYPE_P2P_CLIENT] = {
371 .tx = 0xffff,
372 .rx = BIT(SIR_MAC_MGMT_ACTION) |
373 BIT(SIR_MAC_MGMT_PROBE_REQ),
374 },
375 [NL80211_IFTYPE_P2P_GO] = {
376 /* This is also same as for SoftAP */
377 .tx = 0xffff,
378 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
379 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
380 BIT(SIR_MAC_MGMT_PROBE_REQ) |
381 BIT(SIR_MAC_MGMT_DISASSOC) |
382 BIT(SIR_MAC_MGMT_AUTH) |
383 BIT(SIR_MAC_MGMT_DEAUTH) |
384 BIT(SIR_MAC_MGMT_ACTION),
385 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700386};
387
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800388#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800389static const struct ieee80211_iface_limit
390wlan_hdd_iface_limit[] = {
391 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800392 /* max = 3 ; Our driver create two interfaces during driver init
393 * wlan0 and p2p0 interfaces. p2p0 is considered as station
394 * interface until a group is formed. In JB architecture, once the
395 * group is formed, interface type of p2p0 is changed to P2P GO or
396 * Client.
397 * When supplicant remove the group, it first issue a set interface
398 * cmd to change the mode back to Station. In JB this works fine as
399 * we advertize two station type interface during driver init.
400 * Some vendors create separate interface for P2P GO/Client,
401 * after group formation(Third one). But while group remove
402 * supplicant first tries to change the mode(3rd interface) to STATION
403 * But as we advertized only two sta type interfaces nl80211 was
404 * returning error for the third one which was leading to failure in
405 * delete interface. Ideally while removing the group, supplicant
406 * should not try to change the 3rd interface mode to Station type.
407 * Till we get a fix in wpa_supplicant, we advertize max STA
408 * interface type to 3
409 */
410 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800411 .types = BIT(NL80211_IFTYPE_STATION),
412 },
413 {
414 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700415 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800416 },
417 {
418 .max = 1,
419 .types = BIT(NL80211_IFTYPE_P2P_GO) |
420 BIT(NL80211_IFTYPE_P2P_CLIENT),
421 },
422};
423
424/* By default, only single channel concurrency is allowed */
425static struct ieee80211_iface_combination
426wlan_hdd_iface_combination = {
427 .limits = wlan_hdd_iface_limit,
428 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800429 /*
430 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
431 * and p2p0 interfaces during driver init
432 * Some vendors create separate interface for P2P operations.
433 * wlan0: STA interface
434 * p2p0: P2P Device interface, action frames goes
435 * through this interface.
436 * p2p-xx: P2P interface, After GO negotiation this interface is
437 * created for p2p operations(GO/CLIENT interface).
438 */
439 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800440 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
441 .beacon_int_infra_match = false,
442};
443#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800444
Jeff Johnson295189b2012-06-20 16:38:30 -0700445static struct cfg80211_ops wlan_hdd_cfg80211_ops;
446
447/* Data rate 100KBPS based on IE Index */
448struct index_data_rate_type
449{
450 v_U8_t beacon_rate_index;
451 v_U16_t supported_rate[4];
452};
453
454/* 11B, 11G Rate table include Basic rate and Extended rate
455 The IDX field is the rate index
456 The HI field is the rate when RSSI is strong or being ignored
457 (in this case we report actual rate)
458 The MID field is the rate when RSSI is moderate
459 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
460 The LO field is the rate when RSSI is low
461 (in this case we don't report rates, actual current rate used)
462 */
463static const struct
464{
465 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700466 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700467} supported_data_rate[] =
468{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700469/* IDX HI HM LM LO (RSSI-based index */
470 {2, { 10, 10, 10, 0}},
471 {4, { 20, 20, 10, 0}},
472 {11, { 55, 20, 10, 0}},
473 {12, { 60, 55, 20, 0}},
474 {18, { 90, 55, 20, 0}},
475 {22, {110, 55, 20, 0}},
476 {24, {120, 90, 60, 0}},
477 {36, {180, 120, 60, 0}},
478 {44, {220, 180, 60, 0}},
479 {48, {240, 180, 90, 0}},
480 {66, {330, 180, 90, 0}},
481 {72, {360, 240, 90, 0}},
482 {96, {480, 240, 120, 0}},
483 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700484};
485
486/* MCS Based rate table */
487static struct index_data_rate_type supported_mcs_rate[] =
488{
489/* MCS L20 L40 S20 S40 */
490 {0, {65, 135, 72, 150}},
491 {1, {130, 270, 144, 300}},
492 {2, {195, 405, 217, 450}},
493 {3, {260, 540, 289, 600}},
494 {4, {390, 810, 433, 900}},
495 {5, {520, 1080, 578, 1200}},
496 {6, {585, 1215, 650, 1350}},
497 {7, {650, 1350, 722, 1500}}
498};
499
Leo Chang6f8870f2013-03-26 18:11:36 -0700500#ifdef WLAN_FEATURE_11AC
501
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530502#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700503
504struct index_vht_data_rate_type
505{
506 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530507 v_U16_t supported_VHT80_rate[2];
508 v_U16_t supported_VHT40_rate[2];
509 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700510};
511
512typedef enum
513{
514 DATA_RATE_11AC_MAX_MCS_7,
515 DATA_RATE_11AC_MAX_MCS_8,
516 DATA_RATE_11AC_MAX_MCS_9,
517 DATA_RATE_11AC_MAX_MCS_NA
518} eDataRate11ACMaxMcs;
519
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530520/* SSID broadcast type */
521typedef enum eSSIDBcastType
522{
523 eBCAST_UNKNOWN = 0,
524 eBCAST_NORMAL = 1,
525 eBCAST_HIDDEN = 2,
526} tSSIDBcastType;
527
Leo Chang6f8870f2013-03-26 18:11:36 -0700528/* MCS Based VHT rate table */
529static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
530{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530531/* MCS L80 S80 L40 S40 L20 S40*/
532 {0, {293, 325}, {135, 150}, {65, 72}},
533 {1, {585, 650}, {270, 300}, {130, 144}},
534 {2, {878, 975}, {405, 450}, {195, 217}},
535 {3, {1170, 1300}, {540, 600}, {260, 289}},
536 {4, {1755, 1950}, {810, 900}, {390, 433}},
537 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
538 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
539 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
540 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
541 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700542};
543#endif /* WLAN_FEATURE_11AC */
544
c_hpothu79aab322014-07-14 21:11:01 +0530545/*array index points to MCS and array value points respective rssi*/
546static int rssiMcsTbl[][10] =
547{
548/*MCS 0 1 2 3 4 5 6 7 8 9*/
549 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
550 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
551 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
552};
553
Jeff Johnson295189b2012-06-20 16:38:30 -0700554extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530555#ifdef FEATURE_WLAN_SCAN_PNO
556static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
557#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700558
Leo Chang9056f462013-08-01 19:21:11 -0700559#ifdef WLAN_NL80211_TESTMODE
560enum wlan_hdd_tm_attr
561{
562 WLAN_HDD_TM_ATTR_INVALID = 0,
563 WLAN_HDD_TM_ATTR_CMD = 1,
564 WLAN_HDD_TM_ATTR_DATA = 2,
565 WLAN_HDD_TM_ATTR_TYPE = 3,
566 /* keep last */
567 WLAN_HDD_TM_ATTR_AFTER_LAST,
568 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
569};
570
571enum wlan_hdd_tm_cmd
572{
573 WLAN_HDD_TM_CMD_WLAN_HB = 1,
574};
575
576#define WLAN_HDD_TM_DATA_MAX_LEN 5000
577
578static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
579{
580 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
581 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
582 .len = WLAN_HDD_TM_DATA_MAX_LEN },
583};
584#endif /* WLAN_NL80211_TESTMODE */
585
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800586#ifdef FEATURE_WLAN_CH_AVOID
587/*
588 * FUNCTION: wlan_hdd_send_avoid_freq_event
589 * This is called when wlan driver needs to send vendor specific
590 * avoid frequency range event to userspace
591 */
592int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
593 tHddAvoidFreqList *pAvoidFreqList)
594{
595 struct sk_buff *vendor_event;
596
597 ENTER();
598
599 if (!pHddCtx)
600 {
601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
602 "%s: HDD context is null", __func__);
603 return -1;
604 }
605
606 if (!pAvoidFreqList)
607 {
608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
609 "%s: pAvoidFreqList is null", __func__);
610 return -1;
611 }
612
613 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530614#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
615 NULL,
616#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800617 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530618 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800619 GFP_KERNEL);
620 if (!vendor_event)
621 {
622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
623 "%s: cfg80211_vendor_event_alloc failed", __func__);
624 return -1;
625 }
626
627 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
628 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
629
630 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
631
632 EXIT();
633 return 0;
634}
635#endif /* FEATURE_WLAN_CH_AVOID */
636
Srinivas Dasari030bad32015-02-18 23:23:54 +0530637/*
638 * FUNCTION: __wlan_hdd_cfg80211_nan_request
639 * This is called when wlan driver needs to send vendor specific
640 * nan request event.
641 */
642static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
643 struct wireless_dev *wdev,
644 const void *data, int data_len)
645{
646 tNanRequestReq nan_req;
647 VOS_STATUS status;
648 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530649 struct net_device *dev = wdev->netdev;
650 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
651 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530652 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
653
654 if (0 == data_len)
655 {
656 hddLog(VOS_TRACE_LEVEL_ERROR,
657 FL("NAN - Invalid Request, length = 0"));
658 return ret_val;
659 }
660
661 if (NULL == data)
662 {
663 hddLog(VOS_TRACE_LEVEL_ERROR,
664 FL("NAN - Invalid Request, data is NULL"));
665 return ret_val;
666 }
667
668 status = wlan_hdd_validate_context(pHddCtx);
669 if (0 != status)
670 {
671 hddLog(VOS_TRACE_LEVEL_ERROR,
672 FL("HDD context is not valid"));
673 return -EINVAL;
674 }
675
676 hddLog(LOG1, FL("Received NAN command"));
677 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
678 (tANI_U8 *)data, data_len);
679
680 /* check the NAN Capability */
681 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
682 {
683 hddLog(VOS_TRACE_LEVEL_ERROR,
684 FL("NAN is not supported by Firmware"));
685 return -EINVAL;
686 }
687
688 nan_req.request_data_len = data_len;
689 nan_req.request_data = data;
690
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530691 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530692 if (VOS_STATUS_SUCCESS == status)
693 {
694 ret_val = 0;
695 }
696 return ret_val;
697}
698
699/*
700 * FUNCTION: wlan_hdd_cfg80211_nan_request
701 * Wrapper to protect the nan vendor command from ssr
702 */
703static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
704 struct wireless_dev *wdev,
705 const void *data, int data_len)
706{
707 int ret;
708
709 vos_ssr_protect(__func__);
710 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
711 vos_ssr_unprotect(__func__);
712
713 return ret;
714}
715
716/*
717 * FUNCTION: wlan_hdd_cfg80211_nan_callback
718 * This is a callback function and it gets called
719 * when we need to report nan response event to
720 * upper layers.
721 */
722static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
723{
724 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
725 struct sk_buff *vendor_event;
726 int status;
727 tSirNanEvent *data;
728
729 ENTER();
730 if (NULL == msg)
731 {
732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
733 FL(" msg received here is null"));
734 return;
735 }
736 data = msg;
737
738 status = wlan_hdd_validate_context(pHddCtx);
739
740 if (0 != status)
741 {
742 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
743 FL("HDD context is not valid"));
744 return;
745 }
746
747 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530748#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
749 NULL,
750#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530751 data->event_data_len +
752 NLMSG_HDRLEN,
753 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
754 GFP_KERNEL);
755
756 if (!vendor_event)
757 {
758 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
759 FL("cfg80211_vendor_event_alloc failed"));
760 return;
761 }
762 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
763 data->event_data_len, data->event_data))
764 {
765 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
766 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
767 kfree_skb(vendor_event);
768 return;
769 }
770 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
771 EXIT();
772}
773
774/*
775 * FUNCTION: wlan_hdd_cfg80211_nan_init
776 * This function is called to register the callback to sme layer
777 */
778inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
779{
780 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
781}
782
783
Sunil Duttc69bccb2014-05-26 21:30:20 +0530784#ifdef WLAN_FEATURE_LINK_LAYER_STATS
785
786static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
787 struct sk_buff *vendor_event)
788{
789 if (nla_put_u8(vendor_event,
790 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
791 stats->rate.preamble) ||
792 nla_put_u8(vendor_event,
793 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
794 stats->rate.nss) ||
795 nla_put_u8(vendor_event,
796 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
797 stats->rate.bw) ||
798 nla_put_u8(vendor_event,
799 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
800 stats->rate.rateMcsIdx) ||
801 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
802 stats->rate.bitrate ) ||
803 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
804 stats->txMpdu ) ||
805 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
806 stats->rxMpdu ) ||
807 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
808 stats->mpduLost ) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
810 stats->retries) ||
811 nla_put_u32(vendor_event,
812 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
813 stats->retriesShort ) ||
814 nla_put_u32(vendor_event,
815 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
816 stats->retriesLong))
817 {
818 hddLog(VOS_TRACE_LEVEL_ERROR,
819 FL("QCA_WLAN_VENDOR_ATTR put fail"));
820 return FALSE;
821 }
822 return TRUE;
823}
824
825static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
826 struct sk_buff *vendor_event)
827{
828 u32 i = 0;
829 struct nlattr *rateInfo;
830 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
831 stats->type) ||
832 nla_put(vendor_event,
833 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
834 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
835 nla_put_u32(vendor_event,
836 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
837 stats->capabilities) ||
838 nla_put_u32(vendor_event,
839 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
840 stats->numRate))
841 {
842 hddLog(VOS_TRACE_LEVEL_ERROR,
843 FL("QCA_WLAN_VENDOR_ATTR put fail"));
844 goto error;
845 }
846
847 rateInfo = nla_nest_start(vendor_event,
848 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530849 if(!rateInfo)
850 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530851 for (i = 0; i < stats->numRate; i++)
852 {
853 struct nlattr *rates;
854 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
855 stats->rateStats +
856 (i * sizeof(tSirWifiRateStat)));
857 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530858 if(!rates)
859 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530860
861 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
862 {
863 hddLog(VOS_TRACE_LEVEL_ERROR,
864 FL("QCA_WLAN_VENDOR_ATTR put fail"));
865 return FALSE;
866 }
867 nla_nest_end(vendor_event, rates);
868 }
869 nla_nest_end(vendor_event, rateInfo);
870
871 return TRUE;
872error:
873 return FALSE;
874}
875
876static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
877 struct sk_buff *vendor_event)
878{
879 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
880 stats->ac ) ||
881 nla_put_u32(vendor_event,
882 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
883 stats->txMpdu ) ||
884 nla_put_u32(vendor_event,
885 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
886 stats->rxMpdu ) ||
887 nla_put_u32(vendor_event,
888 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
889 stats->txMcast ) ||
890 nla_put_u32(vendor_event,
891 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
892 stats->rxMcast ) ||
893 nla_put_u32(vendor_event,
894 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
895 stats->rxAmpdu ) ||
896 nla_put_u32(vendor_event,
897 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
898 stats->txAmpdu ) ||
899 nla_put_u32(vendor_event,
900 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
901 stats->mpduLost )||
902 nla_put_u32(vendor_event,
903 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
904 stats->retries ) ||
905 nla_put_u32(vendor_event,
906 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
907 stats->retriesShort ) ||
908 nla_put_u32(vendor_event,
909 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
910 stats->retriesLong ) ||
911 nla_put_u32(vendor_event,
912 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
913 stats->contentionTimeMin ) ||
914 nla_put_u32(vendor_event,
915 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
916 stats->contentionTimeMax ) ||
917 nla_put_u32(vendor_event,
918 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
919 stats->contentionTimeAvg ) ||
920 nla_put_u32(vendor_event,
921 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
922 stats->contentionNumSamples ))
923 {
924 hddLog(VOS_TRACE_LEVEL_ERROR,
925 FL("QCA_WLAN_VENDOR_ATTR put fail") );
926 return FALSE;
927 }
928 return TRUE;
929}
930
931static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
932 struct sk_buff *vendor_event)
933{
Dino Myclec8f3f332014-07-21 16:48:27 +0530934 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530935 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
936 nla_put(vendor_event,
937 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
938 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
939 nla_put_u32(vendor_event,
940 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
941 stats->state ) ||
942 nla_put_u32(vendor_event,
943 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
944 stats->roaming ) ||
945 nla_put_u32(vendor_event,
946 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
947 stats->capabilities ) ||
948 nla_put(vendor_event,
949 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
950 strlen(stats->ssid), stats->ssid) ||
951 nla_put(vendor_event,
952 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
953 WNI_CFG_BSSID_LEN, stats->bssid) ||
954 nla_put(vendor_event,
955 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
956 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
957 nla_put(vendor_event,
958 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
959 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
960 )
961 {
962 hddLog(VOS_TRACE_LEVEL_ERROR,
963 FL("QCA_WLAN_VENDOR_ATTR put fail") );
964 return FALSE;
965 }
966 return TRUE;
967}
968
Dino Mycle3b9536d2014-07-09 22:05:24 +0530969static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
970 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530971 struct sk_buff *vendor_event)
972{
973 int i = 0;
974 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530975 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
976 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530977 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530978
Sunil Duttc69bccb2014-05-26 21:30:20 +0530979 if (FALSE == put_wifi_interface_info(
980 &pWifiIfaceStat->info,
981 vendor_event))
982 {
983 hddLog(VOS_TRACE_LEVEL_ERROR,
984 FL("QCA_WLAN_VENDOR_ATTR put fail") );
985 return FALSE;
986
987 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530988 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
989 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
990 if (NULL == pWifiIfaceStatTL)
991 {
992 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
993 return FALSE;
994 }
995
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530996 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
997 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
998 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
999 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1000
1001 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1002 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1003 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1004 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301005
1006 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1007 {
1008 if (VOS_STATUS_SUCCESS ==
1009 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1010 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1011 {
1012 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1013 * obtained from TL structure
1014 */
1015
1016 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1017 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301018 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1019
Srinivas Dasari98947432014-11-07 19:41:24 +05301020 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1021 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1022 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1023 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1024 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1025 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1026 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1027 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301028
Srinivas Dasari98947432014-11-07 19:41:24 +05301029 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1030 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1031 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1032 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1033 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1034 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1035 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1036 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301037
Srinivas Dasari98947432014-11-07 19:41:24 +05301038 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1039 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1040 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1041 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1042 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1043 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1044 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1045 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301046 }
1047 else
1048 {
1049 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1050 }
1051
Dino Mycle3b9536d2014-07-09 22:05:24 +05301052 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1053 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1054 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1055 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1056 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1057 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1058 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1059 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1060 }
1061 else
1062 {
1063 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1064 }
1065
1066
Sunil Duttc69bccb2014-05-26 21:30:20 +05301067
1068 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301069 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1070 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
1071 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301072 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1073 pWifiIfaceStat->beaconRx) ||
1074 nla_put_u32(vendor_event,
1075 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1076 pWifiIfaceStat->mgmtRx) ||
1077 nla_put_u32(vendor_event,
1078 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1079 pWifiIfaceStat->mgmtActionRx) ||
1080 nla_put_u32(vendor_event,
1081 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1082 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301083 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301084 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1085 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301086 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301087 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1088 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301089 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301090 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1091 pWifiIfaceStat->rssiAck))
1092 {
1093 hddLog(VOS_TRACE_LEVEL_ERROR,
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05301094 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1095 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301096 return FALSE;
1097 }
1098
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05301099#ifdef FEATURE_EXT_LL_STAT
1100 /*
1101 * Ensure when EXT_LL_STAT is supported by both host and fwr,
1102 * then host should send Leaky AP stats to upper layer,
1103 * otherwise no need to send these stats.
1104 */
1105 if(sme_IsFeatureSupportedByFW(EXT_LL_STAT) &&
1106 sme_IsFeatureSupportedByDriver(EXT_LL_STAT)
1107 )
1108 {
1109 hddLog(VOS_TRACE_LEVEL_INFO,
1110 FL("EXT_LL_STAT is supported by fwr and host %u %u %u %llu"),
1111 pWifiIfaceStat->leakyApStat.is_leaky_ap,
1112 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked,
1113 pWifiIfaceStat->leakyApStat.rx_leak_window,
1114 pWifiIfaceStat->leakyApStat.avg_bcn_spread);
1115 if (nla_put_u32(vendor_event,
1116 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_DETECTED,
1117 pWifiIfaceStat->leakyApStat.is_leaky_ap) ||
1118 nla_put_u32(vendor_event,
1119 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_AVG_NUM_FRAMES_LEAKED,
1120 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked) ||
1121 nla_put_u32(vendor_event,
1122 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_GUARD_TIME,
1123 pWifiIfaceStat->leakyApStat.rx_leak_window) ||
1124 nla_put_u64(vendor_event,
1125 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_AVERAGE_TSF_OFFSET,
1126 pWifiIfaceStat->leakyApStat.avg_bcn_spread))
1127 {
1128 hddLog(VOS_TRACE_LEVEL_ERROR,
1129 FL("EXT_LL_STAT put fail"));
1130 vos_mem_free(pWifiIfaceStatTL);
1131 return FALSE;
1132 }
1133 }
1134#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +05301135 wmmInfo = nla_nest_start(vendor_event,
1136 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301137 if(!wmmInfo)
1138 {
1139 vos_mem_free(pWifiIfaceStatTL);
1140 return FALSE;
1141 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301142 for (i = 0; i < WIFI_AC_MAX; i++)
1143 {
1144 struct nlattr *wmmStats;
1145 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301146 if(!wmmStats)
1147 {
1148 vos_mem_free(pWifiIfaceStatTL);
1149 return FALSE;
1150 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301151 if (FALSE == put_wifi_wmm_ac_stat(
1152 &pWifiIfaceStat->AccessclassStats[i],
1153 vendor_event))
1154 {
1155 hddLog(VOS_TRACE_LEVEL_ERROR,
1156 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301157 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301158 return FALSE;
1159 }
1160
1161 nla_nest_end(vendor_event, wmmStats);
1162 }
1163 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301164 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301165 return TRUE;
1166}
1167
1168static tSirWifiInterfaceMode
1169 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1170{
1171 switch (deviceMode)
1172 {
1173 case WLAN_HDD_INFRA_STATION:
1174 return WIFI_INTERFACE_STA;
1175 case WLAN_HDD_SOFTAP:
1176 return WIFI_INTERFACE_SOFTAP;
1177 case WLAN_HDD_P2P_CLIENT:
1178 return WIFI_INTERFACE_P2P_CLIENT;
1179 case WLAN_HDD_P2P_GO:
1180 return WIFI_INTERFACE_P2P_GO;
1181 case WLAN_HDD_IBSS:
1182 return WIFI_INTERFACE_IBSS;
1183 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301184 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301185 }
1186}
1187
1188static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1189 tpSirWifiInterfaceInfo pInfo)
1190{
1191 v_U8_t *staMac = NULL;
1192 hdd_station_ctx_t *pHddStaCtx;
1193 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1194 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1195
1196 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1197
1198 vos_mem_copy(pInfo->macAddr,
1199 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1200
1201 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1202 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1203 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1204 {
1205 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1206 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1207 {
1208 pInfo->state = WIFI_DISCONNECTED;
1209 }
1210 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1211 {
1212 hddLog(VOS_TRACE_LEVEL_ERROR,
1213 "%s: Session ID %d, Connection is in progress", __func__,
1214 pAdapter->sessionId);
1215 pInfo->state = WIFI_ASSOCIATING;
1216 }
1217 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1218 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1219 {
1220 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1221 hddLog(VOS_TRACE_LEVEL_ERROR,
1222 "%s: client " MAC_ADDRESS_STR
1223 " is in the middle of WPS/EAPOL exchange.", __func__,
1224 MAC_ADDR_ARRAY(staMac));
1225 pInfo->state = WIFI_AUTHENTICATING;
1226 }
1227 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1228 {
1229 pInfo->state = WIFI_ASSOCIATED;
1230 vos_mem_copy(pInfo->bssid,
1231 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1232 vos_mem_copy(pInfo->ssid,
1233 pHddStaCtx->conn_info.SSID.SSID.ssId,
1234 pHddStaCtx->conn_info.SSID.SSID.length);
1235 //NULL Terminate the string.
1236 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1237 }
1238 }
1239 vos_mem_copy(pInfo->countryStr,
1240 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1241
1242 vos_mem_copy(pInfo->apCountryStr,
1243 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1244
1245 return TRUE;
1246}
1247
1248/*
1249 * hdd_link_layer_process_peer_stats () - This function is called after
1250 * receiving Link Layer Peer statistics from FW.This function converts
1251 * the firmware data to the NL data and sends the same to the kernel/upper
1252 * layers.
1253 */
1254static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1255 v_VOID_t *pData)
1256{
1257 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301258 tpSirWifiPeerStat pWifiPeerStat;
1259 tpSirWifiPeerInfo pWifiPeerInfo;
1260 struct nlattr *peerInfo;
1261 struct sk_buff *vendor_event;
1262 int status, i;
1263
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301264 ENTER();
1265
Sunil Duttc69bccb2014-05-26 21:30:20 +05301266 status = wlan_hdd_validate_context(pHddCtx);
1267 if (0 != status)
1268 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301269 return;
1270 }
1271
1272 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1273
1274 hddLog(VOS_TRACE_LEVEL_INFO,
1275 "LL_STATS_PEER_ALL : numPeers %u",
1276 pWifiPeerStat->numPeers);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301277 /*
1278 * Allocate a size of 4096 for the peer stats comprising
1279 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1280 * sizeof (tSirWifiRateStat).Each field is put with an
1281 * NL attribute.The size of 4096 is considered assuming
1282 * that number of rates shall not exceed beyond 50 with
1283 * the sizeof (tSirWifiRateStat) being 32.
1284 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301285 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1286 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301287 if (!vendor_event)
1288 {
1289 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301290 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301291 __func__);
1292 return;
1293 }
1294 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301295 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1296 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
1297 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301298 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1299 pWifiPeerStat->numPeers))
1300 {
1301 hddLog(VOS_TRACE_LEVEL_ERROR,
1302 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1303 kfree_skb(vendor_event);
1304 return;
1305 }
1306
1307 peerInfo = nla_nest_start(vendor_event,
1308 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301309 if(!peerInfo)
1310 {
1311 hddLog(VOS_TRACE_LEVEL_ERROR,
1312 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1313 __func__);
1314 kfree_skb(vendor_event);
1315 return;
1316 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301317
1318 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1319 pWifiPeerStat->peerInfo);
1320
1321 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1322 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301323 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301324 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301325
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301326 if(!peers)
1327 {
1328 hddLog(VOS_TRACE_LEVEL_ERROR,
1329 "%s: peer stats put fail",
1330 __func__);
1331 kfree_skb(vendor_event);
1332 return;
1333 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301334 if (FALSE == put_wifi_peer_info(
1335 pWifiPeerInfo, vendor_event))
1336 {
1337 hddLog(VOS_TRACE_LEVEL_ERROR,
1338 "%s: put_wifi_peer_info put fail", __func__);
1339 kfree_skb(vendor_event);
1340 return;
1341 }
1342
1343 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1344 pWifiPeerStat->peerInfo +
1345 (i * sizeof(tSirWifiPeerInfo)) +
1346 (numRate * sizeof (tSirWifiRateStat)));
1347 nla_nest_end(vendor_event, peers);
1348 }
1349 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301350 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301351 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301352}
1353
1354/*
1355 * hdd_link_layer_process_iface_stats () - This function is called after
1356 * receiving Link Layer Interface statistics from FW.This function converts
1357 * the firmware data to the NL data and sends the same to the kernel/upper
1358 * layers.
1359 */
1360static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1361 v_VOID_t *pData)
1362{
1363 tpSirWifiIfaceStat pWifiIfaceStat;
1364 struct sk_buff *vendor_event;
1365 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1366 int status;
1367
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301368 ENTER();
1369
Sunil Duttc69bccb2014-05-26 21:30:20 +05301370 status = wlan_hdd_validate_context(pHddCtx);
1371 if (0 != status)
1372 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301373 return;
1374 }
1375 /*
1376 * Allocate a size of 4096 for the interface stats comprising
1377 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1378 * assuming that all these fit with in the limit.Please take
1379 * a call on the limit based on the data requirements on
1380 * interface statistics.
1381 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301382 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1383 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301384 if (!vendor_event)
1385 {
1386 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301387 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301388 return;
1389 }
1390
1391 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1392
Dino Mycle3b9536d2014-07-09 22:05:24 +05301393
1394 if (FALSE == hdd_get_interface_info( pAdapter,
1395 &pWifiIfaceStat->info))
1396 {
1397 hddLog(VOS_TRACE_LEVEL_ERROR,
1398 FL("hdd_get_interface_info get fail") );
1399 kfree_skb(vendor_event);
1400 return;
1401 }
1402
1403 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1404 vendor_event))
1405 {
1406 hddLog(VOS_TRACE_LEVEL_ERROR,
1407 FL("put_wifi_iface_stats fail") );
1408 kfree_skb(vendor_event);
1409 return;
1410 }
1411
Sunil Duttc69bccb2014-05-26 21:30:20 +05301412 hddLog(VOS_TRACE_LEVEL_INFO,
1413 "WMI_LINK_STATS_IFACE Data");
1414
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301415 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301416
1417 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301418}
1419
1420/*
1421 * hdd_link_layer_process_radio_stats () - This function is called after
1422 * receiving Link Layer Radio statistics from FW.This function converts
1423 * the firmware data to the NL data and sends the same to the kernel/upper
1424 * layers.
1425 */
1426static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1427 v_VOID_t *pData)
1428{
1429 int status, i;
1430 tpSirWifiRadioStat pWifiRadioStat;
1431 tpSirWifiChannelStats pWifiChannelStats;
1432 struct sk_buff *vendor_event;
1433 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1434 struct nlattr *chList;
1435
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301436 ENTER();
1437
Sunil Duttc69bccb2014-05-26 21:30:20 +05301438 status = wlan_hdd_validate_context(pHddCtx);
1439 if (0 != status)
1440 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301441 return;
1442 }
1443 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1444
1445 hddLog(VOS_TRACE_LEVEL_INFO,
1446 "LL_STATS_RADIO"
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05301447 " number of radios = %u"
Sunil Duttc69bccb2014-05-26 21:30:20 +05301448 " radio is %d onTime is %u "
1449 " txTime is %u rxTime is %u "
1450 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301451 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301452 " onTimePnoScan is %u onTimeHs20 is %u "
1453 " numChannels is %u",
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05301454 NUM_RADIOS,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301455 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1456 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1457 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301458 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301459 pWifiRadioStat->onTimeRoamScan,
1460 pWifiRadioStat->onTimePnoScan,
1461 pWifiRadioStat->onTimeHs20,
1462 pWifiRadioStat->numChannels);
1463 /*
1464 * Allocate a size of 4096 for the Radio stats comprising
1465 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1466 * (tSirWifiChannelStats).Each channel data is put with an
1467 * NL attribute.The size of 4096 is considered assuming that
1468 * number of channels shall not exceed beyond 60 with the
1469 * sizeof (tSirWifiChannelStats) being 24 bytes.
1470 */
1471
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301472 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1473 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301474 if (!vendor_event)
1475 {
1476 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301477 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301478 return;
1479 }
1480
1481 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301482 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1483 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
1484 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301485 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1486 pWifiRadioStat->radio) ||
1487 nla_put_u32(vendor_event,
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05301488 QCA_WLAN_VENDOR_ATTR_LL_STATS_NUM_RADIOS,
1489 NUM_RADIOS) ||
1490 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301491 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1492 pWifiRadioStat->onTime) ||
1493 nla_put_u32(vendor_event,
1494 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1495 pWifiRadioStat->txTime) ||
1496 nla_put_u32(vendor_event,
1497 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1498 pWifiRadioStat->rxTime) ||
1499 nla_put_u32(vendor_event,
1500 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1501 pWifiRadioStat->onTimeScan) ||
1502 nla_put_u32(vendor_event,
1503 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1504 pWifiRadioStat->onTimeNbd) ||
1505 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301506 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1507 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301508 nla_put_u32(vendor_event,
1509 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1510 pWifiRadioStat->onTimeRoamScan) ||
1511 nla_put_u32(vendor_event,
1512 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1513 pWifiRadioStat->onTimePnoScan) ||
1514 nla_put_u32(vendor_event,
1515 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1516 pWifiRadioStat->onTimeHs20) ||
1517 nla_put_u32(vendor_event,
1518 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1519 pWifiRadioStat->numChannels))
1520 {
1521 hddLog(VOS_TRACE_LEVEL_ERROR,
1522 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1523 kfree_skb(vendor_event);
1524 return ;
1525 }
1526
1527 chList = nla_nest_start(vendor_event,
1528 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301529 if(!chList)
1530 {
1531 hddLog(VOS_TRACE_LEVEL_ERROR,
1532 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1533 __func__);
1534 kfree_skb(vendor_event);
1535 return;
1536 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301537 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1538 {
1539 struct nlattr *chInfo;
1540
1541 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1542 pWifiRadioStat->channels +
1543 (i * sizeof(tSirWifiChannelStats)));
1544
Sunil Duttc69bccb2014-05-26 21:30:20 +05301545 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301546 if(!chInfo)
1547 {
1548 hddLog(VOS_TRACE_LEVEL_ERROR,
1549 "%s: failed to put chInfo",
1550 __func__);
1551 kfree_skb(vendor_event);
1552 return;
1553 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301554
1555 if (nla_put_u32(vendor_event,
1556 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1557 pWifiChannelStats->channel.width) ||
1558 nla_put_u32(vendor_event,
1559 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1560 pWifiChannelStats->channel.centerFreq) ||
1561 nla_put_u32(vendor_event,
1562 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1563 pWifiChannelStats->channel.centerFreq0) ||
1564 nla_put_u32(vendor_event,
1565 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1566 pWifiChannelStats->channel.centerFreq1) ||
1567 nla_put_u32(vendor_event,
1568 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1569 pWifiChannelStats->onTime) ||
1570 nla_put_u32(vendor_event,
1571 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1572 pWifiChannelStats->ccaBusyTime))
1573 {
1574 hddLog(VOS_TRACE_LEVEL_ERROR,
1575 FL("cfg80211_vendor_event_alloc failed") );
1576 kfree_skb(vendor_event);
1577 return ;
1578 }
1579 nla_nest_end(vendor_event, chInfo);
1580 }
1581 nla_nest_end(vendor_event, chList);
1582
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301583 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301584
1585 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301586 return;
1587}
1588
1589/*
1590 * hdd_link_layer_stats_ind_callback () - This function is called after
1591 * receiving Link Layer indications from FW.This callback converts the firmware
1592 * data to the NL data and send the same to the kernel/upper layers.
1593 */
1594static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1595 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301596 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301597{
Dino Mycled3d50022014-07-07 12:58:25 +05301598 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1599 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301600 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05301601 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301602 int status;
1603
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301604 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301605
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301606 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301607 if (0 != status)
1608 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301609 return;
1610 }
1611
Dino Mycled3d50022014-07-07 12:58:25 +05301612 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1613 if (NULL == pAdapter)
1614 {
1615 hddLog(VOS_TRACE_LEVEL_ERROR,
1616 FL(" MAC address %pM does not exist with host"),
1617 macAddr);
1618 return;
1619 }
1620
Sunil Duttc69bccb2014-05-26 21:30:20 +05301621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301622 "%s: Interface: %s LLStats indType: %d", __func__,
1623 pAdapter->dev->name, indType);
1624
Sunil Duttc69bccb2014-05-26 21:30:20 +05301625 switch (indType)
1626 {
1627 case SIR_HAL_LL_STATS_RESULTS_RSP:
1628 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301629 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301630 "LL_STATS RESP paramID = 0x%x, ifaceId = %u MAC: %pM "
1631 "respId = %u, moreResultToFollow = %u",
1632 linkLayerStatsResults->paramId, linkLayerStatsResults->ifaceId,
1633 macAddr, linkLayerStatsResults->respId,
1634 linkLayerStatsResults->moreResultToFollow);
1635
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301636 spin_lock(&hdd_context_lock);
1637 context = &pHddCtx->ll_stats_context;
1638 /* validate response received from target */
1639 if ((context->request_id != linkLayerStatsResults->respId) ||
1640 !(context->request_bitmap & linkLayerStatsResults->paramId))
1641 {
1642 spin_unlock(&hdd_context_lock);
1643 hddLog(LOGE,
1644 FL("Error : Request id %d response id %d request bitmap 0x%x"
1645 "response bitmap 0x%x"),
1646 context->request_id, linkLayerStatsResults->respId,
1647 context->request_bitmap, linkLayerStatsResults->paramId);
1648 return;
1649 }
1650 spin_unlock(&hdd_context_lock);
1651
Sunil Duttc69bccb2014-05-26 21:30:20 +05301652 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1653 {
1654 hdd_link_layer_process_radio_stats(pAdapter,
1655 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301656 spin_lock(&hdd_context_lock);
1657 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
1658 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301659 }
1660 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1661 {
1662 hdd_link_layer_process_iface_stats(pAdapter,
1663 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301664 spin_lock(&hdd_context_lock);
1665 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
1666 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301667 }
1668 else if ( linkLayerStatsResults->paramId &
1669 WMI_LINK_STATS_ALL_PEER )
1670 {
1671 hdd_link_layer_process_peer_stats(pAdapter,
1672 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301673 spin_lock(&hdd_context_lock);
1674 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
1675 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301676 } /* WMI_LINK_STATS_ALL_PEER */
1677 else
1678 {
1679 hddLog(VOS_TRACE_LEVEL_ERROR,
1680 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1681 }
1682
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301683 spin_lock(&hdd_context_lock);
1684 /* complete response event if all requests are completed */
1685 if (0 == context->request_bitmap)
1686 complete(&context->response_event);
1687 spin_unlock(&hdd_context_lock);
1688
Sunil Duttc69bccb2014-05-26 21:30:20 +05301689 break;
1690 }
1691 default:
1692 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1693 break;
1694 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301695
1696 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301697 return;
1698}
1699
1700const struct
1701nla_policy
1702qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1703{
1704 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1705 { .type = NLA_U32 },
1706 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1707 { .type = NLA_U32 },
1708};
1709
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301710static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1711 struct wireless_dev *wdev,
1712 const void *data,
1713 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301714{
1715 int status;
1716 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301717 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301718 struct net_device *dev = wdev->netdev;
1719 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1720 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1721
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301722 ENTER();
1723
Sunil Duttc69bccb2014-05-26 21:30:20 +05301724 status = wlan_hdd_validate_context(pHddCtx);
1725 if (0 != status)
1726 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301727 return -EINVAL;
1728 }
1729
1730 if (NULL == pAdapter)
1731 {
1732 hddLog(VOS_TRACE_LEVEL_ERROR,
1733 FL("HDD adapter is Null"));
1734 return -ENODEV;
1735 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301736 /* check the LLStats Capability */
1737 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1738 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1739 {
Anurag Chouhan65ea6dc2016-10-25 19:59:14 +05301740 hddLog(VOS_TRACE_LEVEL_WARN,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301741 FL("Link Layer Statistics not supported by Firmware"));
1742 return -EINVAL;
1743 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301744
1745 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1746 (struct nlattr *)data,
1747 data_len, qca_wlan_vendor_ll_set_policy))
1748 {
1749 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1750 return -EINVAL;
1751 }
1752 if (!tb_vendor
1753 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1754 {
1755 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1756 return -EINVAL;
1757 }
1758 if (!tb_vendor[
1759 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1760 {
1761 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1762 return -EINVAL;
1763 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301764 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301765 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301766
Dino Mycledf0a5d92014-07-04 09:41:55 +05301767 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301768 nla_get_u32(
1769 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1770
Dino Mycledf0a5d92014-07-04 09:41:55 +05301771 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301772 nla_get_u32(
1773 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1774
Dino Mycled3d50022014-07-07 12:58:25 +05301775 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1776 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301777
1778
1779 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301780 "LL_STATS_SET reqId = %d, MAC = %pM, mpduSizeThreshold = %d "
1781 "Statistics Gathering = %d ",
1782 linkLayerStatsSetReq.reqId, linkLayerStatsSetReq.macAddr,
1783 linkLayerStatsSetReq.mpduSizeThreshold,
1784 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301785
1786 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1787 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301788 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301789 {
1790 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1791 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301792 return -EINVAL;
1793
1794 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301795
Sunil Duttc69bccb2014-05-26 21:30:20 +05301796 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301797 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301798 {
1799 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1800 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301801 return -EINVAL;
1802 }
1803
1804 pAdapter->isLinkLayerStatsSet = 1;
1805
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301806 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301807 return 0;
1808}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301809static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1810 struct wireless_dev *wdev,
1811 const void *data,
1812 int data_len)
1813{
1814 int ret = 0;
1815
1816 vos_ssr_protect(__func__);
1817 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1818 vos_ssr_unprotect(__func__);
1819
1820 return ret;
1821}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301822
1823const struct
1824nla_policy
1825qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1826{
1827 /* Unsigned 32bit value provided by the caller issuing the GET stats
1828 * command. When reporting
1829 * the stats results, the driver uses the same value to indicate
1830 * which GET request the results
1831 * correspond to.
1832 */
1833 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1834
1835 /* Unsigned 32bit value . bit mask to identify what statistics are
1836 requested for retrieval */
1837 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1838};
1839
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301840static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1841 struct wireless_dev *wdev,
1842 const void *data,
1843 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301844{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301845 unsigned long rc;
1846 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301847 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1848 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301849 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301850 struct net_device *dev = wdev->netdev;
1851 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05301852 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301853 int status;
1854
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301855 ENTER();
1856
Sunil Duttc69bccb2014-05-26 21:30:20 +05301857 status = wlan_hdd_validate_context(pHddCtx);
1858 if (0 != status)
1859 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301860 return -EINVAL ;
1861 }
1862
1863 if (NULL == pAdapter)
1864 {
1865 hddLog(VOS_TRACE_LEVEL_FATAL,
1866 "%s: HDD adapter is Null", __func__);
1867 return -ENODEV;
1868 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05301869
1870 if (pHddStaCtx == NULL)
1871 {
1872 hddLog(VOS_TRACE_LEVEL_FATAL,
1873 "%s: HddStaCtx is Null", __func__);
1874 return -ENODEV;
1875 }
1876
Dino Mycledf0a5d92014-07-04 09:41:55 +05301877 /* check the LLStats Capability */
1878 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1879 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1880 {
1881 hddLog(VOS_TRACE_LEVEL_ERROR,
1882 FL("Link Layer Statistics not supported by Firmware"));
1883 return -EINVAL;
1884 }
1885
Sunil Duttc69bccb2014-05-26 21:30:20 +05301886
1887 if (!pAdapter->isLinkLayerStatsSet)
1888 {
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05301889 hddLog(VOS_TRACE_LEVEL_ERROR,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301890 "%s: isLinkLayerStatsSet : %d",
1891 __func__, pAdapter->isLinkLayerStatsSet);
1892 return -EINVAL;
1893 }
1894
Mukul Sharma10313ba2015-07-29 19:14:39 +05301895 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1896 {
1897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1898 "%s: Roaming in progress, so unable to proceed this request", __func__);
1899 return -EBUSY;
1900 }
1901
Sunil Duttc69bccb2014-05-26 21:30:20 +05301902 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
1903 (struct nlattr *)data,
1904 data_len, qca_wlan_vendor_ll_get_policy))
1905 {
1906 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1907 return -EINVAL;
1908 }
1909
1910 if (!tb_vendor
1911 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
1912 {
1913 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
1914 return -EINVAL;
1915 }
1916
1917 if (!tb_vendor
1918 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
1919 {
1920 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
1921 return -EINVAL;
1922 }
1923
Sunil Duttc69bccb2014-05-26 21:30:20 +05301924
Dino Mycledf0a5d92014-07-04 09:41:55 +05301925 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301926 nla_get_u32( tb_vendor[
1927 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05301928 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301929 nla_get_u32( tb_vendor[
1930 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
1931
Dino Mycled3d50022014-07-07 12:58:25 +05301932 vos_mem_copy(linkLayerStatsGetReq.macAddr,
1933 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301934
1935 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301936 "LL_STATS_GET reqId = %d, MAC = %pM, paramIdMask = %d",
1937 linkLayerStatsGetReq.reqId, linkLayerStatsGetReq.macAddr,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301938 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301939
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301940 spin_lock(&hdd_context_lock);
1941 context = &pHddCtx->ll_stats_context;
1942 context->request_id = linkLayerStatsGetReq.reqId;
1943 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
1944 INIT_COMPLETION(context->response_event);
1945 spin_unlock(&hdd_context_lock);
1946
Sunil Duttc69bccb2014-05-26 21:30:20 +05301947 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301948 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301949 {
1950 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1951 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301952 return -EINVAL;
1953 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301954
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301955 rc = wait_for_completion_timeout(&context->response_event,
1956 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
1957 if (!rc)
1958 {
1959 hddLog(LOGE,
1960 FL("Target response timed out request id %d request bitmap 0x%x"),
1961 context->request_id, context->request_bitmap);
1962 return -ETIMEDOUT;
1963 }
1964
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301965 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301966 return 0;
1967}
1968
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301969static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1970 struct wireless_dev *wdev,
1971 const void *data,
1972 int data_len)
1973{
1974 int ret = 0;
1975
1976 vos_ssr_protect(__func__);
1977 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
1978 vos_ssr_unprotect(__func__);
1979
1980 return ret;
1981}
1982
Sunil Duttc69bccb2014-05-26 21:30:20 +05301983const struct
1984nla_policy
1985qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
1986{
1987 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
1988 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
1989 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
1990 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
1991};
1992
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301993static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
1994 struct wireless_dev *wdev,
1995 const void *data,
1996 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301997{
1998 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1999 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302000 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302001 struct net_device *dev = wdev->netdev;
2002 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2003 u32 statsClearReqMask;
2004 u8 stopReq;
2005 int status;
2006
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302007 ENTER();
2008
Sunil Duttc69bccb2014-05-26 21:30:20 +05302009 status = wlan_hdd_validate_context(pHddCtx);
2010 if (0 != status)
2011 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302012 return -EINVAL;
2013 }
2014
2015 if (NULL == pAdapter)
2016 {
2017 hddLog(VOS_TRACE_LEVEL_FATAL,
2018 "%s: HDD adapter is Null", __func__);
2019 return -ENODEV;
2020 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302021 /* check the LLStats Capability */
2022 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2023 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2024 {
2025 hddLog(VOS_TRACE_LEVEL_ERROR,
2026 FL("Enable LLStats Capability"));
2027 return -EINVAL;
2028 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302029
2030 if (!pAdapter->isLinkLayerStatsSet)
2031 {
2032 hddLog(VOS_TRACE_LEVEL_FATAL,
2033 "%s: isLinkLayerStatsSet : %d",
2034 __func__, pAdapter->isLinkLayerStatsSet);
2035 return -EINVAL;
2036 }
2037
2038 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2039 (struct nlattr *)data,
2040 data_len, qca_wlan_vendor_ll_clr_policy))
2041 {
2042 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2043 return -EINVAL;
2044 }
2045
2046 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2047
2048 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2049 {
2050 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2051 return -EINVAL;
2052
2053 }
2054
Sunil Duttc69bccb2014-05-26 21:30:20 +05302055
Dino Mycledf0a5d92014-07-04 09:41:55 +05302056 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302057 nla_get_u32(
2058 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2059
Dino Mycledf0a5d92014-07-04 09:41:55 +05302060 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302061 nla_get_u8(
2062 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2063
2064 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302065 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302066
Dino Mycled3d50022014-07-07 12:58:25 +05302067 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2068 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302069
2070 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302071 "LL_STATS_CLEAR reqId = %d, MAC = %pM,"
2072 "statsClearReqMask = 0x%X, stopReq = %d",
2073 linkLayerStatsClearReq.reqId,
2074 linkLayerStatsClearReq.macAddr,
2075 linkLayerStatsClearReq.statsClearReqMask,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302076 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302077
2078 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302079 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302080 {
2081 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302082 hdd_station_ctx_t *pHddStaCtx;
2083
2084 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2085 if (VOS_STATUS_SUCCESS !=
2086 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2087 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2088 {
2089 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2090 "WLANTL_ClearInterfaceStats Failed", __func__);
2091 return -EINVAL;
2092 }
2093 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2094 (statsClearReqMask & WIFI_STATS_IFACE)) {
2095 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2096 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2097 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2098 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2099 }
2100
Sunil Duttc69bccb2014-05-26 21:30:20 +05302101 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2102 2 * sizeof(u32) +
2103 NLMSG_HDRLEN);
2104
2105 if (temp_skbuff != NULL)
2106 {
2107
2108 if (nla_put_u32(temp_skbuff,
2109 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2110 statsClearReqMask) ||
2111 nla_put_u32(temp_skbuff,
2112 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2113 stopReq))
2114 {
2115 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2116 kfree_skb(temp_skbuff);
2117 return -EINVAL;
2118 }
2119 /* If the ask is to stop the stats collection as part of clear
2120 * (stopReq = 1) , ensure that no further requests of get
2121 * go to the firmware by having isLinkLayerStatsSet set to 0.
2122 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302123 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302124 * case the firmware is just asked to clear the statistics.
2125 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302126 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302127 pAdapter->isLinkLayerStatsSet = 0;
2128 return cfg80211_vendor_cmd_reply(temp_skbuff);
2129 }
2130 return -ENOMEM;
2131 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302132
2133 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302134 return -EINVAL;
2135}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302136static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2137 struct wireless_dev *wdev,
2138 const void *data,
2139 int data_len)
2140{
2141 int ret = 0;
2142
2143 vos_ssr_protect(__func__);
2144 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2145 vos_ssr_unprotect(__func__);
2146
2147 return ret;
2148
2149
2150}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302151#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2152
Dino Mycle6fb96c12014-06-10 11:52:40 +05302153#ifdef WLAN_FEATURE_EXTSCAN
2154static const struct nla_policy
2155wlan_hdd_extscan_config_policy
2156 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2157{
2158 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2159 { .type = NLA_U32 },
2160 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2161 { .type = NLA_U32 },
2162 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2163 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2164 { .type = NLA_U32 },
2165 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2166 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2167
2168 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2169 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2170 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2171 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2172 { .type = NLA_U8 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302173 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD] =
2174 { .type = NLA_U32 },
2175 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT] =
2176 { .type = NLA_U32 },
2177 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT] =
2178 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302179 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2180 { .type = NLA_U32 },
2181 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2182 { .type = NLA_U32 },
2183 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2184 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302185 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT] =
2186 { .type = NLA_U8 },
2187 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302188 { .type = NLA_U8 },
2189 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2190 { .type = NLA_U8 },
2191 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2192 { .type = NLA_U8 },
2193
2194 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2195 { .type = NLA_U32 },
2196 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2197 { .type = NLA_UNSPEC },
2198 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2199 { .type = NLA_S32 },
2200 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2201 { .type = NLA_S32 },
2202 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2203 { .type = NLA_U32 },
2204 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2205 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302206 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE] =
2207 { .type = NLA_U32 },
2208 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID] =
2209 { .type = NLA_BINARY,
2210 .len = IEEE80211_MAX_SSID_LEN + 1 },
2211 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302212 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302213 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID] =
2214 { .type = NLA_U32 },
2215 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND] =
2216 { .type = NLA_U8 },
2217 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW] =
2218 { .type = NLA_S32 },
2219 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH] =
2220 { .type = NLA_S32 },
2221 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS] =
2222 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302223};
2224
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302225/**
2226 * wlan_hdd_cfg80211_extscan_get_capabilities_rsp() - response from target
2227 * @ctx: hdd global context
2228 * @data: capabilities data
2229 *
2230 * Return: none
2231 */
2232static void
2233wlan_hdd_cfg80211_extscan_get_capabilities_rsp(void *ctx, void *pMsg)
Dino Mycle6fb96c12014-06-10 11:52:40 +05302234{
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302235 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302236 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302237 tSirEXTScanCapabilitiesEvent *data =
2238 (tSirEXTScanCapabilitiesEvent *) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302239
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302240 ENTER();
2241
2242 if (wlan_hdd_validate_context(pHddCtx))
2243 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302244 return;
2245 }
2246
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302247 if (!pMsg)
2248 {
2249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2250 return;
2251 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302252
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302253 vos_spin_lock_acquire(&hdd_context_lock);
2254
2255 context = &pHddCtx->ext_scan_context;
2256 /* validate response received from target*/
2257 if (context->request_id != data->requestId)
2258 {
2259 vos_spin_lock_release(&hdd_context_lock);
2260 hddLog(LOGE,
2261 FL("Target response id did not match: request_id %d resposne_id %d"),
2262 context->request_id, data->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302263 return;
2264 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302265 else
2266 {
2267 context->capability_response = *data;
2268 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302269 }
2270
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302271 vos_spin_lock_release(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302272
Dino Mycle6fb96c12014-06-10 11:52:40 +05302273 return;
2274}
2275
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302276/*
2277 * define short names for the global vendor params
2278 * used by wlan_hdd_send_ext_scan_capability()
2279 */
2280#define PARAM_REQUEST_ID \
2281 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
2282#define PARAM_STATUS \
2283 QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS
2284#define MAX_SCAN_CACHE_SIZE \
2285 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE
2286#define MAX_SCAN_BUCKETS \
2287 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS
2288#define MAX_AP_CACHE_PER_SCAN \
2289 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN
2290#define MAX_RSSI_SAMPLE_SIZE \
2291 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE
2292#define MAX_SCAN_RPT_THRHOLD \
2293 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD
2294#define MAX_HOTLIST_BSSIDS \
2295 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS
2296#define MAX_BSSID_HISTORY_ENTRIES \
2297 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES
2298#define MAX_HOTLIST_SSIDS \
2299 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302300#define MAX_SIGNIFICANT_WIFI_CHANGE_APS \
2301 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302302
2303static int wlan_hdd_send_ext_scan_capability(void *ctx)
2304{
2305 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2306 struct sk_buff *skb = NULL;
2307 int ret;
2308 tSirEXTScanCapabilitiesEvent *data;
2309 tANI_U32 nl_buf_len;
2310
2311 ret = wlan_hdd_validate_context(pHddCtx);
2312 if (0 != ret)
2313 {
2314 return ret;
2315 }
2316
2317 data = &(pHddCtx->ext_scan_context.capability_response);
2318
2319 nl_buf_len = NLMSG_HDRLEN;
2320 nl_buf_len += (sizeof(data->requestId) + NLA_HDRLEN) +
2321 (sizeof(data->status) + NLA_HDRLEN) +
2322 (sizeof(data->scanCacheSize) + NLA_HDRLEN) +
2323 (sizeof(data->scanBuckets) + NLA_HDRLEN) +
2324 (sizeof(data->maxApPerScan) + NLA_HDRLEN) +
2325 (sizeof(data->maxRssiSampleSize) + NLA_HDRLEN) +
2326 (sizeof(data->maxScanReportingThreshold) + NLA_HDRLEN) +
2327 (sizeof(data->maxHotlistAPs) + NLA_HDRLEN) +
2328 (sizeof(data->maxBsidHistoryEntries) + NLA_HDRLEN) +
2329 (sizeof(data->maxHotlistSSIDs) + NLA_HDRLEN);
2330
2331 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, nl_buf_len);
2332
2333 if (!skb)
2334 {
2335 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
2336 return -ENOMEM;
2337 }
2338
2339 hddLog(LOG1, "Req Id (%u) Status (%u)", data->requestId, data->status);
2340 hddLog(LOG1, "Scan cache size (%u) Scan buckets (%u) Max AP per scan (%u)",
2341 data->scanCacheSize, data->scanBuckets, data->maxApPerScan);
2342 hddLog(LOG1, "max_rssi_sample_size (%u) max_scan_reporting_threshold (%u)",
2343 data->maxRssiSampleSize, data->maxScanReportingThreshold);
2344 hddLog(LOG1, "max_hotlist_bssids (%u) max_bssid_history_entries (%u)"
2345 "max_hotlist_ssids (%u)", data->maxHotlistAPs,
2346 data->maxBsidHistoryEntries, data->maxHotlistSSIDs);
2347
2348 if (nla_put_u32(skb, PARAM_REQUEST_ID, data->requestId) ||
2349 nla_put_u32(skb, PARAM_STATUS, data->status) ||
2350 nla_put_u32(skb, MAX_SCAN_CACHE_SIZE, data->scanCacheSize) ||
2351 nla_put_u32(skb, MAX_SCAN_BUCKETS, data->scanBuckets) ||
2352 nla_put_u32(skb, MAX_AP_CACHE_PER_SCAN,
2353 data->maxApPerScan) ||
2354 nla_put_u32(skb, MAX_RSSI_SAMPLE_SIZE,
2355 data->maxRssiSampleSize) ||
2356 nla_put_u32(skb, MAX_SCAN_RPT_THRHOLD,
2357 data->maxScanReportingThreshold) ||
2358 nla_put_u32(skb, MAX_HOTLIST_BSSIDS, data->maxHotlistAPs) ||
2359 nla_put_u32(skb, MAX_BSSID_HISTORY_ENTRIES,
2360 data->maxBsidHistoryEntries) ||
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302361 nla_put_u32(skb, MAX_HOTLIST_SSIDS, data->maxHotlistSSIDs) ||
2362 nla_put_u32(skb, MAX_SIGNIFICANT_WIFI_CHANGE_APS, 0))
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302363 {
2364 hddLog(LOGE, FL("nla put fail"));
2365 goto nla_put_failure;
2366 }
2367
2368 cfg80211_vendor_cmd_reply(skb);
2369 return 0;
2370
2371nla_put_failure:
2372 kfree_skb(skb);
2373 return -EINVAL;;
2374}
2375
2376/*
2377 * done with short names for the global vendor params
2378 * used by wlan_hdd_send_ext_scan_capability()
2379 */
2380#undef PARAM_REQUEST_ID
2381#undef PARAM_STATUS
2382#undef MAX_SCAN_CACHE_SIZE
2383#undef MAX_SCAN_BUCKETS
2384#undef MAX_AP_CACHE_PER_SCAN
2385#undef MAX_RSSI_SAMPLE_SIZE
2386#undef MAX_SCAN_RPT_THRHOLD
2387#undef MAX_HOTLIST_BSSIDS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302388#undef MAX_BSSID_HISTORY_ENTRIES
2389#undef MAX_HOTLIST_SSIDS
Dino Mycle6fb96c12014-06-10 11:52:40 +05302390
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;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302395 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302396 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302397
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302398 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302399
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302400 if (wlan_hdd_validate_context(pHddCtx))
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302401 return;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302402
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302403 if (!pMsg)
2404 {
2405 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302406 return;
2407 }
2408
Dino Mycle6fb96c12014-06-10 11:52:40 +05302409 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2410 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2411
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302412 context = &pHddCtx->ext_scan_context;
2413 spin_lock(&hdd_context_lock);
2414 if (context->request_id == pData->requestId) {
2415 context->response_status = pData->status ? -EINVAL : 0;
2416 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302417 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302418 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302419
2420 /*
2421 * Store the Request ID for comparing with the requestID obtained
2422 * in other requests.HDD shall return a failure is the extscan_stop
2423 * request is issued with a different requestId as that of the
2424 * extscan_start request. Also, This requestId shall be used while
2425 * indicating the full scan results to the upper layers.
2426 * The requestId is stored with the assumption that the firmware
2427 * shall return the ext scan start request's requestId in ext scan
2428 * start response.
2429 */
2430 if (pData->status == 0)
2431 pMac->sme.extScanStartReqId = pData->requestId;
2432
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302433 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302434 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302435}
2436
2437
2438static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2439{
2440 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2441 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302442 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302443
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302444 ENTER();
2445
2446 if (wlan_hdd_validate_context(pHddCtx)){
2447 return;
2448 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302449
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302450 if (!pMsg)
2451 {
2452 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302453 return;
2454 }
2455
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302456 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2457 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302458
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302459 context = &pHddCtx->ext_scan_context;
2460 spin_lock(&hdd_context_lock);
2461 if (context->request_id == pData->requestId) {
2462 context->response_status = pData->status ? -EINVAL : 0;
2463 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302464 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302465 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302466
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302467 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302468 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302469}
2470
Dino Mycle6fb96c12014-06-10 11:52:40 +05302471static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2472 void *pMsg)
2473{
2474 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302475 tpSirEXTScanSetBssidHotListRspParams pData =
2476 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302477 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302478
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302479 ENTER();
2480
2481 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302482 return;
2483 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302484
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302485 if (!pMsg)
2486 {
2487 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2488 return;
2489 }
2490
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302491 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2492 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302493
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302494 context = &pHddCtx->ext_scan_context;
2495 spin_lock(&hdd_context_lock);
2496 if (context->request_id == pData->requestId) {
2497 context->response_status = pData->status ? -EINVAL : 0;
2498 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302499 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302500 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302501
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302502 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302503 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302504}
2505
2506static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2507 void *pMsg)
2508{
2509 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302510 tpSirEXTScanResetBssidHotlistRspParams pData =
2511 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302512 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302513
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302514 ENTER();
2515
2516 if (wlan_hdd_validate_context(pHddCtx)) {
2517 return;
2518 }
2519 if (!pMsg)
2520 {
2521 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302522 return;
2523 }
2524
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302525 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2526 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302527
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302528 context = &pHddCtx->ext_scan_context;
2529 spin_lock(&hdd_context_lock);
2530 if (context->request_id == pData->requestId) {
2531 context->response_status = pData->status ? -EINVAL : 0;
2532 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302533 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302534 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302535
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302536 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302537 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302538}
2539
Dino Mycle6fb96c12014-06-10 11:52:40 +05302540static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2541 void *pMsg)
2542{
2543 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2544 struct sk_buff *skb = NULL;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302545 tANI_U32 i = 0, j, resultsPerEvent, scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302546 tANI_S32 totalResults;
2547 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302548 tpSirWifiScanResult pSirWifiScanResult, head_ptr;
2549 struct hdd_ext_scan_context *context;
2550 bool ignore_cached_results = false;
2551 tExtscanCachedScanResult *result;
2552 struct nlattr *nla_results;
2553 tANI_U16 ieLength= 0;
2554 tANI_U8 *ie = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302555
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302556 ENTER();
2557
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302558 if (wlan_hdd_validate_context(pHddCtx))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302559 return;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302560
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302561 if (!pMsg)
2562 {
2563 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2564 return;
2565 }
2566
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302567 spin_lock(&hdd_context_lock);
2568 context = &pHddCtx->ext_scan_context;
2569 ignore_cached_results = context->ignore_cached_results;
2570 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302571
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302572 if (ignore_cached_results) {
2573 hddLog(LOGE,
2574 FL("Ignore the cached results received after timeout"));
2575 return;
2576 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302577
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302578 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u More Data %u No of scan ids %u",
2579 pData->requestId, pData->moreData, pData->scanResultSize);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302580
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302581 result = (tExtscanCachedScanResult *)&(pData->result);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302582
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302583 for (scan_id_index = 0; scan_id_index < pData->scanResultSize;
2584 scan_id_index++) {
2585 result+= scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302586
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302587 totalResults = result->num_results;
2588 hddLog(VOS_TRACE_LEVEL_INFO, "scan_id %u flags %u Num results %u",
2589 result->scan_id, result->flags, totalResults);
2590 i = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302591
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302592 do{
2593 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2594 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2595 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302596
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302597 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
2598 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN);
2599
2600 if (!skb) {
2601 hddLog(VOS_TRACE_LEVEL_ERROR,
2602 FL("cfg80211_vendor_event_alloc failed"));
2603 return;
2604 }
2605
2606 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2607
2608 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2609 pData->requestId) ||
2610 nla_put_u32(skb,
2611 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2612 resultsPerEvent)) {
2613 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2614 goto fail;
2615 }
2616 if (nla_put_u8(skb,
2617 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2618 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302619 {
2620 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2621 goto fail;
2622 }
2623
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302624 if (nla_put_u32(skb,
2625 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
2626 result->scan_id)) {
2627 hddLog(LOGE, FL("put fail"));
2628 goto fail;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302629 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302630
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302631 nla_results = nla_nest_start(skb,
2632 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST);
2633 if (!nla_results)
2634 goto fail;
2635
2636 if (resultsPerEvent) {
2637 struct nlattr *aps;
2638 struct nlattr *nla_result;
2639
2640 nla_result = nla_nest_start(skb, scan_id_index);
2641 if(!nla_result)
2642 goto fail;
2643
2644 if (nla_put_u32(skb,
2645 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
2646 result->scan_id) ||
2647 nla_put_u32(skb,
2648 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_FLAGS,
2649 result->flags) ||
2650 nla_put_u32(skb,
2651 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2652 totalResults)) {
2653 hddLog(LOGE, FL("put fail"));
2654 goto fail;
2655 }
2656
2657 aps = nla_nest_start(skb,
2658 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2659 if (!aps)
2660 {
2661 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2662 goto fail;
2663 }
2664
2665 head_ptr = (tpSirWifiScanResult) &(result->ap);
2666
2667 for (j = 0; j < resultsPerEvent; j++, i++) {
2668 struct nlattr *ap;
2669 pSirWifiScanResult = head_ptr + i;
2670
2671 /*
Srinivas Dasari91727c12016-03-23 17:59:06 +05302672 * Firmware returns timestamp from extscan_start till
2673 * BSSID was cached (in micro seconds). Add this with
2674 * time gap between system boot up to extscan_start
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302675 * to derive the time since boot when the
2676 * BSSID was cached.
2677 */
Srinivas Dasari91727c12016-03-23 17:59:06 +05302678 pSirWifiScanResult->ts +=
2679 pHddCtx->extscan_start_time_since_boot;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302680 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2681 "Ssid (%s)"
2682 "Bssid: %pM "
2683 "Channel (%u)"
2684 "Rssi (%d)"
2685 "RTT (%u)"
2686 "RTT_SD (%u)"
2687 "Beacon Period %u"
2688 "Capability 0x%x "
2689 "Ie length %d",
2690 i,
2691 pSirWifiScanResult->ts,
2692 pSirWifiScanResult->ssid,
2693 pSirWifiScanResult->bssid,
2694 pSirWifiScanResult->channel,
2695 pSirWifiScanResult->rssi,
2696 pSirWifiScanResult->rtt,
2697 pSirWifiScanResult->rtt_sd,
2698 pSirWifiScanResult->beaconPeriod,
2699 pSirWifiScanResult->capability,
2700 ieLength);
2701
2702 ap = nla_nest_start(skb, j + 1);
2703 if (!ap)
2704 {
2705 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2706 goto fail;
2707 }
2708
2709 if (nla_put_u64(skb,
2710 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2711 pSirWifiScanResult->ts) )
2712 {
2713 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2714 goto fail;
2715 }
2716 if (nla_put(skb,
2717 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2718 sizeof(pSirWifiScanResult->ssid),
2719 pSirWifiScanResult->ssid) )
2720 {
2721 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2722 goto fail;
2723 }
2724 if (nla_put(skb,
2725 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2726 sizeof(pSirWifiScanResult->bssid),
2727 pSirWifiScanResult->bssid) )
2728 {
2729 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2730 goto fail;
2731 }
2732 if (nla_put_u32(skb,
2733 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2734 pSirWifiScanResult->channel) )
2735 {
2736 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2737 goto fail;
2738 }
2739 if (nla_put_s32(skb,
2740 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2741 pSirWifiScanResult->rssi) )
2742 {
2743 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2744 goto fail;
2745 }
2746 if (nla_put_u32(skb,
2747 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2748 pSirWifiScanResult->rtt) )
2749 {
2750 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2751 goto fail;
2752 }
2753 if (nla_put_u32(skb,
2754 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2755 pSirWifiScanResult->rtt_sd))
2756 {
2757 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2758 goto fail;
2759 }
2760 if (nla_put_u32(skb,
2761 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
2762 pSirWifiScanResult->beaconPeriod))
2763 {
2764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2765 goto fail;
2766 }
2767 if (nla_put_u32(skb,
2768 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
2769 pSirWifiScanResult->capability))
2770 {
2771 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2772 goto fail;
2773 }
2774 if (nla_put_u32(skb,
2775 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
2776 ieLength))
2777 {
2778 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2779 goto fail;
2780 }
2781
2782 if (ieLength)
2783 if (nla_put(skb,
2784 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
2785 ieLength, ie)) {
2786 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2787 goto fail;
2788 }
2789
2790 nla_nest_end(skb, ap);
2791 }
2792 nla_nest_end(skb, aps);
2793 nla_nest_end(skb, nla_result);
2794 }
2795
2796 nla_nest_end(skb, nla_results);
2797
2798 cfg80211_vendor_cmd_reply(skb);
2799
2800 } while (totalResults > 0);
2801 }
2802
2803 if (!pData->moreData) {
2804 spin_lock(&hdd_context_lock);
2805 context->response_status = 0;
2806 complete(&context->response_event);
2807 spin_unlock(&hdd_context_lock);
2808 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302809
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302810 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302811 return;
2812fail:
2813 kfree_skb(skb);
2814 return;
2815}
2816
2817static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2818 void *pMsg)
2819{
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302820 tpSirEXTScanHotlistMatch pData = (tpSirEXTScanHotlistMatch) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302821 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2822 struct sk_buff *skb = NULL;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302823 tANI_U32 i, index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302824
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302825 ENTER();
2826
2827 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302828 hddLog(LOGE,
2829 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302830 return;
2831 }
2832 if (!pMsg)
2833 {
2834 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302835 return;
2836 }
2837
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302838 if (pData->bss_found)
2839 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX;
2840 else
2841 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX;
2842
Dino Mycle6fb96c12014-06-10 11:52:40 +05302843 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302844#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2845 NULL,
2846#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302847 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302848 index, GFP_KERNEL);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302849
2850 if (!skb) {
2851 hddLog(VOS_TRACE_LEVEL_ERROR,
2852 FL("cfg80211_vendor_event_alloc failed"));
2853 return;
2854 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302855
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302856 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2857 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numHotlistBss);
2858 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2859 hddLog(VOS_TRACE_LEVEL_INFO, "ap_found %u", pData->bss_found);
2860
2861 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302862 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2863 "Ssid (%s) "
2864 "Bssid (" MAC_ADDRESS_STR ") "
2865 "Channel (%u) "
2866 "Rssi (%d) "
2867 "RTT (%u) "
2868 "RTT_SD (%u) ",
2869 i,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302870 pData->bssHotlist[i].ts,
2871 pData->bssHotlist[i].ssid,
2872 MAC_ADDR_ARRAY(pData->bssHotlist[i].bssid),
2873 pData->bssHotlist[i].channel,
2874 pData->bssHotlist[i].rssi,
2875 pData->bssHotlist[i].rtt,
2876 pData->bssHotlist[i].rtt_sd);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302877 }
2878
2879 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2880 pData->requestId) ||
2881 nla_put_u32(skb,
2882 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302883 pData->numHotlistBss)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302884 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2885 goto fail;
2886 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302887 if (pData->numHotlistBss) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302888 struct nlattr *aps;
2889
2890 aps = nla_nest_start(skb,
2891 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2892 if (!aps)
2893 goto fail;
2894
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302895 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302896 struct nlattr *ap;
2897
2898 ap = nla_nest_start(skb, i + 1);
2899 if (!ap)
2900 goto fail;
2901
2902 if (nla_put_u64(skb,
2903 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302904 pData->bssHotlist[i].ts) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302905 nla_put(skb,
2906 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302907 sizeof(pData->bssHotlist[i].ssid),
2908 pData->bssHotlist[i].ssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302909 nla_put(skb,
2910 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302911 sizeof(pData->bssHotlist[i].bssid),
2912 pData->bssHotlist[i].bssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302913 nla_put_u32(skb,
2914 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302915 pData->bssHotlist[i].channel) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302916 nla_put_s32(skb,
2917 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302918 pData->bssHotlist[i].rssi) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302919 nla_put_u32(skb,
2920 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302921 pData->bssHotlist[i].rtt) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302922 nla_put_u32(skb,
2923 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302924 pData->bssHotlist[i].rtt_sd))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302925 goto fail;
2926
2927 nla_nest_end(skb, ap);
2928 }
2929 nla_nest_end(skb, aps);
2930
2931 if (nla_put_u8(skb,
2932 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2933 pData->moreData))
2934 goto fail;
2935 }
2936
2937 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302938 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302939 return;
2940
2941fail:
2942 kfree_skb(skb);
2943 return;
2944
2945}
Dino Mycle6fb96c12014-06-10 11:52:40 +05302946
2947static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
2948 void *pMsg)
2949{
2950 struct sk_buff *skb;
2951 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2952 tpSirWifiFullScanResultEvent pData =
2953 (tpSirWifiFullScanResultEvent) (pMsg);
2954
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302955 ENTER();
2956
2957 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302958 hddLog(LOGE,
2959 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302960 return;
2961 }
2962 if (!pMsg)
2963 {
2964 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302965 return;
2966 }
2967
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302968 /*
2969 * If the full scan result including IE data exceeds NL 4K size
2970 * limitation, drop that beacon/probe rsp frame.
2971 */
2972 if ((sizeof(*pData) + pData->ieLength) >= EXTSCAN_EVENT_BUF_SIZE) {
2973 hddLog(LOGE, FL("Frame exceeded NL size limilation, drop it!"));
2974 return;
2975 }
2976
Dino Mycle6fb96c12014-06-10 11:52:40 +05302977 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302978#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2979 NULL,
2980#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302981 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2982 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
2983 GFP_KERNEL);
2984
2985 if (!skb) {
2986 hddLog(VOS_TRACE_LEVEL_ERROR,
2987 FL("cfg80211_vendor_event_alloc failed"));
2988 return;
2989 }
2990
Dino Mycle6fb96c12014-06-10 11:52:40 +05302991 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
2992 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
2993 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
2994 "Ssid (%s)"
2995 "Bssid (" MAC_ADDRESS_STR ")"
2996 "Channel (%u)"
2997 "Rssi (%d)"
2998 "RTT (%u)"
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302999 "RTT_SD (%u)"
3000 "Bcn Period %d"
3001 "Capability 0x%X "),
Dino Mycle6fb96c12014-06-10 11:52:40 +05303002 pData->ap.ts,
3003 pData->ap.ssid,
3004 MAC_ADDR_ARRAY(pData->ap.bssid),
3005 pData->ap.channel,
3006 pData->ap.rssi,
3007 pData->ap.rtt,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303008 pData->ap.rtt_sd,
3009 pData->ap.beaconPeriod,
3010 pData->ap.capability);
3011
Dino Mycle6fb96c12014-06-10 11:52:40 +05303012 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3013 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3014 pData->requestId) ||
3015 nla_put_u64(skb,
3016 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3017 pData->ap.ts) ||
3018 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3019 sizeof(pData->ap.ssid),
3020 pData->ap.ssid) ||
3021 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3022 WNI_CFG_BSSID_LEN,
3023 pData->ap.bssid) ||
3024 nla_put_u32(skb,
3025 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3026 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303027 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303028 pData->ap.rssi) ||
3029 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3030 pData->ap.rtt) ||
3031 nla_put_u32(skb,
3032 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3033 pData->ap.rtt_sd) ||
3034 nla_put_u16(skb,
3035 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3036 pData->ap.beaconPeriod) ||
3037 nla_put_u16(skb,
3038 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3039 pData->ap.capability) ||
3040 nla_put_u32(skb,
3041 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303042 pData->ieLength) ||
3043 nla_put_u8(skb,
3044 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3045 pData->moreData))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303046 {
3047 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3048 goto nla_put_failure;
3049 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303050
3051 if (pData->ieLength) {
3052 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3053 pData->ieLength,
3054 pData->ie))
3055 {
3056 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3057 goto nla_put_failure;
3058 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303059 }
3060
3061 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303062 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303063 return;
3064
3065nla_put_failure:
3066 kfree_skb(skb);
3067 return;
3068}
3069
3070static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3071 void *pMsg)
3072{
3073 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3074 struct sk_buff *skb = NULL;
3075 tpSirEXTScanResultsAvailableIndParams pData =
3076 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3077
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303078 ENTER();
3079
3080 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303081 hddLog(LOGE,
3082 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303083 return;
3084 }
3085 if (!pMsg)
3086 {
3087 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303088 return;
3089 }
3090
3091 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303092#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3093 NULL,
3094#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303095 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3096 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3097 GFP_KERNEL);
3098
3099 if (!skb) {
3100 hddLog(VOS_TRACE_LEVEL_ERROR,
3101 FL("cfg80211_vendor_event_alloc failed"));
3102 return;
3103 }
3104
Dino Mycle6fb96c12014-06-10 11:52:40 +05303105 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3106 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3107 pData->numResultsAvailable);
3108 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3109 pData->requestId) ||
3110 nla_put_u32(skb,
3111 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3112 pData->numResultsAvailable)) {
3113 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3114 goto nla_put_failure;
3115 }
3116
3117 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303118 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303119 return;
3120
3121nla_put_failure:
3122 kfree_skb(skb);
3123 return;
3124}
3125
3126static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3127{
3128 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3129 struct sk_buff *skb = NULL;
3130 tpSirEXTScanProgressIndParams pData =
3131 (tpSirEXTScanProgressIndParams) pMsg;
3132
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303133 ENTER();
3134
3135 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303136 hddLog(LOGE,
3137 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303138 return;
3139 }
3140 if (!pMsg)
3141 {
3142 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303143 return;
3144 }
3145
3146 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303147#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3148 NULL,
3149#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303150 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3151 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3152 GFP_KERNEL);
3153
3154 if (!skb) {
3155 hddLog(VOS_TRACE_LEVEL_ERROR,
3156 FL("cfg80211_vendor_event_alloc failed"));
3157 return;
3158 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303159 hddLog(VOS_TRACE_LEVEL_INFO, FL("Request Id (%u) "), pData->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303160 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3161 pData->extScanEventType);
3162 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3163 pData->status);
3164
3165 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3166 pData->extScanEventType) ||
3167 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303168 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3169 pData->requestId) ||
3170 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303171 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3172 pData->status)) {
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
3186void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3187 void *pMsg)
3188{
3189 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3190
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303191 ENTER();
3192
Dino Mycle6fb96c12014-06-10 11:52:40 +05303193 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303194 return;
3195 }
3196
3197 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3198
3199
3200 switch(evType) {
3201 case SIR_HAL_EXTSCAN_START_RSP:
3202 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3203 break;
3204
3205 case SIR_HAL_EXTSCAN_STOP_RSP:
3206 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3207 break;
3208 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3209 /* There is no need to send this response to upper layer
3210 Just log the message */
3211 hddLog(VOS_TRACE_LEVEL_INFO,
3212 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3213 break;
3214 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3215 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3216 break;
3217
3218 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3219 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3220 break;
3221
Dino Mycle6fb96c12014-06-10 11:52:40 +05303222 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303223 wlan_hdd_cfg80211_extscan_get_capabilities_rsp(ctx, pMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303224 break;
3225 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3226 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3227 break;
3228 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3229 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3230 break;
3231 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3232 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3233 break;
3234 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3235 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3236 break;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303237 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3238 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3239 break;
3240 default:
3241 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3242 break;
3243 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303244 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303245}
3246
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303247static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3248 struct wireless_dev *wdev,
3249 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303250{
Dino Myclee8843b32014-07-04 14:21:45 +05303251 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303252 struct net_device *dev = wdev->netdev;
3253 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3254 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3255 struct nlattr
3256 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3257 eHalStatus status;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303258 struct hdd_ext_scan_context *context;
3259 unsigned long rc;
3260 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303261
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303262 ENTER();
3263
Dino Mycle6fb96c12014-06-10 11:52:40 +05303264 status = wlan_hdd_validate_context(pHddCtx);
3265 if (0 != status)
3266 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303267 return -EINVAL;
3268 }
Dino Myclee8843b32014-07-04 14:21:45 +05303269 /* check the EXTScan Capability */
3270 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303271 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3272 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303273 {
3274 hddLog(VOS_TRACE_LEVEL_ERROR,
3275 FL("EXTScan not enabled/supported by Firmware"));
3276 return -EINVAL;
3277 }
3278
Dino Mycle6fb96c12014-06-10 11:52:40 +05303279 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3280 data, dataLen,
3281 wlan_hdd_extscan_config_policy)) {
3282 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3283 return -EINVAL;
3284 }
3285
3286 /* Parse and fetch request Id */
3287 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3288 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3289 return -EINVAL;
3290 }
3291
Dino Myclee8843b32014-07-04 14:21:45 +05303292 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303293 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303294 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303295
Dino Myclee8843b32014-07-04 14:21:45 +05303296 reqMsg.sessionId = pAdapter->sessionId;
3297 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303298
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303299 vos_spin_lock_acquire(&hdd_context_lock);
3300 context = &pHddCtx->ext_scan_context;
3301 context->request_id = reqMsg.requestId;
3302 INIT_COMPLETION(context->response_event);
3303 vos_spin_lock_release(&hdd_context_lock);
3304
Dino Myclee8843b32014-07-04 14:21:45 +05303305 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303306 if (!HAL_STATUS_SUCCESS(status)) {
3307 hddLog(VOS_TRACE_LEVEL_ERROR,
3308 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303309 return -EINVAL;
3310 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303311
3312 rc = wait_for_completion_timeout(&context->response_event,
3313 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3314 if (!rc) {
3315 hddLog(LOGE, FL("Target response timed out"));
3316 return -ETIMEDOUT;
3317 }
3318
3319 ret = wlan_hdd_send_ext_scan_capability(pHddCtx);
3320 if (ret)
3321 hddLog(LOGE, FL("Failed to send ext scan capability to user space"));
3322
3323 return ret;
3324
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303325 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303326 return 0;
3327}
3328
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303329static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3330 struct wireless_dev *wdev,
3331 const void *data, int dataLen)
3332{
3333 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303334
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303335 vos_ssr_protect(__func__);
3336 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3337 vos_ssr_unprotect(__func__);
3338
3339 return ret;
3340}
3341
3342static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3343 struct wireless_dev *wdev,
3344 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303345{
Dino Myclee8843b32014-07-04 14:21:45 +05303346 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303347 struct net_device *dev = wdev->netdev;
3348 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3349 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3350 struct nlattr
3351 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3352 eHalStatus status;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303353 struct hdd_ext_scan_context *context;
3354 unsigned long rc;
3355 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303356
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303357 ENTER();
3358
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303359 if (VOS_FTM_MODE == hdd_get_conparam()) {
3360 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3361 return -EINVAL;
3362 }
3363
Dino Mycle6fb96c12014-06-10 11:52:40 +05303364 status = wlan_hdd_validate_context(pHddCtx);
3365 if (0 != status)
3366 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303367 return -EINVAL;
3368 }
Dino Myclee8843b32014-07-04 14:21:45 +05303369 /* check the EXTScan Capability */
3370 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303371 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3372 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303373 {
3374 hddLog(VOS_TRACE_LEVEL_ERROR,
3375 FL("EXTScan not enabled/supported by Firmware"));
3376 return -EINVAL;
3377 }
3378
Dino Mycle6fb96c12014-06-10 11:52:40 +05303379 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3380 data, dataLen,
3381 wlan_hdd_extscan_config_policy)) {
3382 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3383 return -EINVAL;
3384 }
3385 /* Parse and fetch request Id */
3386 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3387 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3388 return -EINVAL;
3389 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303390
Dino Myclee8843b32014-07-04 14:21:45 +05303391 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303392 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3393
Dino Myclee8843b32014-07-04 14:21:45 +05303394 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303395
Dino Myclee8843b32014-07-04 14:21:45 +05303396 reqMsg.sessionId = pAdapter->sessionId;
3397 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303398
3399 /* Parse and fetch flush parameter */
3400 if (!tb
3401 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3402 {
3403 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3404 goto failed;
3405 }
Dino Myclee8843b32014-07-04 14:21:45 +05303406 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303407 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3408
Dino Myclee8843b32014-07-04 14:21:45 +05303409 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303410
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303411 spin_lock(&hdd_context_lock);
3412 context = &pHddCtx->ext_scan_context;
3413 context->request_id = reqMsg.requestId;
3414 context->ignore_cached_results = false;
3415 INIT_COMPLETION(context->response_event);
3416 spin_unlock(&hdd_context_lock);
3417
Dino Myclee8843b32014-07-04 14:21:45 +05303418 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303419 if (!HAL_STATUS_SUCCESS(status)) {
3420 hddLog(VOS_TRACE_LEVEL_ERROR,
3421 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303422 return -EINVAL;
3423 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303424
3425 rc = wait_for_completion_timeout(&context->response_event,
3426 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3427 if (!rc) {
3428 hddLog(LOGE, FL("Target response timed out"));
3429 retval = -ETIMEDOUT;
3430 spin_lock(&hdd_context_lock);
3431 context->ignore_cached_results = true;
3432 spin_unlock(&hdd_context_lock);
3433 } else {
3434 spin_lock(&hdd_context_lock);
3435 retval = context->response_status;
3436 spin_unlock(&hdd_context_lock);
3437 }
3438
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303439 EXIT();
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303440 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303441
3442failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303443 return -EINVAL;
3444}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303445static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3446 struct wireless_dev *wdev,
3447 const void *data, int dataLen)
3448{
3449 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303450
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303451 vos_ssr_protect(__func__);
3452 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3453 vos_ssr_unprotect(__func__);
3454
3455 return ret;
3456}
3457
3458static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303459 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303460 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303461{
3462 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3463 struct net_device *dev = wdev->netdev;
3464 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3465 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3466 struct nlattr
3467 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3468 struct nlattr
3469 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3470 struct nlattr *apTh;
3471 eHalStatus status;
3472 tANI_U8 i = 0;
3473 int rem;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303474 struct hdd_ext_scan_context *context;
3475 tANI_U32 request_id;
3476 unsigned long rc;
3477 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303478
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303479 ENTER();
3480
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303481 if (VOS_FTM_MODE == hdd_get_conparam()) {
3482 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3483 return -EINVAL;
3484 }
3485
Dino Mycle6fb96c12014-06-10 11:52:40 +05303486 status = wlan_hdd_validate_context(pHddCtx);
3487 if (0 != status)
3488 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303489 return -EINVAL;
3490 }
Dino Myclee8843b32014-07-04 14:21:45 +05303491 /* check the EXTScan Capability */
3492 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303493 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3494 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303495 {
3496 hddLog(VOS_TRACE_LEVEL_ERROR,
3497 FL("EXTScan not enabled/supported by Firmware"));
3498 return -EINVAL;
3499 }
3500
Dino Mycle6fb96c12014-06-10 11:52:40 +05303501 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3502 data, dataLen,
3503 wlan_hdd_extscan_config_policy)) {
3504 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3505 return -EINVAL;
3506 }
3507
3508 /* Parse and fetch request Id */
3509 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3510 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3511 return -EINVAL;
3512 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303513 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3514 vos_mem_malloc(sizeof(*pReqMsg));
3515 if (!pReqMsg) {
3516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3517 return -ENOMEM;
3518 }
3519
Dino Myclee8843b32014-07-04 14:21:45 +05303520
Dino Mycle6fb96c12014-06-10 11:52:40 +05303521 pReqMsg->requestId = nla_get_u32(
3522 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3523 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3524
3525 /* Parse and fetch number of APs */
3526 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3527 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3528 goto fail;
3529 }
3530
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303531 /* Parse and fetch lost ap sample size */
3532 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]) {
3533 hddLog(LOGE, FL("attr lost ap sample size failed"));
3534 goto fail;
3535 }
3536
3537 pReqMsg->lostBssidSampleSize = nla_get_u32(
3538 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]);
3539 hddLog(LOG1, FL("Lost ap sample size %d"), pReqMsg->lostBssidSampleSize);
3540
Dino Mycle6fb96c12014-06-10 11:52:40 +05303541 pReqMsg->sessionId = pAdapter->sessionId;
3542 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3543
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303544 pReqMsg->numBssid = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303545 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05303546 if (pReqMsg->numBssid > WLAN_EXTSCAN_MAX_HOTLIST_APS) {
3547 hddLog(LOGE, FL("Number of AP: %u exceeds max: %u"),
3548 pReqMsg->numBssid, WLAN_EXTSCAN_MAX_HOTLIST_APS);
3549 goto fail;
3550 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303551 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303552
3553 nla_for_each_nested(apTh,
3554 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05303555 if (i == pReqMsg->numBssid) {
3556 hddLog(LOGW, FL("Ignoring excess AP"));
3557 break;
3558 }
3559
Dino Mycle6fb96c12014-06-10 11:52:40 +05303560 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3561 nla_data(apTh), nla_len(apTh),
3562 NULL)) {
3563 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3564 goto fail;
3565 }
3566
3567 /* Parse and fetch MAC address */
3568 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3570 goto fail;
3571 }
3572 memcpy(pReqMsg->ap[i].bssid, nla_data(
3573 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3574 sizeof(tSirMacAddr));
3575 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3576
3577 /* Parse and fetch low RSSI */
3578 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3579 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3580 goto fail;
3581 }
3582 pReqMsg->ap[i].low = nla_get_s32(
3583 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3584 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3585
3586 /* Parse and fetch high RSSI */
3587 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3588 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3589 goto fail;
3590 }
3591 pReqMsg->ap[i].high = nla_get_s32(
3592 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3593 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3594 pReqMsg->ap[i].high);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303595 i++;
3596 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303597
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05303598 if (i < pReqMsg->numBssid) {
3599 hddLog(LOGW, FL("Number of AP %u less than expected %u"),
3600 i, pReqMsg->numBssid);
3601 pReqMsg->numBssid = i;
3602 }
3603
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303604 context = &pHddCtx->ext_scan_context;
3605 spin_lock(&hdd_context_lock);
3606 INIT_COMPLETION(context->response_event);
3607 context->request_id = request_id = pReqMsg->requestId;
3608 spin_unlock(&hdd_context_lock);
3609
Dino Mycle6fb96c12014-06-10 11:52:40 +05303610 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3611 if (!HAL_STATUS_SUCCESS(status)) {
3612 hddLog(VOS_TRACE_LEVEL_ERROR,
3613 FL("sme_SetBssHotlist failed(err=%d)"), status);
3614 vos_mem_free(pReqMsg);
3615 return -EINVAL;
3616 }
3617
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303618 /* request was sent -- wait for the response */
3619 rc = wait_for_completion_timeout(&context->response_event,
3620 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3621
3622 if (!rc) {
3623 hddLog(LOGE, FL("sme_SetBssHotlist timed out"));
3624 retval = -ETIMEDOUT;
3625 } else {
3626 spin_lock(&hdd_context_lock);
3627 if (context->request_id == request_id)
3628 retval = context->response_status;
3629 else
3630 retval = -EINVAL;
3631 spin_unlock(&hdd_context_lock);
3632 }
3633
Dino Myclee8843b32014-07-04 14:21:45 +05303634 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303635 EXIT();
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303636 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303637
3638fail:
3639 vos_mem_free(pReqMsg);
3640 return -EINVAL;
3641}
3642
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303643static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3644 struct wireless_dev *wdev,
3645 const void *data, int dataLen)
3646{
3647 int ret = 0;
3648
3649 vos_ssr_protect(__func__);
3650 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3651 dataLen);
3652 vos_ssr_unprotect(__func__);
3653
3654 return ret;
3655}
3656
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303657static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303658 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303659 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303660{
Agrawal Ashish16abf782016-08-18 22:42:59 +05303661 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3662 struct net_device *dev = wdev->netdev;
3663 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3664 uint32_t chan_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3665 uint8_t num_channels = 0;
3666 uint8_t num_chan_new = 0;
3667 uint8_t buf[256] = {0};
Dino Mycle6fb96c12014-06-10 11:52:40 +05303668 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05303669 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303670 tWifiBand wifiBand;
3671 eHalStatus status;
3672 struct sk_buff *replySkb;
Agrawal Ashish16abf782016-08-18 22:42:59 +05303673 tANI_U8 i,j,k;
3674 int ret,len = 0;;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303675
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303676 ENTER();
3677
Dino Mycle6fb96c12014-06-10 11:52:40 +05303678 status = wlan_hdd_validate_context(pHddCtx);
3679 if (0 != status)
3680 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303681 return -EINVAL;
3682 }
Dino Myclee8843b32014-07-04 14:21:45 +05303683
Dino Mycle6fb96c12014-06-10 11:52:40 +05303684 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3685 data, dataLen,
3686 wlan_hdd_extscan_config_policy)) {
3687 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3688 return -EINVAL;
3689 }
3690
3691 /* Parse and fetch request Id */
3692 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3693 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3694 return -EINVAL;
3695 }
3696 requestId = nla_get_u32(
3697 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3698 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3699
3700 /* Parse and fetch wifi band */
3701 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3702 {
3703 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3704 return -EINVAL;
3705 }
3706 wifiBand = nla_get_u32(
3707 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3708 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3709
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05303710 /* Parse and fetch max channels */
3711 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
3712 {
3713 hddLog(LOGE, FL("attr max channels failed"));
3714 return -EINVAL;
3715 }
3716 maxChannels = nla_get_u32(
3717 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
3718 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
3719
Dino Mycle6fb96c12014-06-10 11:52:40 +05303720 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
Agrawal Ashish16abf782016-08-18 22:42:59 +05303721 wifiBand, chan_list,
3722 &num_channels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303723 if (eHAL_STATUS_SUCCESS != status) {
3724 hddLog(VOS_TRACE_LEVEL_ERROR,
3725 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3726 return -EINVAL;
3727 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05303728
Agrawal Ashish16abf782016-08-18 22:42:59 +05303729 num_channels = VOS_MIN(num_channels, maxChannels);
3730 num_chan_new = num_channels;
3731 /* remove the indoor only channels if iface is SAP */
3732 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
3733 {
3734 num_chan_new = 0;
3735 for (i = 0; i < num_channels; i++)
3736 for (j = 0; j < IEEE80211_NUM_BANDS; j++) {
3737 if (wiphy->bands[j] == NULL)
3738 continue;
3739 for (k = 0; k < wiphy->bands[j]->n_channels; k++) {
3740 if ((chan_list[i] ==
3741 wiphy->bands[j]->channels[k].center_freq) &&
3742 (!(wiphy->bands[j]->channels[k].flags &
3743 IEEE80211_CHAN_INDOOR_ONLY))) {
3744 chan_list[num_chan_new] = chan_list[i];
3745 num_chan_new++;
3746 }
3747 }
3748 }
3749 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05303750
Agrawal Ashish16abf782016-08-18 22:42:59 +05303751 hddLog(LOG1, FL("Number of channels: %d"), num_chan_new);
3752 for (i = 0; i < num_chan_new; i++)
3753 len += scnprintf(buf + len, sizeof(buf) - len, "%u ", chan_list[i]);
3754 hddLog(LOG1, "Channels: %s", buf);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303755
3756 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
Agrawal Ashish16abf782016-08-18 22:42:59 +05303757 sizeof(u32) * num_chan_new +
Dino Mycle6fb96c12014-06-10 11:52:40 +05303758 NLMSG_HDRLEN);
3759
3760 if (!replySkb) {
3761 hddLog(VOS_TRACE_LEVEL_ERROR,
3762 FL("valid channels: buffer alloc fail"));
3763 return -EINVAL;
3764 }
3765 if (nla_put_u32(replySkb,
3766 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05303767 num_chan_new) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303768 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05303769 sizeof(u32) * num_chan_new, chan_list)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303770
3771 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3772 kfree_skb(replySkb);
3773 return -EINVAL;
3774 }
3775
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303776 ret = cfg80211_vendor_cmd_reply(replySkb);
3777
3778 EXIT();
3779 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303780}
3781
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303782static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3783 struct wireless_dev *wdev,
3784 const void *data, int dataLen)
3785{
3786 int ret = 0;
3787
3788 vos_ssr_protect(__func__);
3789 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
3790 dataLen);
3791 vos_ssr_unprotect(__func__);
3792
3793 return ret;
3794}
3795
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303796static int hdd_extscan_start_fill_bucket_channel_spec(
3797 hdd_context_t *pHddCtx,
3798 tpSirEXTScanStartReqParams pReqMsg,
3799 struct nlattr **tb)
3800{
3801 struct nlattr *bucket[
3802 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3803 struct nlattr *channel[
3804 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3805 struct nlattr *buckets;
3806 struct nlattr *channels;
3807 int rem1, rem2;
3808 eHalStatus status;
3809 tANI_U8 bktIndex, j, numChannels;
3810 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3811 tANI_U32 passive_max_chn_time, active_max_chn_time;
3812
3813 bktIndex = 0;
3814
3815 nla_for_each_nested(buckets,
3816 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
3817 if (nla_parse(bucket,
Ashish Kumar Dhanotiya9c93f562017-06-20 12:13:33 +05303818 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3819 nla_data(buckets), nla_len(buckets),
3820 wlan_hdd_extscan_config_policy)) {
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303821 hddLog(LOGE, FL("nla_parse failed"));
3822 return -EINVAL;
3823 }
3824
3825 /* Parse and fetch bucket spec */
3826 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
3827 hddLog(LOGE, FL("attr bucket index failed"));
3828 return -EINVAL;
3829 }
3830 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
3831 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
3832 hddLog(LOG1, FL("Bucket spec Index %d"),
3833 pReqMsg->buckets[bktIndex].bucket);
3834
3835 /* Parse and fetch wifi band */
3836 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
3837 hddLog(LOGE, FL("attr wifi band failed"));
3838 return -EINVAL;
3839 }
3840 pReqMsg->buckets[bktIndex].band = nla_get_u8(
3841 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
3842 hddLog(LOG1, FL("Wifi band %d"),
3843 pReqMsg->buckets[bktIndex].band);
3844
3845 /* Parse and fetch period */
3846 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
3847 hddLog(LOGE, FL("attr period failed"));
3848 return -EINVAL;
3849 }
3850 pReqMsg->buckets[bktIndex].period = nla_get_u32(
3851 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
3852 hddLog(LOG1, FL("period %d"),
3853 pReqMsg->buckets[bktIndex].period);
3854
3855 /* Parse and fetch report events */
3856 if (!bucket[
3857 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
3858 hddLog(LOGE, FL("attr report events failed"));
3859 return -EINVAL;
3860 }
3861 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
3862 bucket[
3863 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
3864 hddLog(LOG1, FL("report events %d"),
3865 pReqMsg->buckets[bktIndex].reportEvents);
3866
3867 /* Parse and fetch max period */
3868 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
3869 hddLog(LOGE, FL("attr max period failed"));
3870 return -EINVAL;
3871 }
3872 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
3873 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
3874 hddLog(LOG1, FL("max period %u"),
3875 pReqMsg->buckets[bktIndex].max_period);
3876
3877 /* Parse and fetch exponent */
3878 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
3879 hddLog(LOGE, FL("attr exponent failed"));
3880 return -EINVAL;
3881 }
3882 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
3883 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
3884 hddLog(LOG1, FL("exponent %u"),
3885 pReqMsg->buckets[bktIndex].exponent);
3886
3887 /* Parse and fetch step count */
3888 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
3889 hddLog(LOGE, FL("attr step count failed"));
3890 return -EINVAL;
3891 }
3892 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
3893 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
3894 hddLog(LOG1, FL("Step count %u"),
3895 pReqMsg->buckets[bktIndex].step_count);
3896
3897 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
3898 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
3899
3900 /* Framework shall pass the channel list if the input WiFi band is
3901 * WIFI_BAND_UNSPECIFIED.
3902 * If the input WiFi band is specified (any value other than
3903 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
3904 */
3905 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
3906 numChannels = 0;
3907 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
3908 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
3909 pReqMsg->buckets[bktIndex].band,
3910 chanList, &numChannels);
3911 if (!HAL_STATUS_SUCCESS(status)) {
3912 hddLog(LOGE,
3913 FL("sme_GetValidChannelsByBand failed (err=%d)"),
3914 status);
3915 return -EINVAL;
3916 }
3917
3918 pReqMsg->buckets[bktIndex].numChannels =
3919 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
3920 hddLog(LOG1, FL("Num channels %d"),
3921 pReqMsg->buckets[bktIndex].numChannels);
3922
3923 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
3924 j++) {
3925 pReqMsg->buckets[bktIndex].channels[j].channel =
3926 chanList[j];
3927 pReqMsg->buckets[bktIndex].channels[j].
3928 chnlClass = 0;
3929 if (CSR_IS_CHANNEL_DFS(
3930 vos_freq_to_chan(chanList[j]))) {
3931 pReqMsg->buckets[bktIndex].channels[j].
3932 passive = 1;
3933 pReqMsg->buckets[bktIndex].channels[j].
3934 dwellTimeMs = passive_max_chn_time;
3935 } else {
3936 pReqMsg->buckets[bktIndex].channels[j].
3937 passive = 0;
3938 pReqMsg->buckets[bktIndex].channels[j].
3939 dwellTimeMs = active_max_chn_time;
3940 }
3941
3942 hddLog(LOG1,
3943 "Channel %u Passive %u Dwell time %u ms",
3944 pReqMsg->buckets[bktIndex].channels[j].channel,
3945 pReqMsg->buckets[bktIndex].channels[j].passive,
3946 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
3947 }
3948
3949 bktIndex++;
3950 continue;
3951 }
3952
3953 /* Parse and fetch number of channels */
3954 if (!bucket[
3955 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
3956 hddLog(LOGE, FL("attr num channels failed"));
3957 return -EINVAL;
3958 }
3959
3960 pReqMsg->buckets[bktIndex].numChannels =
3961 nla_get_u32(bucket[
3962 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
3963 hddLog(LOG1, FL("num channels %d"),
3964 pReqMsg->buckets[bktIndex].numChannels);
3965
3966 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
3967 hddLog(LOGE, FL("attr channel spec failed"));
3968 return -EINVAL;
3969 }
3970
3971 j = 0;
3972 nla_for_each_nested(channels,
3973 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
3974 if (nla_parse(channel,
3975 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3976 nla_data(channels), nla_len(channels),
3977 wlan_hdd_extscan_config_policy)) {
3978 hddLog(LOGE, FL("nla_parse failed"));
3979 return -EINVAL;
3980 }
3981
3982 /* Parse and fetch channel */
3983 if (!channel[
3984 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
3985 hddLog(LOGE, FL("attr channel failed"));
3986 return -EINVAL;
3987 }
3988 pReqMsg->buckets[bktIndex].channels[j].channel =
3989 nla_get_u32(channel[
3990 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
3991 hddLog(LOG1, FL("channel %u"),
3992 pReqMsg->buckets[bktIndex].channels[j].channel);
3993
3994 /* Parse and fetch dwell time */
3995 if (!channel[
3996 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
3997 hddLog(LOGE, FL("attr dwelltime failed"));
3998 return -EINVAL;
3999 }
4000 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
4001 nla_get_u32(channel[
4002 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4003
4004 hddLog(LOG1, FL("Dwell time (%u ms)"),
4005 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4006
4007
4008 /* Parse and fetch channel spec passive */
4009 if (!channel[
4010 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4011 hddLog(LOGE,
4012 FL("attr channel spec passive failed"));
4013 return -EINVAL;
4014 }
4015 pReqMsg->buckets[bktIndex].channels[j].passive =
4016 nla_get_u8(channel[
4017 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4018 hddLog(LOG1, FL("Chnl spec passive %u"),
4019 pReqMsg->buckets[bktIndex].channels[j].passive);
4020
4021 j++;
4022 }
4023
4024 bktIndex++;
4025 }
4026
4027 return 0;
4028}
4029
4030
4031/*
4032 * define short names for the global vendor params
4033 * used by wlan_hdd_cfg80211_extscan_start()
4034 */
4035#define PARAM_MAX \
4036QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
4037#define PARAM_REQUEST_ID \
4038QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
4039#define PARAM_BASE_PERIOD \
4040QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
4041#define PARAM_MAX_AP_PER_SCAN \
4042QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
4043#define PARAM_RPT_THRHLD_PERCENT \
4044QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
4045#define PARAM_RPT_THRHLD_NUM_SCANS \
4046QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
4047#define PARAM_NUM_BUCKETS \
4048QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
4049
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304050static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304051 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304052 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304053{
Dino Myclee8843b32014-07-04 14:21:45 +05304054 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304055 struct net_device *dev = wdev->netdev;
4056 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4057 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4058 struct nlattr *tb[PARAM_MAX + 1];
4059 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304060 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304061 tANI_U32 request_id;
4062 struct hdd_ext_scan_context *context;
4063 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304064
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304065 ENTER();
4066
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304067 if (VOS_FTM_MODE == hdd_get_conparam()) {
4068 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4069 return -EINVAL;
4070 }
4071
Dino Mycle6fb96c12014-06-10 11:52:40 +05304072 status = wlan_hdd_validate_context(pHddCtx);
4073 if (0 != status)
4074 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304075 return -EINVAL;
4076 }
Dino Myclee8843b32014-07-04 14:21:45 +05304077 /* check the EXTScan Capability */
4078 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304079 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4080 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304081 {
4082 hddLog(VOS_TRACE_LEVEL_ERROR,
4083 FL("EXTScan not enabled/supported by Firmware"));
4084 return -EINVAL;
4085 }
4086
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304087 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304088 data, dataLen,
4089 wlan_hdd_extscan_config_policy)) {
4090 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4091 return -EINVAL;
4092 }
4093
4094 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304095 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304096 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4097 return -EINVAL;
4098 }
4099
Dino Myclee8843b32014-07-04 14:21:45 +05304100 pReqMsg = (tpSirEXTScanStartReqParams)
4101 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304102 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304103 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4104 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304105 }
4106
4107 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304108 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304109 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4110
4111 pReqMsg->sessionId = pAdapter->sessionId;
4112 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4113
4114 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304115 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304116 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4117 goto fail;
4118 }
4119 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304120 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304121 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4122 pReqMsg->basePeriod);
4123
4124 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304125 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304126 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4127 goto fail;
4128 }
4129 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304130 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304131 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4132 pReqMsg->maxAPperScan);
4133
4134 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304135 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304136 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4137 goto fail;
4138 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304139 pReqMsg->reportThresholdPercent = nla_get_u8(
4140 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304141 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304142 pReqMsg->reportThresholdPercent);
4143
4144 /* Parse and fetch report threshold num scans */
4145 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
4146 hddLog(LOGE, FL("attr report_threshold num scans failed"));
4147 goto fail;
4148 }
4149 pReqMsg->reportThresholdNumScans = nla_get_u8(
4150 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
4151 hddLog(LOG1, FL("Report Threshold num scans %d"),
4152 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304153
4154 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304155 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304156 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4157 goto fail;
4158 }
4159 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304160 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304161 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4162 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4163 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4164 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4165 }
4166 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4167 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304168
Dino Mycle6fb96c12014-06-10 11:52:40 +05304169 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4170 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4171 goto fail;
4172 }
4173
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304174 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304175
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304176 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
4177 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304178
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304179 context = &pHddCtx->ext_scan_context;
4180 spin_lock(&hdd_context_lock);
4181 INIT_COMPLETION(context->response_event);
4182 context->request_id = request_id = pReqMsg->requestId;
4183 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304184
Dino Mycle6fb96c12014-06-10 11:52:40 +05304185 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4186 if (!HAL_STATUS_SUCCESS(status)) {
4187 hddLog(VOS_TRACE_LEVEL_ERROR,
4188 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304189 goto fail;
4190 }
4191
Srinivas Dasari91727c12016-03-23 17:59:06 +05304192 pHddCtx->extscan_start_time_since_boot = vos_get_monotonic_boottime();
4193
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304194 /* request was sent -- wait for the response */
4195 rc = wait_for_completion_timeout(&context->response_event,
4196 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4197
4198 if (!rc) {
4199 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
4200 retval = -ETIMEDOUT;
4201 } else {
4202 spin_lock(&hdd_context_lock);
4203 if (context->request_id == request_id)
4204 retval = context->response_status;
4205 else
4206 retval = -EINVAL;
4207 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304208 }
4209
Dino Myclee8843b32014-07-04 14:21:45 +05304210 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304211 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304212 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304213
4214fail:
4215 vos_mem_free(pReqMsg);
4216 return -EINVAL;
4217}
4218
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304219/*
4220 * done with short names for the global vendor params
4221 * used by wlan_hdd_cfg80211_extscan_start()
4222 */
4223#undef PARAM_MAX
4224#undef PARAM_REQUEST_ID
4225#undef PARAM_BASE_PERIOD
4226#undef PARAMS_MAX_AP_PER_SCAN
4227#undef PARAMS_RPT_THRHLD_PERCENT
4228#undef PARAMS_RPT_THRHLD_NUM_SCANS
4229#undef PARAMS_NUM_BUCKETS
4230
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304231static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4232 struct wireless_dev *wdev,
4233 const void *data, int dataLen)
4234{
4235 int ret = 0;
4236
4237 vos_ssr_protect(__func__);
4238 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4239 vos_ssr_unprotect(__func__);
4240
4241 return ret;
4242}
4243
4244static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304245 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304246 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304247{
Dino Myclee8843b32014-07-04 14:21:45 +05304248 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304249 struct net_device *dev = wdev->netdev;
4250 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4251 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4252 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4253 eHalStatus status;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304254 int retval;
4255 unsigned long rc;
4256 struct hdd_ext_scan_context *context;
4257 tANI_U32 request_id;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304258
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304259 ENTER();
4260
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304261 if (VOS_FTM_MODE == hdd_get_conparam()) {
4262 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4263 return -EINVAL;
4264 }
4265
Dino Mycle6fb96c12014-06-10 11:52:40 +05304266 status = wlan_hdd_validate_context(pHddCtx);
4267 if (0 != status)
4268 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304269 return -EINVAL;
4270 }
Dino Myclee8843b32014-07-04 14:21:45 +05304271 /* check the EXTScan Capability */
4272 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304273 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4274 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304275 {
4276 hddLog(VOS_TRACE_LEVEL_ERROR,
4277 FL("EXTScan not enabled/supported by Firmware"));
4278 return -EINVAL;
4279 }
4280
Dino Mycle6fb96c12014-06-10 11:52:40 +05304281 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4282 data, dataLen,
4283 wlan_hdd_extscan_config_policy)) {
4284 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4285 return -EINVAL;
4286 }
4287
4288 /* Parse and fetch request Id */
4289 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4290 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4291 return -EINVAL;
4292 }
4293
Dino Myclee8843b32014-07-04 14:21:45 +05304294 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304295 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304296 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304297
Dino Myclee8843b32014-07-04 14:21:45 +05304298 reqMsg.sessionId = pAdapter->sessionId;
4299 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304300
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304301 context = &pHddCtx->ext_scan_context;
4302 spin_lock(&hdd_context_lock);
4303 INIT_COMPLETION(context->response_event);
Sravanti Palakonda7539fb92016-02-26 17:49:21 +05304304 context->request_id = request_id = reqMsg.requestId;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304305 spin_unlock(&hdd_context_lock);
4306
Dino Myclee8843b32014-07-04 14:21:45 +05304307 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304308 if (!HAL_STATUS_SUCCESS(status)) {
4309 hddLog(VOS_TRACE_LEVEL_ERROR,
4310 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304311 return -EINVAL;
4312 }
4313
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304314 /* request was sent -- wait for the response */
4315 rc = wait_for_completion_timeout(&context->response_event,
4316 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4317
4318 if (!rc) {
4319 hddLog(LOGE, FL("sme_ExtScanStop timed out"));
4320 retval = -ETIMEDOUT;
4321 } else {
4322 spin_lock(&hdd_context_lock);
4323 if (context->request_id == request_id)
4324 retval = context->response_status;
4325 else
4326 retval = -EINVAL;
4327 spin_unlock(&hdd_context_lock);
4328 }
4329
4330 return retval;
4331
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304332 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304333 return 0;
4334}
4335
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304336static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4337 struct wireless_dev *wdev,
4338 const void *data, int dataLen)
4339{
4340 int ret = 0;
4341
4342 vos_ssr_protect(__func__);
4343 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4344 vos_ssr_unprotect(__func__);
4345
4346 return ret;
4347}
4348
4349static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304350 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304351 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304352{
Dino Myclee8843b32014-07-04 14:21:45 +05304353 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304354 struct net_device *dev = wdev->netdev;
4355 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4356 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4357 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4358 eHalStatus status;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304359 struct hdd_ext_scan_context *context;
4360 tANI_U32 request_id;
4361 unsigned long rc;
4362 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304363
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304364 ENTER();
4365
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304366 if (VOS_FTM_MODE == hdd_get_conparam()) {
4367 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4368 return -EINVAL;
4369 }
4370
Dino Mycle6fb96c12014-06-10 11:52:40 +05304371 status = wlan_hdd_validate_context(pHddCtx);
4372 if (0 != status)
4373 {
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304374 hddLog(LOGE, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304375 return -EINVAL;
4376 }
Dino Myclee8843b32014-07-04 14:21:45 +05304377 /* check the EXTScan Capability */
4378 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304379 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4380 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304381 {
4382 hddLog(VOS_TRACE_LEVEL_ERROR,
4383 FL("EXTScan not enabled/supported by Firmware"));
4384 return -EINVAL;
4385 }
4386
Dino Mycle6fb96c12014-06-10 11:52:40 +05304387 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4388 data, dataLen,
4389 wlan_hdd_extscan_config_policy)) {
4390 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4391 return -EINVAL;
4392 }
4393
4394 /* Parse and fetch request Id */
4395 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4396 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4397 return -EINVAL;
4398 }
4399
Dino Myclee8843b32014-07-04 14:21:45 +05304400 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304401 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304402 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304403
Dino Myclee8843b32014-07-04 14:21:45 +05304404 reqMsg.sessionId = pAdapter->sessionId;
4405 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304406
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304407 context = &pHddCtx->ext_scan_context;
4408 spin_lock(&hdd_context_lock);
4409 INIT_COMPLETION(context->response_event);
4410 context->request_id = request_id = reqMsg.requestId;
4411 spin_unlock(&hdd_context_lock);
4412
Dino Myclee8843b32014-07-04 14:21:45 +05304413 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304414 if (!HAL_STATUS_SUCCESS(status)) {
4415 hddLog(VOS_TRACE_LEVEL_ERROR,
4416 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304417 return -EINVAL;
4418 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304419
4420 /* request was sent -- wait for the response */
4421 rc = wait_for_completion_timeout(&context->response_event,
4422 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4423 if (!rc) {
4424 hddLog(LOGE, FL("sme_ResetBssHotlist timed out"));
4425 retval = -ETIMEDOUT;
4426 } else {
4427 spin_lock(&hdd_context_lock);
4428 if (context->request_id == request_id)
4429 retval = context->response_status;
4430 else
4431 retval = -EINVAL;
4432 spin_unlock(&hdd_context_lock);
4433 }
4434
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304435 EXIT();
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304436 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304437}
4438
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304439static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4440 struct wireless_dev *wdev,
4441 const void *data, int dataLen)
4442{
4443 int ret = 0;
4444
4445 vos_ssr_protect(__func__);
4446 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4447 vos_ssr_unprotect(__func__);
4448
4449 return ret;
4450}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304451#endif /* WLAN_FEATURE_EXTSCAN */
4452
Atul Mittal115287b2014-07-08 13:26:33 +05304453/*EXT TDLS*/
4454static const struct nla_policy
4455wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4456{
4457 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4458 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4459 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4460 {.type = NLA_S32 },
4461 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4462 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4463
4464};
4465
4466static const struct nla_policy
4467wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4468{
4469 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4470
4471};
4472
4473static const struct nla_policy
4474wlan_hdd_tdls_config_state_change_policy[
4475 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4476{
4477 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4478 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4479 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304480 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4481 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4482 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304483
4484};
4485
4486static const struct nla_policy
4487wlan_hdd_tdls_config_get_status_policy[
4488 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4489{
4490 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4491 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4492 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304493 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4494 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4495 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304496
4497};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304498
4499static const struct nla_policy
4500wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4501{
4502 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4503};
4504
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304505static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304506 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304507 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304508 int data_len)
4509{
4510
4511 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4512 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4513
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304514 ENTER();
4515
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304516 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304517 return -EINVAL;
4518 }
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +05304519 if (0 == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05304520 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304521 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304522 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304523 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05304524 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304525 return -ENOTSUPP;
4526 }
4527
4528 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4529 data, data_len, wlan_hdd_mac_config)) {
4530 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4531 return -EINVAL;
4532 }
4533
4534 /* Parse and fetch mac address */
4535 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4536 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4537 return -EINVAL;
4538 }
4539
4540 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4541 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4542 VOS_MAC_ADDR_LAST_3_BYTES);
4543
Siddharth Bhal76972212014-10-15 16:22:51 +05304544 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4545
4546 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304547 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4548 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304549 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4550 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4551 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4552 {
4553 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4554 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4555 VOS_MAC_ADDRESS_LEN);
4556 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304557 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304558
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +05304559 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
4560 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304561
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304562 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304563 return 0;
4564}
4565
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304566static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4567 struct wireless_dev *wdev,
4568 const void *data,
4569 int data_len)
4570{
4571 int ret = 0;
4572
4573 vos_ssr_protect(__func__);
4574 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4575 vos_ssr_unprotect(__func__);
4576
4577 return ret;
4578}
4579
4580static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304581 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304582 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304583 int data_len)
4584{
4585 u8 peer[6] = {0};
4586 struct net_device *dev = wdev->netdev;
4587 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4588 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4589 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4590 eHalStatus ret;
4591 tANI_S32 state;
4592 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304593 tANI_S32 global_operating_class = 0;
4594 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304595 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304596 int retVal;
4597
4598 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304599
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304600 if (!pAdapter) {
4601 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4602 return -EINVAL;
4603 }
4604
Atul Mittal115287b2014-07-08 13:26:33 +05304605 ret = wlan_hdd_validate_context(pHddCtx);
4606 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304607 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304608 return -EINVAL;
4609 }
4610 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304611 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304612 return -ENOTSUPP;
4613 }
4614 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4615 data, data_len,
4616 wlan_hdd_tdls_config_get_status_policy)) {
4617 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4618 return -EINVAL;
4619 }
4620
4621 /* Parse and fetch mac address */
4622 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4623 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4624 return -EINVAL;
4625 }
4626
4627 memcpy(peer, nla_data(
4628 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4629 sizeof(peer));
4630 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4631
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05304632 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05304633
Atul Mittal115287b2014-07-08 13:26:33 +05304634 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304635 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304636 NLMSG_HDRLEN);
4637
4638 if (!skb) {
4639 hddLog(VOS_TRACE_LEVEL_ERROR,
4640 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4641 return -EINVAL;
4642 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304643 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 +05304644 reason,
4645 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304646 global_operating_class,
4647 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304648 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304649 if (nla_put_s32(skb,
4650 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4651 state) ||
4652 nla_put_s32(skb,
4653 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4654 reason) ||
4655 nla_put_s32(skb,
4656 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4657 global_operating_class) ||
4658 nla_put_s32(skb,
4659 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4660 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304661
4662 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4663 goto nla_put_failure;
4664 }
4665
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304666 retVal = cfg80211_vendor_cmd_reply(skb);
4667 EXIT();
4668 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304669
4670nla_put_failure:
4671 kfree_skb(skb);
4672 return -EINVAL;
4673}
4674
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304675static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4676 struct wireless_dev *wdev,
4677 const void *data,
4678 int data_len)
4679{
4680 int ret = 0;
4681
4682 vos_ssr_protect(__func__);
4683 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4684 vos_ssr_unprotect(__func__);
4685
4686 return ret;
4687}
4688
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05304689static int wlan_hdd_cfg80211_exttdls_callback(
4690#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
4691 const tANI_U8* mac,
4692#else
4693 tANI_U8* mac,
4694#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304695 tANI_S32 state,
4696 tANI_S32 reason,
4697 void *ctx)
4698{
4699 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304700 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304701 tANI_S32 global_operating_class = 0;
4702 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304703 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304704
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304705 ENTER();
4706
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304707 if (!pAdapter) {
4708 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4709 return -EINVAL;
4710 }
4711
4712 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304713 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304714 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304715 return -EINVAL;
4716 }
4717
4718 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304719 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304720 return -ENOTSUPP;
4721 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304722 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
4723#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4724 NULL,
4725#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304726 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4727 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4728 GFP_KERNEL);
4729
4730 if (!skb) {
4731 hddLog(VOS_TRACE_LEVEL_ERROR,
4732 FL("cfg80211_vendor_event_alloc failed"));
4733 return -EINVAL;
4734 }
4735 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304736 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4737 reason,
4738 state,
4739 global_operating_class,
4740 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304741 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4742 MAC_ADDR_ARRAY(mac));
4743
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304744 if (nla_put(skb,
4745 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4746 VOS_MAC_ADDR_SIZE, mac) ||
4747 nla_put_s32(skb,
4748 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4749 state) ||
4750 nla_put_s32(skb,
4751 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4752 reason) ||
4753 nla_put_s32(skb,
4754 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4755 channel) ||
4756 nla_put_s32(skb,
4757 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4758 global_operating_class)
4759 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304760 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4761 goto nla_put_failure;
4762 }
4763
4764 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304765 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304766 return (0);
4767
4768nla_put_failure:
4769 kfree_skb(skb);
4770 return -EINVAL;
4771}
4772
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304773static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304774 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304775 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304776 int data_len)
4777{
4778 u8 peer[6] = {0};
4779 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304780 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4781 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4782 eHalStatus status;
4783 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304784 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304785 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304786
4787 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304788
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304789 if (!dev) {
4790 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4791 return -EINVAL;
4792 }
4793
4794 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4795 if (!pAdapter) {
4796 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4797 return -EINVAL;
4798 }
4799
Atul Mittal115287b2014-07-08 13:26:33 +05304800 status = wlan_hdd_validate_context(pHddCtx);
4801 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304802 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304803 return -EINVAL;
4804 }
4805 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304806 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304807 return -ENOTSUPP;
4808 }
4809 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4810 data, data_len,
4811 wlan_hdd_tdls_config_enable_policy)) {
4812 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4813 return -EINVAL;
4814 }
4815
4816 /* Parse and fetch mac address */
4817 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4819 return -EINVAL;
4820 }
4821
4822 memcpy(peer, nla_data(
4823 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4824 sizeof(peer));
4825 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4826
4827 /* Parse and fetch channel */
4828 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4829 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4830 return -EINVAL;
4831 }
4832 pReqMsg.channel = nla_get_s32(
4833 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4834 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4835
4836 /* Parse and fetch global operating class */
4837 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4838 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4839 return -EINVAL;
4840 }
4841 pReqMsg.global_operating_class = nla_get_s32(
4842 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4843 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4844 pReqMsg.global_operating_class);
4845
4846 /* Parse and fetch latency ms */
4847 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4848 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4849 return -EINVAL;
4850 }
4851 pReqMsg.max_latency_ms = nla_get_s32(
4852 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4853 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4854 pReqMsg.max_latency_ms);
4855
4856 /* Parse and fetch required bandwidth kbps */
4857 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4858 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4859 return -EINVAL;
4860 }
4861
4862 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4863 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4864 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4865 pReqMsg.min_bandwidth_kbps);
4866
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304867 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304868 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304869 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304870 wlan_hdd_cfg80211_exttdls_callback);
4871
4872 EXIT();
4873 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304874}
4875
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304876static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4877 struct wireless_dev *wdev,
4878 const void *data,
4879 int data_len)
4880{
4881 int ret = 0;
4882
4883 vos_ssr_protect(__func__);
4884 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4885 vos_ssr_unprotect(__func__);
4886
4887 return ret;
4888}
4889
4890static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304891 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304892 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304893 int data_len)
4894{
4895 u8 peer[6] = {0};
4896 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304897 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4898 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4899 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304900 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304901 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304902
4903 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304904
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304905 if (!dev) {
4906 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4907 return -EINVAL;
4908 }
4909
4910 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4911 if (!pAdapter) {
4912 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4913 return -EINVAL;
4914 }
4915
Atul Mittal115287b2014-07-08 13:26:33 +05304916 status = wlan_hdd_validate_context(pHddCtx);
4917 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304918 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304919 return -EINVAL;
4920 }
4921 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304922 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304923 return -ENOTSUPP;
4924 }
4925 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4926 data, data_len,
4927 wlan_hdd_tdls_config_disable_policy)) {
4928 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4929 return -EINVAL;
4930 }
4931 /* Parse and fetch mac address */
4932 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4933 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4934 return -EINVAL;
4935 }
4936
4937 memcpy(peer, nla_data(
4938 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4939 sizeof(peer));
4940 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4941
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304942 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
4943
4944 EXIT();
4945 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304946}
4947
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304948static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4949 struct wireless_dev *wdev,
4950 const void *data,
4951 int data_len)
4952{
4953 int ret = 0;
4954
4955 vos_ssr_protect(__func__);
4956 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
4957 vos_ssr_unprotect(__func__);
4958
4959 return ret;
4960}
4961
Dasari Srinivas7875a302014-09-26 17:50:57 +05304962static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304963__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05304964 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304965 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05304966{
4967 struct net_device *dev = wdev->netdev;
4968 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4969 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4970 struct sk_buff *skb = NULL;
4971 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304972 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05304973
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304974 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304975
4976 ret = wlan_hdd_validate_context(pHddCtx);
4977 if (0 != ret)
4978 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304979 return ret;
4980 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304981 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4982 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4983 fset |= WIFI_FEATURE_INFRA;
4984 }
4985
4986 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4987 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4988 fset |= WIFI_FEATURE_INFRA_5G;
4989 }
4990
4991#ifdef WLAN_FEATURE_P2P
4992 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4993 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4994 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4995 fset |= WIFI_FEATURE_P2P;
4996 }
4997#endif
4998
4999 /* Soft-AP is supported currently by default */
5000 fset |= WIFI_FEATURE_SOFT_AP;
5001
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305002 /* HOTSPOT is a supplicant feature, enable it by default */
5003 fset |= WIFI_FEATURE_HOTSPOT;
5004
Dasari Srinivas7875a302014-09-26 17:50:57 +05305005#ifdef WLAN_FEATURE_EXTSCAN
5006 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05305007 sme_IsFeatureSupportedByFW(EXTENDED_SCAN) &&
5008 sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)) {
5009 hddLog(LOG1, FL("Enhanced EXTScan is supported by firmware"));
Dasari Srinivas7875a302014-09-26 17:50:57 +05305010 fset |= WIFI_FEATURE_EXTSCAN;
5011 }
5012#endif
5013
Dasari Srinivas7875a302014-09-26 17:50:57 +05305014 if (sme_IsFeatureSupportedByFW(NAN)) {
5015 hddLog(LOG1, FL("NAN is supported by firmware"));
5016 fset |= WIFI_FEATURE_NAN;
5017 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305018
5019 /* D2D RTT is not supported currently by default */
5020 if (sme_IsFeatureSupportedByFW(RTT)) {
5021 hddLog(LOG1, FL("RTT is supported by firmware"));
5022 fset |= WIFI_FEATURE_D2AP_RTT;
5023 }
5024
Padma, Santhosh Kumaraac4c4d2015-12-08 16:07:47 +05305025 if (sme_IsFeatureSupportedByFW(RTT3)) {
5026 hddLog(LOG1, FL("RTT3 is supported by firmware"));
5027 fset |= WIFI_FEATURE_RTT3;
5028 }
5029
Dasari Srinivas7875a302014-09-26 17:50:57 +05305030#ifdef FEATURE_WLAN_BATCH_SCAN
5031 if (fset & WIFI_FEATURE_EXTSCAN) {
5032 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5033 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5034 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5035 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5036 fset |= WIFI_FEATURE_BATCH_SCAN;
5037 }
5038#endif
5039
5040#ifdef FEATURE_WLAN_SCAN_PNO
5041 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5042 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5043 hddLog(LOG1, FL("PNO is supported by firmware"));
5044 fset |= WIFI_FEATURE_PNO;
5045 }
5046#endif
5047
5048 /* STA+STA is supported currently by default */
5049 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5050
5051#ifdef FEATURE_WLAN_TDLS
5052 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5053 sme_IsFeatureSupportedByFW(TDLS)) {
5054 hddLog(LOG1, FL("TDLS is supported by firmware"));
5055 fset |= WIFI_FEATURE_TDLS;
5056 }
5057
5058 /* TDLS_OFFCHANNEL is not supported currently by default */
5059#endif
5060
5061#ifdef WLAN_AP_STA_CONCURRENCY
5062 /* AP+STA concurrency is supported currently by default */
5063 fset |= WIFI_FEATURE_AP_STA;
5064#endif
5065
Mukul Sharma5add0532015-08-17 15:57:47 +05305066#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5067 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5068 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5069#endif
5070
Dasari Srinivas7875a302014-09-26 17:50:57 +05305071 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5072 NLMSG_HDRLEN);
5073
5074 if (!skb) {
5075 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5076 return -EINVAL;
5077 }
5078 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5079
5080 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5081 hddLog(LOGE, FL("nla put fail"));
5082 goto nla_put_failure;
5083 }
5084
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305085 ret = cfg80211_vendor_cmd_reply(skb);
5086 EXIT();
5087 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305088
5089nla_put_failure:
5090 kfree_skb(skb);
5091 return -EINVAL;
5092}
5093
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305094static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305095wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5096 struct wireless_dev *wdev,
5097 const void *data, int data_len)
5098{
5099 int ret = 0;
5100
5101 vos_ssr_protect(__func__);
5102 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5103 vos_ssr_unprotect(__func__);
5104
5105 return ret;
5106}
5107
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305108
5109static const struct
5110nla_policy
5111qca_wlan_vendor_wifi_logger_get_ring_data_policy
5112[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = {
5113 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]
5114 = {.type = NLA_U32 },
5115};
5116
5117static int
5118 __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5119 struct wireless_dev *wdev,
5120 const void *data,
5121 int data_len)
5122{
5123 int ret;
5124 VOS_STATUS status;
5125 uint32_t ring_id;
5126 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5127 struct nlattr *tb
5128 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1];
5129
5130 ENTER();
5131
5132 ret = wlan_hdd_validate_context(hdd_ctx);
5133 if (0 != ret) {
5134 return ret;
5135 }
5136
5137 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX,
5138 data, data_len,
5139 qca_wlan_vendor_wifi_logger_get_ring_data_policy)) {
5140 hddLog(LOGE, FL("Invalid attribute"));
5141 return -EINVAL;
5142 }
5143
5144 /* Parse and fetch ring id */
5145 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) {
5146 hddLog(LOGE, FL("attr ATTR failed"));
5147 return -EINVAL;
5148 }
5149
5150 ring_id = nla_get_u32(
5151 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]);
5152
5153 hddLog(LOG1, FL("Bug report triggered by framework"));
5154
5155 status = vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
5156 WLAN_LOG_INDICATOR_FRAMEWORK,
5157 WLAN_LOG_REASON_CODE_FRAMEWORK,
Abhishek Singh837adf22015-10-01 17:37:37 +05305158 TRUE, TRUE
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305159 );
5160 if (VOS_STATUS_SUCCESS != status) {
5161 hddLog(LOGE, FL("Failed to trigger bug report"));
5162
5163 return -EINVAL;
5164 }
5165
5166 return 0;
5167
5168
5169}
5170
5171
5172static int
5173 wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5174 struct wireless_dev *wdev,
5175 const void *data,
5176 int data_len)
5177{
5178 int ret = 0;
5179
5180 vos_ssr_protect(__func__);
5181 ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy,
5182 wdev, data, data_len);
5183 vos_ssr_unprotect(__func__);
5184
5185 return ret;
5186
5187}
5188
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05305189#define MAX_CONCURRENT_MATRIX \
5190 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX
5191#define MATRIX_CONFIG_PARAM_SET_SIZE_MAX \
5192 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX
5193static const struct nla_policy
5194wlan_hdd_get_concurrency_matrix_policy[MAX_CONCURRENT_MATRIX + 1] = {
5195 [MATRIX_CONFIG_PARAM_SET_SIZE_MAX] = {.type = NLA_U32},
5196};
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305197
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305198static int
5199__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305200 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305201 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305202{
5203 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5204 uint8_t i, feature_sets, max_feature_sets;
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05305205 struct nlattr *tb[MAX_CONCURRENT_MATRIX + 1];
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305206 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305207 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5208 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305209
5210 ENTER();
5211
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305212 ret = wlan_hdd_validate_context(pHddCtx);
5213 if (0 != ret)
5214 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305215 return ret;
5216 }
5217
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05305218 if (nla_parse(tb, MAX_CONCURRENT_MATRIX, data, data_len,
5219 wlan_hdd_get_concurrency_matrix_policy)) {
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305220 hddLog(LOGE, FL("Invalid ATTR"));
5221 return -EINVAL;
5222 }
5223
5224 /* Parse and fetch max feature set */
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05305225 if (!tb[MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305226 hddLog(LOGE, FL("Attr max feature set size failed"));
5227 return -EINVAL;
5228 }
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05305229 max_feature_sets = nla_get_u32(tb[MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305230 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5231
5232 /* Fill feature combination matrix */
5233 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305234 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5235 WIFI_FEATURE_P2P;
5236
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305237 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5238 WIFI_FEATURE_SOFT_AP;
5239
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305240 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5241 WIFI_FEATURE_SOFT_AP;
5242
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305243 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5244 WIFI_FEATURE_SOFT_AP |
5245 WIFI_FEATURE_P2P;
5246
5247 /* Add more feature combinations here */
5248
5249 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5250 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5251 hddLog(LOG1, "Feature set matrix");
5252 for (i = 0; i < feature_sets; i++)
5253 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5254
5255 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5256 sizeof(u32) * feature_sets +
5257 NLMSG_HDRLEN);
5258
5259 if (reply_skb) {
5260 if (nla_put_u32(reply_skb,
5261 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5262 feature_sets) ||
5263 nla_put(reply_skb,
5264 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5265 sizeof(u32) * feature_sets, feature_set_matrix)) {
5266 hddLog(LOGE, FL("nla put fail"));
5267 kfree_skb(reply_skb);
5268 return -EINVAL;
5269 }
5270
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305271 ret = cfg80211_vendor_cmd_reply(reply_skb);
5272 EXIT();
5273 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305274 }
5275 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5276 return -ENOMEM;
5277
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305278}
5279
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05305280#undef MAX_CONCURRENT_MATRIX
5281#undef MATRIX_CONFIG_PARAM_SET_SIZE_MAX
5282
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305283static int
5284wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5285 struct wireless_dev *wdev,
5286 const void *data, int data_len)
5287{
5288 int ret = 0;
5289
5290 vos_ssr_protect(__func__);
5291 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5292 data_len);
5293 vos_ssr_unprotect(__func__);
5294
5295 return ret;
5296}
5297
c_manjeecfd1efb2015-09-25 19:32:34 +05305298
5299static int
5300__wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5301 struct wireless_dev *wdev,
5302 const void *data, int data_len)
5303{
5304 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5305 int ret;
5306 ENTER();
5307
5308 ret = wlan_hdd_validate_context(pHddCtx);
5309 if (0 != ret)
5310 {
5311 return ret;
5312 }
5313
5314 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
5315 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
5316 {
5317 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
5318 return -EINVAL;
5319 }
5320 /*call common API for FW mem dump req*/
5321 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
5322
Abhishek Singhc783fa72015-12-09 18:07:34 +05305323 if (!ret)
c_manjee04b4c5c2015-10-13 18:35:01 +05305324 {
5325 /*indicate to userspace the status of fw mem dump */
5326 wlan_indicate_mem_dump_complete(true);
5327 }
5328 else
5329 {
5330 /*else send failure to userspace */
5331 wlan_indicate_mem_dump_complete(false);
5332 }
c_manjeecfd1efb2015-09-25 19:32:34 +05305333 EXIT();
5334 return ret;
5335}
5336
5337/**
5338 * wlan_hdd_cfg80211_get_fw_mem_dump() - Get FW memory dump
5339 * @wiphy: pointer to wireless wiphy structure.
5340 * @wdev: pointer to wireless_dev structure.
5341 * @data: Pointer to the NL data.
5342 * @data_len:Length of @data
5343 *
5344 * This is called when wlan driver needs to get the firmware memory dump
5345 * via vendor specific command.
5346 *
5347 * Return: 0 on success, error number otherwise.
5348 */
5349
5350static int
5351wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5352 struct wireless_dev *wdev,
5353 const void *data, int data_len)
Sushant Kaushik8e644982015-09-23 12:18:54 +05305354{
5355 int ret = 0;
5356 vos_ssr_protect(__func__);
5357 ret = __wlan_hdd_cfg80211_get_fw_mem_dump(wiphy, wdev, data,
5358 data_len);
5359 vos_ssr_unprotect(__func__);
5360 return ret;
5361}
c_manjeecfd1efb2015-09-25 19:32:34 +05305362
Sushant Kaushik8e644982015-09-23 12:18:54 +05305363static const struct
5364nla_policy
5365qca_wlan_vendor_wifi_logger_start_policy
5366[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = {
5367 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]
5368 = {.type = NLA_U32 },
5369 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]
5370 = {.type = NLA_U32 },
5371 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]
5372 = {.type = NLA_U32 },
5373};
5374
5375/**
5376 * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable
5377 * or disable the collection of packet statistics from the firmware
5378 * @wiphy: WIPHY structure pointer
5379 * @wdev: Wireless device structure pointer
5380 * @data: Pointer to the data received
5381 * @data_len: Length of the data received
5382 *
5383 * This function is used to enable or disable the collection of packet
5384 * statistics from the firmware
5385 *
5386 * Return: 0 on success and errno on failure
5387 */
5388static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5389 struct wireless_dev *wdev,
5390 const void *data,
5391 int data_len)
5392{
5393 eHalStatus status;
5394 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5395 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1];
5396 tAniWifiStartLog start_log;
5397
5398 status = wlan_hdd_validate_context(hdd_ctx);
5399 if (0 != status) {
5400 return -EINVAL;
5401 }
5402
5403 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX,
5404 data, data_len,
5405 qca_wlan_vendor_wifi_logger_start_policy)) {
5406 hddLog(LOGE, FL("Invalid attribute"));
5407 return -EINVAL;
5408 }
5409
5410 /* Parse and fetch ring id */
5411 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) {
5412 hddLog(LOGE, FL("attr ATTR failed"));
5413 return -EINVAL;
5414 }
5415 start_log.ringId = nla_get_u32(
5416 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]);
5417 hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId);
5418
5419 /* Parse and fetch verbose level */
5420 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) {
5421 hddLog(LOGE, FL("attr verbose_level failed"));
5422 return -EINVAL;
5423 }
5424 start_log.verboseLevel = nla_get_u32(
5425 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]);
5426 hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel);
5427
5428 /* Parse and fetch flag */
5429 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) {
5430 hddLog(LOGE, FL("attr flag failed"));
5431 return -EINVAL;
5432 }
5433 start_log.flag = nla_get_u32(
5434 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]);
5435 hddLog(LOG1, FL("flag=%d"), start_log.flag);
5436
5437 if ((RING_ID_PER_PACKET_STATS == start_log.ringId) &&
Sushant Kaushik33200572015-08-05 16:46:20 +05305438 (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable ||
5439 !vos_isPktStatsEnabled()))
5440
Sushant Kaushik8e644982015-09-23 12:18:54 +05305441 {
5442 hddLog(LOGE, FL("per pkt stats not enabled"));
5443 return -EINVAL;
5444 }
Sushant Kaushik8e644982015-09-23 12:18:54 +05305445
Sushant Kaushik33200572015-08-05 16:46:20 +05305446 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
Sushant Kaushik8e644982015-09-23 12:18:54 +05305447 return 0;
5448}
5449
5450/**
5451 * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable
5452 * or disable the collection of packet statistics from the firmware
5453 * @wiphy: WIPHY structure pointer
5454 * @wdev: Wireless device structure pointer
5455 * @data: Pointer to the data received
5456 * @data_len: Length of the data received
5457 *
5458 * This function is used to enable or disable the collection of packet
5459 * statistics from the firmware
5460 *
5461 * Return: 0 on success and errno on failure
5462 */
5463static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5464 struct wireless_dev *wdev,
5465 const void *data,
5466 int data_len)
c_manjeecfd1efb2015-09-25 19:32:34 +05305467{
5468 int ret = 0;
5469
5470 vos_ssr_protect(__func__);
Sushant Kaushik8e644982015-09-23 12:18:54 +05305471
5472 ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy,
5473 wdev, data, data_len);
c_manjeecfd1efb2015-09-25 19:32:34 +05305474 vos_ssr_unprotect(__func__);
5475
5476 return ret;
c_manjeecfd1efb2015-09-25 19:32:34 +05305477}
5478
5479
Agarwal Ashish738843c2014-09-25 12:27:56 +05305480static const struct nla_policy
5481wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5482 +1] =
5483{
5484 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5485};
5486
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305487static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305488 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305489 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305490 int data_len)
5491{
5492 struct net_device *dev = wdev->netdev;
5493 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5494 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5495 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5496 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5497 eHalStatus status;
5498 u32 dfsFlag = 0;
5499
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305500 ENTER();
5501
Agarwal Ashish738843c2014-09-25 12:27:56 +05305502 status = wlan_hdd_validate_context(pHddCtx);
5503 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305504 return -EINVAL;
5505 }
5506 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5507 data, data_len,
5508 wlan_hdd_set_no_dfs_flag_config_policy)) {
5509 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5510 return -EINVAL;
5511 }
5512
5513 /* Parse and fetch required bandwidth kbps */
5514 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5515 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5516 return -EINVAL;
5517 }
5518
5519 dfsFlag = nla_get_u32(
5520 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5521 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5522 dfsFlag);
5523
5524 pHddCtx->disable_dfs_flag = dfsFlag;
5525
5526 sme_disable_dfs_channel(hHal, dfsFlag);
5527 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305528
5529 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305530 return 0;
5531}
Atul Mittal115287b2014-07-08 13:26:33 +05305532
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305533static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5534 struct wireless_dev *wdev,
5535 const void *data,
5536 int data_len)
5537{
5538 int ret = 0;
5539
5540 vos_ssr_protect(__func__);
5541 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5542 vos_ssr_unprotect(__func__);
5543
5544 return ret;
5545
5546}
5547
Mukul Sharma2a271632014-10-13 14:59:01 +05305548const struct
5549nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5550{
5551 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5552 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5553};
5554
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305555static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305556 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305557{
5558
5559 u8 bssid[6] = {0};
5560 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5561 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5562 eHalStatus status = eHAL_STATUS_SUCCESS;
5563 v_U32_t isFwrRoamEnabled = FALSE;
5564 int ret;
5565
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305566 ENTER();
5567
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305568 ret = wlan_hdd_validate_context(pHddCtx);
5569 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305570 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305571 }
5572
5573 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5574 data, data_len,
5575 qca_wlan_vendor_attr);
5576 if (ret){
5577 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5578 return -EINVAL;
5579 }
5580
5581 /* Parse and fetch Enable flag */
5582 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5583 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5584 return -EINVAL;
5585 }
5586
5587 isFwrRoamEnabled = nla_get_u32(
5588 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5589
5590 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5591
5592 /* Parse and fetch bssid */
5593 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5594 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5595 return -EINVAL;
5596 }
5597
5598 memcpy(bssid, nla_data(
5599 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5600 sizeof(bssid));
5601 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5602
5603 //Update roaming
5604 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05305605 if (!HAL_STATUS_SUCCESS(status)) {
5606 hddLog(LOGE,
5607 FL("sme_ConfigFwrRoaming failed (err=%d)"), status);
5608 return -EINVAL;
5609 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305610 EXIT();
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05305611 return 0;
Mukul Sharma2a271632014-10-13 14:59:01 +05305612}
5613
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305614static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5615 struct wireless_dev *wdev, const void *data, int data_len)
5616{
5617 int ret = 0;
5618
5619 vos_ssr_protect(__func__);
5620 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5621 vos_ssr_unprotect(__func__);
5622
5623 return ret;
5624}
5625
Sushant Kaushik847890c2015-09-28 16:05:17 +05305626static const struct
5627nla_policy
5628qca_wlan_vendor_get_wifi_info_policy[
5629 QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = {
5630 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
5631 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
5632};
5633
5634
5635/**
5636 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
5637 * @wiphy: pointer to wireless wiphy structure.
5638 * @wdev: pointer to wireless_dev structure.
5639 * @data: Pointer to the data to be passed via vendor interface
5640 * @data_len:Length of the data to be passed
5641 *
5642 * This is called when wlan driver needs to send wifi driver related info
5643 * (driver/fw version) to the user space application upon request.
5644 *
5645 * Return: Return the Success or Failure code.
5646 */
5647static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
5648 struct wireless_dev *wdev,
5649 const void *data, int data_len)
5650{
5651 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5652 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
5653 tSirVersionString version;
5654 uint32 version_len;
5655 uint8 attr;
5656 int status;
5657 struct sk_buff *reply_skb = NULL;
5658
5659 if (VOS_FTM_MODE == hdd_get_conparam()) {
5660 hddLog(LOGE, FL("Command not allowed in FTM mode"));
5661 return -EINVAL;
5662 }
5663
5664 status = wlan_hdd_validate_context(hdd_ctx);
5665 if (0 != status) {
5666 hddLog(LOGE, FL("HDD context is not valid"));
5667 return -EINVAL;
5668 }
5669
5670 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
5671 data_len, qca_wlan_vendor_get_wifi_info_policy)) {
5672 hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
5673 return -EINVAL;
5674 }
5675
5676 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
5677 hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"),
5678 QWLAN_VERSIONSTR);
5679 strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
5680 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
5681 } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
5682 hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"),
5683 hdd_ctx->fw_Version);
5684 strlcpy(version, hdd_ctx->fw_Version, sizeof(version));
5685 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
5686 } else {
5687 hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
5688 return -EINVAL;
5689 }
5690
5691 version_len = strlen(version);
5692 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
5693 version_len + NLA_HDRLEN + NLMSG_HDRLEN);
5694 if (!reply_skb) {
5695 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5696 return -ENOMEM;
5697 }
5698
5699 if (nla_put(reply_skb, attr, version_len, version)) {
5700 hddLog(LOGE, FL("nla put fail"));
5701 kfree_skb(reply_skb);
5702 return -EINVAL;
5703 }
5704
5705 return cfg80211_vendor_cmd_reply(reply_skb);
5706}
5707
5708/**
5709 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
5710 * @wiphy: pointer to wireless wiphy structure.
5711 * @wdev: pointer to wireless_dev structure.
5712 * @data: Pointer to the data to be passed via vendor interface
5713 * @data_len:Length of the data to be passed
5714 * @data_len: Length of the data received
5715 *
5716 * This function is used to enable or disable the collection of packet
5717 * statistics from the firmware
5718 *
5719 * Return: 0 on success and errno on failure
5720 */
5721
5722static int
5723wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
5724 struct wireless_dev *wdev,
5725 const void *data, int data_len)
5726
5727
5728{
5729 int ret = 0;
5730
5731 vos_ssr_protect(__func__);
5732 ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy,
5733 wdev, data, data_len);
5734 vos_ssr_unprotect(__func__);
5735
5736 return ret;
5737}
5738
5739
Gupta, Kapil7c34b322015-09-30 13:12:35 +05305740/*
5741 * define short names for the global vendor params
5742 * used by __wlan_hdd_cfg80211_monitor_rssi()
5743 */
5744#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX
5745#define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID
5746#define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL
5747#define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI
5748#define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI
5749
5750/**---------------------------------------------------------------------------
5751
5752 \brief hdd_rssi_monitor_start_done - callback to be executed when rssi
5753 monitor start is completed successfully.
5754
5755 \return - None
5756
5757 --------------------------------------------------------------------------*/
5758void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
5759{
5760 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
5761
5762 if (NULL == pHddCtx)
5763 {
5764 hddLog(VOS_TRACE_LEVEL_ERROR,
5765 "%s: HDD context is NULL",__func__);
5766 return;
5767 }
5768
5769 if (VOS_STATUS_SUCCESS == status)
5770 {
5771 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful"));
5772 }
5773 else
5774 {
5775 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful"));
5776 }
5777
5778 return;
5779}
5780
5781/**---------------------------------------------------------------------------
5782
5783 \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor
5784 stop is completed successfully.
5785
5786 \return - None
5787
5788 --------------------------------------------------------------------------*/
5789void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
5790{
5791 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
5792
5793 if (NULL == pHddCtx)
5794 {
5795 hddLog(VOS_TRACE_LEVEL_ERROR,
5796 "%s: HDD context is NULL",__func__);
5797 return;
5798 }
5799
5800 if (VOS_STATUS_SUCCESS == status)
5801 {
5802 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful"));
5803 }
5804 else
5805 {
5806 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful"));
5807 }
5808
5809 return;
5810}
5811
5812/**
5813 * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi
5814 * @wiphy: Pointer to wireless phy
5815 * @wdev: Pointer to wireless device
5816 * @data: Pointer to data
5817 * @data_len: Data length
5818 *
5819 * Return: 0 on success, negative errno on failure
5820 */
5821
5822static int
5823__wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy,
5824 struct wireless_dev *wdev,
5825 const void *data,
5826 int data_len)
5827{
5828 struct net_device *dev = wdev->netdev;
5829 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5830 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5831 hdd_station_ctx_t *pHddStaCtx;
5832 struct nlattr *tb[PARAM_MAX + 1];
5833 tpSirRssiMonitorReq pReq;
5834 eHalStatus status;
5835 int ret;
5836 uint32_t control;
5837 static const struct nla_policy policy[PARAM_MAX + 1] = {
5838 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
5839 [PARAM_CONTROL] = { .type = NLA_U32 },
5840 [PARAM_MIN_RSSI] = { .type = NLA_S8 },
5841 [PARAM_MAX_RSSI] = { .type = NLA_S8 },
5842 };
5843
5844 ENTER();
5845
5846 ret = wlan_hdd_validate_context(hdd_ctx);
5847 if (0 != ret) {
5848 return -EINVAL;
5849 }
5850
5851 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
5852 hddLog(LOGE, FL("Not in Connected state!"));
5853 return -ENOTSUPP;
5854 }
5855
5856 if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) {
5857 hddLog(LOGE, FL("Invalid ATTR"));
5858 return -EINVAL;
5859 }
5860
5861 if (!tb[PARAM_REQUEST_ID]) {
5862 hddLog(LOGE, FL("attr request id failed"));
5863 return -EINVAL;
5864 }
5865
5866 if (!tb[PARAM_CONTROL]) {
5867 hddLog(LOGE, FL("attr control failed"));
5868 return -EINVAL;
5869 }
5870
5871 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5872
5873 pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq));
5874 if(NULL == pReq)
5875 {
5876 hddLog(LOGE,
5877 FL("vos_mem_alloc failed "));
5878 return eHAL_STATUS_FAILED_ALLOC;
5879 }
5880 vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0);
5881
5882 pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
5883 pReq->sessionId = pAdapter->sessionId;
5884 pReq->rssiMonitorCbContext = hdd_ctx;
5885 control = nla_get_u32(tb[PARAM_CONTROL]);
5886 vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
5887
5888 hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"),
5889 pReq->requestId, pReq->sessionId, control);
5890
5891 if (control == QCA_WLAN_RSSI_MONITORING_START) {
5892 if (!tb[PARAM_MIN_RSSI]) {
5893 hddLog(LOGE, FL("attr min rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05305894 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05305895 }
5896
5897 if (!tb[PARAM_MAX_RSSI]) {
5898 hddLog(LOGE, FL("attr max rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05305899 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05305900 }
5901
5902 pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]);
5903 pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]);
5904 pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done;
5905
5906 if (!(pReq->minRssi < pReq->maxRssi)) {
5907 hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"),
5908 pReq->minRssi, pReq->maxRssi);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05305909 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05305910 }
5911 hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"),
5912 pReq->minRssi, pReq->maxRssi);
5913 status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq);
5914
5915 }
5916 else if (control == QCA_WLAN_RSSI_MONITORING_STOP) {
5917 pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done;
5918 status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq);
5919 }
5920 else {
5921 hddLog(LOGE, FL("Invalid control cmd: %d"), control);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05305922 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05305923 }
5924
5925 if (!HAL_STATUS_SUCCESS(status)) {
5926 hddLog(LOGE,
5927 FL("sme_set_rssi_monitoring failed(err=%d)"), status);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05305928 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05305929 }
5930
5931 return 0;
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05305932fail:
5933 vos_mem_free(pReq);
5934 return -EINVAL;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05305935}
5936
5937/*
5938 * done with short names for the global vendor params
5939 * used by __wlan_hdd_cfg80211_monitor_rssi()
5940 */
5941#undef PARAM_MAX
5942#undef PARAM_CONTROL
5943#undef PARAM_REQUEST_ID
5944#undef PARAM_MAX_RSSI
5945#undef PARAM_MIN_RSSI
5946
5947/**
5948 * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
5949 * @wiphy: wiphy structure pointer
5950 * @wdev: Wireless device structure pointer
5951 * @data: Pointer to the data received
5952 * @data_len: Length of @data
5953 *
5954 * Return: 0 on success; errno on failure
5955 */
5956static int
5957wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
5958 const void *data, int data_len)
5959{
5960 int ret;
5961
5962 vos_ssr_protect(__func__);
5963 ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len);
5964 vos_ssr_unprotect(__func__);
5965
5966 return ret;
5967}
5968
5969/**
5970 * hdd_rssi_threshold_breached_cb() - rssi breached NL event
5971 * @hddctx: HDD context
5972 * @data: rssi breached event data
5973 *
5974 * This function reads the rssi breached event %data and fill in the skb with
5975 * NL attributes and send up the NL event.
5976 * This callback execute in atomic context and must not invoke any
5977 * blocking calls.
5978 *
5979 * Return: none
5980 */
5981void hdd_rssi_threshold_breached_cb(void *hddctx,
5982 struct rssi_breach_event *data)
5983{
5984 hdd_context_t *pHddCtx = (hdd_context_t *)hddctx;
5985 int status;
5986 struct sk_buff *skb;
5987
5988 ENTER();
5989 status = wlan_hdd_validate_context(pHddCtx);
5990
5991 if (0 != status) {
5992 return;
5993 }
5994
5995 if (!data) {
5996 hddLog(LOGE, FL("data is null"));
5997 return;
5998 }
5999
6000 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
6001#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6002 NULL,
6003#endif
6004 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
6005 QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
6006 GFP_KERNEL);
6007
6008 if (!skb) {
6009 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
6010 return;
6011 }
6012
6013 hddLog(LOG1, "Req Id: %u Current rssi: %d",
6014 data->request_id, data->curr_rssi);
6015 hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR,
6016 MAC_ADDR_ARRAY(data->curr_bssid.bytes));
6017
6018 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID,
6019 data->request_id) ||
6020 nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID,
6021 sizeof(data->curr_bssid), data->curr_bssid.bytes) ||
6022 nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI,
6023 data->curr_rssi)) {
6024 hddLog(LOGE, FL("nla put fail"));
6025 goto fail;
6026 }
6027
6028 cfg80211_vendor_event(skb, GFP_KERNEL);
6029 return;
6030
6031fail:
6032 kfree_skb(skb);
6033 return;
6034}
6035
6036
6037
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306038/**
6039 * __wlan_hdd_cfg80211_setband() - set band
6040 * @wiphy: Pointer to wireless phy
6041 * @wdev: Pointer to wireless device
6042 * @data: Pointer to data
6043 * @data_len: Data length
6044 *
6045 * Return: 0 on success, negative errno on failure
6046 */
6047static int
6048__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6049 struct wireless_dev *wdev,
6050 const void *data,
6051 int data_len)
6052{
6053 struct net_device *dev = wdev->netdev;
6054 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6055 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6056 int ret;
6057 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
6058 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
6059
6060 ENTER();
6061
6062 ret = wlan_hdd_validate_context(hdd_ctx);
6063 if (0 != ret) {
6064 hddLog(LOGE, FL("HDD context is not valid"));
6065 return ret;
6066 }
6067
6068 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
6069 policy)) {
6070 hddLog(LOGE, FL("Invalid ATTR"));
6071 return -EINVAL;
6072 }
6073
6074 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
6075 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
6076 return -EINVAL;
6077 }
6078
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306079 hdd_ctx->isSetBandByNL = TRUE;
6080 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306081 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306082 hdd_ctx->isSetBandByNL = FALSE;
6083
6084 EXIT();
6085 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306086}
6087
6088/**
6089 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
6090 * @wiphy: wiphy structure pointer
6091 * @wdev: Wireless device structure pointer
6092 * @data: Pointer to the data received
6093 * @data_len: Length of @data
6094 *
6095 * Return: 0 on success; errno on failure
6096 */
6097static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6098 struct wireless_dev *wdev,
6099 const void *data,
6100 int data_len)
6101{
6102 int ret = 0;
6103
6104 vos_ssr_protect(__func__);
6105 ret = __wlan_hdd_cfg80211_setband(wiphy,
6106 wdev, data, data_len);
6107 vos_ssr_unprotect(__func__);
6108
6109 return ret;
6110}
6111
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306112#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
6113/**
6114 * hdd_map_req_id_to_pattern_id() - map request id to pattern id
6115 * @hdd_ctx: HDD context
6116 * @request_id: [input] request id
6117 * @pattern_id: [output] pattern id
6118 *
6119 * This function loops through request id to pattern id array
6120 * if the slot is available, store the request id and return pattern id
6121 * if entry exists, return the pattern id
6122 *
6123 * Return: 0 on success and errno on failure
6124 */
6125static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6126 uint32_t request_id,
6127 uint8_t *pattern_id)
6128{
6129 uint32_t i;
6130
6131 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6132 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6133 {
6134 if (hdd_ctx->op_ctx.op_table[i].request_id == 0)
6135 {
6136 hdd_ctx->op_ctx.op_table[i].request_id = request_id;
6137 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6138 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6139 return 0;
6140 } else if (hdd_ctx->op_ctx.op_table[i].request_id ==
6141 request_id) {
6142 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6143 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6144 return 0;
6145 }
6146 }
6147 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6148 return -EINVAL;
6149}
6150
6151/**
6152 * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id
6153 * @hdd_ctx: HDD context
6154 * @request_id: [input] request id
6155 * @pattern_id: [output] pattern id
6156 *
6157 * This function loops through request id to pattern id array
6158 * reset request id to 0 (slot available again) and
6159 * return pattern id
6160 *
6161 * Return: 0 on success and errno on failure
6162 */
6163static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6164 uint32_t request_id,
6165 uint8_t *pattern_id)
6166{
6167 uint32_t i;
6168
6169 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6170 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6171 {
6172 if (hdd_ctx->op_ctx.op_table[i].request_id == request_id)
6173 {
6174 hdd_ctx->op_ctx.op_table[i].request_id = 0;
6175 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6176 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6177 return 0;
6178 }
6179 }
6180 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6181 return -EINVAL;
6182}
6183
6184
6185/*
6186 * define short names for the global vendor params
6187 * used by __wlan_hdd_cfg80211_offloaded_packets()
6188 */
6189#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX
6190#define PARAM_REQUEST_ID \
6191 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID
6192#define PARAM_CONTROL \
6193 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL
6194#define PARAM_IP_PACKET \
6195 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA
6196#define PARAM_SRC_MAC_ADDR \
6197 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR
6198#define PARAM_DST_MAC_ADDR \
6199 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR
6200#define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD
6201
6202/**
6203 * wlan_hdd_add_tx_ptrn() - add tx pattern
6204 * @adapter: adapter pointer
6205 * @hdd_ctx: hdd context
6206 * @tb: nl attributes
6207 *
6208 * This function reads the NL attributes and forms a AddTxPtrn message
6209 * posts it to SME.
6210 *
6211 */
6212static int
6213wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6214 struct nlattr **tb)
6215{
6216 struct sSirAddPeriodicTxPtrn *add_req;
6217 eHalStatus status;
6218 uint32_t request_id, ret, len;
6219 uint8_t pattern_id = 0;
6220 v_MACADDR_t dst_addr;
6221 uint16_t eth_type = htons(ETH_P_IP);
6222
6223 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
6224 {
6225 hddLog(LOGE, FL("Not in Connected state!"));
6226 return -ENOTSUPP;
6227 }
6228
6229 add_req = vos_mem_malloc(sizeof(*add_req));
6230 if (!add_req)
6231 {
6232 hddLog(LOGE, FL("memory allocation failed"));
6233 return -ENOMEM;
6234 }
6235
6236 /* Parse and fetch request Id */
6237 if (!tb[PARAM_REQUEST_ID])
6238 {
6239 hddLog(LOGE, FL("attr request id failed"));
6240 goto fail;
6241 }
6242
6243 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6244 hddLog(LOG1, FL("Request Id: %u"), request_id);
6245 if (request_id == 0)
6246 {
6247 hddLog(LOGE, FL("request_id cannot be zero"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306248 goto fail;
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306249 }
6250
6251 if (!tb[PARAM_PERIOD])
6252 {
6253 hddLog(LOGE, FL("attr period failed"));
6254 goto fail;
6255 }
6256 add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]);
6257 hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs);
6258 if (add_req->usPtrnIntervalMs == 0)
6259 {
6260 hddLog(LOGE, FL("Invalid interval zero, return failure"));
6261 goto fail;
6262 }
6263
6264 if (!tb[PARAM_SRC_MAC_ADDR])
6265 {
6266 hddLog(LOGE, FL("attr source mac address failed"));
6267 goto fail;
6268 }
6269 nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR],
6270 VOS_MAC_ADDR_SIZE);
6271 hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR,
6272 MAC_ADDR_ARRAY(add_req->macAddress));
6273
6274 if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes,
6275 VOS_MAC_ADDR_SIZE))
6276 {
6277 hddLog(LOGE,
6278 FL("input src mac address and connected ap bssid are different"));
6279 goto fail;
6280 }
6281
6282 if (!tb[PARAM_DST_MAC_ADDR])
6283 {
6284 hddLog(LOGE, FL("attr dst mac address failed"));
6285 goto fail;
6286 }
6287 nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE);
6288 hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR,
6289 MAC_ADDR_ARRAY(dst_addr.bytes));
6290
6291 if (!tb[PARAM_IP_PACKET])
6292 {
6293 hddLog(LOGE, FL("attr ip packet failed"));
6294 goto fail;
6295 }
6296 add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]);
6297 hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize);
6298
6299 if (add_req->ucPtrnSize < 0 ||
6300 add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE -
6301 HDD_ETH_HEADER_LEN))
6302 {
6303 hddLog(LOGE, FL("Invalid IP packet len: %d"),
6304 add_req->ucPtrnSize);
6305 goto fail;
6306 }
6307
6308 len = 0;
6309 vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE);
6310 len += VOS_MAC_ADDR_SIZE;
6311 vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress,
6312 VOS_MAC_ADDR_SIZE);
6313 len += VOS_MAC_ADDR_SIZE;
6314 vos_mem_copy(&add_req->ucPattern[len], &eth_type, 2);
6315 len += 2;
6316
6317 /*
6318 * This is the IP packet, add 14 bytes Ethernet (802.3) header
6319 * ------------------------------------------------------------
6320 * | 14 bytes Ethernet (802.3) header | IP header and payload |
6321 * ------------------------------------------------------------
6322 */
6323 vos_mem_copy(&add_req->ucPattern[len],
6324 nla_data(tb[PARAM_IP_PACKET]),
6325 add_req->ucPtrnSize);
6326 add_req->ucPtrnSize += len;
6327
6328 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6329 add_req->ucPattern, add_req->ucPtrnSize);
6330
6331 ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6332 if (ret)
6333 {
6334 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6335 goto fail;
6336 }
6337 add_req->ucPtrnId = pattern_id;
6338 hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId);
6339
6340 status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req);
6341 if (!HAL_STATUS_SUCCESS(status))
6342 {
6343 hddLog(LOGE,
6344 FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status);
6345 goto fail;
6346 }
6347
6348 EXIT();
6349 vos_mem_free(add_req);
6350 return 0;
6351
6352fail:
6353 vos_mem_free(add_req);
6354 return -EINVAL;
6355}
6356
6357/**
6358 * wlan_hdd_del_tx_ptrn() - delete tx pattern
6359 * @adapter: adapter pointer
6360 * @hdd_ctx: hdd context
6361 * @tb: nl attributes
6362 *
6363 * This function reads the NL attributes and forms a DelTxPtrn message
6364 * posts it to SME.
6365 *
6366 */
6367static int
6368wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6369 struct nlattr **tb)
6370{
6371 struct sSirDelPeriodicTxPtrn *del_req;
6372 eHalStatus status;
6373 uint32_t request_id, ret;
6374 uint8_t pattern_id = 0;
6375
6376 /* Parse and fetch request Id */
6377 if (!tb[PARAM_REQUEST_ID])
6378 {
6379 hddLog(LOGE, FL("attr request id failed"));
6380 return -EINVAL;
6381 }
6382 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6383 if (request_id == 0)
6384 {
6385 hddLog(LOGE, FL("request_id cannot be zero"));
6386 return -EINVAL;
6387 }
6388
6389 ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6390 if (ret)
6391 {
6392 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6393 return -EINVAL;
6394 }
6395
6396 del_req = vos_mem_malloc(sizeof(*del_req));
6397 if (!del_req)
6398 {
6399 hddLog(LOGE, FL("memory allocation failed"));
6400 return -ENOMEM;
6401 }
6402
6403 vos_mem_set(del_req, sizeof(*del_req), 0);
6404 vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes,
6405 VOS_MAC_ADDR_SIZE);
6406 hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress));
6407 del_req->ucPatternIdBitmap |= (0x1 << pattern_id);
6408 hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"),
6409 request_id, pattern_id, del_req->ucPatternIdBitmap);
6410
6411 status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req);
6412 if (!HAL_STATUS_SUCCESS(status))
6413 {
6414 hddLog(LOGE,
6415 FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status);
6416 goto fail;
6417 }
6418
6419 EXIT();
6420 vos_mem_free(del_req);
6421 return 0;
6422
6423fail:
6424 vos_mem_free(del_req);
6425 return -EINVAL;
6426}
6427
6428
6429/**
6430 * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets
6431 * @wiphy: Pointer to wireless phy
6432 * @wdev: Pointer to wireless device
6433 * @data: Pointer to data
6434 * @data_len: Data length
6435 *
6436 * Return: 0 on success, negative errno on failure
6437 */
6438static int
6439__wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
6440 struct wireless_dev *wdev,
6441 const void *data,
6442 int data_len)
6443{
6444 struct net_device *dev = wdev->netdev;
6445 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6446 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6447 struct nlattr *tb[PARAM_MAX + 1];
6448 uint8_t control;
6449 int ret;
6450 static const struct nla_policy policy[PARAM_MAX + 1] =
6451 {
6452 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6453 [PARAM_CONTROL] = { .type = NLA_U32 },
6454 [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY,
6455 .len = VOS_MAC_ADDR_SIZE },
6456 [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY,
6457 .len = VOS_MAC_ADDR_SIZE },
6458 [PARAM_PERIOD] = { .type = NLA_U32 },
6459 };
6460
6461 ENTER();
6462
6463 ret = wlan_hdd_validate_context(hdd_ctx);
6464 if (0 != ret)
6465 {
6466 hddLog(LOGE, FL("HDD context is not valid"));
6467 return ret;
6468 }
6469
6470 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
6471 {
6472 hddLog(LOGE,
6473 FL("Periodic Tx Pattern Offload feature is not supported in FW!"));
6474 return -ENOTSUPP;
6475 }
6476
6477 if (nla_parse(tb, PARAM_MAX, data, data_len, policy))
6478 {
6479 hddLog(LOGE, FL("Invalid ATTR"));
6480 return -EINVAL;
6481 }
6482
6483 if (!tb[PARAM_CONTROL])
6484 {
6485 hddLog(LOGE, FL("attr control failed"));
6486 return -EINVAL;
6487 }
6488 control = nla_get_u32(tb[PARAM_CONTROL]);
6489 hddLog(LOG1, FL("Control: %d"), control);
6490
6491 if (control == WLAN_START_OFFLOADED_PACKETS)
6492 return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb);
6493 else if (control == WLAN_STOP_OFFLOADED_PACKETS)
6494 return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb);
6495 else
6496 {
6497 hddLog(LOGE, FL("Invalid control: %d"), control);
6498 return -EINVAL;
6499 }
6500}
6501
6502/*
6503 * done with short names for the global vendor params
6504 * used by __wlan_hdd_cfg80211_offloaded_packets()
6505 */
6506#undef PARAM_MAX
6507#undef PARAM_REQUEST_ID
6508#undef PARAM_CONTROL
6509#undef PARAM_IP_PACKET
6510#undef PARAM_SRC_MAC_ADDR
6511#undef PARAM_DST_MAC_ADDR
6512#undef PARAM_PERIOD
6513
6514/**
6515 * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets
6516 * @wiphy: wiphy structure pointer
6517 * @wdev: Wireless device structure pointer
6518 * @data: Pointer to the data received
6519 * @data_len: Length of @data
6520 *
6521 * Return: 0 on success; errno on failure
6522 */
6523static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
6524 struct wireless_dev *wdev,
6525 const void *data,
6526 int data_len)
6527{
6528 int ret = 0;
6529
6530 vos_ssr_protect(__func__);
6531 ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy,
6532 wdev, data, data_len);
6533 vos_ssr_unprotect(__func__);
6534
6535 return ret;
6536}
6537#endif
6538
Deepthi Gowriae6a1662015-10-12 12:59:37 +05306539static const struct
6540nla_policy
6541qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = {
Ashish Kumar Dhanotiyaddaf0482017-06-23 15:22:42 +05306542 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] =
6543 { .type = NLA_BINARY, .len = VOS_MAC_ADDR_SIZE },
Deepthi Gowriae6a1662015-10-12 12:59:37 +05306544};
6545
6546/**
6547 * wlan_hdd_cfg80211_get_link_properties() - This function is used to
6548 * get link properties like nss, rate flags and operating frequency for
6549 * the connection with the given peer.
6550 * @wiphy: WIPHY structure pointer
6551 * @wdev: Wireless device structure pointer
6552 * @data: Pointer to the data received
6553 * @data_len: Length of the data received
6554 *
6555 * This function return the above link properties on success.
6556 *
6557 * Return: 0 on success and errno on failure
6558 */
6559static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
6560 struct wireless_dev *wdev,
6561 const void *data,
6562 int data_len)
6563{
6564 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6565 struct net_device *dev = wdev->netdev;
6566 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6567 hdd_station_ctx_t *hdd_sta_ctx;
6568 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1];
6569 uint8_t peer_mac[VOS_MAC_ADDR_SIZE];
6570 uint32_t sta_id;
6571 struct sk_buff *reply_skb;
6572 uint32_t rate_flags = 0;
6573 uint8_t nss;
6574 uint8_t final_rate_flags = 0;
6575 uint32_t freq;
6576 v_CONTEXT_t pVosContext = NULL;
6577 ptSapContext pSapCtx = NULL;
6578
6579 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
6580 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
6581 return -EINVAL;
6582 }
6583
6584 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
6585 qca_wlan_vendor_attr_policy)) {
6586 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute"));
6587 return -EINVAL;
6588 }
6589
6590 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6591 hddLog(VOS_TRACE_LEVEL_ERROR,
6592 FL("Attribute peerMac not provided for mode=%d"),
6593 adapter->device_mode);
6594 return -EINVAL;
6595 }
6596
Ashish Kumar Dhanotiyaddaf0482017-06-23 15:22:42 +05306597 if (nla_len(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) < sizeof(peer_mac)) {
6598 hddLog(VOS_TRACE_LEVEL_ERROR,
6599 FL("Attribute peerMac is invalid=%d"),
6600 adapter->device_mode);
6601 return -EINVAL;
6602 }
6603
Deepthi Gowriae6a1662015-10-12 12:59:37 +05306604 memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6605 sizeof(peer_mac));
6606 hddLog(VOS_TRACE_LEVEL_INFO,
6607 FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"),
6608 MAC_ADDR_ARRAY(peer_mac), adapter->device_mode);
6609
6610 if (adapter->device_mode == WLAN_HDD_INFRA_STATION ||
6611 adapter->device_mode == WLAN_HDD_P2P_CLIENT) {
6612 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6613 if ((hdd_sta_ctx->conn_info.connState !=
6614 eConnectionState_Associated) ||
6615 !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac,
6616 VOS_MAC_ADDRESS_LEN)) {
6617 hddLog(VOS_TRACE_LEVEL_ERROR,
6618 FL("Not Associated to mac "MAC_ADDRESS_STR),
6619 MAC_ADDR_ARRAY(peer_mac));
6620 return -EINVAL;
6621 }
6622
6623 nss = 1; //pronto supports only one spatial stream
6624 freq = vos_chan_to_freq(
6625 hdd_sta_ctx->conn_info.operationChannel);
6626 rate_flags = hdd_sta_ctx->conn_info.rate_flags;
6627
6628 } else if (adapter->device_mode == WLAN_HDD_P2P_GO ||
6629 adapter->device_mode == WLAN_HDD_SOFTAP) {
6630
6631 pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext;
6632 pSapCtx = VOS_GET_SAP_CB(pVosContext);
6633 if(pSapCtx == NULL){
6634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6635 FL("psapCtx is NULL"));
6636 return -ENOENT;
6637 }
6638
6639
6640 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
6641 if (pSapCtx->aStaInfo[sta_id].isUsed &&
6642 !vos_is_macaddr_broadcast(
6643 &pSapCtx->aStaInfo[sta_id].macAddrSTA) &&
6644 vos_mem_compare(
6645 &pSapCtx->aStaInfo[sta_id].macAddrSTA,
6646 peer_mac, VOS_MAC_ADDRESS_LEN))
6647 break;
6648 }
6649
6650 if (WLAN_MAX_STA_COUNT == sta_id) {
6651 hddLog(VOS_TRACE_LEVEL_ERROR,
6652 FL("No active peer with mac="MAC_ADDRESS_STR),
6653 MAC_ADDR_ARRAY(peer_mac));
6654 return -EINVAL;
6655 }
6656
6657 nss = 1; //pronto supports only one spatial stream
6658 freq = vos_chan_to_freq(
6659 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel);
6660 rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags;
6661 } else {
6662 hddLog(VOS_TRACE_LEVEL_ERROR,
6663 FL("Not Associated! with mac"MAC_ADDRESS_STR),
6664 MAC_ADDR_ARRAY(peer_mac));
6665 return -EINVAL;
6666 }
6667
6668 if (!(rate_flags & eHAL_TX_RATE_LEGACY)) {
6669 if (rate_flags & eHAL_TX_RATE_VHT80) {
6670 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
6671 final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
6672 } else if (rate_flags & eHAL_TX_RATE_VHT40) {
6673 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
6674 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6675 } else if (rate_flags & eHAL_TX_RATE_VHT20) {
6676 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
6677 } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) {
6678 final_rate_flags |= RATE_INFO_FLAGS_MCS;
6679 if (rate_flags & eHAL_TX_RATE_HT40)
6680 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6681 }
6682
6683 if (rate_flags & eHAL_TX_RATE_SGI) {
6684 if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS))
6685 final_rate_flags |= RATE_INFO_FLAGS_MCS;
6686 final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI;
6687 }
6688 }
6689
6690 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6691 sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN);
6692
6693 if (NULL == reply_skb) {
6694 hddLog(VOS_TRACE_LEVEL_ERROR,
6695 FL("getLinkProperties: skb alloc failed"));
6696 return -EINVAL;
6697 }
6698
6699 if (nla_put_u8(reply_skb,
6700 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS,
6701 nss) ||
6702 nla_put_u8(reply_skb,
6703 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS,
6704 final_rate_flags) ||
6705 nla_put_u32(reply_skb,
6706 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ,
6707 freq)) {
6708 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed"));
6709 kfree_skb(reply_skb);
6710 return -EINVAL;
6711 }
6712
6713 return cfg80211_vendor_cmd_reply(reply_skb);
6714}
6715
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05306716#define BEACON_MISS_THRESH_2_4 \
6717 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24
6718#define BEACON_MISS_THRESH_5_0 \
6719 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306720#define PARAM_WIFICONFIG_MAX QCA_WLAN_VENDOR_ATTR_CONFIG_MAX
6721#define PARAM_MODULATED_DTIM QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM
6722#define PARAM_STATS_AVG_FACTOR QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR
6723#define PARAM_GUARD_TIME QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05306724#define PARAM_BCNMISS_PENALTY_PARAM_COUNT \
6725 QCA_WLAN_VENDOR_ATTR_CONFIG_PENALIZE_AFTER_NCONS_BEACON_MISS
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306726
6727/**
6728 * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
6729 * vendor command
6730 *
6731 * @wiphy: wiphy device pointer
6732 * @wdev: wireless device pointer
6733 * @data: Vendor command data buffer
6734 * @data_len: Buffer length
6735 *
6736 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
6737 *
6738 * Return: EOK or other error codes.
6739 */
6740
6741static int __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
6742 struct wireless_dev *wdev,
6743 const void *data,
6744 int data_len)
6745{
6746 struct net_device *dev = wdev->netdev;
6747 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6748 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6749 hdd_station_ctx_t *pHddStaCtx;
6750 struct nlattr *tb[PARAM_WIFICONFIG_MAX + 1];
6751 tpSetWifiConfigParams pReq;
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05306752 tModifyRoamParamsReqParams modifyRoamParamsReq;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306753 eHalStatus status;
6754 int ret_val;
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05306755 uint8_t hb_thresh_val;
6756
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306757 static const struct nla_policy policy[PARAM_WIFICONFIG_MAX + 1] = {
6758 [PARAM_STATS_AVG_FACTOR] = { .type = NLA_U16 },
6759 [PARAM_MODULATED_DTIM] = { .type = NLA_U32 },
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05306760 [PARAM_GUARD_TIME] = { .type = NLA_U32},
6761 [PARAM_BCNMISS_PENALTY_PARAM_COUNT] =
6762 { .type = NLA_U32},
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05306763 [BEACON_MISS_THRESH_2_4] = { .type = NLA_U8 },
6764 [BEACON_MISS_THRESH_5_0] = { .type = NLA_U8 },
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306765 };
6766
6767 ENTER();
6768
6769 if (VOS_FTM_MODE == hdd_get_conparam()) {
6770 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6771 return -EINVAL;
6772 }
6773
6774 ret_val = wlan_hdd_validate_context(pHddCtx);
6775 if (ret_val) {
6776 return ret_val;
6777 }
6778
6779 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6780
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306781 if (nla_parse(tb, PARAM_WIFICONFIG_MAX, data, data_len, policy)) {
6782 hddLog(LOGE, FL("Invalid ATTR"));
6783 return -EINVAL;
6784 }
6785
6786 /* check the Wifi Capability */
6787 if ( (TRUE != pHddCtx->cfg_ini->fEnableWifiConfig) &&
6788 (TRUE != sme_IsFeatureSupportedByFW(WIFI_CONFIG)))
6789 {
6790 hddLog(VOS_TRACE_LEVEL_ERROR,
6791 FL("WIFICONFIG not supported by Firmware"));
6792 return -EINVAL;
6793 }
6794
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05306795 if (tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]) {
6796 modifyRoamParamsReq.param = WIFI_CONFIG_SET_BCNMISS_PENALTY_COUNT;
6797 modifyRoamParamsReq.value =
6798 nla_get_u32(tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]);
6799
6800 if (eHAL_STATUS_SUCCESS !=
6801 sme_setBcnMissPenaltyCount(pHddCtx->hHal,&modifyRoamParamsReq))
6802 {
6803 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed", __func__);
6804 ret_val = -EINVAL;
6805 }
6806 return ret_val;
6807 }
6808
6809 /* Moved this down in order to provide provision to set beacon
6810 * miss penalty count irrespective of connection state.
6811 */
6812 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6813 hddLog(LOGE, FL("Not in Connected state!"));
6814 return -ENOTSUPP;
6815 }
6816
6817 pReq = vos_mem_malloc(sizeof(tSetWifiConfigParams));
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306818
6819 if (!pReq) {
6820 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6821 "%s: Not able to allocate memory for tSetWifiConfigParams",
6822 __func__);
6823 return eHAL_STATUS_E_MALLOC_FAILED;
6824 }
6825
6826 vos_mem_set(pReq, sizeof(tSetWifiConfigParams), 0);
6827
6828 pReq->sessionId = pAdapter->sessionId;
6829 vos_mem_copy( &pReq->bssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6830
6831 if (tb[PARAM_MODULATED_DTIM]) {
6832 pReq->paramValue = nla_get_u32(
6833 tb[PARAM_MODULATED_DTIM]);
6834 hddLog(LOG1, FL("Modulated DTIM: pReq->paramValue:%d "),
6835 pReq->paramValue);
Arun Khandavalli876886f2015-11-23 11:42:27 +05306836 pHddCtx->cfg_ini->enableDynamicDTIM = pReq->paramValue;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306837 hdd_set_pwrparams(pHddCtx);
6838 if (BMPS == pmcGetPmcState(pHddCtx->hHal)) {
6839 hddLog( LOG1, FL("WifiConfig: Requesting FullPower!"));
6840
6841 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
6842 iw_full_power_cbfn, pAdapter,
6843 eSME_FULL_PWR_NEEDED_BY_HDD);
6844 }
6845 else
6846 {
6847 hddLog( LOG1, FL("WifiConfig Not in BMPS state"));
6848 }
6849 }
6850
6851 if (tb[PARAM_STATS_AVG_FACTOR]) {
6852 pReq->paramType = WIFI_CONFIG_SET_AVG_STATS_FACTOR;
6853 pReq->paramValue = nla_get_u16(
6854 tb[PARAM_STATS_AVG_FACTOR]);
6855 hddLog(LOG1, FL("AVG_STATS_FACTOR pReq->paramType:%d,pReq->paramValue:%d "),
6856 pReq->paramType, pReq->paramValue);
6857 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
6858
6859 if (eHAL_STATUS_SUCCESS != status)
6860 {
6861 vos_mem_free(pReq);
6862 pReq = NULL;
6863 ret_val = -EPERM;
6864 return ret_val;
6865 }
6866 }
6867
6868
6869 if (tb[PARAM_GUARD_TIME]) {
6870 pReq->paramType = WIFI_CONFIG_SET_GUARD_TIME;
6871 pReq->paramValue = nla_get_u32(
6872 tb[PARAM_GUARD_TIME]);
6873 hddLog(LOG1, FL("GUARD_TIME pReq->paramType:%d,pReq->paramValue:%d "),
6874 pReq->paramType, pReq->paramValue);
6875 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
6876
6877 if (eHAL_STATUS_SUCCESS != status)
6878 {
6879 vos_mem_free(pReq);
6880 pReq = NULL;
6881 ret_val = -EPERM;
6882 return ret_val;
6883 }
6884
6885 }
6886
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05306887 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]) {
6888 hb_thresh_val = nla_get_u8(
6889 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]);
6890
6891 hddLog(LOG1, "WLAN set heartbeat threshold for 2.4Ghz %d",
6892 hb_thresh_val);
6893 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
6894 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
6895 NULL, eANI_BOOLEAN_FALSE);
6896
6897 status = sme_update_hb_threshold(
6898 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
6899 WNI_CFG_HEART_BEAT_THRESHOLD,
6900 hb_thresh_val, eCSR_BAND_24);
6901 if (eHAL_STATUS_SUCCESS != status) {
6902 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
6903 vos_mem_free(pReq);
6904 pReq = NULL;
6905 return -EPERM;
6906 }
6907 }
6908
6909 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]) {
6910 hb_thresh_val = nla_get_u8(
6911 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]);
6912
6913 hddLog(LOG1, "WLAN set heartbeat threshold for 5Ghz %d",
6914 hb_thresh_val);
6915 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
6916 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
6917 NULL, eANI_BOOLEAN_FALSE);
6918
6919 status = sme_update_hb_threshold(
6920 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
6921 WNI_CFG_HEART_BEAT_THRESHOLD,
6922 hb_thresh_val, eCSR_BAND_5G);
6923 if (eHAL_STATUS_SUCCESS != status) {
6924 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
6925 vos_mem_free(pReq);
6926 pReq = NULL;
6927 return -EPERM;
6928 }
6929 }
6930
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306931 EXIT();
6932 return ret_val;
6933}
6934
6935/**
6936 * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
6937 * vendor command
6938 *
6939 * @wiphy: wiphy device pointer
6940 * @wdev: wireless device pointer
6941 * @data: Vendor command data buffer
6942 * @data_len: Buffer length
6943 *
6944 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
6945 *
6946 * Return: EOK or other error codes.
6947 */
6948static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
6949 struct wireless_dev *wdev,
6950 const void *data,
6951 int data_len)
6952{
6953 int ret;
6954
6955 vos_ssr_protect(__func__);
6956 ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev,
6957 data, data_len);
6958 vos_ssr_unprotect(__func__);
6959
6960 return ret;
6961}
Anurag Chouhan6ee81542017-02-09 18:09:27 +05306962
6963/*
6964 * define short names for the global vendor params
6965 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
6966 */
6967#define STATS_SET_INVALID \
6968 QCA_ATTR_NUD_STATS_SET_INVALID
6969#define STATS_SET_START \
6970 QCA_ATTR_NUD_STATS_SET_START
6971#define STATS_GW_IPV4 \
6972 QCA_ATTR_NUD_STATS_GW_IPV4
6973#define STATS_SET_MAX \
6974 QCA_ATTR_NUD_STATS_SET_MAX
6975
6976const struct nla_policy
6977qca_wlan_vendor_set_nud_stats[STATS_SET_MAX +1] =
6978{
6979 [STATS_SET_START] = {.type = NLA_FLAG },
6980 [STATS_GW_IPV4] = {.type = NLA_U32 },
6981};
6982
6983/**
6984 * hdd_set_nud_stats_cb() - hdd callback api to get status
6985 * @data: pointer to adapter
6986 * @rsp: status
6987 *
6988 * Return: None
6989 */
6990static void hdd_set_nud_stats_cb(void *data, VOS_STATUS rsp)
6991{
6992
6993 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
6994
6995 if (NULL == adapter)
6996 return;
6997
6998 if (VOS_STATUS_SUCCESS == rsp) {
6999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7000 "%s success received STATS_SET_START", __func__);
7001 } else {
7002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7003 "%s STATS_SET_START Failed!!", __func__);
7004 }
7005 return;
7006}
7007
7008/**
7009 * __wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
7010 * @wiphy: pointer to wireless wiphy structure.
7011 * @wdev: pointer to wireless_dev structure.
7012 * @data: pointer to apfind configuration data.
7013 * @data_len: the length in byte of apfind data.
7014 *
7015 * This is called when wlan driver needs to send arp stats to
7016 * firmware.
7017 *
7018 * Return: An error code or 0 on success.
7019 */
7020static int __wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
7021 struct wireless_dev *wdev,
7022 const void *data, int data_len)
7023{
7024 struct nlattr *tb[STATS_SET_MAX + 1];
7025 struct net_device *dev = wdev->netdev;
7026 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7027 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05307028 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307029 setArpStatsParams arp_stats_params;
7030 int err = 0;
7031
7032 ENTER();
7033
7034 err = wlan_hdd_validate_context(hdd_ctx);
7035 if (0 != err)
7036 return err;
7037
7038 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
7039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7040 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
7041 return -EINVAL;
7042 }
7043
7044 err = nla_parse(tb, STATS_SET_MAX, data, data_len,
7045 qca_wlan_vendor_set_nud_stats);
7046 if (err)
7047 {
7048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7049 "%s STATS_SET_START ATTR", __func__);
7050 return err;
7051 }
7052
7053 if (tb[STATS_SET_START])
7054 {
7055 if (!tb[STATS_GW_IPV4]) {
7056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7057 "%s STATS_SET_START CMD", __func__);
7058 return -EINVAL;
7059 }
7060 arp_stats_params.flag = true;
7061 arp_stats_params.ip_addr = nla_get_u32(tb[STATS_GW_IPV4]);
7062 } else {
7063 arp_stats_params.flag = false;
7064 }
Anurag Chouhan630c5562017-03-23 14:51:47 +05307065 if (arp_stats_params.flag)
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7067 "%s STATS_SET_START Cleared!!", __func__);
Anurag Chouhan630c5562017-03-23 14:51:47 +05307068 vos_mem_zero(&adapter->hdd_stats.hddArpStats,
7069 sizeof(adapter->hdd_stats.hddArpStats));
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307070
7071 arp_stats_params.pkt_type = 1; // ARP packet type
7072
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05307073 if (arp_stats_params.flag) {
7074 hdd_ctx->track_arp_ip = arp_stats_params.ip_addr;
7075 WLANTL_SetARPFWDatapath(pVosContext, true);
7076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7077 "%s Set FW in data path for ARP with tgt IP :%d",
7078 __func__, hdd_ctx->track_arp_ip);
7079 }
7080 else {
7081 WLANTL_SetARPFWDatapath(pVosContext, false);
7082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7083 "%s Remove FW from data path", __func__);
7084 }
7085
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307086 arp_stats_params.rsp_cb_fn = hdd_set_nud_stats_cb;
7087 arp_stats_params.data_ctx = adapter;
7088
7089 if (eHAL_STATUS_SUCCESS !=
7090 sme_set_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
7091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7092 "%s STATS_SET_START CMD Failed!!", __func__);
7093 return -EINVAL;
7094 }
7095
7096 EXIT();
7097
7098 return err;
7099}
7100
7101/**
7102 * wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
7103 * @wiphy: pointer to wireless wiphy structure.
7104 * @wdev: pointer to wireless_dev structure.
7105 * @data: pointer to apfind configuration data.
7106 * @data_len: the length in byte of apfind data.
7107 *
7108 * This is called when wlan driver needs to send arp stats to
7109 * firmware.
7110 *
7111 * Return: An error code or 0 on success.
7112 */
7113static int wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
7114 struct wireless_dev *wdev,
7115 const void *data, int data_len)
7116{
7117 int ret;
7118
7119 vos_ssr_protect(__func__);
7120 ret = __wlan_hdd_cfg80211_set_nud_stats(wiphy, wdev, data, data_len);
7121 vos_ssr_unprotect(__func__);
7122
7123 return ret;
7124}
7125#undef STATS_SET_INVALID
7126#undef STATS_SET_START
7127#undef STATS_GW_IPV4
7128#undef STATS_SET_MAX
7129
7130/*
7131 * define short names for the global vendor params
7132 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
7133 */
7134#define STATS_GET_INVALID \
7135 QCA_ATTR_NUD_STATS_SET_INVALID
7136#define COUNT_FROM_NETDEV \
7137 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
7138#define COUNT_TO_LOWER_MAC \
7139 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
7140#define RX_COUNT_BY_LOWER_MAC \
7141 QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
7142#define COUNT_TX_SUCCESS \
7143 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
7144#define RSP_RX_COUNT_BY_LOWER_MAC \
7145 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
7146#define RSP_RX_COUNT_BY_UPPER_MAC \
7147 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
7148#define RSP_COUNT_TO_NETDEV \
7149 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
7150#define RSP_COUNT_OUT_OF_ORDER_DROP \
7151 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
7152#define AP_LINK_ACTIVE \
7153 QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
7154#define AP_LINK_DAD \
7155 QCA_ATTR_NUD_STATS_AP_LINK_DAD
7156#define STATS_GET_MAX \
7157 QCA_ATTR_NUD_STATS_GET_MAX
7158
7159const struct nla_policy
7160qca_wlan_vendor_get_nud_stats[STATS_GET_MAX +1] =
7161{
7162 [COUNT_FROM_NETDEV] = {.type = NLA_U16 },
7163 [COUNT_TO_LOWER_MAC] = {.type = NLA_U16 },
7164 [RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
7165 [COUNT_TX_SUCCESS] = {.type = NLA_U16 },
7166 [RSP_RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
7167 [RSP_RX_COUNT_BY_UPPER_MAC] = {.type = NLA_U16 },
7168 [RSP_COUNT_TO_NETDEV] = {.type = NLA_U16 },
7169 [RSP_COUNT_OUT_OF_ORDER_DROP] = {.type = NLA_U16 },
7170 [AP_LINK_ACTIVE] = {.type = NLA_FLAG },
7171 [AP_LINK_DAD] = {.type = NLA_FLAG },
7172};
7173
7174static void hdd_get_nud_stats_cb(void *data, rsp_stats *rsp)
7175{
7176
7177 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
7178 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
7179 struct hdd_nud_stats_context *context;
7180 int status;
7181
7182 ENTER();
7183
7184 if (NULL == adapter)
7185 return;
7186
7187 status = wlan_hdd_validate_context(hdd_ctx);
7188 if (0 != status) {
7189 return;
7190 }
7191
7192 if (!rsp) {
7193 hddLog(LOGE, FL("data is null"));
7194 return;
7195 }
7196
7197 adapter->hdd_stats.hddArpStats.tx_fw_cnt = rsp->tx_fw_cnt;
7198 adapter->hdd_stats.hddArpStats.rx_fw_cnt = rsp->rx_fw_cnt;
7199 adapter->hdd_stats.hddArpStats.tx_ack_cnt = rsp->tx_ack_cnt;
7200 adapter->dad |= rsp->dad;
7201
7202 spin_lock(&hdd_context_lock);
7203 context = &hdd_ctx->nud_stats_context;
7204 complete(&context->response_event);
7205 spin_unlock(&hdd_context_lock);
7206
7207 return;
7208}
7209static int __wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
7210 struct wireless_dev *wdev,
7211 const void *data, int data_len)
7212{
7213 int err = 0;
7214 unsigned long rc;
7215 struct hdd_nud_stats_context *context;
7216 struct net_device *dev = wdev->netdev;
7217 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7218 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7219 getArpStatsParams arp_stats_params;
7220 struct sk_buff *skb;
7221
7222 ENTER();
7223
7224 err = wlan_hdd_validate_context(hdd_ctx);
7225 if (0 != err)
7226 return err;
7227
7228 arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE;
7229 arp_stats_params.get_rsp_cb_fn = hdd_get_nud_stats_cb;
7230 arp_stats_params.data_ctx = adapter;
7231
7232 spin_lock(&hdd_context_lock);
7233 context = &hdd_ctx->nud_stats_context;
7234 INIT_COMPLETION(context->response_event);
7235 spin_unlock(&hdd_context_lock);
7236
7237 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
7238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7239 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
7240 return -EINVAL;
7241 }
7242
7243 if (eHAL_STATUS_SUCCESS !=
7244 sme_get_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
7245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7246 "%s STATS_SET_START CMD Failed!!", __func__);
7247 return -EINVAL;
7248 }
7249
7250 rc = wait_for_completion_timeout(&context->response_event,
7251 msecs_to_jiffies(WLAN_WAIT_TIME_NUD_STATS));
7252 if (!rc)
7253 {
7254 hddLog(LOGE,
7255 FL("Target response timed out request "));
7256 return -ETIMEDOUT;
7257 }
7258
7259 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7260 WLAN_NUD_STATS_LEN);
7261 if (!skb)
7262 {
7263 hddLog(VOS_TRACE_LEVEL_ERROR,
7264 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
7265 __func__);
7266 return -ENOMEM;
7267 }
7268
7269 if (nla_put_u16(skb, COUNT_FROM_NETDEV,
7270 adapter->hdd_stats.hddArpStats.txCount) ||
7271 nla_put_u16(skb, COUNT_TO_LOWER_MAC,
7272 adapter->hdd_stats.hddArpStats.tx_host_fw_sent) ||
7273 nla_put_u16(skb, RX_COUNT_BY_LOWER_MAC,
7274 adapter->hdd_stats.hddArpStats.tx_fw_cnt) ||
7275 nla_put_u16(skb, COUNT_TX_SUCCESS,
7276 adapter->hdd_stats.hddArpStats.tx_ack_cnt) ||
7277 nla_put_u16(skb, RSP_RX_COUNT_BY_LOWER_MAC,
7278 adapter->hdd_stats.hddArpStats.rx_fw_cnt) ||
7279 nla_put_u16(skb, RSP_RX_COUNT_BY_UPPER_MAC,
7280 adapter->hdd_stats.hddArpStats.rxCount) ||
7281 nla_put_u16(skb, RSP_COUNT_TO_NETDEV,
7282 adapter->hdd_stats.hddArpStats.rxDelivered) ||
7283 nla_put_u16(skb, RSP_COUNT_OUT_OF_ORDER_DROP,
7284 adapter->hdd_stats.hddArpStats.rx_host_drop_reorder)) {
7285 hddLog(LOGE, FL("nla put fail"));
7286 kfree_skb(skb);
7287 return -EINVAL;
7288 }
7289 if (adapter->con_status)
7290 nla_put_flag(skb, AP_LINK_ACTIVE);
7291 if (adapter->dad)
7292 nla_put_flag(skb, AP_LINK_DAD);
7293
7294 cfg80211_vendor_cmd_reply(skb);
7295 return err;
7296}
7297
7298static int wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
7299 struct wireless_dev *wdev,
7300 const void *data, int data_len)
7301{
7302 int ret;
7303
7304 vos_ssr_protect(__func__);
7305 ret = __wlan_hdd_cfg80211_get_nud_stats(wiphy, wdev, data, data_len);
7306 vos_ssr_unprotect(__func__);
7307
7308 return ret;
7309}
7310
7311#undef QCA_ATTR_NUD_STATS_SET_INVALID
7312#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
7313#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
7314#undef QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
7315#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
7316#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
7317#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
7318#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
7319#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
7320#undef QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
7321#undef QCA_ATTR_NUD_STATS_GET_MAX
7322
7323
7324
Kapil Guptaee33bf12016-12-20 18:27:37 +05307325#ifdef WLAN_FEATURE_APFIND
7326/**
7327 * __wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
7328 * @wiphy: pointer to wireless wiphy structure.
7329 * @wdev: pointer to wireless_dev structure.
7330 * @data: pointer to apfind configuration data.
7331 * @data_len: the length in byte of apfind data.
7332 *
7333 * This is called when wlan driver needs to send APFIND configurations to
7334 * firmware.
7335 *
7336 * Return: An error code or 0 on success.
7337 */
7338static int __wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
7339 struct wireless_dev *wdev,
7340 const void *data, int data_len)
7341{
7342 struct sme_ap_find_request_req apfind_req;
7343 VOS_STATUS status;
7344 int ret_val;
7345 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7346
7347 ENTER();
7348
7349 ret_val = wlan_hdd_validate_context(hdd_ctx);
7350 if (ret_val)
7351 return ret_val;
7352
7353 if (VOS_FTM_MODE == hdd_get_conparam()) {
7354 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7355 return -EPERM;
7356 }
7357
7358 apfind_req.request_data_len = data_len;
7359 apfind_req.request_data = data;
7360
7361 status = sme_apfind_set_cmd(&apfind_req);
7362 if (VOS_STATUS_SUCCESS != status) {
7363 ret_val = -EIO;
7364 }
7365 return ret_val;
7366}
7367
7368/**
7369 * wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
7370 * @wiphy: pointer to wireless wiphy structure.
7371 * @wdev: pointer to wireless_dev structure.
7372 * @data: pointer to apfind configuration data.
7373 * @data_len: the length in byte of apfind data.
7374 *
7375 * This is called when wlan driver needs to send APFIND configurations to
7376 * firmware.
7377 *
7378 * Return: An error code or 0 on success.
7379 */
7380static int wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
7381 struct wireless_dev *wdev,
7382 const void *data, int data_len)
7383{
7384 int ret;
7385
7386 vos_ssr_protect(__func__);
7387 ret = __wlan_hdd_cfg80211_apfind_cmd(wiphy, wdev, data, data_len);
7388 vos_ssr_unprotect(__func__);
7389
7390 return ret;
7391}
7392#endif /* WLAN_FEATURE_APFIND */
Sunil Duttc69bccb2014-05-26 21:30:20 +05307393const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
7394{
Mukul Sharma2a271632014-10-13 14:59:01 +05307395 {
7396 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7397 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
7398 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7399 WIPHY_VENDOR_CMD_NEED_NETDEV |
7400 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307401 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05307402 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05307403
7404 {
7405 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7406 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
7407 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7408 WIPHY_VENDOR_CMD_NEED_NETDEV |
7409 WIPHY_VENDOR_CMD_NEED_RUNNING,
7410 .doit = wlan_hdd_cfg80211_nan_request
7411 },
7412
Sunil Duttc69bccb2014-05-26 21:30:20 +05307413#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7414 {
7415 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7416 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
7417 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7418 WIPHY_VENDOR_CMD_NEED_NETDEV |
7419 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307420 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05307421 },
7422
7423 {
7424 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7425 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
7426 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7427 WIPHY_VENDOR_CMD_NEED_NETDEV |
7428 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307429 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05307430 },
7431
7432 {
7433 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7434 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
7435 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7436 WIPHY_VENDOR_CMD_NEED_NETDEV |
7437 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307438 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05307439 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307440#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307441#ifdef WLAN_FEATURE_EXTSCAN
7442 {
7443 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7444 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
7445 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7446 WIPHY_VENDOR_CMD_NEED_NETDEV |
7447 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307448 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05307449 },
7450 {
7451 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7452 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
7453 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7454 WIPHY_VENDOR_CMD_NEED_NETDEV |
7455 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307456 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05307457 },
7458 {
7459 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7460 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
7461 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7462 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307463 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05307464 },
7465 {
7466 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7467 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
7468 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7469 WIPHY_VENDOR_CMD_NEED_NETDEV |
7470 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307471 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05307472 },
7473 {
7474 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7475 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
7476 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7477 WIPHY_VENDOR_CMD_NEED_NETDEV |
7478 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307479 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05307480 },
7481 {
7482 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7483 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
7484 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7485 WIPHY_VENDOR_CMD_NEED_NETDEV |
7486 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307487 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307488 },
7489 {
7490 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7491 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
7492 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7493 WIPHY_VENDOR_CMD_NEED_NETDEV |
7494 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307495 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307496 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307497#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307498/*EXT TDLS*/
7499 {
7500 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7501 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
7502 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7503 WIPHY_VENDOR_CMD_NEED_NETDEV |
7504 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307505 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05307506 },
7507 {
7508 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7509 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
7510 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7511 WIPHY_VENDOR_CMD_NEED_NETDEV |
7512 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307513 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05307514 },
7515 {
7516 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7517 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
7518 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7519 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307520 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05307521 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05307522 {
7523 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7524 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
7525 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7526 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307527 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05307528 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05307529 {
7530 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7531 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
7532 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7533 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307534 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05307535 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307536 {
7537 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7538 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
7539 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7540 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307541 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307542 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307543 {
7544 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7545 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
7546 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7547 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307548 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307549 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307550 {
7551 .info.vendor_id = QCA_NL80211_VENDOR_ID,
c_manjeecfd1efb2015-09-25 19:32:34 +05307552 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP,
7553 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7554 WIPHY_VENDOR_CMD_NEED_NETDEV |
7555 WIPHY_VENDOR_CMD_NEED_RUNNING,
7556 .doit = wlan_hdd_cfg80211_get_fw_mem_dump
7557 },
7558 {
7559 .info.vendor_id = QCA_NL80211_VENDOR_ID,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307560 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
7561 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7562 WIPHY_VENDOR_CMD_NEED_NETDEV |
7563 WIPHY_VENDOR_CMD_NEED_RUNNING,
7564 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05307565 },
7566 {
7567 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7568 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
7569 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7570 WIPHY_VENDOR_CMD_NEED_NETDEV,
7571 .doit = wlan_hdd_cfg80211_wifi_logger_start
7572 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05307573 {
7574 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7575 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
7576 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7577 WIPHY_VENDOR_CMD_NEED_NETDEV|
7578 WIPHY_VENDOR_CMD_NEED_RUNNING,
7579 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307580 },
7581 {
7582 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7583 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
7584 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7585 WIPHY_VENDOR_CMD_NEED_NETDEV |
7586 WIPHY_VENDOR_CMD_NEED_RUNNING,
7587 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307588 },
7589 {
7590 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7591 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
7592 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7593 WIPHY_VENDOR_CMD_NEED_NETDEV |
7594 WIPHY_VENDOR_CMD_NEED_RUNNING,
7595 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307596 },
7597#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
7598 {
7599 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7600 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
7601 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7602 WIPHY_VENDOR_CMD_NEED_NETDEV |
7603 WIPHY_VENDOR_CMD_NEED_RUNNING,
7604 .doit = wlan_hdd_cfg80211_offloaded_packets
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307605 },
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307606#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307607 {
7608 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7609 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
7610 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7611 WIPHY_VENDOR_CMD_NEED_NETDEV |
7612 WIPHY_VENDOR_CMD_NEED_RUNNING,
7613 .doit = wlan_hdd_cfg80211_get_link_properties
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307614 },
7615 {
7616 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7617 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION,
7618 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7619 WIPHY_VENDOR_CMD_NEED_NETDEV |
7620 WIPHY_VENDOR_CMD_NEED_RUNNING,
7621 .doit = wlan_hdd_cfg80211_wifi_configuration_set
Kapil Guptaee33bf12016-12-20 18:27:37 +05307622 },
7623#ifdef WLAN_FEATURE_APFIND
7624 {
7625 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7626 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_APFIND,
7627 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7628 WIPHY_VENDOR_CMD_NEED_NETDEV,
7629 .doit = wlan_hdd_cfg80211_apfind_cmd
7630 },
7631#endif /* WLAN_FEATURE_APFIND */
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307632 {
7633 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7634 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_SET,
7635 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7636 WIPHY_VENDOR_CMD_NEED_NETDEV |
7637 WIPHY_VENDOR_CMD_NEED_RUNNING,
7638 .doit = wlan_hdd_cfg80211_set_nud_stats
7639 },
7640 {
7641 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7642 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
7643 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7644 WIPHY_VENDOR_CMD_NEED_NETDEV |
7645 WIPHY_VENDOR_CMD_NEED_RUNNING,
7646 .doit = wlan_hdd_cfg80211_get_nud_stats
7647 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307648};
7649
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007650/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05307651static const
7652struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007653{
7654#ifdef FEATURE_WLAN_CH_AVOID
7655 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05307656 .vendor_id = QCA_NL80211_VENDOR_ID,
7657 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007658 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307659#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
7660#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7661 {
7662 /* Index = 1*/
7663 .vendor_id = QCA_NL80211_VENDOR_ID,
7664 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
7665 },
7666 {
7667 /* Index = 2*/
7668 .vendor_id = QCA_NL80211_VENDOR_ID,
7669 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
7670 },
7671 {
7672 /* Index = 3*/
7673 .vendor_id = QCA_NL80211_VENDOR_ID,
7674 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
7675 },
7676 {
7677 /* Index = 4*/
7678 .vendor_id = QCA_NL80211_VENDOR_ID,
7679 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
7680 },
7681 {
7682 /* Index = 5*/
7683 .vendor_id = QCA_NL80211_VENDOR_ID,
7684 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
7685 },
7686 {
7687 /* Index = 6*/
7688 .vendor_id = QCA_NL80211_VENDOR_ID,
7689 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
7690 },
7691#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307692#ifdef WLAN_FEATURE_EXTSCAN
7693 {
7694 .vendor_id = QCA_NL80211_VENDOR_ID,
7695 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
7696 },
7697 {
7698 .vendor_id = QCA_NL80211_VENDOR_ID,
7699 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
7700 },
7701 {
7702 .vendor_id = QCA_NL80211_VENDOR_ID,
7703 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
7704 },
7705 {
7706 .vendor_id = QCA_NL80211_VENDOR_ID,
7707 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
7708 },
7709 {
7710 .vendor_id = QCA_NL80211_VENDOR_ID,
7711 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
7712 },
7713 {
7714 .vendor_id = QCA_NL80211_VENDOR_ID,
7715 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
7716 },
7717 {
7718 .vendor_id = QCA_NL80211_VENDOR_ID,
7719 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
7720 },
7721 {
7722 .vendor_id = QCA_NL80211_VENDOR_ID,
7723 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
7724 },
7725 {
7726 .vendor_id = QCA_NL80211_VENDOR_ID,
7727 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
7728 },
7729 {
7730 .vendor_id = QCA_NL80211_VENDOR_ID,
7731 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
7732 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307733#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307734/*EXT TDLS*/
7735 {
7736 .vendor_id = QCA_NL80211_VENDOR_ID,
7737 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
7738 },
c_manjeecfd1efb2015-09-25 19:32:34 +05307739 [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = {
7740 .vendor_id = QCA_NL80211_VENDOR_ID,
7741 .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP
7742 },
7743
Srinivas Dasari030bad32015-02-18 23:23:54 +05307744
Srinivas Dasaribd1cf642017-01-23 14:54:41 +05307745 [QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX] = {
Srinivas Dasari030bad32015-02-18 23:23:54 +05307746 .vendor_id = QCA_NL80211_VENDOR_ID,
7747 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
7748 },
7749
Sushant Kaushik084f6592015-09-10 13:11:56 +05307750 {
7751 .vendor_id = QCA_NL80211_VENDOR_ID,
7752 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307753 },
7754 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
7755 .vendor_id = QCA_NL80211_VENDOR_ID,
7756 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
7757 },
Padma, Santhosh Kumar7bbc7d92015-12-08 20:23:19 +05307758 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = {
7759 .vendor_id = QCA_NL80211_VENDOR_ID,
7760 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST
7761 },
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307762 [QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET_INDEX] = {
7763 .vendor_id = QCA_NL80211_VENDOR_ID,
7764 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
7765 },
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007766};
7767
Jeff Johnson295189b2012-06-20 16:38:30 -07007768/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307769 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307770 * This function is called by hdd_wlan_startup()
7771 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307772 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07007773 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307774struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07007775{
7776 struct wiphy *wiphy;
7777 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307778 /*
7779 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07007780 */
7781 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
7782
7783 if (!wiphy)
7784 {
7785 /* Print error and jump into err label and free the memory */
7786 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
7787 return NULL;
7788 }
7789
Sunil Duttc69bccb2014-05-26 21:30:20 +05307790
Jeff Johnson295189b2012-06-20 16:38:30 -07007791 return wiphy;
7792}
7793
Anurag Chouhan343af7e2016-12-16 13:11:19 +05307794#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,4,0)) || \
7795 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
7796/**
7797 * hdd_config_sched_scan_plans_to_wiphy() - configure sched scan plans to wiphy
7798 * @wiphy: pointer to wiphy
7799 * @config: pointer to config
7800 *
7801 * Return: None
7802 */
7803static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
7804 hdd_config_t *config)
7805{
7806 wiphy->max_sched_scan_plans = MAX_SCHED_SCAN_PLANS;
7807 if (config->max_sched_scan_plan_interval)
7808 wiphy->max_sched_scan_plan_interval =
7809 config->max_sched_scan_plan_interval;
7810 if (config->max_sched_scan_plan_iterations)
7811 wiphy->max_sched_scan_plan_iterations =
7812 config->max_sched_scan_plan_iterations;
7813}
7814#else
7815static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
7816 hdd_config_t *config)
7817{
7818}
7819#endif
7820
Jeff Johnson295189b2012-06-20 16:38:30 -07007821/*
7822 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307823 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07007824 * private ioctl to change the band value
7825 */
7826int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
7827{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307828 int i, j;
7829 eNVChannelEnabledType channelEnabledState;
7830
Jeff Johnsone7245742012-09-05 17:12:55 -07007831 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307832
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307833 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007834 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307835
7836 if (NULL == wiphy->bands[i])
7837 {
7838 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
7839 __func__, i);
7840 continue;
7841 }
7842
7843 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
7844 {
7845 struct ieee80211_supported_band *band = wiphy->bands[i];
7846
7847 channelEnabledState = vos_nv_getChannelEnabledState(
7848 band->channels[j].hw_value);
7849
7850 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
7851 {
Abhishek Singh678227a2014-11-04 10:52:38 +05307852 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307853 continue;
7854 }
7855 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
7856 {
7857 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7858 continue;
7859 }
7860
7861 if (NV_CHANNEL_DISABLE == channelEnabledState ||
7862 NV_CHANNEL_INVALID == channelEnabledState)
7863 {
7864 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7865 }
7866 else if (NV_CHANNEL_DFS == channelEnabledState)
7867 {
7868 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
7869 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
7870 }
7871 else
7872 {
7873 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
7874 |IEEE80211_CHAN_RADAR);
7875 }
7876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007877 }
7878 return 0;
7879}
7880/*
7881 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307882 * This function is called by hdd_wlan_startup()
7883 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 * This function is used to initialize and register wiphy structure.
7885 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307886int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007887 struct wiphy *wiphy,
7888 hdd_config_t *pCfg
7889 )
7890{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307891 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05307892 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7893
Jeff Johnsone7245742012-09-05 17:12:55 -07007894 ENTER();
7895
Jeff Johnson295189b2012-06-20 16:38:30 -07007896 /* Now bind the underlying wlan device with wiphy */
7897 set_wiphy_dev(wiphy, dev);
7898
7899 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007900
Kiet Lam6c583332013-10-14 05:37:09 +05307901#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07007902 /* the flag for the other case would be initialzed in
7903 vos_init_wiphy_from_nv_bin */
Manjeet Singh9e19de62016-08-18 18:26:41 +05307904#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7905 wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
7906#else
Amar Singhal0a402232013-10-11 20:57:16 -07007907 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05307908#endif
Manjeet Singh9e19de62016-08-18 18:26:41 +05307909#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007910
Amar Singhalfddc28c2013-09-05 13:03:40 -07007911 /* This will disable updating of NL channels from passive to
7912 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307913#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7914 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
7915#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07007916 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307917#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07007918
Amar Singhala49cbc52013-10-08 18:37:44 -07007919
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007920#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07007921 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
7922 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
7923 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07007924 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307925#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Rajeev Kumar Sirasanagandla0d6dd752016-08-17 15:01:39 +05307926 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307927#else
7928 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
7929#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007930#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007931
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007932#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007933 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08007934#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007935 || pCfg->isFastRoamIniFeatureEnabled
7936#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007937#ifdef FEATURE_WLAN_ESE
7938 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007939#endif
7940 )
7941 {
7942 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
7943 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08007944#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007945#ifdef FEATURE_WLAN_TDLS
7946 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
7947 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
7948#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307949#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05307950 if (pCfg->configPNOScanSupport)
7951 {
7952 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
7953 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
7954 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
7955 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
7956 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307957#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007958
Abhishek Singh10d85972015-04-17 10:27:23 +05307959#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7960 wiphy->features |= NL80211_FEATURE_HT_IBSS;
7961#endif
7962
Amar Singhalfddc28c2013-09-05 13:03:40 -07007963#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007964 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
7965 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07007966 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007967 driver need to determine what to do with both
7968 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07007969
7970 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07007971#else
7972 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007973#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007974
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307975 wiphy->max_scan_ssids = MAX_SCAN_SSID;
7976
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05307977 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07007978
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307979 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
7980
Jeff Johnson295189b2012-06-20 16:38:30 -07007981 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05307982 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
7983 | BIT(NL80211_IFTYPE_ADHOC)
7984 | BIT(NL80211_IFTYPE_P2P_CLIENT)
7985 | BIT(NL80211_IFTYPE_P2P_GO)
7986 | BIT(NL80211_IFTYPE_AP);
7987
7988 if (VOS_MONITOR_MODE == hdd_get_conparam())
7989 {
7990 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
7991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007992
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307993 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007994 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307995#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7996 if( pCfg->enableMCC )
7997 {
7998 /* Currently, supports up to two channels */
7999 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008000
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308001 if( !pCfg->allowMCCGODiffBI )
8002 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008003
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308004 }
8005 wiphy->iface_combinations = &wlan_hdd_iface_combination;
8006 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008007#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308008 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008009
Jeff Johnson295189b2012-06-20 16:38:30 -07008010 /* Before registering we need to update the ht capabilitied based
8011 * on ini values*/
8012 if( !pCfg->ShortGI20MhzEnable )
8013 {
8014 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
8015 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
Jeff Johnson295189b2012-06-20 16:38:30 -07008016 }
8017
8018 if( !pCfg->ShortGI40MhzEnable )
8019 {
8020 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
8021 }
8022
8023 if( !pCfg->nChannelBondingMode5GHz )
8024 {
8025 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
8026 }
Agrawal Ashish97dec502015-11-26 20:20:58 +05308027 /*
8028 * In case of static linked driver at the time of driver unload,
8029 * module exit doesn't happens. Module cleanup helps in cleaning
8030 * of static memory.
8031 * If driver load happens statically, at the time of driver unload,
8032 * wiphy flags don't get reset because of static memory.
8033 * It's better not to store channel in static memory.
8034 */
8035 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
8036 wiphy->bands[IEEE80211_BAND_2GHZ]->channels =
8037 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_2_4_GHZ));
8038 if (wiphy->bands[IEEE80211_BAND_2GHZ]->channels == NULL)
8039 {
8040 hddLog(VOS_TRACE_LEVEL_ERROR,
8041 FL("Not enough memory to allocate channels"));
8042 return -ENOMEM;
8043 }
8044 vos_mem_copy(wiphy->bands[IEEE80211_BAND_2GHZ]->channels,
8045 &hdd_channels_2_4_GHZ[0],
8046 sizeof(hdd_channels_2_4_GHZ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008047
Agrawal Ashish97dec502015-11-26 20:20:58 +05308048 if (true == hdd_is_5g_supported(pHddCtx))
8049 {
8050 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
8051 wiphy->bands[IEEE80211_BAND_5GHZ]->channels =
8052 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_5_GHZ));
8053 if (wiphy->bands[IEEE80211_BAND_5GHZ]->channels == NULL)
8054 {
8055 hddLog(VOS_TRACE_LEVEL_ERROR,
8056 FL("Not enough memory to allocate channels"));
8057 vos_mem_free(wiphy->bands[IEEE80211_BAND_2GHZ]->channels);
8058 wiphy->bands[IEEE80211_BAND_2GHZ]->channels = NULL;
8059 return -ENOMEM;
8060 }
8061 vos_mem_copy(wiphy->bands[IEEE80211_BAND_5GHZ]->channels,
8062 &hdd_channels_5_GHZ[0],
8063 sizeof(hdd_channels_5_GHZ));
8064 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308065
8066 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8067 {
8068
8069 if (NULL == wiphy->bands[i])
8070 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05308071 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308072 __func__, i);
8073 continue;
8074 }
8075
8076 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8077 {
8078 struct ieee80211_supported_band *band = wiphy->bands[i];
8079
8080 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
8081 {
8082 // Enable social channels for P2P
8083 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
8084 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
8085 else
8086 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8087 continue;
8088 }
8089 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
8090 {
8091 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8092 continue;
8093 }
8094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008095 }
8096 /*Initialise the supported cipher suite details*/
8097 wiphy->cipher_suites = hdd_cipher_suites;
8098 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
8099
8100 /*signal strength in mBm (100*dBm) */
8101 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
8102
8103#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05308104 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07008105#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008106
Sunil Duttc69bccb2014-05-26 21:30:20 +05308107 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
8108 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008109 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
8110 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
8111
Anurag Chouhan343af7e2016-12-16 13:11:19 +05308112 hdd_config_sched_scan_plans_to_wiphy(wiphy, pCfg);
8113
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308114 EXIT();
8115 return 0;
8116}
8117
8118/* In this function we are registering wiphy. */
8119int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
8120{
8121 ENTER();
8122 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008123 if (0 > wiphy_register(wiphy))
8124 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308125 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07008126 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
8127 return -EIO;
8128 }
8129
8130 EXIT();
8131 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308132}
Jeff Johnson295189b2012-06-20 16:38:30 -07008133
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308134/* In this function we are updating channel list when,
8135 regulatory domain is FCC and country code is US.
8136 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
8137 As per FCC smart phone is not a indoor device.
8138 GO should not opeate on indoor channels */
8139void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
8140{
8141 int j;
8142 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8143 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
8144 //Default counrtycode from NV at the time of wiphy initialization.
8145 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
8146 &defaultCountryCode[0]))
8147 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008148 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308149 }
8150 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
8151 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308152 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
8153 {
8154 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
8155 return;
8156 }
8157 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
8158 {
8159 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
8160 // Mark UNII -1 band channel as passive
8161 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
8162 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
8163 }
8164 }
8165}
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308166/* This function registers for all frame which supplicant is interested in */
8167void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008168{
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8170 /* Register for all P2P action, public action etc frames */
8171 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
Jeff Johnsone7245742012-09-05 17:12:55 -07008172 ENTER();
Abhishek Singh16e05762015-11-30 14:29:27 +05308173 /* Register frame indication call back */
8174 sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame);
Jeff Johnson295189b2012-06-20 16:38:30 -07008175 /* Right now we are registering these frame when driver is getting
8176 initialized. Once we will move to 2.6.37 kernel, in which we have
8177 frame register ops, we will move this code as a part of that */
8178 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308179 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07008180 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8181
8182 /* GAS Initial Response */
8183 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8184 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308185
Jeff Johnson295189b2012-06-20 16:38:30 -07008186 /* GAS Comeback Request */
8187 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8188 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8189
8190 /* GAS Comeback Response */
8191 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8192 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8193
8194 /* P2P Public Action */
8195 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308196 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008197 P2P_PUBLIC_ACTION_FRAME_SIZE );
8198
8199 /* P2P Action */
8200 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8201 (v_U8_t*)P2P_ACTION_FRAME,
8202 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07008203
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05308204 /* WNM BSS Transition Request frame */
8205 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8206 (v_U8_t*)WNM_BSS_ACTION_FRAME,
8207 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008208
8209 /* WNM-Notification */
8210 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8211 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8212 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008213}
8214
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308215void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008216{
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8218 /* Register for all P2P action, public action etc frames */
8219 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
8220
Jeff Johnsone7245742012-09-05 17:12:55 -07008221 ENTER();
8222
Jeff Johnson295189b2012-06-20 16:38:30 -07008223 /* Right now we are registering these frame when driver is getting
8224 initialized. Once we will move to 2.6.37 kernel, in which we have
8225 frame register ops, we will move this code as a part of that */
8226 /* GAS Initial Request */
8227
8228 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8229 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8230
8231 /* GAS Initial Response */
8232 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8233 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308234
Jeff Johnson295189b2012-06-20 16:38:30 -07008235 /* GAS Comeback Request */
8236 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8237 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8238
8239 /* GAS Comeback Response */
8240 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8241 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8242
8243 /* P2P Public Action */
8244 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308245 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008246 P2P_PUBLIC_ACTION_FRAME_SIZE );
8247
8248 /* P2P Action */
8249 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8250 (v_U8_t*)P2P_ACTION_FRAME,
8251 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008252 /* WNM-Notification */
8253 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8254 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8255 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008256}
8257
8258#ifdef FEATURE_WLAN_WAPI
8259void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05308260 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07008261{
8262 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8263 tCsrRoamSetKey setKey;
8264 v_BOOL_t isConnected = TRUE;
8265 int status = 0;
8266 v_U32_t roamId= 0xFF;
8267 tANI_U8 *pKeyPtr = NULL;
8268 int n = 0;
8269
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308270 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
8271 __func__, hdd_device_modetoString(pAdapter->device_mode),
8272 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008273
Gopichand Nakkalae7480202013-02-11 15:24:22 +05308274 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 setKey.keyId = key_index; // Store Key ID
8276 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
8277 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
8278 setKey.paeRole = 0 ; // the PAE role
8279 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
8280 {
8281 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
8282 }
8283 else
8284 {
8285 isConnected = hdd_connIsConnected(pHddStaCtx);
8286 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
8287 }
8288 setKey.keyLength = key_Len;
8289 pKeyPtr = setKey.Key;
8290 memcpy( pKeyPtr, key, key_Len);
8291
Arif Hussain6d2a3322013-11-17 19:50:10 -08008292 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07008293 __func__, key_Len);
8294 for (n = 0 ; n < key_Len; n++)
8295 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
8296 __func__,n,setKey.Key[n]);
8297
8298 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8299 if ( isConnected )
8300 {
8301 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8302 pAdapter->sessionId, &setKey, &roamId );
8303 }
8304 if ( status != 0 )
8305 {
8306 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8307 "[%4d] sme_RoamSetKey returned ERROR status= %d",
8308 __LINE__, status );
8309 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8310 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308311 /* Need to clear any trace of key value in the memory.
8312 * Thus zero out the memory even though it is local
8313 * variable.
8314 */
8315 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008316}
8317#endif /* FEATURE_WLAN_WAPI*/
8318
8319#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308320int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008321 beacon_data_t **ppBeacon,
8322 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008323#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308324int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008325 beacon_data_t **ppBeacon,
8326 struct cfg80211_beacon_data *params,
8327 int dtim_period)
8328#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308329{
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 int size;
8331 beacon_data_t *beacon = NULL;
8332 beacon_data_t *old = NULL;
Kapil Gupta137ef892016-12-13 19:38:00 +05308333 int head_len, tail_len, proberesp_ies_len, assocresp_ies_len;
8334 const u8 *head, *tail, *proberesp_ies, *assocresp_ies;
Jeff Johnson295189b2012-06-20 16:38:30 -07008335
Jeff Johnsone7245742012-09-05 17:12:55 -07008336 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308338 {
8339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8340 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008341 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008343
8344 old = pAdapter->sessionCtx.ap.beacon;
8345
8346 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308347 {
8348 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8349 FL("session(%d) old and new heads points to NULL"),
8350 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008351 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308352 }
8353
8354 if (params->tail && !params->tail_len)
8355 {
8356 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8357 FL("tail_len is zero but tail is not NULL"));
8358 return -EINVAL;
8359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008360
Jeff Johnson295189b2012-06-20 16:38:30 -07008361#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
8362 /* Kernel 3.0 is not updating dtim_period for set beacon */
8363 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308364 {
8365 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8366 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008367 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008369#endif
8370
Kapil Gupta137ef892016-12-13 19:38:00 +05308371 if (params->head)
8372 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 head_len = params->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308374 head = params->head;
8375 } else
8376 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008377 head_len = old->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308378 head = old->head;
8379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008380
Kapil Gupta137ef892016-12-13 19:38:00 +05308381 if (params->tail || !old)
8382 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008383 tail_len = params->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308384 tail = params->tail;
8385 } else
8386 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008387 tail_len = old->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308388 tail = old->tail;
8389 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008390
Kapil Gupta137ef892016-12-13 19:38:00 +05308391 if (params->proberesp_ies || !old)
8392 {
8393 proberesp_ies_len = params->proberesp_ies_len;
8394 proberesp_ies = params->proberesp_ies;
8395 } else
8396 {
8397 proberesp_ies_len = old->proberesp_ies_len;
8398 proberesp_ies = old->proberesp_ies;
8399 }
8400
8401 if (params->assocresp_ies || !old)
8402 {
8403 assocresp_ies_len = params->assocresp_ies_len;
8404 assocresp_ies = params->assocresp_ies;
8405 } else
8406 {
8407 assocresp_ies_len = old->assocresp_ies_len;
8408 assocresp_ies = old->assocresp_ies;
8409 }
8410
8411 size = sizeof(beacon_data_t) + head_len + tail_len +
8412 proberesp_ies_len + assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07008413
8414 beacon = kzalloc(size, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07008415 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308416 {
8417 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8418 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308420 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008421
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008422#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Kapil Gupta137ef892016-12-13 19:38:00 +05308423 if (params->dtim_period)
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 beacon->dtim_period = params->dtim_period;
8425 else
8426 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008427#else
Kapil Gupta137ef892016-12-13 19:38:00 +05308428 if (dtim_period)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008429 beacon->dtim_period = dtim_period;
8430 else
8431 beacon->dtim_period = old->dtim_period;
8432#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308433
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
8435 beacon->tail = beacon->head + head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308436 beacon->proberesp_ies = beacon->tail + tail_len;
8437 beacon->assocresp_ies = beacon->proberesp_ies + proberesp_ies_len;
8438
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 beacon->head_len = head_len;
8440 beacon->tail_len = tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308441 beacon->proberesp_ies_len = proberesp_ies_len;
8442 beacon->assocresp_ies_len= assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07008443
c_manjee527ecac2017-01-25 12:25:27 +05308444 if (head && head_len)
8445 memcpy(beacon->head, head, head_len);
8446 if (tail && tail_len)
8447 memcpy(beacon->tail, tail, tail_len);
8448 if (proberesp_ies && proberesp_ies_len)
8449 memcpy(beacon->proberesp_ies, proberesp_ies, proberesp_ies_len);
8450 if (assocresp_ies && assocresp_ies_len)
8451 memcpy(beacon->assocresp_ies, assocresp_ies, assocresp_ies_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008452
8453 *ppBeacon = beacon;
8454
8455 kfree(old);
8456
8457 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008458}
Jeff Johnson295189b2012-06-20 16:38:30 -07008459
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308460v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
8461#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
8462 const v_U8_t *pIes,
8463#else
8464 v_U8_t *pIes,
8465#endif
8466 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008467{
8468 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308469 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308471
Jeff Johnson295189b2012-06-20 16:38:30 -07008472 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308473 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008474 elem_id = ptr[0];
8475 elem_len = ptr[1];
8476 left -= 2;
8477 if(elem_len > left)
8478 {
8479 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07008480 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008481 eid,elem_len,left);
8482 return NULL;
8483 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308484 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008485 {
8486 return ptr;
8487 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308488
Jeff Johnson295189b2012-06-20 16:38:30 -07008489 left -= elem_len;
8490 ptr += (elem_len + 2);
8491 }
8492 return NULL;
8493}
8494
Jeff Johnson295189b2012-06-20 16:38:30 -07008495/* Check if rate is 11g rate or not */
8496static int wlan_hdd_rate_is_11g(u8 rate)
8497{
Sanjay Devnani28322e22013-06-21 16:13:40 -07008498 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008499 u8 i;
8500 for (i = 0; i < 8; i++)
8501 {
8502 if(rate == gRateArray[i])
8503 return TRUE;
8504 }
8505 return FALSE;
8506}
8507
8508/* Check for 11g rate and set proper 11g only mode */
8509static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
8510 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
8511{
8512 u8 i, num_rates = pIe[0];
8513
8514 pIe += 1;
8515 for ( i = 0; i < num_rates; i++)
8516 {
8517 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
8518 {
8519 /* If rate set have 11g rate than change the mode to 11G */
8520 *pSapHw_mode = eSAP_DOT11_MODE_11g;
8521 if (pIe[i] & BASIC_RATE_MASK)
8522 {
8523 /* If we have 11g rate as basic rate, it means mode
8524 is 11g only mode.
8525 */
8526 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
8527 *pCheckRatesfor11g = FALSE;
8528 }
8529 }
8530 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
8531 {
8532 *require_ht = TRUE;
8533 }
8534 }
8535 return;
8536}
8537
8538static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
8539{
8540 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
8541 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8542 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
8543 u8 checkRatesfor11g = TRUE;
8544 u8 require_ht = FALSE;
8545 u8 *pIe=NULL;
8546
8547 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
8548
8549 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
8550 pBeacon->head_len, WLAN_EID_SUPP_RATES);
8551 if (pIe != NULL)
8552 {
8553 pIe += 1;
8554 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8555 &pConfig->SapHw_mode);
8556 }
8557
8558 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8559 WLAN_EID_EXT_SUPP_RATES);
8560 if (pIe != NULL)
8561 {
8562
8563 pIe += 1;
8564 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8565 &pConfig->SapHw_mode);
8566 }
8567
8568 if( pConfig->channel > 14 )
8569 {
8570 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
8571 }
8572
8573 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8574 WLAN_EID_HT_CAPABILITY);
8575
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308576 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 {
8578 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
8579 if(require_ht)
8580 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
8581 }
8582}
8583
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308584static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
8585 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
8586{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008587 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308588 v_U8_t *pIe = NULL;
8589 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8590
8591 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
8592 pBeacon->tail, pBeacon->tail_len);
8593
8594 if (pIe)
8595 {
8596 ielen = pIe[1] + 2;
8597 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8598 {
8599 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
8600 }
8601 else
8602 {
8603 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
8604 return -EINVAL;
8605 }
8606 *total_ielen += ielen;
8607 }
8608 return 0;
8609}
8610
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008611static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
8612 v_U8_t *genie, v_U8_t *total_ielen)
8613{
8614 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8615 int left = pBeacon->tail_len;
8616 v_U8_t *ptr = pBeacon->tail;
8617 v_U8_t elem_id, elem_len;
8618 v_U16_t ielen = 0;
8619
8620 if ( NULL == ptr || 0 == left )
8621 return;
8622
8623 while (left >= 2)
8624 {
8625 elem_id = ptr[0];
8626 elem_len = ptr[1];
8627 left -= 2;
8628 if (elem_len > left)
8629 {
8630 hddLog( VOS_TRACE_LEVEL_ERROR,
8631 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
8632 elem_id, elem_len, left);
8633 return;
8634 }
8635 if (IE_EID_VENDOR == elem_id)
8636 {
8637 /* skipping the VSIE's which we don't want to include or
8638 * it will be included by existing code
8639 */
8640 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
8641#ifdef WLAN_FEATURE_WFD
8642 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
8643#endif
8644 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8645 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8646 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
8647 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8648 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
8649 {
8650 ielen = ptr[1] + 2;
8651 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8652 {
8653 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
8654 *total_ielen += ielen;
8655 }
8656 else
8657 {
8658 hddLog( VOS_TRACE_LEVEL_ERROR,
8659 "IE Length is too big "
8660 "IEs eid=%d elem_len=%d total_ie_lent=%d",
8661 elem_id, elem_len, *total_ielen);
8662 }
8663 }
8664 }
8665
8666 left -= elem_len;
8667 ptr += (elem_len + 2);
8668 }
8669 return;
8670}
8671
Kapil Gupta137ef892016-12-13 19:38:00 +05308672int wlan_hdd_cfg80211_update_apies(hdd_adapter_t *pHostapdAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008673{
8674 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308675 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008676 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07008677 int ret = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +05308678 beacon_data_t *pBeacon = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008679
8680 genie = vos_mem_malloc(MAX_GENIE_LEN);
8681
8682 if(genie == NULL) {
8683
8684 return -ENOMEM;
8685 }
8686
Kapil Gupta137ef892016-12-13 19:38:00 +05308687 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308688 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8689 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008690 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308691 hddLog(LOGE,
8692 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308693 ret = -EINVAL;
8694 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008695 }
8696
8697#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308698 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8699 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
8700 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308701 hddLog(LOGE,
8702 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308703 ret = -EINVAL;
8704 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008705 }
8706#endif
8707
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308708 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8709 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308711 hddLog(LOGE,
8712 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308713 ret = -EINVAL;
8714 goto done;
8715 }
8716
8717 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
8718 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008719 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008720 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008721
8722 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8723 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
8724 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
8725 {
8726 hddLog(LOGE,
8727 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008728 ret = -EINVAL;
8729 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 }
8731
8732 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8733 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
8734 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8735 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8736 ==eHAL_STATUS_FAILURE)
8737 {
8738 hddLog(LOGE,
8739 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008740 ret = -EINVAL;
8741 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008742 }
8743
8744 // Added for ProResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +05308745 if ((pBeacon->proberesp_ies != NULL) && (pBeacon->proberesp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 {
Kapil Gupta137ef892016-12-13 19:38:00 +05308747 u16 rem_probe_resp_ie_len = pBeacon->proberesp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07008748 u8 probe_rsp_ie_len[3] = {0};
8749 u8 counter = 0;
8750 /* Check Probe Resp Length if it is greater then 255 then Store
8751 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
8752 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
8753 Store More then 255 bytes into One Variable.
8754 */
8755 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
8756 {
8757 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
8758 {
8759 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
8760 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
8761 }
8762 else
8763 {
8764 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
8765 rem_probe_resp_ie_len = 0;
8766 }
8767 }
8768
8769 rem_probe_resp_ie_len = 0;
8770
8771 if (probe_rsp_ie_len[0] > 0)
8772 {
8773 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8774 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
Kapil Gupta137ef892016-12-13 19:38:00 +05308775 (tANI_U8*)&pBeacon->
8776 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -07008777 probe_rsp_ie_len[0], NULL,
8778 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8779 {
8780 hddLog(LOGE,
8781 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008782 ret = -EINVAL;
8783 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 }
8785 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
8786 }
8787
8788 if (probe_rsp_ie_len[1] > 0)
8789 {
8790 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8791 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
Kapil Gupta137ef892016-12-13 19:38:00 +05308792 (tANI_U8*)&pBeacon->
8793 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -07008794 probe_rsp_ie_len[1], NULL,
8795 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8796 {
8797 hddLog(LOGE,
8798 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008799 ret = -EINVAL;
8800 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 }
8802 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
8803 }
8804
8805 if (probe_rsp_ie_len[2] > 0)
8806 {
8807 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8808 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
Kapil Gupta137ef892016-12-13 19:38:00 +05308809 (tANI_U8*)&pBeacon->
8810 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -07008811 probe_rsp_ie_len[2], NULL,
8812 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8813 {
8814 hddLog(LOGE,
8815 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008816 ret = -EINVAL;
8817 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 }
8819 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
8820 }
8821
8822 if (probe_rsp_ie_len[1] == 0 )
8823 {
8824 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8825 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
8826 eANI_BOOLEAN_FALSE) )
8827 {
8828 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008829 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008830 }
8831 }
8832
8833 if (probe_rsp_ie_len[2] == 0 )
8834 {
8835 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8836 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
8837 eANI_BOOLEAN_FALSE) )
8838 {
8839 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008840 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 }
8842 }
8843
8844 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8845 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
8846 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8847 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8848 == eHAL_STATUS_FAILURE)
8849 {
8850 hddLog(LOGE,
8851 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008852 ret = -EINVAL;
8853 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008854 }
8855 }
8856 else
8857 {
8858 // Reset WNI_CFG_PROBE_RSP Flags
8859 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
8860
8861 hddLog(VOS_TRACE_LEVEL_INFO,
8862 "%s: No Probe Response IE received in set beacon",
8863 __func__);
8864 }
8865
8866 // Added for AssocResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +05308867 if ((pBeacon->assocresp_ies != NULL) && (pBeacon->assocresp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008868 {
8869 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
Kapil Gupta137ef892016-12-13 19:38:00 +05308870 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)pBeacon->assocresp_ies,
8871 pBeacon->assocresp_ies_len, NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -07008872 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8873 {
8874 hddLog(LOGE,
8875 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008876 ret = -EINVAL;
8877 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008878 }
8879
8880 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8881 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
8882 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8883 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8884 == eHAL_STATUS_FAILURE)
8885 {
8886 hddLog(LOGE,
8887 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008888 ret = -EINVAL;
8889 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 }
8891 }
8892 else
8893 {
8894 hddLog(VOS_TRACE_LEVEL_INFO,
8895 "%s: No Assoc Response IE received in set beacon",
8896 __func__);
8897
8898 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8899 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
8900 eANI_BOOLEAN_FALSE) )
8901 {
8902 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008903 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008904 }
8905 }
8906
Jeff Johnsone7245742012-09-05 17:12:55 -07008907done:
Jeff Johnson295189b2012-06-20 16:38:30 -07008908 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308909 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008910}
Jeff Johnson295189b2012-06-20 16:38:30 -07008911
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308912/*
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 * FUNCTION: wlan_hdd_validate_operation_channel
8914 * called by wlan_hdd_cfg80211_start_bss() and
8915 * wlan_hdd_cfg80211_set_channel()
8916 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308917 * channel list.
8918 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008919VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008920{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308921
Jeff Johnson295189b2012-06-20 16:38:30 -07008922 v_U32_t num_ch = 0;
8923 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
8924 u32 indx = 0;
8925 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308926 v_U8_t fValidChannel = FALSE, count = 0;
8927 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308928
Jeff Johnson295189b2012-06-20 16:38:30 -07008929 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8930
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308931 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008932 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308933 /* Validate the channel */
8934 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308936 if ( channel == rfChannels[count].channelNum )
8937 {
8938 fValidChannel = TRUE;
8939 break;
8940 }
8941 }
8942 if (fValidChannel != TRUE)
8943 {
8944 hddLog(VOS_TRACE_LEVEL_ERROR,
8945 "%s: Invalid Channel [%d]", __func__, channel);
8946 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008947 }
8948 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308949 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008950 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308951 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8952 valid_ch, &num_ch))
8953 {
8954 hddLog(VOS_TRACE_LEVEL_ERROR,
8955 "%s: failed to get valid channel list", __func__);
8956 return VOS_STATUS_E_FAILURE;
8957 }
8958 for (indx = 0; indx < num_ch; indx++)
8959 {
8960 if (channel == valid_ch[indx])
8961 {
8962 break;
8963 }
8964 }
8965
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05308966 if (indx >= num_ch)
8967 {
8968 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
8969 {
8970 eCsrBand band;
8971 unsigned int freq;
8972
8973 sme_GetFreqBand(hHal, &band);
8974
8975 if (eCSR_BAND_5G == band)
8976 {
8977#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
8978 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
8979 {
8980 freq = ieee80211_channel_to_frequency(channel,
8981 IEEE80211_BAND_2GHZ);
8982 }
8983 else
8984 {
8985 freq = ieee80211_channel_to_frequency(channel,
8986 IEEE80211_BAND_5GHZ);
8987 }
8988#else
8989 freq = ieee80211_channel_to_frequency(channel);
8990#endif
8991 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
8992 return VOS_STATUS_SUCCESS;
8993 }
8994 }
8995
8996 hddLog(VOS_TRACE_LEVEL_ERROR,
8997 "%s: Invalid Channel [%d]", __func__, channel);
8998 return VOS_STATUS_E_FAILURE;
8999 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009000 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05309001
Jeff Johnson295189b2012-06-20 16:38:30 -07009002 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309003
Jeff Johnson295189b2012-06-20 16:38:30 -07009004}
9005
Viral Modi3a32cc52013-02-08 11:14:52 -08009006/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309007 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08009008 * This function is used to set the channel number
9009 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309010static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08009011 struct ieee80211_channel *chan,
9012 enum nl80211_channel_type channel_type
9013 )
9014{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309015 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08009016 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07009017 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08009018 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309019 hdd_context_t *pHddCtx;
9020 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009021
9022 ENTER();
9023
9024 if( NULL == dev )
9025 {
9026 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009027 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009028 return -ENODEV;
9029 }
9030 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309031
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309032 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9033 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
9034 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08009035 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309036 "%s: device_mode = %s (%d) freq = %d", __func__,
9037 hdd_device_modetoString(pAdapter->device_mode),
9038 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309039
9040 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9041 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309042 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08009043 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309044 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009045 }
9046
9047 /*
9048 * Do freq to chan conversion
9049 * TODO: for 11a
9050 */
9051
9052 channel = ieee80211_frequency_to_channel(freq);
9053
9054 /* Check freq range */
9055 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
9056 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
9057 {
9058 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009059 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08009060 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
9061 WNI_CFG_CURRENT_CHANNEL_STAMAX);
9062 return -EINVAL;
9063 }
9064
9065 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
9066
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05309067 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
9068 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08009069 {
9070 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
9071 {
9072 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009073 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08009074 return -EINVAL;
9075 }
9076 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9077 "%s: set channel to [%d] for device mode =%d",
9078 __func__, channel,pAdapter->device_mode);
9079 }
9080 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08009081 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08009082 )
9083 {
9084 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9085 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
9086 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9087
9088 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
9089 {
9090 /* Link is up then return cant set channel*/
9091 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009092 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009093 return -EINVAL;
9094 }
9095
9096 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
9097 pHddStaCtx->conn_info.operationChannel = channel;
9098 pRoamProfile->ChannelInfo.ChannelList =
9099 &pHddStaCtx->conn_info.operationChannel;
9100 }
9101 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08009102 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08009103 )
9104 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309105 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
9106 {
9107 if(VOS_STATUS_SUCCESS !=
9108 wlan_hdd_validate_operation_channel(pAdapter,channel))
9109 {
9110 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009111 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309112 return -EINVAL;
9113 }
9114 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9115 }
9116 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08009117 {
9118 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
9119
9120 /* If auto channel selection is configured as enable/ 1 then ignore
9121 channel set by supplicant
9122 */
9123 if ( cfg_param->apAutoChannelSelection )
9124 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309125 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
9126 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08009127 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309128 "%s: set channel to auto channel (0) for device mode =%s (%d)",
9129 __func__, hdd_device_modetoString(pAdapter->device_mode),
9130 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08009131 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309132 else
9133 {
9134 if(VOS_STATUS_SUCCESS !=
9135 wlan_hdd_validate_operation_channel(pAdapter,channel))
9136 {
9137 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009138 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309139 return -EINVAL;
9140 }
9141 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9142 }
Viral Modi3a32cc52013-02-08 11:14:52 -08009143 }
9144 }
9145 else
9146 {
9147 hddLog(VOS_TRACE_LEVEL_FATAL,
9148 "%s: Invalid device mode failed to set valid channel", __func__);
9149 return -EINVAL;
9150 }
9151 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309152 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009153}
9154
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309155static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
9156 struct net_device *dev,
9157 struct ieee80211_channel *chan,
9158 enum nl80211_channel_type channel_type
9159 )
9160{
9161 int ret;
9162
9163 vos_ssr_protect(__func__);
9164 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
9165 vos_ssr_unprotect(__func__);
9166
9167 return ret;
9168}
9169
Anurag Chouhan83026002016-12-13 22:46:21 +05309170#ifdef DHCP_SERVER_OFFLOAD
9171void hdd_dhcp_server_offload_done(void *fw_dhcp_srv_offload_cb_context,
9172 VOS_STATUS status)
9173{
9174 hdd_adapter_t* adapter = (hdd_adapter_t*)fw_dhcp_srv_offload_cb_context;
9175
9176 ENTER();
9177
9178 if (NULL == adapter)
9179 {
9180 hddLog(VOS_TRACE_LEVEL_ERROR,
9181 "%s: adapter is NULL",__func__);
9182 return;
9183 }
9184
9185 adapter->dhcp_status.dhcp_offload_status = status;
9186 vos_event_set(&adapter->dhcp_status.vos_event);
9187 return;
9188}
9189
9190/**
9191 * wlan_hdd_set_dhcp_server_offload() - set dhcp server offload
9192 * @hostapd_adapter: pointer to hostapd adapter.
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309193 * @re_init: flag set if api called post ssr
Anurag Chouhan83026002016-12-13 22:46:21 +05309194 *
9195 * Return: None
9196 */
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309197VOS_STATUS wlan_hdd_set_dhcp_server_offload(hdd_adapter_t *hostapd_adapter,
9198 bool re_init)
Anurag Chouhan83026002016-12-13 22:46:21 +05309199{
9200 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(hostapd_adapter);
9201 sir_dhcp_srv_offload_info dhcp_srv_info;
9202 tANI_U8 num_entries = 0;
9203 tANI_U8 srv_ip[IPADDR_NUM_ENTRIES];
9204 tANI_U8 num;
9205 tANI_U32 temp;
9206 VOS_STATUS ret;
9207
9208 ENTER();
9209
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309210 if (!re_init) {
9211 ret = wlan_hdd_validate_context(hdd_ctx);
9212 if (0 != ret)
9213 return VOS_STATUS_E_INVAL;
9214 }
Anurag Chouhan83026002016-12-13 22:46:21 +05309215
9216 /* Prepare the request to send to SME */
9217 dhcp_srv_info = vos_mem_malloc(sizeof(*dhcp_srv_info));
9218 if (NULL == dhcp_srv_info) {
9219 hddLog(VOS_TRACE_LEVEL_ERROR,
9220 "%s: could not allocate tDhcpSrvOffloadInfo!", __func__);
9221 return VOS_STATUS_E_NOMEM;
9222 }
9223
9224 vos_mem_zero(dhcp_srv_info, sizeof(*dhcp_srv_info));
9225
9226 dhcp_srv_info->bssidx = hostapd_adapter->sessionId;
9227 dhcp_srv_info->dhcp_srv_offload_enabled = TRUE;
9228 dhcp_srv_info->dhcp_client_num = hdd_ctx->cfg_ini->dhcp_max_num_clients;
9229 dhcp_srv_info->start_lsb = hdd_ctx->cfg_ini->dhcp_start_lsb;
9230 dhcp_srv_info->dhcp_offload_callback = hdd_dhcp_server_offload_done;
9231 dhcp_srv_info->dhcp_server_offload_cb_context = hostapd_adapter;
9232
9233 hdd_string_to_u8_array(hdd_ctx->cfg_ini->dhcp_srv_ip,
9234 srv_ip,
9235 &num_entries,
Anurag Chouhanac145c22016-11-22 16:51:47 +05309236 IPADDR_NUM_ENTRIES, ".");
Anurag Chouhan83026002016-12-13 22:46:21 +05309237 if (num_entries != IPADDR_NUM_ENTRIES) {
9238 hddLog(VOS_TRACE_LEVEL_ERROR,
9239 "%s: incorrect IP address (%s) assigned for DHCP server!",
9240 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9241 vos_mem_free(dhcp_srv_info);
9242 return VOS_STATUS_E_FAILURE;
9243 }
9244
9245 if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) {
9246 hddLog(VOS_TRACE_LEVEL_ERROR,
9247 "%s: invalid IP address (%s)! It could NOT be multicast IP address!",
9248 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9249 vos_mem_free(dhcp_srv_info);
9250 return VOS_STATUS_E_FAILURE;
9251 }
9252
9253 if (srv_ip[IPADDR_NUM_ENTRIES-1] >= DHCP_START_POOL_ADDRESS) {
9254 hddLog(VOS_TRACE_LEVEL_ERROR,
9255 "%s: invalid IP address (%s)! The last field must be less than 100!",
9256 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9257 vos_mem_free(dhcp_srv_info);
9258 return VOS_STATUS_E_FAILURE;
9259 }
9260
9261 for (num = 0; num < num_entries; num++) {
9262 temp = srv_ip[num];
9263 dhcp_srv_info->dhcp_srv_ip |= (temp << (8 * num));
9264 }
9265
9266 if (eHAL_STATUS_SUCCESS !=
9267 sme_set_dhcp_srv_offload(hdd_ctx->hHal, dhcp_srv_info)) {
9268 hddLog(VOS_TRACE_LEVEL_ERROR,
9269 "%s: sme_set_dhcp_srv_offload fail!", __func__);
9270 vos_mem_free(dhcp_srv_info);
9271 return VOS_STATUS_E_FAILURE;
9272 }
9273
9274 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9275 "%s: enable DHCP Server offload successfully!", __func__);
9276
9277 vos_mem_free(dhcp_srv_info);
9278 return 0;
9279}
9280#endif /* DHCP_SERVER_OFFLOAD */
9281
Jeff Johnson295189b2012-06-20 16:38:30 -07009282#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9283static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9284 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009285#else
9286static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9287 struct cfg80211_beacon_data *params,
9288 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309289 enum nl80211_hidden_ssid hidden_ssid,
9290 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009291#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009292{
9293 tsap_Config_t *pConfig;
9294 beacon_data_t *pBeacon = NULL;
9295 struct ieee80211_mgmt *pMgmt_frame;
9296 v_U8_t *pIe=NULL;
9297 v_U16_t capab_info;
9298 eCsrAuthType RSNAuthType;
9299 eCsrEncryptionType RSNEncryptType;
9300 eCsrEncryptionType mcRSNEncryptType;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309301 int status = VOS_STATUS_SUCCESS, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009302 tpWLAN_SAPEventCB pSapEventCallback;
9303 hdd_hostapd_state_t *pHostapdState;
Jeff Johnson295189b2012-06-20 16:38:30 -07009304 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309305 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009306 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309307 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07009308 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08009309 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05309310 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07009311 v_BOOL_t MFPCapable = VOS_FALSE;
9312 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309313 v_BOOL_t sapEnable11AC =
9314 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Kapil Gupta137ef892016-12-13 19:38:00 +05309315 u_int16_t prev_rsn_length = 0;
9316
Jeff Johnson295189b2012-06-20 16:38:30 -07009317 ENTER();
9318
Nitesh Shah9b066282017-06-06 18:05:52 +05309319 wlan_hdd_tdls_disable_offchan_and_teardown_links(pHddCtx);
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309320 iniConfig = pHddCtx->cfg_ini;
9321
Jeff Johnson295189b2012-06-20 16:38:30 -07009322 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
9323
9324 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9325
9326 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9327
9328 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9329
9330 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
9331
9332 //channel is already set in the set_channel Call back
9333 //pConfig->channel = pCommitConfig->channel;
9334
9335 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309336 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07009337 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
9338
9339 pConfig->dtim_period = pBeacon->dtim_period;
9340
Arif Hussain6d2a3322013-11-17 19:50:10 -08009341 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07009342 pConfig->dtim_period);
9343
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08009344 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07009345 {
9346 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05309348 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
9349 {
9350 tANI_BOOLEAN restartNeeded;
9351 pConfig->ieee80211d = 1;
9352 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
9353 sme_setRegInfo(hHal, pConfig->countryCode);
9354 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
9355 }
9356 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009357 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07009358 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07009359 pConfig->ieee80211d = 1;
9360 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
9361 sme_setRegInfo(hHal, pConfig->countryCode);
9362 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009364 else
9365 {
9366 pConfig->ieee80211d = 0;
9367 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309368 /*
9369 * If auto channel is configured i.e. channel is 0,
9370 * so skip channel validation.
9371 */
9372 if( AUTO_CHANNEL_SELECT != pConfig->channel )
9373 {
9374 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
9375 {
9376 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009377 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309378 return -EINVAL;
9379 }
9380 }
9381 else
9382 {
9383 if(1 != pHddCtx->is_dynamic_channel_range_set)
9384 {
9385 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
9386 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
9387 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
9388 }
9389 pHddCtx->is_dynamic_channel_range_set = 0;
9390 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009391 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009392 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009393 {
9394 pConfig->ieee80211d = 0;
9395 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309396
9397#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9398 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9399 pConfig->authType = eSAP_OPEN_SYSTEM;
9400 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9401 pConfig->authType = eSAP_SHARED_KEY;
9402 else
9403 pConfig->authType = eSAP_AUTO_SWITCH;
9404#else
9405 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9406 pConfig->authType = eSAP_OPEN_SYSTEM;
9407 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9408 pConfig->authType = eSAP_SHARED_KEY;
9409 else
9410 pConfig->authType = eSAP_AUTO_SWITCH;
9411#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009412
9413 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309414
9415 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07009416 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05309417#ifdef SAP_AUTH_OFFLOAD
9418 /* In case of sap offload, hostapd.conf is configuted with open mode and
9419 * security is configured from ini file. Due to open mode in hostapd.conf
9420 * privacy bit is set to false which will result in not sending,
9421 * data packets as encrypted.
9422 * If enable_sap_auth_offload is enabled in ini and
9423 * sap_auth_offload_sec_type is type of WPA2-PSK,
9424 * driver will set privacy bit to 1.
9425 */
9426 if (pHddCtx->cfg_ini->enable_sap_auth_offload &&
9427 pHddCtx->cfg_ini->sap_auth_offload_sec_type)
9428 pConfig->privacy = VOS_TRUE;
9429#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009430
9431 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
9432
9433 /*Set wps station to configured*/
9434 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
9435
9436 if(pIe)
9437 {
9438 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
9439 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009440 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 return -EINVAL;
9442 }
9443 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
9444 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009445 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07009446 /* Check 15 bit of WPS IE as it contain information for wps state
9447 * WPS state
9448 */
9449 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
9450 {
9451 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
9452 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
9453 {
9454 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
9455 }
9456 }
9457 }
9458 else
9459 {
9460 pConfig->wps_state = SAP_WPS_DISABLED;
9461 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309462 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07009463
c_hpothufe599e92014-06-16 11:38:55 +05309464 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9465 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9466 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
9467 eCSR_ENCRYPT_TYPE_NONE;
9468
Jeff Johnson295189b2012-06-20 16:38:30 -07009469 pConfig->RSNWPAReqIELength = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +05309470 memset(&pConfig->RSNWPAReqIE[0], 0, sizeof(pConfig->RSNWPAReqIE));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309471 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009472 WLAN_EID_RSN);
9473 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309474 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +05309476 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
9477 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
9478 pConfig->RSNWPAReqIELength);
9479 else
9480 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
9481 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309482 /* The actual processing may eventually be more extensive than
9483 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07009484 * by the app.
9485 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309486 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009487 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9488 &RSNEncryptType,
9489 &mcRSNEncryptType,
9490 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009491 &MFPCapable,
9492 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +05309493 pConfig->RSNWPAReqIE[1]+2,
9494 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009495
9496 if( VOS_STATUS_SUCCESS == status )
9497 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309498 /* Now copy over all the security attributes you have
9499 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009500 * */
9501 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9502 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9503 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9504 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309505 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009506 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9508 }
9509 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309510
Jeff Johnson295189b2012-06-20 16:38:30 -07009511 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9512 pBeacon->tail, pBeacon->tail_len);
9513
9514 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
9515 {
Kapil Gupta137ef892016-12-13 19:38:00 +05309516 if (pConfig->RSNWPAReqIE[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 {
9518 /*Mixed mode WPA/WPA2*/
Kapil Gupta137ef892016-12-13 19:38:00 +05309519 prev_rsn_length = pConfig->RSNWPAReqIELength;
Jeff Johnson295189b2012-06-20 16:38:30 -07009520 pConfig->RSNWPAReqIELength += pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +05309521 if (pConfig->RSNWPAReqIELength <=
9522 (sizeof(pConfig->RSNWPAReqIE) - prev_rsn_length))
9523 memcpy(&pConfig->RSNWPAReqIE[0] + prev_rsn_length, pIe,
9524 pIe[1] + 2);
9525 else
9526 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
9527 pConfig->RSNWPAReqIELength);
9528
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 }
9530 else
9531 {
9532 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +05309533 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
9534 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
9535 pConfig->RSNWPAReqIELength);
9536 else
9537 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
9538 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309539 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9541 &RSNEncryptType,
9542 &mcRSNEncryptType,
9543 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009544 &MFPCapable,
9545 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +05309546 pConfig->RSNWPAReqIE[1]+2,
9547 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009548
9549 if( VOS_STATUS_SUCCESS == status )
9550 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309551 /* Now copy over all the security attributes you have
9552 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009553 * */
9554 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9555 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9556 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9557 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309558 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009559 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9561 }
9562 }
9563 }
9564
Kapil Gupta137ef892016-12-13 19:38:00 +05309565 if (pConfig->RSNWPAReqIELength > sizeof(pConfig->RSNWPAReqIE)) {
Jeff Johnson4416a782013-03-25 14:17:50 -07009566 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
9567 return -EINVAL;
9568 }
9569
Jeff Johnson295189b2012-06-20 16:38:30 -07009570 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
9571
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009572#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009573 if (params->ssid != NULL)
9574 {
9575 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
9576 pConfig->SSIDinfo.ssid.length = params->ssid_len;
9577 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9578 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9579 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009580#else
9581 if (ssid != NULL)
9582 {
9583 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
9584 pConfig->SSIDinfo.ssid.length = ssid_len;
9585 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9586 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9587 }
9588#endif
9589
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309590 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309592
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 /* default value */
9594 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
9595 pConfig->num_accept_mac = 0;
9596 pConfig->num_deny_mac = 0;
9597
9598 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9599 pBeacon->tail, pBeacon->tail_len);
9600
9601 /* pIe for black list is following form:
9602 type : 1 byte
9603 length : 1 byte
9604 OUI : 4 bytes
9605 acl type : 1 byte
9606 no of mac addr in black list: 1 byte
9607 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309608 */
9609 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009610 {
9611 pConfig->SapMacaddr_acl = pIe[6];
9612 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009613 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009614 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309615 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
9616 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009617 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9618 for (i = 0; i < pConfig->num_deny_mac; i++)
9619 {
9620 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9621 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009623 }
9624 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9625 pBeacon->tail, pBeacon->tail_len);
9626
9627 /* pIe for white list is following form:
9628 type : 1 byte
9629 length : 1 byte
9630 OUI : 4 bytes
9631 acl type : 1 byte
9632 no of mac addr in white list: 1 byte
9633 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309634 */
9635 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 {
9637 pConfig->SapMacaddr_acl = pIe[6];
9638 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009639 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309641 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
9642 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9644 for (i = 0; i < pConfig->num_accept_mac; i++)
9645 {
9646 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9647 acl_entry++;
9648 }
9649 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309650
Jeff Johnson295189b2012-06-20 16:38:30 -07009651 wlan_hdd_set_sapHwmode(pHostapdAdapter);
9652
Jeff Johnsone7245742012-09-05 17:12:55 -07009653#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009654 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309655 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
9656 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05309657 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
9658 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009659 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
9660 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309661 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
9662 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009663 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309664 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07009665 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309666 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009667
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309668 /* If ACS disable and selected channel <= 14
9669 * OR
9670 * ACS enabled and ACS operating band is choosen as 2.4
9671 * AND
9672 * VHT in 2.4G Disabled
9673 * THEN
9674 * Fallback to 11N mode
9675 */
9676 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
9677 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05309678 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309679 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009680 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309681 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
9682 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009683 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
9684 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009685 }
9686#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309687
Jeff Johnson295189b2012-06-20 16:38:30 -07009688 // ht_capab is not what the name conveys,this is used for protection bitmap
9689 pConfig->ht_capab =
9690 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
9691
Kapil Gupta137ef892016-12-13 19:38:00 +05309692 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 {
9694 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
9695 return -EINVAL;
9696 }
9697
9698 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309699 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07009700 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
9701 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309702 pConfig->obssProtEnabled =
9703 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07009704
Chet Lanctot8cecea22014-02-11 19:09:36 -08009705#ifdef WLAN_FEATURE_11W
9706 pConfig->mfpCapable = MFPCapable;
9707 pConfig->mfpRequired = MFPRequired;
9708 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
9709 pConfig->mfpCapable, pConfig->mfpRequired);
9710#endif
9711
Arif Hussain6d2a3322013-11-17 19:50:10 -08009712 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009713 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08009714 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
9715 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
9716 (int)pConfig->channel);
9717 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
9718 pConfig->SapHw_mode, pConfig->privacy,
9719 pConfig->authType);
9720 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
9721 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
9722 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
9723 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009724
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309725 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07009726 {
9727 //Bss already started. just return.
9728 //TODO Probably it should update some beacon params.
9729 hddLog( LOGE, "Bss Already started...Ignore the request");
9730 EXIT();
9731 return 0;
9732 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309733
Agarwal Ashish51325b52014-06-16 16:50:49 +05309734 if (vos_max_concurrent_connections_reached()) {
9735 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9736 return -EINVAL;
9737 }
9738
Jeff Johnson295189b2012-06-20 16:38:30 -07009739 pConfig->persona = pHostapdAdapter->device_mode;
9740
Peng Xu2446a892014-09-05 17:21:18 +05309741 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
9742 if ( NULL != psmeConfig)
9743 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309744 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05309745 sme_GetConfigParam(hHal, psmeConfig);
9746 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309747#ifdef WLAN_FEATURE_AP_HT40_24G
9748 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
9749 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
9750 && pHddCtx->cfg_ini->apHT40_24GEnabled)
9751 {
9752 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
9753 sme_UpdateConfig (hHal, psmeConfig);
9754 }
9755#endif
Peng Xu2446a892014-09-05 17:21:18 +05309756 vos_mem_free(psmeConfig);
9757 }
Peng Xuafc34e32014-09-25 13:23:55 +05309758 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05309759
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309760 set_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
9761
Jeff Johnson295189b2012-06-20 16:38:30 -07009762 pSapEventCallback = hdd_hostapd_SAPEventCB;
9763 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
9764 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
9765 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009766 hddLog(LOGE,FL("SAP Start Bss fail"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309767 ret = -EINVAL;
9768 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009769 }
9770
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309771 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07009772 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
9773
9774 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309775
Jeff Johnson295189b2012-06-20 16:38:30 -07009776 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309777 {
9778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009779 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07009780 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009781 VOS_ASSERT(0);
9782 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309783
Jeff Johnson295189b2012-06-20 16:38:30 -07009784 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Nishank Aggarwalc11826c2016-12-15 18:54:10 +05309785 if (WLANSAP_get_sessionId(pVosContext, &pHostapdAdapter->sessionId) !=
9786 VOS_STATUS_SUCCESS)
9787 {
9788 hddLog(LOGE,FL("Fail to get Softap sessionID"));
9789 VOS_ASSERT(0);
9790 }
Kaushik, Sushantf6070802014-10-15 15:09:23 +05309791 /* Initialize WMM configuation */
9792 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309793 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009794
Anurag Chouhan83026002016-12-13 22:46:21 +05309795#ifdef DHCP_SERVER_OFFLOAD
9796 /* set dhcp server offload */
9797 if (iniConfig->enable_dhcp_srv_offload &&
9798 sme_IsFeatureSupportedByFW(SAP_OFFLOADS)) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309799 vos_event_reset(&pHostapdAdapter->dhcp_status.vos_event);
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309800 status = wlan_hdd_set_dhcp_server_offload(pHostapdAdapter, false);
Anurag Chouhan83026002016-12-13 22:46:21 +05309801 if (!VOS_IS_STATUS_SUCCESS(status))
9802 {
9803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9804 ("HDD DHCP Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309805 vos_event_reset(&pHostapdState->vosEvent);
9806 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
9807 status = vos_wait_single_event(&pHostapdState->vosEvent,
9808 10000);
9809 if (!VOS_IS_STATUS_SUCCESS(status)) {
9810 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309811 ret = -EINVAL;
9812 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309813 }
9814 }
Anurag Chouhan83026002016-12-13 22:46:21 +05309815 }
Anurag Chouhan83026002016-12-13 22:46:21 +05309816 status = vos_wait_single_event(&pHostapdAdapter->dhcp_status.vos_event, 2000);
9817 if (!VOS_IS_STATUS_SUCCESS(status) || pHostapdAdapter->dhcp_status.dhcp_offload_status)
9818 {
9819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9820 ("ERROR: DHCP HDD vos wait for single_event failed!! %d"),
9821 pHostapdAdapter->dhcp_status.dhcp_offload_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309822 vos_event_reset(&pHostapdState->vosEvent);
9823 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
9824 status = vos_wait_single_event(&pHostapdState->vosEvent,
9825 10000);
9826 if (!VOS_IS_STATUS_SUCCESS(status)) {
9827 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309828 ret = -EINVAL;
9829 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309830 }
9831 }
Anurag Chouhan83026002016-12-13 22:46:21 +05309832 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +05309833#ifdef MDNS_OFFLOAD
9834 if (iniConfig->enable_mdns_offload) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309835 vos_event_reset(&pHostapdAdapter->mdns_status.vos_event);
Anurag Chouhan0b29de02016-12-16 13:18:40 +05309836 status = wlan_hdd_set_mdns_offload(pHostapdAdapter);
9837 if (VOS_IS_STATUS_SUCCESS(status))
9838 {
9839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9840 ("HDD MDNS Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309841 vos_event_reset(&pHostapdState->vosEvent);
9842 if (VOS_STATUS_SUCCESS ==
9843 WLANSAP_StopBss(pHddCtx->pvosContext)) {
9844 status = vos_wait_single_event(&pHostapdState->vosEvent,
9845 10000);
9846 if (!VOS_IS_STATUS_SUCCESS(status)) {
9847 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309848 ret = -EINVAL;
9849 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309850 }
9851 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +05309852 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +05309853 status = vos_wait_single_event(&pHostapdAdapter->
9854 mdns_status.vos_event, 2000);
9855 if (!VOS_IS_STATUS_SUCCESS(status) ||
9856 pHostapdAdapter->mdns_status.mdns_enable_status ||
9857 pHostapdAdapter->mdns_status.mdns_fqdn_status ||
9858 pHostapdAdapter->mdns_status.mdns_resp_status)
9859 {
9860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9861 ("MDNS HDD vos wait for single_event failed!! enable %d fqdn %d resp %d"),
9862 pHostapdAdapter->mdns_status.mdns_enable_status,
9863 pHostapdAdapter->mdns_status.mdns_fqdn_status,
9864 pHostapdAdapter->mdns_status.mdns_resp_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309865 vos_event_reset(&pHostapdState->vosEvent);
9866 if (VOS_STATUS_SUCCESS ==
9867 WLANSAP_StopBss(pHddCtx->pvosContext)) {
9868 status = vos_wait_single_event(&pHostapdState->vosEvent,
9869 10000);
9870 if (!VOS_IS_STATUS_SUCCESS(status)) {
9871 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309872 ret = -EINVAL;
9873 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309874 }
9875 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +05309876 }
9877 }
9878#endif /* MDNS_OFFLOAD */
9879 } else {
9880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9881 ("DHCP Disabled ini %d, FW %d"),
9882 iniConfig->enable_dhcp_srv_offload,
9883 sme_IsFeatureSupportedByFW(SAP_OFFLOADS));
Anurag Chouhan83026002016-12-13 22:46:21 +05309884 }
9885#endif /* DHCP_SERVER_OFFLOAD */
9886
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009887#ifdef WLAN_FEATURE_P2P_DEBUG
9888 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
9889 {
9890 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
9891 {
9892 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9893 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009894 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009895 }
9896 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
9897 {
9898 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9899 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009900 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009901 }
9902 }
9903#endif
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05309904 /* Check and restart SAP if it is on Unsafe channel */
9905 hdd_check_for_unsafe_ch(pHostapdAdapter, pHddCtx);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009906
Jeff Johnson295189b2012-06-20 16:38:30 -07009907 pHostapdState->bCommit = TRUE;
9908 EXIT();
9909
9910 return 0;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309911error:
9912 clear_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
9913 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009914}
9915
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009916#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309917static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309918 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009919 struct beacon_parameters *params)
9920{
9921 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309922 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309923 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009924
9925 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309926
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309927 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9928 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
9929 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309930 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
9931 hdd_device_modetoString(pAdapter->device_mode),
9932 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009933
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309934 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9935 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309936 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009937 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309938 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009939 }
9940
Agarwal Ashish51325b52014-06-16 16:50:49 +05309941 if (vos_max_concurrent_connections_reached()) {
9942 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9943 return -EINVAL;
9944 }
9945
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309946 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009947 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 )
9949 {
9950 beacon_data_t *old,*new;
9951
9952 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309953
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309955 {
9956 hddLog(VOS_TRACE_LEVEL_WARN,
9957 FL("already beacon info added to session(%d)"),
9958 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009961
9962 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9963
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309964 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07009965 {
9966 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009967 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009968 return -EINVAL;
9969 }
9970
9971 pAdapter->sessionCtx.ap.beacon = new;
9972
9973 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9974 }
9975
9976 EXIT();
9977 return status;
9978}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309979
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309980static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
9981 struct net_device *dev,
9982 struct beacon_parameters *params)
9983{
9984 int ret;
9985
9986 vos_ssr_protect(__func__);
9987 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
9988 vos_ssr_unprotect(__func__);
9989
9990 return ret;
9991}
9992
9993static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009994 struct net_device *dev,
9995 struct beacon_parameters *params)
9996{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309997 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309998 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9999 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010000 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010001
10002 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010003
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010004 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10005 TRACE_CODE_HDD_CFG80211_SET_BEACON,
10006 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
10007 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10008 __func__, hdd_device_modetoString(pAdapter->device_mode),
10009 pAdapter->device_mode);
10010
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010011 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10012 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010013 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010014 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010015 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010016 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010017
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010018 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010019 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010020 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010021 {
10022 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010023
Jeff Johnson295189b2012-06-20 16:38:30 -070010024 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010025
Jeff Johnson295189b2012-06-20 16:38:30 -070010026 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010027 {
10028 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10029 FL("session(%d) old and new heads points to NULL"),
10030 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010033
10034 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
10035
10036 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010037 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010038 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010039 return -EINVAL;
10040 }
10041
10042 pAdapter->sessionCtx.ap.beacon = new;
10043
10044 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
10045 }
10046
10047 EXIT();
10048 return status;
10049}
10050
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010051static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
10052 struct net_device *dev,
10053 struct beacon_parameters *params)
10054{
10055 int ret;
10056
10057 vos_ssr_protect(__func__);
10058 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
10059 vos_ssr_unprotect(__func__);
10060
10061 return ret;
10062}
10063
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010064#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10065
10066#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010067static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010069#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010070static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010071 struct net_device *dev)
10072#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010073{
10074 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -070010075 hdd_context_t *pHddCtx = NULL;
10076 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010077 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010078 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010079
10080 ENTER();
10081
10082 if (NULL == pAdapter)
10083 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010084 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010085 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010086 return -ENODEV;
10087 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010088
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010089 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10090 TRACE_CODE_HDD_CFG80211_STOP_AP,
10091 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010092 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10093 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010094 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010095 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010096 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -070010097 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010098
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010099 pScanInfo = &pHddCtx->scan_info;
10100
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010101 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10102 __func__, hdd_device_modetoString(pAdapter->device_mode),
10103 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010104
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010105 ret = wlan_hdd_scan_abort(pAdapter);
10106
Girish Gowli4bf7a632014-06-12 13:42:11 +053010107 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -070010108 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010109 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10110 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010111
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010112 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -070010113 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10115 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -080010116
Jeff Johnsone7245742012-09-05 17:12:55 -070010117 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010118 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -070010119 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010120 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010121 }
10122
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010123 /* Delete all associated STAs before stopping AP/P2P GO */
10124 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +053010125 hdd_hostapd_stop(dev);
10126
Jeff Johnson295189b2012-06-20 16:38:30 -070010127 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010128 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010129 )
10130 {
10131 beacon_data_t *old;
10132
10133 old = pAdapter->sessionCtx.ap.beacon;
10134
10135 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010136 {
10137 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10138 FL("session(%d) beacon data points to NULL"),
10139 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010140 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010141 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010142
Jeff Johnson295189b2012-06-20 16:38:30 -070010143 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010144
10145 mutex_lock(&pHddCtx->sap_lock);
10146 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
10147 {
Jeff Johnson4416a782013-03-25 14:17:50 -070010148 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010149 {
10150 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
10151
10152 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
10153
10154 if (!VOS_IS_STATUS_SUCCESS(status))
10155 {
10156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010157 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010158 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010159 }
10160 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010161 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +053010162 /* BSS stopped, clear the active sessions for this device mode */
10163 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010164 }
10165 mutex_unlock(&pHddCtx->sap_lock);
10166
10167 if(status != VOS_STATUS_SUCCESS)
10168 {
10169 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010170 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010171 return -EINVAL;
10172 }
10173
Jeff Johnson4416a782013-03-25 14:17:50 -070010174 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070010175 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
10176 ==eHAL_STATUS_FAILURE)
10177 {
10178 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010179 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010180 }
10181
Jeff Johnson4416a782013-03-25 14:17:50 -070010182 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070010183 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
10184 eANI_BOOLEAN_FALSE) )
10185 {
10186 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010187 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010188 }
10189
10190 // Reset WNI_CFG_PROBE_RSP Flags
10191 wlan_hdd_reset_prob_rspies(pAdapter);
10192
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010193 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
10194
Jeff Johnson295189b2012-06-20 16:38:30 -070010195 pAdapter->sessionCtx.ap.beacon = NULL;
10196 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010197#ifdef WLAN_FEATURE_P2P_DEBUG
10198 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
10199 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
10200 {
10201 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
10202 "GO got removed");
10203 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
10204 }
10205#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 }
10207 EXIT();
10208 return status;
10209}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010210
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010211#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10212static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
10213 struct net_device *dev)
10214{
10215 int ret;
10216
10217 vos_ssr_protect(__func__);
10218 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
10219 vos_ssr_unprotect(__func__);
10220
10221 return ret;
10222}
10223#else
10224static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
10225 struct net_device *dev)
10226{
10227 int ret;
10228
10229 vos_ssr_protect(__func__);
10230 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
10231 vos_ssr_unprotect(__func__);
10232
10233 return ret;
10234}
10235#endif
10236
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010237#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
10238
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010239static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010240 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010241 struct cfg80211_ap_settings *params)
10242{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010243 hdd_adapter_t *pAdapter;
10244 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010245 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010246
10247 ENTER();
10248
Girish Gowlib143d7a2015-02-18 19:39:55 +053010249 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010250 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010251 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +053010252 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010253 return -ENODEV;
10254 }
10255
10256 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10257 if (NULL == pAdapter)
10258 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010259 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010260 "%s: HDD adapter is Null", __func__);
10261 return -ENODEV;
10262 }
10263
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010264 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10265 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
10266 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010267 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
10268 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010269 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010270 "%s: HDD adapter magic is invalid", __func__);
10271 return -ENODEV;
10272 }
10273
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010274 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
10275
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010276 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010277 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010278 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010279 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010280 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010281 }
10282
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010283 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
10284 __func__, hdd_device_modetoString(pAdapter->device_mode),
10285 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010286
10287 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010288 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010289 )
10290 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010291 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010292
10293 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010294
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010295 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010296 {
10297 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10298 FL("already beacon info added to session(%d)"),
10299 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010300 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010301 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010302
Girish Gowlib143d7a2015-02-18 19:39:55 +053010303#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10304 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10305 &new,
10306 &params->beacon);
10307#else
10308 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10309 &new,
10310 &params->beacon,
10311 params->dtim_period);
10312#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010313
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010314 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010315 {
10316 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010317 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010318 return -EINVAL;
10319 }
10320 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -080010321#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -070010322 wlan_hdd_cfg80211_set_channel(wiphy, dev,
10323#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
10324 params->channel, params->channel_type);
10325#else
10326 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
10327#endif
Viral Modi3a32cc52013-02-08 11:14:52 -080010328#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010329 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010330 params->ssid_len, params->hidden_ssid,
10331 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010332 }
10333
10334 EXIT();
10335 return status;
10336}
10337
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010338static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
10339 struct net_device *dev,
10340 struct cfg80211_ap_settings *params)
10341{
10342 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010343
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010344 vos_ssr_protect(__func__);
10345 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
10346 vos_ssr_unprotect(__func__);
10347
10348 return ret;
10349}
10350
10351static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010352 struct net_device *dev,
10353 struct cfg80211_beacon_data *params)
10354{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010355 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010356 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010357 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010358
10359 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010360
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010361 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10362 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
10363 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -080010364 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010365 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010366
10367 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10368 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010369 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010370 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010371 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010372 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010373
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010374 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010375 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010376 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010377 {
10378 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010379
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010380 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010381
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010382 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010383 {
10384 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10385 FL("session(%d) beacon data points to NULL"),
10386 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010387 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010388 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010389
10390 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
10391
10392 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010393 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010394 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010395 return -EINVAL;
10396 }
10397
10398 pAdapter->sessionCtx.ap.beacon = new;
10399
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010400 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
10401 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010402 }
10403
10404 EXIT();
10405 return status;
10406}
10407
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010408static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
10409 struct net_device *dev,
10410 struct cfg80211_beacon_data *params)
10411{
10412 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010413
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010414 vos_ssr_protect(__func__);
10415 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
10416 vos_ssr_unprotect(__func__);
10417
10418 return ret;
10419}
10420
10421#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010422
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010423static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010424 struct net_device *dev,
10425 struct bss_parameters *params)
10426{
10427 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010428 hdd_context_t *pHddCtx;
10429 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010430
10431 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010432
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010433 if (NULL == pAdapter)
10434 {
10435 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10436 "%s: HDD adapter is Null", __func__);
10437 return -ENODEV;
10438 }
10439 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010440 ret = wlan_hdd_validate_context(pHddCtx);
10441 if (0 != ret)
10442 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010443 return ret;
10444 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010445 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10446 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
10447 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010448 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10449 __func__, hdd_device_modetoString(pAdapter->device_mode),
10450 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010451
10452 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010453 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010454 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010455 {
10456 /* ap_isolate == -1 means that in change bss, upper layer doesn't
10457 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010458 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -070010459 {
10460 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010461 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010462 }
10463
10464 EXIT();
10465 return 0;
10466}
10467
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010468static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
10469 struct net_device *dev,
10470 struct bss_parameters *params)
10471{
10472 int ret;
10473
10474 vos_ssr_protect(__func__);
10475 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
10476 vos_ssr_unprotect(__func__);
10477
10478 return ret;
10479}
Kiet Lam10841362013-11-01 11:36:50 +053010480/* FUNCTION: wlan_hdd_change_country_code_cd
10481* to wait for contry code completion
10482*/
10483void* wlan_hdd_change_country_code_cb(void *pAdapter)
10484{
10485 hdd_adapter_t *call_back_pAdapter = pAdapter;
10486 complete(&call_back_pAdapter->change_country_code);
10487 return NULL;
10488}
10489
Jeff Johnson295189b2012-06-20 16:38:30 -070010490/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010491 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -070010492 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
10493 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010494int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010495 struct net_device *ndev,
10496 enum nl80211_iftype type,
10497 u32 *flags,
10498 struct vif_params *params
10499 )
10500{
10501 struct wireless_dev *wdev;
10502 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010503 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -070010504 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010505 tCsrRoamProfile *pRoamProfile = NULL;
10506 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010507 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 eMib_dot11DesiredBssType connectedBssType;
10509 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010510 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010511
10512 ENTER();
10513
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010514 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010515 {
10516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10517 "%s: Adapter context is null", __func__);
10518 return VOS_STATUS_E_FAILURE;
10519 }
10520
10521 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10522 if (!pHddCtx)
10523 {
10524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10525 "%s: HDD context is null", __func__);
10526 return VOS_STATUS_E_FAILURE;
10527 }
10528
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010529 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10530 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
10531 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010532 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010533 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010534 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010535 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010536 }
10537
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010538 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10539 __func__, hdd_device_modetoString(pAdapter->device_mode),
10540 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010541
Agarwal Ashish51325b52014-06-16 16:50:49 +053010542 if (vos_max_concurrent_connections_reached()) {
10543 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10544 return -EINVAL;
10545 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010546 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 wdev = ndev->ieee80211_ptr;
10548
10549#ifdef WLAN_BTAMP_FEATURE
10550 if((NL80211_IFTYPE_P2P_CLIENT == type)||
10551 (NL80211_IFTYPE_ADHOC == type)||
10552 (NL80211_IFTYPE_AP == type)||
10553 (NL80211_IFTYPE_P2P_GO == type))
10554 {
10555 pHddCtx->isAmpAllowed = VOS_FALSE;
10556 // stop AMP traffic
10557 status = WLANBAP_StopAmp();
10558 if(VOS_STATUS_SUCCESS != status )
10559 {
10560 pHddCtx->isAmpAllowed = VOS_TRUE;
10561 hddLog(VOS_TRACE_LEVEL_FATAL,
10562 "%s: Failed to stop AMP", __func__);
10563 return -EINVAL;
10564 }
10565 }
10566#endif //WLAN_BTAMP_FEATURE
10567 /* Reset the current device mode bit mask*/
10568 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
10569
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053010570 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
10571 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
10572 (type == NL80211_IFTYPE_P2P_GO)))
10573 {
10574 /* Notify Mode change in case of concurrency.
10575 * Below function invokes TDLS teardown Functionality Since TDLS is
10576 * not Supported in case of concurrency i.e Once P2P session
10577 * is detected disable offchannel and teardown TDLS links
10578 */
10579 hddLog(LOG1,
10580 FL("Device mode = %d Interface type = %d"),
10581 pAdapter->device_mode, type);
10582 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
10583 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053010584
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070010586 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070010587 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010588 )
10589 {
10590 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010591 if (!pWextState)
10592 {
10593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10594 "%s: pWextState is null", __func__);
10595 return VOS_STATUS_E_FAILURE;
10596 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010597 pRoamProfile = &pWextState->roamProfile;
10598 LastBSSType = pRoamProfile->BSSType;
10599
10600 switch (type)
10601 {
10602 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010603 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010604 hddLog(VOS_TRACE_LEVEL_INFO,
10605 "%s: setting interface Type to INFRASTRUCTURE", __func__);
10606 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010607#ifdef WLAN_FEATURE_11AC
10608 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
10609 {
10610 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
10611 }
10612#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010613 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070010614 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010615 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010616 //Check for sub-string p2p to confirm its a p2p interface
10617 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010618 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053010619#ifdef FEATURE_WLAN_TDLS
10620 mutex_lock(&pHddCtx->tdls_lock);
10621 wlan_hdd_tdls_exit(pAdapter, TRUE);
10622 mutex_unlock(&pHddCtx->tdls_lock);
10623#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010624 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10625 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10626 }
10627 else
10628 {
10629 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010630 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010631 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010632 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053010633
Jeff Johnson295189b2012-06-20 16:38:30 -070010634 case NL80211_IFTYPE_ADHOC:
10635 hddLog(VOS_TRACE_LEVEL_INFO,
10636 "%s: setting interface Type to ADHOC", __func__);
10637 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
10638 pRoamProfile->phyMode =
10639 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070010640 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053010642 hdd_set_ibss_ops( pAdapter );
10643 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053010644
10645 status = hdd_sta_id_hash_attach(pAdapter);
10646 if (VOS_STATUS_SUCCESS != status) {
10647 hddLog(VOS_TRACE_LEVEL_ERROR,
10648 FL("Failed to initialize hash for IBSS"));
10649 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010650 break;
10651
10652 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010653 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010654 {
10655 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10656 "%s: setting interface Type to %s", __func__,
10657 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
10658
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010659 //Cancel any remain on channel for GO mode
10660 if (NL80211_IFTYPE_P2P_GO == type)
10661 {
10662 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
10663 }
Mohit Khanna0f232092012-09-11 14:46:08 -070010664 if (NL80211_IFTYPE_AP == type)
10665 {
10666 /* As Loading WLAN Driver one interface being created for p2p device
10667 * address. This will take one HW STA and the max number of clients
10668 * that can connect to softAP will be reduced by one. so while changing
10669 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
10670 * interface as it is not required in SoftAP mode.
10671 */
10672
10673 // Get P2P Adapter
10674 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
10675
10676 if (pP2pAdapter)
10677 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +053010678 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +053010679 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -070010680 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
10681 }
10682 }
Swaroop Goltia2e32212014-04-09 23:37:33 +053010683 //Disable IMPS & BMPS for SAP/GO
10684 if(VOS_STATUS_E_FAILURE ==
10685 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
10686 {
10687 //Fail to Exit BMPS
10688 VOS_ASSERT(0);
10689 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053010690
10691 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
10692
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010693#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070010694
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010695 /* A Mutex Lock is introduced while changing the mode to
10696 * protect the concurrent access for the Adapters by TDLS
10697 * module.
10698 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010699 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010700#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010701 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053010702 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010703 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070010704 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10705 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010706#ifdef FEATURE_WLAN_TDLS
10707 mutex_unlock(&pHddCtx->tdls_lock);
10708#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010709 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
10710 (pConfig->apRandomBssidEnabled))
10711 {
10712 /* To meet Android requirements create a randomized
10713 MAC address of the form 02:1A:11:Fx:xx:xx */
10714 get_random_bytes(&ndev->dev_addr[3], 3);
10715 ndev->dev_addr[0] = 0x02;
10716 ndev->dev_addr[1] = 0x1A;
10717 ndev->dev_addr[2] = 0x11;
10718 ndev->dev_addr[3] |= 0xF0;
10719 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
10720 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080010721 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
10722 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010723 }
10724
Jeff Johnson295189b2012-06-20 16:38:30 -070010725 hdd_set_ap_ops( pAdapter->dev );
10726
Kiet Lam10841362013-11-01 11:36:50 +053010727 /* This is for only SAP mode where users can
10728 * control country through ini.
10729 * P2P GO follows station country code
10730 * acquired during the STA scanning. */
10731 if((NL80211_IFTYPE_AP == type) &&
10732 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
10733 {
10734 int status = 0;
10735 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
10736 "%s: setting country code from INI ", __func__);
10737 init_completion(&pAdapter->change_country_code);
10738 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
10739 (void *)(tSmeChangeCountryCallback)
10740 wlan_hdd_change_country_code_cb,
10741 pConfig->apCntryCode, pAdapter,
10742 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053010743 eSIR_FALSE,
10744 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053010745 if (eHAL_STATUS_SUCCESS == status)
10746 {
10747 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010748 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053010749 &pAdapter->change_country_code,
10750 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010751 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053010752 {
10753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010754 FL("SME Timed out while setting country code %ld"),
10755 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080010756
10757 if (pHddCtx->isLogpInProgress)
10758 {
10759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10760 "%s: LOGP in Progress. Ignore!!!", __func__);
10761 return -EAGAIN;
10762 }
Kiet Lam10841362013-11-01 11:36:50 +053010763 }
10764 }
10765 else
10766 {
10767 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010768 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053010769 return -EINVAL;
10770 }
10771 }
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +053010772 status = hdd_init_ap_mode(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -070010773 if(status != VOS_STATUS_SUCCESS)
10774 {
10775 hddLog(VOS_TRACE_LEVEL_FATAL,
10776 "%s: Error initializing the ap mode", __func__);
10777 return -EINVAL;
10778 }
10779 hdd_set_conparam(1);
10780
Nirav Shah7e3c8132015-06-22 23:51:42 +053010781 status = hdd_sta_id_hash_attach(pAdapter);
10782 if (VOS_STATUS_SUCCESS != status)
10783 {
10784 hddLog(VOS_TRACE_LEVEL_ERROR,
10785 FL("Failed to initialize hash for AP"));
10786 return -EINVAL;
10787 }
10788
Jeff Johnson295189b2012-06-20 16:38:30 -070010789 /*interface type changed update in wiphy structure*/
10790 if(wdev)
10791 {
10792 wdev->iftype = type;
10793 pHddCtx->change_iface = type;
10794 }
10795 else
10796 {
10797 hddLog(VOS_TRACE_LEVEL_ERROR,
10798 "%s: ERROR !!!! Wireless dev is NULL", __func__);
10799 return -EINVAL;
10800 }
10801 goto done;
10802 }
10803
10804 default:
10805 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10806 __func__);
10807 return -EOPNOTSUPP;
10808 }
10809 }
10810 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010811 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010812 )
10813 {
10814 switch(type)
10815 {
10816 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010817 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010818 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053010819
10820 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010821#ifdef FEATURE_WLAN_TDLS
10822
10823 /* A Mutex Lock is introduced while changing the mode to
10824 * protect the concurrent access for the Adapters by TDLS
10825 * module.
10826 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010827 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010828#endif
c_hpothu002231a2015-02-05 14:58:51 +053010829 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010830 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010831 //Check for sub-string p2p to confirm its a p2p interface
10832 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010833 {
10834 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10835 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10836 }
10837 else
10838 {
10839 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010840 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010841 }
Agrawal Ashishcfe83282016-09-29 13:03:45 +053010842
10843 /* set con_mode to STA only when no SAP concurrency mode */
10844 if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO)))
10845 hdd_set_conparam(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010846 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010847 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
10848 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010849#ifdef FEATURE_WLAN_TDLS
10850 mutex_unlock(&pHddCtx->tdls_lock);
10851#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053010852 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070010853 if( VOS_STATUS_SUCCESS != status )
10854 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070010855 /* In case of JB, for P2P-GO, only change interface will be called,
10856 * This is the right place to enable back bmps_imps()
10857 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053010858 if (pHddCtx->hdd_wlan_suspended)
10859 {
10860 hdd_set_pwrparams(pHddCtx);
10861 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010862 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010863 goto done;
10864 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010865 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010867 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10868 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010869 goto done;
10870 default:
10871 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10872 __func__);
10873 return -EOPNOTSUPP;
10874
10875 }
10876
10877 }
10878 else
10879 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010880 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
10881 __func__, hdd_device_modetoString(pAdapter->device_mode),
10882 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010883 return -EOPNOTSUPP;
10884 }
10885
10886
10887 if(pRoamProfile)
10888 {
10889 if ( LastBSSType != pRoamProfile->BSSType )
10890 {
10891 /*interface type changed update in wiphy structure*/
10892 wdev->iftype = type;
10893
10894 /*the BSS mode changed, We need to issue disconnect
10895 if connected or in IBSS disconnect state*/
10896 if ( hdd_connGetConnectedBssType(
10897 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
10898 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
10899 {
10900 /*need to issue a disconnect to CSR.*/
10901 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10902 if( eHAL_STATUS_SUCCESS ==
10903 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10904 pAdapter->sessionId,
10905 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
10906 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010907 ret = wait_for_completion_interruptible_timeout(
10908 &pAdapter->disconnect_comp_var,
10909 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10910 if (ret <= 0)
10911 {
10912 hddLog(VOS_TRACE_LEVEL_ERROR,
10913 FL("wait on disconnect_comp_var failed %ld"), ret);
10914 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010915 }
10916 }
10917 }
10918 }
10919
10920done:
10921 /*set bitmask based on updated value*/
10922 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070010923
10924 /* Only STA mode support TM now
10925 * all other mode, TM feature should be disabled */
10926 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
10927 (~VOS_STA & pHddCtx->concurrency_mode) )
10928 {
10929 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
10930 }
10931
Jeff Johnson295189b2012-06-20 16:38:30 -070010932#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010933 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053010934 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010935 {
10936 //we are ok to do AMP
10937 pHddCtx->isAmpAllowed = VOS_TRUE;
10938 }
10939#endif //WLAN_BTAMP_FEATURE
10940 EXIT();
10941 return 0;
10942}
10943
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010944/*
10945 * FUNCTION: wlan_hdd_cfg80211_change_iface
10946 * wrapper function to protect the actual implementation from SSR.
10947 */
10948int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
10949 struct net_device *ndev,
10950 enum nl80211_iftype type,
10951 u32 *flags,
10952 struct vif_params *params
10953 )
10954{
10955 int ret;
10956
10957 vos_ssr_protect(__func__);
10958 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
10959 vos_ssr_unprotect(__func__);
10960
10961 return ret;
10962}
10963
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010964#ifdef FEATURE_WLAN_TDLS
10965static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010966 struct net_device *dev,
10967#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10968 const u8 *mac,
10969#else
10970 u8 *mac,
10971#endif
10972 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010973{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010974 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010975 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010976 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010977 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010978 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010979 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010980
10981 ENTER();
10982
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010983 if (!dev) {
10984 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
10985 return -EINVAL;
10986 }
10987
10988 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10989 if (!pAdapter) {
10990 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
10991 return -EINVAL;
10992 }
10993
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010994 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010995 {
10996 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10997 "Invalid arguments");
10998 return -EINVAL;
10999 }
Hoonki Lee27511902013-03-14 18:19:06 -070011000
11001 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
11002 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
11003 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011004 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070011005 "%s: TDLS mode is disabled OR not enabled in FW."
11006 MAC_ADDRESS_STR " Request declined.",
11007 __func__, MAC_ADDR_ARRAY(mac));
11008 return -ENOTSUPP;
11009 }
11010
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011011 if (pHddCtx->isLogpInProgress)
11012 {
11013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11014 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053011015 wlan_hdd_tdls_set_link_status(pAdapter,
11016 mac,
11017 eTDLS_LINK_IDLE,
11018 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011019 return -EBUSY;
11020 }
11021
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053011022 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053011023 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011024
11025 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011026 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011027 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
11028 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053011029 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011030 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011031 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011032
11033 /* in add station, we accept existing valid staId if there is */
11034 if ((0 == update) &&
11035 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
11036 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011037 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011038 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011039 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011040 " link_status %d. staId %d. add station ignored.",
11041 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011042 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011043 return 0;
11044 }
11045 /* in change station, we accept only when staId is valid */
11046 if ((1 == update) &&
11047 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
11048 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
11049 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011050 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011051 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011052 "%s: " MAC_ADDRESS_STR
11053 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011054 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
11055 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
11056 mutex_unlock(&pHddCtx->tdls_lock);
11057 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011058 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011059 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011060
11061 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053011062 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011063 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011064 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11065 "%s: " MAC_ADDRESS_STR
11066 " TDLS setup is ongoing. Request declined.",
11067 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070011068 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011069 }
11070
11071 /* first to check if we reached to maximum supported TDLS peer.
11072 TODO: for now, return -EPERM looks working fine,
11073 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011074 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
11075 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011076 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11078 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011079 " TDLS Max peer already connected. Request declined."
11080 " Num of peers (%d), Max allowed (%d).",
11081 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
11082 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070011083 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011084 }
11085 else
11086 {
11087 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011088 mutex_lock(&pHddCtx->tdls_lock);
11089 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011090 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011091 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011092 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011093 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11094 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
11095 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011096 return -EPERM;
11097 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011098 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011099 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011100 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053011101 wlan_hdd_tdls_set_link_status(pAdapter,
11102 mac,
11103 eTDLS_LINK_CONNECTING,
11104 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011105
Jeff Johnsond75fe012013-04-06 10:53:06 -070011106 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053011107 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011108 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011110 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070011111 if(StaParams->htcap_present)
11112 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011114 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011116 "ht_capa->extended_capabilities: %0x",
11117 StaParams->HTCap.extendedHtCapInfo);
11118 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011120 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011122 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070011123 if(StaParams->vhtcap_present)
11124 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011126 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
11127 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
11128 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
11129 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011130 {
11131 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011132 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011133 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011135 "[%d]: %x ", i, StaParams->supported_rates[i]);
11136 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070011137 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053011138 else if ((1 == update) && (NULL == StaParams))
11139 {
11140 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11141 "%s : update is true, but staParams is NULL. Error!", __func__);
11142 return -EPERM;
11143 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011144
11145 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
11146
11147 if (!update)
11148 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053011149 /*Before adding sta make sure that device exited from BMPS*/
11150 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
11151 {
11152 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11153 "%s: Adding tdls peer sta. Disable BMPS", __func__);
11154 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
11155 if (status != VOS_STATUS_SUCCESS) {
11156 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
11157 }
11158 }
11159
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011160 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011161 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011162 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053011163 hddLog(VOS_TRACE_LEVEL_ERROR,
11164 FL("Failed to add TDLS peer STA. Enable Bmps"));
11165 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011166 return -EPERM;
11167 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011168 }
11169 else
11170 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011171 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011172 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011173 if (ret != eHAL_STATUS_SUCCESS) {
11174 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
11175 return -EPERM;
11176 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011177 }
11178
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011179 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011180 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
11181
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053011182 mutex_lock(&pHddCtx->tdls_lock);
11183 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
11184
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011185 if ((pTdlsPeer != NULL) &&
11186 (pTdlsPeer->link_status == eTDLS_LINK_TEARING))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011187 {
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011188 hddLog(VOS_TRACE_LEVEL_ERROR,
11189 FL("peer link status %u"), pTdlsPeer->link_status);
11190 mutex_unlock(&pHddCtx->tdls_lock);
11191 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011192 }
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053011193 mutex_unlock(&pHddCtx->tdls_lock);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011194
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011195 if (ret <= 0)
11196 {
11197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11198 "%s: timeout waiting for tdls add station indication %ld",
11199 __func__, ret);
11200 goto error;
11201 }
11202
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011203 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
11204 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011206 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011207 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011208 }
11209
11210 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070011211
11212error:
Atul Mittal115287b2014-07-08 13:26:33 +053011213 wlan_hdd_tdls_set_link_status(pAdapter,
11214 mac,
11215 eTDLS_LINK_IDLE,
11216 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070011217 return -EPERM;
11218
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011219}
11220#endif
11221
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011222static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011223 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011224#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11225 const u8 *mac,
11226#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011227 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011228#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011229 struct station_parameters *params)
11230{
11231 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011232 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011233 hdd_context_t *pHddCtx;
11234 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011235 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011236 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011237#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011238 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011239 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011240 tANI_U8 isOffChannelSupported = 0;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011241 tANI_U8 isQosWmmSta = FALSE;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011242#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011243
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011244 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011245
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011246 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011247 if ((NULL == pAdapter))
11248 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011249 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011250 "invalid adapter ");
11251 return -EINVAL;
11252 }
11253
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011254 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11255 TRACE_CODE_HDD_CHANGE_STATION,
11256 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053011257 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011258
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011259 ret = wlan_hdd_validate_context(pHddCtx);
11260 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053011261 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011262 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011263 }
11264
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011265 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11266
11267 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011268 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11270 "invalid HDD station context");
11271 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011272 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011273 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
11274
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011275 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
11276 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070011277 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011278 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070011279 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011280 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070011281 WLANTL_STA_AUTHENTICATED);
11282
Gopichand Nakkala29149562013-05-10 21:43:41 +053011283 if (status != VOS_STATUS_SUCCESS)
11284 {
11285 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11286 "%s: Not able to change TL state to AUTHENTICATED", __func__);
11287 return -EINVAL;
11288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011289 }
11290 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070011291 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
11292 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011293#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011294 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
11295 StaParams.capability = params->capability;
11296 StaParams.uapsd_queues = params->uapsd_queues;
11297 StaParams.max_sp = params->max_sp;
11298
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011299 /* Convert (first channel , number of channels) tuple to
11300 * the total list of channels. This goes with the assumption
11301 * that if the first channel is < 14, then the next channels
11302 * are an incremental of 1 else an incremental of 4 till the number
11303 * of channels.
11304 */
11305 if (0 != params->supported_channels_len) {
11306 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
11307 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
11308 {
11309 int wifi_chan_index;
11310 StaParams.supported_channels[j] = params->supported_channels[i];
11311 wifi_chan_index =
11312 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
11313 no_of_channels = params->supported_channels[i+1];
11314 for(k=1; k <= no_of_channels; k++)
11315 {
11316 StaParams.supported_channels[j+1] =
11317 StaParams.supported_channels[j] + wifi_chan_index;
11318 j+=1;
11319 }
11320 }
11321 StaParams.supported_channels_len = j;
11322 }
SaidiReddy Yenuga0f1a1592017-04-05 13:18:26 +053011323 if (params->supported_oper_classes_len >
11324 SIR_MAC_MAX_SUPP_OPER_CLASSES) {
11325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11326 "received oper classes:%d, resetting it to max supported %d",
11327 params->supported_oper_classes_len,
11328 SIR_MAC_MAX_SUPP_OPER_CLASSES);
11329 params->supported_oper_classes_len =
11330 SIR_MAC_MAX_SUPP_OPER_CLASSES;
11331 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011332 vos_mem_copy(StaParams.supported_oper_classes,
11333 params->supported_oper_classes,
11334 params->supported_oper_classes_len);
11335 StaParams.supported_oper_classes_len =
11336 params->supported_oper_classes_len;
11337
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053011338 if (params->ext_capab_len > sizeof(StaParams.extn_capability)) {
11339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11340 "received extn capabilities:%d, resetting it to max supported",
11341 params->ext_capab_len);
11342 params->ext_capab_len = sizeof(StaParams.extn_capability);
11343 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011344 if (0 != params->ext_capab_len)
11345 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053011346 params->ext_capab_len);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011347
11348 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011349 {
11350 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011351 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011352 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011353
11354 StaParams.supported_rates_len = params->supported_rates_len;
11355
11356 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
11357 * The supported_rates array , for all the structures propogating till Add Sta
11358 * to the firmware has to be modified , if the supplicant (ieee80211) is
11359 * modified to send more rates.
11360 */
11361
11362 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
11363 */
11364 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
11365 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
11366
11367 if (0 != StaParams.supported_rates_len) {
11368 int i = 0;
11369 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
11370 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011371 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011372 "Supported Rates with Length %d", StaParams.supported_rates_len);
11373 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011374 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011375 "[%d]: %0x", i, StaParams.supported_rates[i]);
11376 }
11377
11378 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011379 {
11380 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011381 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011382 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011383
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011384 if (0 != params->ext_capab_len ) {
11385 /*Define A Macro : TODO Sunil*/
11386 if ((1<<4) & StaParams.extn_capability[3]) {
11387 isBufSta = 1;
11388 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011389 /* TDLS Channel Switching Support */
11390 if ((1<<6) & StaParams.extn_capability[3]) {
11391 isOffChannelSupported = 1;
11392 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011393 }
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011394
11395 if (pHddCtx->cfg_ini->fEnableTDLSWmmMode &&
Nitesh Shah48df4c02016-08-12 16:27:33 +053011396 (params->ht_capa || params->vht_capa ||
11397 (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME))))
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011398 /* TDLS Peer is WME/QoS capable */
11399 isQosWmmSta = TRUE;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011400
11401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11402 "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d",
11403 __func__, isQosWmmSta, StaParams.htcap_present);
11404
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011405 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
11406 &StaParams, isBufSta,
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011407 isOffChannelSupported,
11408 isQosWmmSta);
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011409
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011410 if (VOS_STATUS_SUCCESS != status) {
11411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11412 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
11413 return -EINVAL;
11414 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011415 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
11416
11417 if (VOS_STATUS_SUCCESS != status) {
11418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11419 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
11420 return -EINVAL;
11421 }
11422 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011423#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053011424 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011425 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 return status;
11427}
11428
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011429#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
11430static int wlan_hdd_change_station(struct wiphy *wiphy,
11431 struct net_device *dev,
11432 const u8 *mac,
11433 struct station_parameters *params)
11434#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011435static int wlan_hdd_change_station(struct wiphy *wiphy,
11436 struct net_device *dev,
11437 u8 *mac,
11438 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011439#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011440{
11441 int ret;
11442
11443 vos_ssr_protect(__func__);
11444 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
11445 vos_ssr_unprotect(__func__);
11446
11447 return ret;
11448}
11449
Jeff Johnson295189b2012-06-20 16:38:30 -070011450/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011451 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011452 * This function is used to initialize the key information
11453 */
11454#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011455static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011456 struct net_device *ndev,
11457 u8 key_index, bool pairwise,
11458 const u8 *mac_addr,
11459 struct key_params *params
11460 )
11461#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011462static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011463 struct net_device *ndev,
11464 u8 key_index, const u8 *mac_addr,
11465 struct key_params *params
11466 )
11467#endif
11468{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011469 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011470 tCsrRoamSetKey setKey;
11471 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011472 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011473 v_U32_t roamId= 0xFF;
11474 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 hdd_hostapd_state_t *pHostapdState;
11476 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011477 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011478 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011479
11480 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011481
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011482 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11483 TRACE_CODE_HDD_CFG80211_ADD_KEY,
11484 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011485 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11486 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011487 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011488 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011489 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011490 }
11491
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011492 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11493 __func__, hdd_device_modetoString(pAdapter->device_mode),
11494 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011495
11496 if (CSR_MAX_NUM_KEY <= key_index)
11497 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011498 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011499 key_index);
11500
11501 return -EINVAL;
11502 }
11503
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011504 if (CSR_MAX_KEY_LEN < params->key_len)
11505 {
11506 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
11507 params->key_len);
11508
11509 return -EINVAL;
11510 }
11511
11512 hddLog(VOS_TRACE_LEVEL_INFO,
11513 "%s: called with key index = %d & key length %d",
11514 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011515
11516 /*extract key idx, key len and key*/
11517 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11518 setKey.keyId = key_index;
11519 setKey.keyLength = params->key_len;
11520 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
11521
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011522 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011523 {
11524 case WLAN_CIPHER_SUITE_WEP40:
11525 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
11526 break;
11527
11528 case WLAN_CIPHER_SUITE_WEP104:
11529 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
11530 break;
11531
11532 case WLAN_CIPHER_SUITE_TKIP:
11533 {
11534 u8 *pKey = &setKey.Key[0];
11535 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
11536
11537 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
11538
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011539 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070011540
11541 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011542 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011543 |--------------|----------|----------|
11544 <---16bytes---><--8bytes--><--8bytes-->
11545
11546 */
11547 /*Sme expects the 32 bytes key to be in the below order
11548
11549 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011550 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011551 |--------------|----------|----------|
11552 <---16bytes---><--8bytes--><--8bytes-->
11553 */
11554 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011555 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011556
11557 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011558 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011559
11560 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011561 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011562
11563
11564 break;
11565 }
11566
11567 case WLAN_CIPHER_SUITE_CCMP:
11568 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
11569 break;
11570
11571#ifdef FEATURE_WLAN_WAPI
11572 case WLAN_CIPHER_SUITE_SMS4:
11573 {
11574 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11575 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
11576 params->key, params->key_len);
11577 return 0;
11578 }
11579#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011580
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011581#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011582 case WLAN_CIPHER_SUITE_KRK:
11583 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
11584 break;
11585#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011586
11587#ifdef WLAN_FEATURE_11W
11588 case WLAN_CIPHER_SUITE_AES_CMAC:
11589 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070011590 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070011591#endif
11592
Jeff Johnson295189b2012-06-20 16:38:30 -070011593 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011594 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011595 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011596 status = -EOPNOTSUPP;
11597 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011598 }
11599
11600 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
11601 __func__, setKey.encType);
11602
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011603 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070011604#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11605 (!pairwise)
11606#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011607 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070011608#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011609 )
11610 {
11611 /* set group key*/
11612 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11613 "%s- %d: setting Broadcast key",
11614 __func__, __LINE__);
11615 setKey.keyDirection = eSIR_RX_ONLY;
11616 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11617 }
11618 else
11619 {
11620 /* set pairwise key*/
11621 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11622 "%s- %d: setting pairwise key",
11623 __func__, __LINE__);
11624 setKey.keyDirection = eSIR_TX_RX;
11625 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11626 }
11627 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
11628 {
11629 setKey.keyDirection = eSIR_TX_RX;
11630 /*Set the group key*/
11631 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11632 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011633
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011634 if ( 0 != status )
11635 {
11636 hddLog(VOS_TRACE_LEVEL_ERROR,
11637 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011638 status = -EINVAL;
11639 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011640 }
11641 /*Save the keys here and call sme_RoamSetKey for setting
11642 the PTK after peer joins the IBSS network*/
11643 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
11644 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011645 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011646 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053011647 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
11648 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
11649 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011650 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011651 if( pHostapdState->bssState == BSS_START )
11652 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011653 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11654 vos_status = wlan_hdd_check_ula_done(pAdapter);
11655
11656 if ( vos_status != VOS_STATUS_SUCCESS )
11657 {
11658 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11659 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11660 __LINE__, vos_status );
11661
11662 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11663
11664 status = -EINVAL;
11665 goto end;
11666 }
11667
Jeff Johnson295189b2012-06-20 16:38:30 -070011668 status = WLANSAP_SetKeySta( pVosContext, &setKey);
11669
11670 if ( status != eHAL_STATUS_SUCCESS )
11671 {
11672 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11673 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11674 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011675 status = -EINVAL;
11676 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011677 }
11678 }
11679
11680 /* Saving WEP keys */
11681 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
11682 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
11683 {
11684 //Save the wep key in ap context. Issue setkey after the BSS is started.
11685 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
11686 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
11687 }
11688 else
11689 {
11690 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011691 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011692 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
11693 }
11694 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011695 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
11696 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 {
11698 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11699 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11700
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011701#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11702 if (!pairwise)
11703#else
11704 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
11705#endif
11706 {
11707 /* set group key*/
11708 if (pHddStaCtx->roam_info.deferKeyComplete)
11709 {
11710 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11711 "%s- %d: Perform Set key Complete",
11712 __func__, __LINE__);
11713 hdd_PerformRoamSetKeyComplete(pAdapter);
11714 }
11715 }
11716
Jeff Johnson295189b2012-06-20 16:38:30 -070011717 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
11718
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080011719 pWextState->roamProfile.Keys.defaultIndex = key_index;
11720
11721
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011722 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011723 params->key, params->key_len);
11724
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011725
Jeff Johnson295189b2012-06-20 16:38:30 -070011726 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11727
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011728 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011729 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011730 __func__, setKey.peerMac[0], setKey.peerMac[1],
11731 setKey.peerMac[2], setKey.peerMac[3],
11732 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011733 setKey.keyDirection);
11734
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011735 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053011736
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011737 if ( vos_status != VOS_STATUS_SUCCESS )
11738 {
11739 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011740 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11741 __LINE__, vos_status );
11742
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011743 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011744
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011745 status = -EINVAL;
11746 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011747
11748 }
11749
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011750#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011751 /* The supplicant may attempt to set the PTK once pre-authentication
11752 is done. Save the key in the UMAC and include it in the ADD BSS
11753 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011754 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011755 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011756 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011757 hddLog(VOS_TRACE_LEVEL_INFO_MED,
11758 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011759 status = 0;
11760 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011761 }
11762 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
11763 {
11764 hddLog(VOS_TRACE_LEVEL_ERROR,
11765 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011766 status = -EINVAL;
11767 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011768 }
11769#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070011770
11771 /* issue set key request to SME*/
11772 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11773 pAdapter->sessionId, &setKey, &roamId );
11774
11775 if ( 0 != status )
11776 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011777 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011778 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
11779 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011780 status = -EINVAL;
11781 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011782 }
11783
11784
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011785 /* in case of IBSS as there was no information available about WEP keys during
11786 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070011787 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011788 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
11789 !( ( IW_AUTH_KEY_MGMT_802_1X
11790 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070011791 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
11792 )
11793 &&
11794 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
11795 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
11796 )
11797 )
11798 {
11799 setKey.keyDirection = eSIR_RX_ONLY;
11800 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11801
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011802 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011803 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011804 __func__, setKey.peerMac[0], setKey.peerMac[1],
11805 setKey.peerMac[2], setKey.peerMac[3],
11806 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 setKey.keyDirection);
11808
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011809 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011810 pAdapter->sessionId, &setKey, &roamId );
11811
11812 if ( 0 != status )
11813 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011814 hddLog(VOS_TRACE_LEVEL_ERROR,
11815 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 __func__, status);
11817 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011818 status = -EINVAL;
11819 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011820 }
11821 }
11822 }
11823
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011824end:
11825 /* Need to clear any trace of key value in the memory.
11826 * Thus zero out the memory even though it is local
11827 * variable.
11828 */
11829 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011830 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011831 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011832}
11833
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011834#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11835static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11836 struct net_device *ndev,
11837 u8 key_index, bool pairwise,
11838 const u8 *mac_addr,
11839 struct key_params *params
11840 )
11841#else
11842static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11843 struct net_device *ndev,
11844 u8 key_index, const u8 *mac_addr,
11845 struct key_params *params
11846 )
11847#endif
11848{
11849 int ret;
11850 vos_ssr_protect(__func__);
11851#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11852 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
11853 mac_addr, params);
11854#else
11855 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
11856 params);
11857#endif
11858 vos_ssr_unprotect(__func__);
11859
11860 return ret;
11861}
11862
Jeff Johnson295189b2012-06-20 16:38:30 -070011863/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011864 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 * This function is used to get the key information
11866 */
11867#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011868static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011869 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011870 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011871 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011872 const u8 *mac_addr, void *cookie,
11873 void (*callback)(void *cookie, struct key_params*)
11874 )
11875#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011876static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011877 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 struct net_device *ndev,
11879 u8 key_index, const u8 *mac_addr, void *cookie,
11880 void (*callback)(void *cookie, struct key_params*)
11881 )
11882#endif
11883{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011884 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011885 hdd_wext_state_t *pWextState = NULL;
11886 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011887 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011888 hdd_context_t *pHddCtx;
11889 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011890
11891 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011892
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011893 if (NULL == pAdapter)
11894 {
11895 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11896 "%s: HDD adapter is Null", __func__);
11897 return -ENODEV;
11898 }
11899
11900 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11901 ret = wlan_hdd_validate_context(pHddCtx);
11902 if (0 != ret)
11903 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011904 return ret;
11905 }
11906
11907 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11908 pRoamProfile = &(pWextState->roamProfile);
11909
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011910 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11911 __func__, hdd_device_modetoString(pAdapter->device_mode),
11912 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011913
Jeff Johnson295189b2012-06-20 16:38:30 -070011914 memset(&params, 0, sizeof(params));
11915
11916 if (CSR_MAX_NUM_KEY <= key_index)
11917 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011918 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011920 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011921
11922 switch(pRoamProfile->EncryptionType.encryptionType[0])
11923 {
11924 case eCSR_ENCRYPT_TYPE_NONE:
11925 params.cipher = IW_AUTH_CIPHER_NONE;
11926 break;
11927
11928 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
11929 case eCSR_ENCRYPT_TYPE_WEP40:
11930 params.cipher = WLAN_CIPHER_SUITE_WEP40;
11931 break;
11932
11933 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
11934 case eCSR_ENCRYPT_TYPE_WEP104:
11935 params.cipher = WLAN_CIPHER_SUITE_WEP104;
11936 break;
11937
11938 case eCSR_ENCRYPT_TYPE_TKIP:
11939 params.cipher = WLAN_CIPHER_SUITE_TKIP;
11940 break;
11941
11942 case eCSR_ENCRYPT_TYPE_AES:
11943 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
11944 break;
11945
11946 default:
11947 params.cipher = IW_AUTH_CIPHER_NONE;
11948 break;
11949 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011950
c_hpothuaaf19692014-05-17 17:01:48 +053011951 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11952 TRACE_CODE_HDD_CFG80211_GET_KEY,
11953 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011954
Jeff Johnson295189b2012-06-20 16:38:30 -070011955 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
11956 params.seq_len = 0;
11957 params.seq = NULL;
11958 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
11959 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011960 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011961 return 0;
11962}
11963
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011964#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11965static int wlan_hdd_cfg80211_get_key(
11966 struct wiphy *wiphy,
11967 struct net_device *ndev,
11968 u8 key_index, bool pairwise,
11969 const u8 *mac_addr, void *cookie,
11970 void (*callback)(void *cookie, struct key_params*)
11971 )
11972#else
11973static int wlan_hdd_cfg80211_get_key(
11974 struct wiphy *wiphy,
11975 struct net_device *ndev,
11976 u8 key_index, const u8 *mac_addr, void *cookie,
11977 void (*callback)(void *cookie, struct key_params*)
11978 )
11979#endif
11980{
11981 int ret;
11982
11983 vos_ssr_protect(__func__);
11984#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11985 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
11986 mac_addr, cookie, callback);
11987#else
11988 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
11989 callback);
11990#endif
11991 vos_ssr_unprotect(__func__);
11992
11993 return ret;
11994}
11995
Jeff Johnson295189b2012-06-20 16:38:30 -070011996/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011997 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011998 * This function is used to delete the key information
11999 */
12000#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012001static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012002 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012003 u8 key_index,
12004 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070012005 const u8 *mac_addr
12006 )
12007#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012008static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012009 struct net_device *ndev,
12010 u8 key_index,
12011 const u8 *mac_addr
12012 )
12013#endif
12014{
12015 int status = 0;
12016
12017 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012018 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070012019 //it is observed that this is invalidating peer
12020 //key index whenever re-key is done. This is affecting data link.
12021 //It should be ok to ignore del_key.
12022#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012023 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
12024 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070012025 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
12026 tCsrRoamSetKey setKey;
12027 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012028
Jeff Johnson295189b2012-06-20 16:38:30 -070012029 ENTER();
12030
12031 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
12032 __func__,pAdapter->device_mode);
12033
12034 if (CSR_MAX_NUM_KEY <= key_index)
12035 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012036 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012037 key_index);
12038
12039 return -EINVAL;
12040 }
12041
12042 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12043 setKey.keyId = key_index;
12044
12045 if (mac_addr)
12046 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
12047 else
12048 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
12049
12050 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
12051
12052 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012054 )
12055 {
12056
12057 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
12059 if( pHostapdState->bssState == BSS_START)
12060 {
12061 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012062
Jeff Johnson295189b2012-06-20 16:38:30 -070012063 if ( status != eHAL_STATUS_SUCCESS )
12064 {
12065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12066 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
12067 __LINE__, status );
12068 }
12069 }
12070 }
12071 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012072 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070012073 )
12074 {
12075 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12076
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012077 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
12078
12079 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012081 __func__, setKey.peerMac[0], setKey.peerMac[1],
12082 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070012083 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012084 if(pAdapter->sessionCtx.station.conn_info.connState ==
12085 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070012086 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012087 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012088 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012089
Jeff Johnson295189b2012-06-20 16:38:30 -070012090 if ( 0 != status )
12091 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012092 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012093 "%s: sme_RoamSetKey failure, returned %d",
12094 __func__, status);
12095 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
12096 return -EINVAL;
12097 }
12098 }
12099 }
12100#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012101 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012102 return status;
12103}
12104
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012105#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12106static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
12107 struct net_device *ndev,
12108 u8 key_index,
12109 bool pairwise,
12110 const u8 *mac_addr
12111 )
12112#else
12113static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
12114 struct net_device *ndev,
12115 u8 key_index,
12116 const u8 *mac_addr
12117 )
12118#endif
12119{
12120 int ret;
12121
12122 vos_ssr_protect(__func__);
12123#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12124 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
12125 mac_addr);
12126#else
12127 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
12128#endif
12129 vos_ssr_unprotect(__func__);
12130
12131 return ret;
12132}
12133
Jeff Johnson295189b2012-06-20 16:38:30 -070012134/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012135 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070012136 * This function is used to set the default tx key index
12137 */
12138#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012139static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012140 struct net_device *ndev,
12141 u8 key_index,
12142 bool unicast, bool multicast)
12143#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012144static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012145 struct net_device *ndev,
12146 u8 key_index)
12147#endif
12148{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012149 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012150 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053012151 hdd_wext_state_t *pWextState;
12152 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012153 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012154
12155 ENTER();
12156
Gopichand Nakkala29149562013-05-10 21:43:41 +053012157 if ((NULL == pAdapter))
12158 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053012160 "invalid adapter");
12161 return -EINVAL;
12162 }
12163
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012164 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12165 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
12166 pAdapter->sessionId, key_index));
12167
Gopichand Nakkala29149562013-05-10 21:43:41 +053012168 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12169 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12170
12171 if ((NULL == pWextState) || (NULL == pHddStaCtx))
12172 {
12173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
12174 "invalid Wext state or HDD context");
12175 return -EINVAL;
12176 }
12177
Arif Hussain6d2a3322013-11-17 19:50:10 -080012178 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012179 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012180
Jeff Johnson295189b2012-06-20 16:38:30 -070012181 if (CSR_MAX_NUM_KEY <= key_index)
12182 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012183 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012184 key_index);
12185
12186 return -EINVAL;
12187 }
12188
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012189 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12190 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012191 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012192 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012193 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012194 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012195
Jeff Johnson295189b2012-06-20 16:38:30 -070012196 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070012197 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012198 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053012200 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080012201 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012202 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080012203 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070012204 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012205 {
12206 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070012207 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012208
Jeff Johnson295189b2012-06-20 16:38:30 -070012209 tCsrRoamSetKey setKey;
12210 v_U32_t roamId= 0xFF;
12211 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012212
12213 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012214 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012215
Jeff Johnson295189b2012-06-20 16:38:30 -070012216 Keys->defaultIndex = (u8)key_index;
12217 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12218 setKey.keyId = key_index;
12219 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012220
12221 vos_mem_copy(&setKey.Key[0],
12222 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012223 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012224
Gopichand Nakkala29149562013-05-10 21:43:41 +053012225 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012226
12227 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070012228 &pHddStaCtx->conn_info.bssId[0],
12229 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012230
Gopichand Nakkala29149562013-05-10 21:43:41 +053012231 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
12232 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
12233 eCSR_ENCRYPT_TYPE_WEP104)
12234 {
12235 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
12236 even though ap is configured for WEP-40 encryption. In this canse the key length
12237 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
12238 type(104) and switching encryption type to 40*/
12239 pWextState->roamProfile.EncryptionType.encryptionType[0] =
12240 eCSR_ENCRYPT_TYPE_WEP40;
12241 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
12242 eCSR_ENCRYPT_TYPE_WEP40;
12243 }
12244
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012245 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012246 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012247
Jeff Johnson295189b2012-06-20 16:38:30 -070012248 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012249 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012250 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012251
Jeff Johnson295189b2012-06-20 16:38:30 -070012252 if ( 0 != status )
12253 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012254 hddLog(VOS_TRACE_LEVEL_ERROR,
12255 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012256 status);
12257 return -EINVAL;
12258 }
12259 }
12260 }
12261
12262 /* In SoftAp mode setting key direction for default mode */
12263 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
12264 {
12265 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
12266 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
12267 (eCSR_ENCRYPT_TYPE_AES !=
12268 pWextState->roamProfile.EncryptionType.encryptionType[0])
12269 )
12270 {
12271 /* Saving key direction for default key index to TX default */
12272 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
12273 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
12274 }
12275 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012276 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012277 return status;
12278}
12279
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012280#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12281static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12282 struct net_device *ndev,
12283 u8 key_index,
12284 bool unicast, bool multicast)
12285#else
12286static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12287 struct net_device *ndev,
12288 u8 key_index)
12289#endif
12290{
12291 int ret;
12292 vos_ssr_protect(__func__);
12293#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12294 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
12295 multicast);
12296#else
12297 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
12298#endif
12299 vos_ssr_unprotect(__func__);
12300
12301 return ret;
12302}
12303
Jeff Johnson295189b2012-06-20 16:38:30 -070012304/*
12305 * FUNCTION: wlan_hdd_cfg80211_inform_bss
12306 * This function is used to inform the BSS details to nl80211 interface.
12307 */
12308static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
12309 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
12310{
12311 struct net_device *dev = pAdapter->dev;
12312 struct wireless_dev *wdev = dev->ieee80211_ptr;
12313 struct wiphy *wiphy = wdev->wiphy;
12314 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
12315 int chan_no;
12316 int ie_length;
12317 const char *ie;
12318 unsigned int freq;
12319 struct ieee80211_channel *chan;
12320 int rssi = 0;
12321 struct cfg80211_bss *bss = NULL;
12322
Jeff Johnson295189b2012-06-20 16:38:30 -070012323 if( NULL == pBssDesc )
12324 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012325 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012326 return bss;
12327 }
12328
12329 chan_no = pBssDesc->channelId;
12330 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
12331 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
12332
12333 if( NULL == ie )
12334 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012335 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012336 return bss;
12337 }
12338
12339#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
12340 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
12341 {
12342 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12343 }
12344 else
12345 {
12346 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12347 }
12348#else
12349 freq = ieee80211_channel_to_frequency(chan_no);
12350#endif
12351
12352 chan = __ieee80211_get_channel(wiphy, freq);
12353
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053012354 if (!chan) {
12355 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
12356 return NULL;
12357 }
12358
Abhishek Singhaee43942014-06-16 18:55:47 +053012359 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070012360
Anand N Sunkad9f80b742015-07-30 20:05:51 +053012361 return cfg80211_inform_bss(wiphy, chan,
12362#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12363 CFG80211_BSS_FTYPE_UNKNOWN,
12364#endif
12365 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012366 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070012367 pBssDesc->capabilityInfo,
12368 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053012369 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070012370}
12371
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012372/*
12373 * wlan_hdd_cfg80211_update_bss_list :to inform nl80211
12374 * interface that BSS might have been lost.
12375 * @pAdapter: adaptor
12376 * @bssid: bssid which might have been lost
12377 *
12378 * Return: bss which is unlinked from kernel cache
12379 */
12380struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_list(
12381 hdd_adapter_t *pAdapter, tSirMacAddr bssid)
12382{
12383 struct net_device *dev = pAdapter->dev;
12384 struct wireless_dev *wdev = dev->ieee80211_ptr;
12385 struct wiphy *wiphy = wdev->wiphy;
12386 struct cfg80211_bss *bss = NULL;
12387
Abhishek Singh5a597e62016-12-05 15:16:30 +053012388 bss = hdd_get_bss_entry(wiphy,
12389 NULL, bssid,
12390 NULL, 0);
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012391 if (bss == NULL) {
12392 hddLog(LOGE, FL("BSS not present"));
12393 } else {
12394 hddLog(LOG1, FL("cfg80211_unlink_bss called for BSSID "
12395 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(bssid));
12396 cfg80211_unlink_bss(wiphy, bss);
12397 }
12398 return bss;
12399}
Jeff Johnson295189b2012-06-20 16:38:30 -070012400
12401
12402/*
12403 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
12404 * This function is used to inform the BSS details to nl80211 interface.
12405 */
12406struct cfg80211_bss*
12407wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
12408 tSirBssDescription *bss_desc
12409 )
12410{
12411 /*
12412 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
12413 already exists in bss data base of cfg80211 for that particular BSS ID.
12414 Using cfg80211_inform_bss_frame to update the bss entry instead of
12415 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
12416 now there is no possibility to get the mgmt(probe response) frame from PE,
12417 converting bss_desc to ieee80211_mgmt(probe response) and passing to
12418 cfg80211_inform_bss_frame.
12419 */
12420 struct net_device *dev = pAdapter->dev;
12421 struct wireless_dev *wdev = dev->ieee80211_ptr;
12422 struct wiphy *wiphy = wdev->wiphy;
12423 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012424#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12425 qcom_ie_age *qie_age = NULL;
12426 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
12427#else
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012429#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012430 const char *ie =
12431 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
12432 unsigned int freq;
12433 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012434 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012435 struct cfg80211_bss *bss_status = NULL;
12436 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
12437 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070012438 hdd_context_t *pHddCtx;
12439 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070012440#ifdef WLAN_OPEN_SOURCE
12441 struct timespec ts;
12442#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012443
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012444
Wilson Yangf80a0542013-10-07 13:02:37 -070012445 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12446 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070012447 if (0 != status)
12448 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012449 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012450 }
12451
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012452 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070012453 if (!mgmt)
12454 {
12455 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12456 "%s: memory allocation failed ", __func__);
12457 return NULL;
12458 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012459
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012461
12462#ifdef WLAN_OPEN_SOURCE
12463 /* Android does not want the timestamp from the frame.
12464 Instead it wants a monotonic increasing value */
12465 get_monotonic_boottime(&ts);
12466 mgmt->u.probe_resp.timestamp =
12467 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
12468#else
12469 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070012470 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
12471 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070012472
12473#endif
12474
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
12476 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012477
12478#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12479 /* GPS Requirement: need age ie per entry. Using vendor specific. */
12480 /* Assuming this is the last IE, copy at the end */
12481 ie_length -=sizeof(qcom_ie_age);
12482 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
12483 qie_age->element_id = QCOM_VENDOR_IE_ID;
12484 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
12485 qie_age->oui_1 = QCOM_OUI1;
12486 qie_age->oui_2 = QCOM_OUI2;
12487 qie_age->oui_3 = QCOM_OUI3;
12488 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
Selvaraj, Sridhar4b3a8362016-10-12 12:34:08 +053012489 /* Lowi expects the timestamp of bss in units of 1/10 ms. In driver all
12490 * bss related timestamp is in units of ms. Due to this when scan results
12491 * are sent to lowi the scan age is high.To address this, send age in units
12492 * of 1/10 ms.
12493 */
12494 qie_age->age = (vos_timer_get_system_time() -
12495 bss_desc->nReceivedTime)/10;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012496#endif
12497
Jeff Johnson295189b2012-06-20 16:38:30 -070012498 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053012499 if (bss_desc->fProbeRsp)
12500 {
12501 mgmt->frame_control |=
12502 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
12503 }
12504 else
12505 {
12506 mgmt->frame_control |=
12507 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
12508 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012509
12510#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012511 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012512 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
12513 {
12514 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12515 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012516 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012517 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
12518
12519 {
12520 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12521 }
12522 else
12523 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012524 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
12525 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070012526 kfree(mgmt);
12527 return NULL;
12528 }
12529#else
12530 freq = ieee80211_channel_to_frequency(chan_no);
12531#endif
12532 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012533 /*when the band is changed on the fly using the GUI, three things are done
12534 * 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)
12535 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
12536 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
12537 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
12538 * and discards the channels correponding to previous band and calls back with zero bss results.
12539 * 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
12540 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
12541 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
12542 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
12543 * So drop the bss and continue to next bss.
12544 */
12545 if(chan == NULL)
12546 {
Deepthi Gowri306657b2016-04-28 17:10:41 +053012547 hddLog(VOS_TRACE_LEVEL_ERROR,
12548 FL("chan pointer is NULL, chan_no: %d freq: %d"),
12549 chan_no, freq);
Chilam Ngc4244af2013-04-01 15:37:32 -070012550 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012551 return NULL;
12552 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053012553 /*To keep the rssi icon of the connected AP in the scan window
12554 *and the rssi icon of the wireless networks in sync
12555 * */
12556 if (( eConnectionState_Associated ==
12557 pAdapter->sessionCtx.station.conn_info.connState ) &&
12558 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
12559 pAdapter->sessionCtx.station.conn_info.bssId,
12560 WNI_CFG_BSSID_LEN)) &&
12561 (pHddCtx->hdd_wlan_suspended == FALSE))
12562 {
12563 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
12564 rssi = (pAdapter->rssi * 100);
12565 }
12566 else
12567 {
12568 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
12569 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012570
Nirav Shah20ac06f2013-12-12 18:14:06 +053012571 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053012572 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
12573 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053012574
Jeff Johnson295189b2012-06-20 16:38:30 -070012575 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
12576 frame_len, rssi, GFP_KERNEL);
12577 kfree(mgmt);
12578 return bss_status;
12579}
12580
12581/*
12582 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
12583 * This function is used to update the BSS data base of CFG8011
12584 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012585struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012586 tCsrRoamInfo *pRoamInfo
12587 )
12588{
12589 tCsrRoamConnectedProfile roamProfile;
12590 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12591 struct cfg80211_bss *bss = NULL;
12592
12593 ENTER();
12594
12595 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
12596 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
12597
12598 if (NULL != roamProfile.pBssDesc)
12599 {
Girish Gowlif4b68022014-08-28 23:18:57 +053012600 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12601 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012602
12603 if (NULL == bss)
12604 {
12605 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
12606 __func__);
12607 }
12608
12609 sme_RoamFreeConnectProfile(hHal, &roamProfile);
12610 }
12611 else
12612 {
12613 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
12614 __func__);
12615 }
12616 return bss;
12617}
12618
12619/*
12620 * FUNCTION: wlan_hdd_cfg80211_update_bss
12621 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012622static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
12623 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012625{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012626 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012627 tCsrScanResultInfo *pScanResult;
12628 eHalStatus status = 0;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012629 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012630 tScanResultHandle pResult;
12631 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012632 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012633 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012635
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012636 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12637 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
12638 NO_SESSION, pAdapter->sessionId));
12639
Wilson Yangf80a0542013-10-07 13:02:37 -070012640 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012641 ret = wlan_hdd_validate_context(pHddCtx);
12642 if (0 != ret)
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 {
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012644 return ret;
Wilson Yangf80a0542013-10-07 13:02:37 -070012645 }
12646
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012647 if (pAdapter->request != NULL)
12648 {
12649 if ((pAdapter->request->n_ssids == 1)
12650 && (pAdapter->request->ssids != NULL)
12651 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
12652 is_p2p_scan = true;
12653 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 /*
12655 * start getting scan results and populate cgf80211 BSS database
12656 */
12657 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
12658
12659 /* no scan results */
12660 if (NULL == pResult)
12661 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012662 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
12663 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053012664 wlan_hdd_get_frame_logs(pAdapter,
12665 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070012666 return status;
12667 }
12668
12669 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
12670
12671 while (pScanResult)
12672 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012673 /*
12674 * cfg80211_inform_bss() is not updating ie field of bss entry, if
12675 * entry already exists in bss data base of cfg80211 for that
12676 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
12677 * bss entry instead of cfg80211_inform_bss, But this call expects
12678 * mgmt packet as input. As of now there is no possibility to get
12679 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070012680 * ieee80211_mgmt(probe response) and passing to c
12681 * fg80211_inform_bss_frame.
12682 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012683 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
12684 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
12685 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012686 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12687 continue; //Skip the non p2p bss entries
12688 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12690 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012691
Jeff Johnson295189b2012-06-20 16:38:30 -070012692
12693 if (NULL == bss_status)
12694 {
12695 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012696 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012697 }
12698 else
12699 {
Yue Maf49ba872013-08-19 12:04:25 -070012700 cfg80211_put_bss(
12701#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
12702 wiphy,
12703#endif
12704 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012705 }
12706
12707 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12708 }
12709
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012710 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012711 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012712 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012713}
12714
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012715void
12716hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
12717{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012718 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080012719 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012720} /****** end hddPrintMacAddr() ******/
12721
12722void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012723hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012724{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012725 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012726 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012727 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
12728 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
12729 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012730} /****** end hddPrintPmkId() ******/
12731
12732//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
12733//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
12734
12735//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
12736//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
12737
12738#define dump_bssid(bssid) \
12739 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012740 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
12741 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012742 }
12743
12744#define dump_pmkid(pMac, pmkid) \
12745 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012746 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
12747 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012748 }
12749
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070012750#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012751/*
12752 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
12753 * This function is used to notify the supplicant of a new PMKSA candidate.
12754 */
12755int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012756 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012757 int index, bool preauth )
12758{
Jeff Johnsone7245742012-09-05 17:12:55 -070012759#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012760 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012761 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012762
12763 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070012764 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012765
12766 if( NULL == pRoamInfo )
12767 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012768 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012769 return -EINVAL;
12770 }
12771
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012772 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
12773 {
12774 dump_bssid(pRoamInfo->bssid);
12775 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012776 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012777 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012778#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012779 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012780}
12781#endif //FEATURE_WLAN_LFR
12782
Yue Maef608272013-04-08 23:09:17 -070012783#ifdef FEATURE_WLAN_LFR_METRICS
12784/*
12785 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
12786 * 802.11r/LFR metrics reporting function to report preauth initiation
12787 *
12788 */
12789#define MAX_LFR_METRICS_EVENT_LENGTH 100
12790VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
12791 tCsrRoamInfo *pRoamInfo)
12792{
12793 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12794 union iwreq_data wrqu;
12795
12796 ENTER();
12797
12798 if (NULL == pAdapter)
12799 {
12800 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12801 return VOS_STATUS_E_FAILURE;
12802 }
12803
12804 /* create the event */
12805 memset(&wrqu, 0, sizeof(wrqu));
12806 memset(metrics_notification, 0, sizeof(metrics_notification));
12807
12808 wrqu.data.pointer = metrics_notification;
12809 wrqu.data.length = scnprintf(metrics_notification,
12810 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
12811 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12812
12813 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12814
12815 EXIT();
12816
12817 return VOS_STATUS_SUCCESS;
12818}
12819
12820/*
12821 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
12822 * 802.11r/LFR metrics reporting function to report preauth completion
12823 * or failure
12824 */
12825VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
12826 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
12827{
12828 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12829 union iwreq_data wrqu;
12830
12831 ENTER();
12832
12833 if (NULL == pAdapter)
12834 {
12835 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12836 return VOS_STATUS_E_FAILURE;
12837 }
12838
12839 /* create the event */
12840 memset(&wrqu, 0, sizeof(wrqu));
12841 memset(metrics_notification, 0, sizeof(metrics_notification));
12842
12843 scnprintf(metrics_notification, sizeof(metrics_notification),
12844 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
12845 MAC_ADDR_ARRAY(pRoamInfo->bssid));
12846
12847 if (1 == preauth_status)
12848 strncat(metrics_notification, " TRUE", 5);
12849 else
12850 strncat(metrics_notification, " FALSE", 6);
12851
12852 wrqu.data.pointer = metrics_notification;
12853 wrqu.data.length = strlen(metrics_notification);
12854
12855 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12856
12857 EXIT();
12858
12859 return VOS_STATUS_SUCCESS;
12860}
12861
12862/*
12863 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
12864 * 802.11r/LFR metrics reporting function to report handover initiation
12865 *
12866 */
12867VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
12868 tCsrRoamInfo *pRoamInfo)
12869{
12870 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12871 union iwreq_data wrqu;
12872
12873 ENTER();
12874
12875 if (NULL == pAdapter)
12876 {
12877 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12878 return VOS_STATUS_E_FAILURE;
12879 }
12880
12881 /* create the event */
12882 memset(&wrqu, 0, sizeof(wrqu));
12883 memset(metrics_notification, 0, sizeof(metrics_notification));
12884
12885 wrqu.data.pointer = metrics_notification;
12886 wrqu.data.length = scnprintf(metrics_notification,
12887 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
12888 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12889
12890 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12891
12892 EXIT();
12893
12894 return VOS_STATUS_SUCCESS;
12895}
12896#endif
12897
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053012898
12899/**
12900 * wlan_hdd_cfg80211_validate_scan_req - validate scan request
12901 * @scan_req: scan request to be checked
12902 *
12903 * Return: true or false
12904 */
12905#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
12906static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
12907 cfg80211_scan_request
12908 *scan_req)
12909{
12910 if (!scan_req || !scan_req->wiphy) {
12911 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
12912 return false;
12913 }
12914 if (vos_is_load_unload_in_progress(VOS_MODULE_ID_HDD, NULL)) {
12915 hddLog(VOS_TRACE_LEVEL_ERROR, "Load/Unload in progress");
12916 return false;
12917 }
12918 return true;
12919}
12920#else
12921static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
12922 cfg80211_scan_request
12923 *scan_req)
12924{
12925 if (!scan_req || !scan_req->wiphy) {
12926 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
12927 return false;
12928 }
12929 return true;
12930}
12931#endif
12932
12933
Jeff Johnson295189b2012-06-20 16:38:30 -070012934/*
12935 * FUNCTION: hdd_cfg80211_scan_done_callback
12936 * scanning callback function, called after finishing scan
12937 *
12938 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012939static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070012940 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
12941{
12942 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012943 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070012944 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012945 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012946 struct cfg80211_scan_request *req = NULL;
12947 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012948 bool aborted = false;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012949#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12950 bool iface_down = false;
12951#endif
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012952 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012953 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012954 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012955
12956 ENTER();
12957
c_manjee1b4ab9a2016-10-26 11:36:55 +053012958 if (!pAdapter || pAdapter->magic != WLAN_HDD_ADAPTER_MAGIC ||
12959 !pAdapter->dev) {
12960 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Adapter is not valid"));
12961 return 0;
12962 }
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012963 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053012964 if (NULL == pHddCtx) {
12965 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012966 return 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012967 }
12968
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012969#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12970 if (!(pAdapter->dev->flags & IFF_UP))
12971 {
12972 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012973 iface_down = true;
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012974 }
12975#endif
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012976 pScanInfo = &pHddCtx->scan_info;
12977
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 hddLog(VOS_TRACE_LEVEL_INFO,
12979 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080012980 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012981 __func__, halHandle, pContext, (int) scanId, (int) status);
12982
Kiet Lamac06e2c2013-10-23 16:25:07 +053012983 pScanInfo->mScanPendingCounter = 0;
12984
Jeff Johnson295189b2012-06-20 16:38:30 -070012985 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012986 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 &pScanInfo->scan_req_completion_event,
12988 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012989 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070012990 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012991 hddLog(VOS_TRACE_LEVEL_ERROR,
12992 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012994 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012995 }
12996
Yue Maef608272013-04-08 23:09:17 -070012997 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070012998 {
12999 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070013000 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070013001 }
13002
13003 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013004 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013005 {
13006 hddLog(VOS_TRACE_LEVEL_INFO,
13007 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080013008 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 (int) scanId);
13010 }
13011
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053013012#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013013 if (!iface_down)
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053013014#endif
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013015 {
13016 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
13017 pAdapter);
13018 if (0 > ret)
13019 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053013020 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013021
Jeff Johnson295189b2012-06-20 16:38:30 -070013022 /* If any client wait scan result through WEXT
13023 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013024 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070013025 {
13026 /* The other scan request waiting for current scan finish
13027 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013028 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070013029 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013030 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 }
13032 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013033 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070013034 {
13035 struct net_device *dev = pAdapter->dev;
13036 union iwreq_data wrqu;
13037 int we_event;
13038 char *msg;
13039
13040 memset(&wrqu, '\0', sizeof(wrqu));
13041 we_event = SIOCGIWSCAN;
13042 msg = NULL;
13043 wireless_send_event(dev, we_event, &wrqu, msg);
13044 }
13045 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013046 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013047
13048 /* Get the Scan Req */
13049 req = pAdapter->request;
mukul sharmae7041822015-12-03 15:09:21 +053013050 pAdapter->request = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013051
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013052 /* Scan is no longer pending */
13053 pScanInfo->mScanPending = VOS_FALSE;
13054
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013055 if (!wlan_hdd_cfg80211_validate_scan_req(req))
Jeff Johnson295189b2012-06-20 16:38:30 -070013056 {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013057#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13058 hddLog(VOS_TRACE_LEVEL_ERROR, FL("interface state %s"),
13059 iface_down ? "up" : "down");
13060#endif
13061
13062 if (pAdapter->dev) {
13063 hddLog(VOS_TRACE_LEVEL_ERROR, FL("device name %s"),
13064 pAdapter->dev->name);
13065 }
mukul sharmae7041822015-12-03 15:09:21 +053013066 complete(&pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -070013067 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070013068 }
13069
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013070 /* last_scan_timestamp is used to decide if new scan
13071 * is needed or not on station interface. If last station
13072 * scan time and new station scan time is less then
13073 * last_scan_timestamp ; driver will return cached scan.
13074 */
13075 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
13076 {
13077 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
13078
13079 if ( req->n_channels )
13080 {
13081 for (i = 0; i < req->n_channels ; i++ )
13082 {
13083 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
13084 }
13085 /* store no of channel scanned */
13086 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
13087 }
13088
13089 }
13090
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070013091 /*
13092 * cfg80211_scan_done informing NL80211 about completion
13093 * of scanning
13094 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053013095 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
13096 {
13097 aborted = true;
13098 }
mukul sharmae7041822015-12-03 15:09:21 +053013099
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013100#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13101 if (!iface_down)
13102#endif
13103 cfg80211_scan_done(req, aborted);
mukul sharmae7041822015-12-03 15:09:21 +053013104
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080013105 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070013106
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013107allow_suspend:
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053013108 if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
13109 ) && (pHddCtx->spoofMacAddr.isEnabled
13110 || pHddCtx->spoofMacAddr.isReqDeferred)) {
Siddharth Bhal76972212014-10-15 16:22:51 +053013111 /* Generate new random mac addr for next scan */
13112 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +053013113
13114 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
13115 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhal76972212014-10-15 16:22:51 +053013116 }
13117
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070013118 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013119 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013120
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070013121 /* Acquire wakelock to handle the case where APP's tries to suspend
13122 * immediatly after the driver gets connect request(i.e after scan)
13123 * from supplicant, this result in app's is suspending and not able
13124 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013125 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070013126
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013127#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13128 if (!iface_down)
13129#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070013130#ifdef FEATURE_WLAN_TDLS
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013131 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070013132#endif
13133
Jeff Johnson295189b2012-06-20 16:38:30 -070013134 EXIT();
13135 return 0;
13136}
13137
13138/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053013139 * FUNCTION: hdd_isConnectionInProgress
13140 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013141 *
13142 */
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013143v_BOOL_t hdd_isConnectionInProgress(hdd_context_t *pHddCtx, v_U8_t *session_id,
13144 scan_reject_states *reason)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013145{
13146 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
13147 hdd_station_ctx_t *pHddStaCtx = NULL;
13148 hdd_adapter_t *pAdapter = NULL;
13149 VOS_STATUS status = 0;
13150 v_U8_t staId = 0;
13151 v_U8_t *staMac = NULL;
13152
13153 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
13154
13155 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
13156 {
13157 pAdapter = pAdapterNode->pAdapter;
13158
13159 if( pAdapter )
13160 {
13161 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013162 "%s: Adapter with device mode %s (%d) exists",
13163 __func__, hdd_device_modetoString(pAdapter->device_mode),
13164 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013165 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053013166 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13167 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
13168 (eConnectionState_Connecting ==
13169 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13170 {
13171 hddLog(VOS_TRACE_LEVEL_ERROR,
13172 "%s: %p(%d) Connection is in progress", __func__,
13173 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013174 if (session_id && reason)
13175 {
13176 *session_id = pAdapter->sessionId;
13177 *reason = eHDD_CONNECTION_IN_PROGRESS;
13178 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013179 return VOS_TRUE;
13180 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013181 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013182 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013183 {
13184 hddLog(VOS_TRACE_LEVEL_ERROR,
13185 "%s: %p(%d) Reassociation is in progress", __func__,
13186 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013187 if (session_id && reason)
13188 {
13189 *session_id = pAdapter->sessionId;
13190 *reason = eHDD_REASSOC_IN_PROGRESS;
13191 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013192 return VOS_TRUE;
13193 }
13194 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013195 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13196 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013197 {
13198 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13199 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013200 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013201 {
13202 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
13203 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080013204 "%s: client " MAC_ADDRESS_STR
13205 " is in the middle of WPS/EAPOL exchange.", __func__,
13206 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013207 if (session_id && reason)
13208 {
13209 *session_id = pAdapter->sessionId;
13210 *reason = eHDD_EAPOL_IN_PROGRESS;
13211 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013212 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013213 }
13214 }
13215 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
13216 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
13217 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013218 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13219 ptSapContext pSapCtx = NULL;
13220 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13221 if(pSapCtx == NULL){
13222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13223 FL("psapCtx is NULL"));
13224 return VOS_FALSE;
13225 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013226 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
13227 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013228 if ((pSapCtx->aStaInfo[staId].isUsed) &&
13229 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013230 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013231 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013232
13233 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080013234 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
13235 "middle of WPS/EAPOL exchange.", __func__,
13236 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013237 if (session_id && reason)
13238 {
13239 *session_id = pAdapter->sessionId;
13240 *reason = eHDD_SAP_EAPOL_IN_PROGRESS;
13241 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013242 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013243 }
13244 }
13245 }
13246 }
13247 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
13248 pAdapterNode = pNext;
13249 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013250 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013251}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013252
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053013253/**
13254 * csr_scan_request_assign_bssid() - Set the BSSID received from Supplicant
13255 * to the Scan request
13256 * @scanRequest: Pointer to the csr scan request
13257 * @request: Pointer to the scan request from supplicant
13258 *
13259 * Return: None
13260 */
13261#ifdef CFG80211_SCAN_BSSID
13262static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13263 struct cfg80211_scan_request *request)
13264{
13265 vos_mem_copy(scanRequest->bssid, request->bssid, VOS_MAC_ADDR_SIZE);
13266}
13267#else
13268static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13269 struct cfg80211_scan_request *request)
13270{
13271}
13272#endif
13273
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013274/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013275 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070013276 * this scan respond to scan trigger and update cfg80211 scan database
13277 * later, scan dump command can be used to recieve scan results
13278 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013279int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080013280#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13281 struct net_device *dev,
13282#endif
13283 struct cfg80211_scan_request *request)
13284{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013285 hdd_adapter_t *pAdapter = NULL;
13286 hdd_context_t *pHddCtx = NULL;
13287 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013288 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013289 tCsrScanRequest scanRequest;
13290 tANI_U8 *channelList = NULL, i;
13291 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013292 int status;
13293 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013295 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053013296 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013297 bool is_p2p_scan = false;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013298 v_U8_t curr_session_id;
13299 scan_reject_states curr_reason;
Jeff Johnson295189b2012-06-20 16:38:30 -070013300
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013301#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
13302 struct net_device *dev = NULL;
13303 if (NULL == request)
13304 {
13305 hddLog(VOS_TRACE_LEVEL_ERROR,
13306 "%s: scan req param null", __func__);
13307 return -EINVAL;
13308 }
13309 dev = request->wdev->netdev;
13310#endif
13311
13312 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13313 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
13314 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13315
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 ENTER();
13317
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013318 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13319 __func__, hdd_device_modetoString(pAdapter->device_mode),
13320 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013321
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013322 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013323 if (0 != status)
13324 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013325 return status;
13326 }
13327
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013328 if (NULL == pwextBuf)
13329 {
13330 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
13331 __func__);
13332 return -EIO;
13333 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013334 cfg_param = pHddCtx->cfg_ini;
13335 pScanInfo = &pHddCtx->scan_info;
13336
Jeff Johnson295189b2012-06-20 16:38:30 -070013337#ifdef WLAN_BTAMP_FEATURE
13338 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013339 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070013340 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013341 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013342 "%s: No scanning when AMP is on", __func__);
13343 return -EOPNOTSUPP;
13344 }
13345#endif
13346 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013347 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013349 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013350 "%s: Not scanning on device_mode = %s (%d)",
13351 __func__, hdd_device_modetoString(pAdapter->device_mode),
13352 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013353 return -EOPNOTSUPP;
13354 }
13355
13356 if (TRUE == pScanInfo->mScanPending)
13357 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013358 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
13359 {
13360 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
13361 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013362 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013363 }
13364
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053013365 // Don't allow scan if PNO scan is going on.
13366 if (pHddCtx->isPnoEnable)
13367 {
13368 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13369 FL("pno scan in progress"));
13370 return -EBUSY;
13371 }
13372
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013373 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070013374 //Channel and action frame is pending
13375 //Otherwise Cancel Remain On Channel and allow Scan
13376 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013377 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070013378 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013379 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070013380 return -EBUSY;
13381 }
13382
Jeff Johnson295189b2012-06-20 16:38:30 -070013383 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
13384 {
13385 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080013386 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013387 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013388 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013389 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
13390 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013391 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013392 "%s: MAX TM Level Scan not allowed", __func__);
13393 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013394 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 }
13396 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
13397
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013398 /* Check if scan is allowed at this point of time.
13399 */
Hanumanth Reddy Pothulaec960842016-09-14 19:04:26 +053013400 if (TRUE == pHddCtx->btCoexModeSet)
13401 {
13402 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13403 FL("BTCoex Mode operation in progress"));
13404 return -EBUSY;
13405 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013406 if (hdd_isConnectionInProgress(pHddCtx, &curr_session_id, &curr_reason))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013407 {
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053013408 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Scan not allowed"));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013409 if (pHddCtx->last_scan_reject_session_id != curr_session_id ||
13410 pHddCtx->last_scan_reject_reason != curr_reason ||
13411 !pHddCtx->last_scan_reject_timestamp)
13412 {
13413 pHddCtx->last_scan_reject_session_id = curr_session_id;
13414 pHddCtx->last_scan_reject_reason = curr_reason;
Sreelakshmi Konamkif0646d52016-12-09 12:35:31 +053013415 pHddCtx->last_scan_reject_timestamp = jiffies_to_msecs(jiffies);
Abhishek Singhe4b12562017-06-20 16:53:39 +053013416 pHddCtx->scan_reject_cnt = 0;
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053013417 }
Abhishek Singhe4b12562017-06-20 16:53:39 +053013418 else
13419 {
13420 pHddCtx->scan_reject_cnt++;
13421
13422 hddLog(LOGE, FL("Reject cnt %d time delta %lu ms"), pHddCtx->scan_reject_cnt,
13423 (jiffies_to_msecs(jiffies) -
13424 pHddCtx->last_scan_reject_timestamp));
13425
13426 if ((pHddCtx->scan_reject_cnt >=
13427 SCAN_REJECT_THRESHOLD) &&
13428 (jiffies_to_msecs(jiffies) -
13429 pHddCtx->last_scan_reject_timestamp) >=
13430 SCAN_REJECT_THRESHOLD_TIME)
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013431 {
13432 pHddCtx->last_scan_reject_timestamp = 0;
Abhishek Singhe4b12562017-06-20 16:53:39 +053013433 pHddCtx->scan_reject_cnt = 0;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013434 if (pHddCtx->cfg_ini->enableFatalEvent)
13435 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
13436 WLAN_LOG_INDICATOR_HOST_DRIVER,
13437 WLAN_LOG_REASON_SCAN_NOT_ALLOWED,
13438 FALSE, FALSE);
13439 else
13440 {
13441 hddLog(LOGE, FL("Triggering SSR"));
13442 vos_wlanRestart();
13443 }
13444 }
13445 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013446 return -EBUSY;
13447 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013448 pHddCtx->last_scan_reject_timestamp = 0;
13449 pHddCtx->last_scan_reject_session_id = 0xFF;
13450 pHddCtx->last_scan_reject_reason = 0;
Abhishek Singhe4b12562017-06-20 16:53:39 +053013451 pHddCtx->scan_reject_cnt = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013452
Jeff Johnson295189b2012-06-20 16:38:30 -070013453 vos_mem_zero( &scanRequest, sizeof(scanRequest));
13454
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013455 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
13456 * Becasue of this, driver is assuming that this is not wildcard scan and so
13457 * is not aging out the scan results.
13458 */
13459 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013461 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013462 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013463
13464 if ((request->ssids) && (0 < request->n_ssids))
13465 {
13466 tCsrSSIDInfo *SsidInfo;
13467 int j;
13468 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
13469 /* Allocate num_ssid tCsrSSIDInfo structure */
13470 SsidInfo = scanRequest.SSIDs.SSIDList =
13471 ( tCsrSSIDInfo *)vos_mem_malloc(
13472 request->n_ssids*sizeof(tCsrSSIDInfo));
13473
13474 if(NULL == scanRequest.SSIDs.SSIDList)
13475 {
13476 hddLog(VOS_TRACE_LEVEL_ERROR,
13477 "%s: memory alloc failed SSIDInfo buffer", __func__);
13478 return -ENOMEM;
13479 }
13480
13481 /* copy all the ssid's and their length */
13482 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
13483 {
13484 /* get the ssid length */
13485 SsidInfo->SSID.length = request->ssids[j].ssid_len;
13486 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
13487 SsidInfo->SSID.length);
13488 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
13489 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
13490 j, SsidInfo->SSID.ssId);
13491 }
13492 /* set the scan type to active */
13493 scanRequest.scanType = eSIR_ACTIVE_SCAN;
13494 }
13495 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013496 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013497 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13498 TRACE_CODE_HDD_CFG80211_SCAN,
13499 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 /* set the scan type to active */
13501 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070013502 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013503 else
13504 {
13505 /*Set the scan type to default type, in this case it is ACTIVE*/
13506 scanRequest.scanType = pScanInfo->scan_mode;
13507 }
13508 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
13509 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070013510
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053013511 csr_scan_request_assign_bssid(&scanRequest, request);
13512
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 /* set BSSType to default type */
13514 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
13515
13516 /*TODO: scan the requested channels only*/
13517
13518 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013519 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070013520 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013521 hddLog(VOS_TRACE_LEVEL_WARN,
13522 "No of Scan Channels exceeded limit: %d", request->n_channels);
13523 request->n_channels = MAX_CHANNEL;
13524 }
13525
13526 hddLog(VOS_TRACE_LEVEL_INFO,
13527 "No of Scan Channels: %d", request->n_channels);
13528
13529
13530 if( request->n_channels )
13531 {
13532 char chList [(request->n_channels*5)+1];
13533 int len;
13534 channelList = vos_mem_malloc( request->n_channels );
13535 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053013536 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013537 hddLog(VOS_TRACE_LEVEL_ERROR,
13538 "%s: memory alloc failed channelList", __func__);
13539 status = -ENOMEM;
13540 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053013541 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013542
13543 for( i = 0, len = 0; i < request->n_channels ; i++ )
13544 {
13545 channelList[i] = request->channels[i]->hw_value;
13546 len += snprintf(chList+len, 5, "%d ", channelList[i]);
13547 }
13548
Nirav Shah20ac06f2013-12-12 18:14:06 +053013549 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013550 "Channel-List: %s ", chList);
13551 }
c_hpothu53512302014-04-15 18:49:53 +053013552
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013553 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
13554 scanRequest.ChannelInfo.ChannelList = channelList;
13555
13556 /* set requestType to full scan */
13557 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
13558
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013559 /* if there is back to back scan happening in driver with in
13560 * nDeferScanTimeInterval interval driver should defer new scan request
13561 * and should provide last cached scan results instead of new channel list.
13562 * This rule is not applicable if scan is p2p scan.
13563 * This condition will work only in case when last request no of channels
13564 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053013565 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053013566 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013567 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013568
Sushant Kaushik86592172015-04-27 16:35:03 +053013569 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
13570 /* if wps ie is NULL , then only defer scan */
13571 if ( pWpsIe == NULL &&
13572 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053013573 {
13574 if ( pScanInfo->last_scan_timestamp !=0 &&
13575 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
13576 {
13577 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
13578 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
13579 vos_mem_compare(pScanInfo->last_scan_channelList,
13580 channelList, pScanInfo->last_scan_numChannels))
13581 {
13582 hddLog(VOS_TRACE_LEVEL_WARN,
13583 " New and old station scan time differ is less then %u",
13584 pHddCtx->cfg_ini->nDeferScanTimeInterval);
13585
13586 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013587 pAdapter);
13588
Agarwal Ashish57e84372014-12-05 18:26:53 +053013589 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013590 "Return old cached scan as all channels and no of channels are same");
13591
Agarwal Ashish57e84372014-12-05 18:26:53 +053013592 if (0 > ret)
13593 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013594
Agarwal Ashish57e84372014-12-05 18:26:53 +053013595 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013596
13597 status = eHAL_STATUS_SUCCESS;
13598 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053013599 }
13600 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013601 }
13602
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013603 /* Flush the scan results(only p2p beacons) for STA scan and P2P
13604 * search (Flush on both full scan and social scan but not on single
13605 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
13606 */
13607
13608 /* Supplicant does single channel scan after 8-way handshake
13609 * and in that case driver shoudnt flush scan results. If
13610 * driver flushes the scan results here and unfortunately if
13611 * the AP doesnt respond to our probe req then association
13612 * fails which is not desired
13613 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013614 if ((request->n_ssids == 1)
13615 && (request->ssids != NULL)
13616 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
13617 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013618
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013619 if( is_p2p_scan ||
13620 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013621 {
13622 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
13623 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
13624 pAdapter->sessionId );
13625 }
13626
13627 if( request->ie_len )
13628 {
13629 /* save this for future association (join requires this) */
13630 /*TODO: Array needs to be converted to dynamic allocation,
13631 * as multiple ie.s can be sent in cfg80211_scan_request structure
13632 * CR 597966
13633 */
13634 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
13635 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
13636 pScanInfo->scanAddIE.length = request->ie_len;
13637
13638 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13639 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13640 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013642 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013644 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
13645 memcpy( pwextBuf->roamProfile.addIEScan,
13646 request->ie, request->ie_len);
13647 }
13648 else
13649 {
13650 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
13651 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013652 }
13653
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013654 }
13655 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
13656 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
13657
13658 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
13659 request->ie_len);
13660 if (pP2pIe != NULL)
13661 {
13662#ifdef WLAN_FEATURE_P2P_DEBUG
13663 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
13664 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
13665 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053013666 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013667 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
13668 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13669 "Go nego completed to Connection is started");
13670 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13671 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053013672 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013673 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
13674 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013676 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
13677 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13678 "Disconnected state to Connection is started");
13679 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13680 "for 4way Handshake");
13681 }
13682#endif
13683
13684 /* no_cck will be set during p2p find to disable 11b rates */
13685 if(TRUE == request->no_cck)
13686 {
13687 hddLog(VOS_TRACE_LEVEL_INFO,
13688 "%s: This is a P2P Search", __func__);
13689 scanRequest.p2pSearch = 1;
13690
13691 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053013692 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013693 /* set requestType to P2P Discovery */
13694 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
13695 }
13696
13697 /*
13698 Skip Dfs Channel in case of P2P Search
13699 if it is set in ini file
13700 */
13701 if(cfg_param->skipDfsChnlInP2pSearch)
13702 {
13703 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013704 }
13705 else
13706 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013707 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013708 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013709
Agarwal Ashish4f616132013-12-30 23:32:50 +053013710 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013711 }
13712 }
13713
13714 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
13715
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013716#ifdef FEATURE_WLAN_TDLS
13717 /* if tdls disagree scan right now, return immediately.
13718 tdls will schedule the scan when scan is allowed. (return SUCCESS)
13719 or will reject the scan if any TDLS is in progress. (return -EBUSY)
13720 */
13721 status = wlan_hdd_tdls_scan_callback (pAdapter,
13722 wiphy,
13723#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13724 dev,
13725#endif
13726 request);
Abhishek Singhe2b63952016-01-05 18:27:29 +053013727 if (status <= 0)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013728 {
Abhishek Singhe2b63952016-01-05 18:27:29 +053013729 if (!status)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013730 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
13731 "scan rejected %d", __func__, status);
13732 else
13733 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
13734 __func__, status);
Abhishek Singhe2b63952016-01-05 18:27:29 +053013735 hdd_wlan_block_scan_by_tdls();
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053013736 goto free_mem;
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013737 }
13738#endif
13739
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070013740 /* acquire the wakelock to avoid the apps suspend during the scan. To
13741 * address the following issues.
13742 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
13743 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
13744 * for long time, this result in apps running at full power for long time.
13745 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
13746 * be stuck in full power because of resume BMPS
13747 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013748 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013749
Nirav Shah20ac06f2013-12-12 18:14:06 +053013750 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
13751 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013752 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
13753 scanRequest.requestType, scanRequest.scanType,
13754 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053013755 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
13756
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053013757 if (pHddCtx->spoofMacAddr.isEnabled &&
13758 pHddCtx->cfg_ini->enableMacSpoofing == 1)
Siddharth Bhal76972212014-10-15 16:22:51 +053013759 {
13760 hddLog(VOS_TRACE_LEVEL_INFO,
13761 "%s: MAC Spoofing enabled for current scan", __func__);
13762 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
13763 * to fill TxBds for probe request during current scan
13764 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013765 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053013766 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013767
13768 if(status != VOS_STATUS_SUCCESS)
13769 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013770 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013771 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053013772#ifdef FEATURE_WLAN_TDLS
13773 wlan_hdd_tdls_scan_done_callback(pAdapter);
13774#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013775 goto free_mem;
13776 }
Siddharth Bhal76972212014-10-15 16:22:51 +053013777 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053013778 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070013779 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 pAdapter->sessionId, &scanRequest, &scanId,
13781 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070013782
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 if (eHAL_STATUS_SUCCESS != status)
13784 {
13785 hddLog(VOS_TRACE_LEVEL_ERROR,
13786 "%s: sme_ScanRequest returned error %d", __func__, status);
13787 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013788 if(eHAL_STATUS_RESOURCES == status)
13789 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013790 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
13791 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013792 status = -EBUSY;
13793 } else {
13794 status = -EIO;
13795 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013796 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013797
13798#ifdef FEATURE_WLAN_TDLS
13799 wlan_hdd_tdls_scan_done_callback(pAdapter);
13800#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 goto free_mem;
13802 }
13803
13804 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053013805 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013806 pAdapter->request = request;
13807 pScanInfo->scanId = scanId;
13808
13809 complete(&pScanInfo->scan_req_completion_event);
13810
13811free_mem:
13812 if( scanRequest.SSIDs.SSIDList )
13813 {
13814 vos_mem_free(scanRequest.SSIDs.SSIDList);
13815 }
13816
13817 if( channelList )
13818 vos_mem_free( channelList );
13819
13820 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013821 return status;
13822}
13823
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013824int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
13825#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13826 struct net_device *dev,
13827#endif
13828 struct cfg80211_scan_request *request)
13829{
13830 int ret;
13831
13832 vos_ssr_protect(__func__);
13833 ret = __wlan_hdd_cfg80211_scan(wiphy,
13834#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13835 dev,
13836#endif
13837 request);
13838 vos_ssr_unprotect(__func__);
13839
13840 return ret;
13841}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013842
13843void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
13844{
13845 v_U8_t iniDot11Mode =
13846 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
13847 eHddDot11Mode hddDot11Mode = iniDot11Mode;
13848
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013849 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
13850 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013851 switch ( iniDot11Mode )
13852 {
13853 case eHDD_DOT11_MODE_AUTO:
13854 case eHDD_DOT11_MODE_11ac:
13855 case eHDD_DOT11_MODE_11ac_ONLY:
13856#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053013857 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
13858 sme_IsFeatureSupportedByFW(DOT11AC) )
13859 hddDot11Mode = eHDD_DOT11_MODE_11ac;
13860 else
13861 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013862#else
13863 hddDot11Mode = eHDD_DOT11_MODE_11n;
13864#endif
13865 break;
13866 case eHDD_DOT11_MODE_11n:
13867 case eHDD_DOT11_MODE_11n_ONLY:
13868 hddDot11Mode = eHDD_DOT11_MODE_11n;
13869 break;
13870 default:
13871 hddDot11Mode = iniDot11Mode;
13872 break;
13873 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013874#ifdef WLAN_FEATURE_AP_HT40_24G
13875 if (operationChannel > SIR_11B_CHANNEL_END)
13876#endif
13877 {
13878 /* This call decides required channel bonding mode */
13879 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013880 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
13881 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013882 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013883}
13884
Jeff Johnson295189b2012-06-20 16:38:30 -070013885/*
13886 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013887 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070013888 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013889int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013890 const u8 *ssid, size_t ssid_len, const u8 *bssid,
13891 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070013892{
13893 int status = 0;
13894 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080013895 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 v_U32_t roamId;
13897 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070013898 eCsrAuthType RSNAuthType;
13899
13900 ENTER();
13901
13902 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080013903 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13904
13905 status = wlan_hdd_validate_context(pHddCtx);
13906 if (status)
13907 {
Yue Mae36e3552014-03-05 17:06:20 -080013908 return status;
13909 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013910
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
13912 {
13913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
13914 return -EINVAL;
13915 }
13916
Nitesh Shah9b066282017-06-06 18:05:52 +053013917 wlan_hdd_tdls_disable_offchan_and_teardown_links(pHddCtx);
13918
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 pRoamProfile = &pWextState->roamProfile;
13920
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013921 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013923 hdd_station_ctx_t *pHddStaCtx;
13924 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Abhishek Singh6782c9e2017-06-06 13:37:45 +053013925 pHddStaCtx->get_mgmt_log_sent = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013926
Siddharth Bhalda0d1622015-04-24 15:47:49 +053013927 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
13928
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013929 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
13931 {
13932 /*QoS not enabled in cfg file*/
13933 pRoamProfile->uapsd_mask = 0;
13934 }
13935 else
13936 {
13937 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013938 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
13940 }
13941
13942 pRoamProfile->SSIDs.numOfSSIDs = 1;
13943 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
13944 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013945 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070013946 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
13947 ssid, ssid_len);
13948
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013949 vos_mem_zero(pRoamProfile->BSSIDs.bssid, WNI_CFG_BSSID_LEN);
13950 vos_mem_zero(pRoamProfile->bssid_hint, WNI_CFG_BSSID_LEN);
13951
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 if (bssid)
13953 {
13954 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013955 vos_mem_copy(pRoamProfile->BSSIDs.bssid, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013957 /* Save BSSID in seperate variable as well, as RoamProfile
13958 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070013959 case of join failure we should send valid BSSID to supplicant
13960 */
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013961 vos_mem_copy(pWextState->req_bssId, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013962 WNI_CFG_BSSID_LEN);
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013963
Jeff Johnson295189b2012-06-20 16:38:30 -070013964 }
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013965 else if (bssid_hint)
Dhanashri Atre51981c62013-06-13 11:47:57 -070013966 {
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013967 /* Store bssid_hint to use in the scan filter. */
13968 vos_mem_copy(pRoamProfile->bssid_hint, bssid_hint,
13969 WNI_CFG_BSSID_LEN);
13970 /*
13971 * Save BSSID in seperate variable as well, as RoamProfile
13972 * BSSID is getting zeroed out in the association process. And in
13973 * case of join failure we should send valid BSSID to supplicant
13974 */
13975 vos_mem_copy(pWextState->req_bssId, bssid_hint,
13976 WNI_CFG_BSSID_LEN);
13977 hddLog(LOG1, FL(" bssid_hint: "MAC_ADDRESS_STR),
13978 MAC_ADDR_ARRAY(pRoamProfile->bssid_hint));
Dhanashri Atre51981c62013-06-13 11:47:57 -070013979 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013980
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013981
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013982 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
13983 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
13985 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013986 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013987 /*set gen ie*/
13988 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
13989 /*set auth*/
13990 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
13991 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013992#ifdef FEATURE_WLAN_WAPI
13993 if (pAdapter->wapi_info.nWapiMode)
13994 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013995 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 switch (pAdapter->wapi_info.wapiAuthMode)
13997 {
13998 case WAPI_AUTH_MODE_PSK:
13999 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014000 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014001 pAdapter->wapi_info.wapiAuthMode);
14002 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
14003 break;
14004 }
14005 case WAPI_AUTH_MODE_CERT:
14006 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014007 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014008 pAdapter->wapi_info.wapiAuthMode);
14009 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
14010 break;
14011 }
14012 } // End of switch
14013 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
14014 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
14015 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014016 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014017 pRoamProfile->AuthType.numEntries = 1;
14018 pRoamProfile->EncryptionType.numEntries = 1;
14019 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
14020 pRoamProfile->mcEncryptionType.numEntries = 1;
14021 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
14022 }
14023 }
14024#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014025#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014026 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014027 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
14028 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
14029 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014030 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
14031 sizeof (tSirGtkOffloadParams));
14032 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014033 }
14034#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 pRoamProfile->csrPersona = pAdapter->device_mode;
14036
Jeff Johnson32d95a32012-09-10 13:15:23 -070014037 if( operatingChannel )
14038 {
14039 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
14040 pRoamProfile->ChannelInfo.numOfChannels = 1;
14041 }
Chet Lanctot186b5732013-03-18 10:26:30 -070014042 else
14043 {
14044 pRoamProfile->ChannelInfo.ChannelList = NULL;
14045 pRoamProfile->ChannelInfo.numOfChannels = 0;
14046 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014047 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
14048 {
14049 hdd_select_cbmode(pAdapter,operatingChannel);
14050 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014051
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014052 /*
14053 * Change conn_state to connecting before sme_RoamConnect(),
14054 * because sme_RoamConnect() has a direct path to call
14055 * hdd_smeRoamCallback(), which will change the conn_state
14056 * If direct path, conn_state will be accordingly changed
14057 * to NotConnected or Associated by either
14058 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
14059 * in sme_RoamCallback()
14060 * if sme_RomConnect is to be queued,
14061 * Connecting state will remain until it is completed.
14062 * If connection state is not changed,
14063 * connection state will remain in eConnectionState_NotConnected state.
14064 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
14065 * if conn state is eConnectionState_NotConnected.
14066 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
14067 * informed of connect result indication which is an issue.
14068 */
14069
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053014070 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
14071 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053014072 {
14073 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014074 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080014075 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
14076 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053014077 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014078 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 pAdapter->sessionId, pRoamProfile, &roamId);
14080
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053014081 if ((eHAL_STATUS_SUCCESS != status) &&
14082 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
14083 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014084
14085 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014086 hddLog(VOS_TRACE_LEVEL_ERROR,
14087 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
14088 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080014089 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014090 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080014091 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014092 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080014093
14094 pRoamProfile->ChannelInfo.ChannelList = NULL;
14095 pRoamProfile->ChannelInfo.numOfChannels = 0;
14096
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 }
14098 else
14099 {
14100 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
14101 return -EINVAL;
14102 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080014103 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014104 return status;
14105}
14106
14107/*
14108 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
14109 * This function is used to set the authentication type (OPEN/SHARED).
14110 *
14111 */
14112static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
14113 enum nl80211_auth_type auth_type)
14114{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014115 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014116 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14117
14118 ENTER();
14119
14120 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014121 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070014122 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014123 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014124 hddLog(VOS_TRACE_LEVEL_INFO,
14125 "%s: set authentication type to AUTOSWITCH", __func__);
14126 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
14127 break;
14128
14129 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014130#ifdef WLAN_FEATURE_VOWIFI_11R
14131 case NL80211_AUTHTYPE_FT:
14132#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014133 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 "%s: set authentication type to OPEN", __func__);
14135 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
14136 break;
14137
14138 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014139 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014140 "%s: set authentication type to SHARED", __func__);
14141 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
14142 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014143#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014144 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014145 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014146 "%s: set authentication type to CCKM WPA", __func__);
14147 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
14148 break;
14149#endif
14150
14151
14152 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014153 hddLog(VOS_TRACE_LEVEL_ERROR,
14154 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014155 auth_type);
14156 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
14157 return -EINVAL;
14158 }
14159
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014160 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014161 pHddStaCtx->conn_info.authType;
14162 return 0;
14163}
14164
14165/*
14166 * FUNCTION: wlan_hdd_set_akm_suite
14167 * This function is used to set the key mgmt type(PSK/8021x).
14168 *
14169 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014170static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014171 u32 key_mgmt
14172 )
14173{
14174 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14175 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053014176 /* Should be in ieee802_11_defs.h */
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053014177#ifndef WLAN_AKM_SUITE_8021X_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053014178#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053014179#endif
14180#ifndef WLAN_AKM_SUITE_PSK_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053014181#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053014182#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014183 /*set key mgmt type*/
14184 switch(key_mgmt)
14185 {
14186 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053014187 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014188#ifdef WLAN_FEATURE_VOWIFI_11R
14189 case WLAN_AKM_SUITE_FT_PSK:
14190#endif
14191 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070014192 __func__);
14193 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
14194 break;
14195
14196 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053014197 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014198#ifdef WLAN_FEATURE_VOWIFI_11R
14199 case WLAN_AKM_SUITE_FT_8021X:
14200#endif
14201 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070014202 __func__);
14203 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
14204 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014205#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014206#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
14207#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
14208 case WLAN_AKM_SUITE_CCKM:
14209 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
14210 __func__);
14211 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
14212 break;
14213#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070014214#ifndef WLAN_AKM_SUITE_OSEN
14215#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
14216 case WLAN_AKM_SUITE_OSEN:
14217 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
14218 __func__);
14219 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
14220 break;
14221#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014222
14223 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014224 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014225 __func__, key_mgmt);
14226 return -EINVAL;
14227
14228 }
14229 return 0;
14230}
14231
14232/*
14233 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014234 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070014235 * (NONE/WEP40/WEP104/TKIP/CCMP).
14236 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014237static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
14238 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 bool ucast
14240 )
14241{
14242 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014243 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014244 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14245
14246 ENTER();
14247
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014248 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053014250 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070014251 __func__, cipher);
14252 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14253 }
14254 else
14255 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014256
Jeff Johnson295189b2012-06-20 16:38:30 -070014257 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014258 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070014259 {
14260 case IW_AUTH_CIPHER_NONE:
14261 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14262 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014263
Jeff Johnson295189b2012-06-20 16:38:30 -070014264 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014265 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070014266 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014267
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014269 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070014270 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014271
Jeff Johnson295189b2012-06-20 16:38:30 -070014272 case WLAN_CIPHER_SUITE_TKIP:
14273 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
14274 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014275
Jeff Johnson295189b2012-06-20 16:38:30 -070014276 case WLAN_CIPHER_SUITE_CCMP:
14277 encryptionType = eCSR_ENCRYPT_TYPE_AES;
14278 break;
14279#ifdef FEATURE_WLAN_WAPI
14280 case WLAN_CIPHER_SUITE_SMS4:
14281 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
14282 break;
14283#endif
14284
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014285#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014286 case WLAN_CIPHER_SUITE_KRK:
14287 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
14288 break;
14289#endif
14290 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014291 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014292 __func__, cipher);
14293 return -EOPNOTSUPP;
14294 }
14295 }
14296
14297 if (ucast)
14298 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014299 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014300 __func__, encryptionType);
14301 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
14302 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014303 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014304 encryptionType;
14305 }
14306 else
14307 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014308 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014309 __func__, encryptionType);
14310 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
14311 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
14312 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
14313 }
14314
14315 return 0;
14316}
14317
14318
14319/*
14320 * FUNCTION: wlan_hdd_cfg80211_set_ie
14321 * This function is used to parse WPA/RSN IE's.
14322 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014323int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014324#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14325 const u8 *ie,
14326#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014327 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014328#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014329 size_t ie_len
14330 )
14331{
14332 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014333#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14334 const u8 *genie = ie;
14335#else
Jeff Johnson295189b2012-06-20 16:38:30 -070014336 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014337#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014338 v_U16_t remLen = ie_len;
14339#ifdef FEATURE_WLAN_WAPI
14340 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
14341 u16 *tmp;
14342 v_U16_t akmsuiteCount;
14343 int *akmlist;
14344#endif
14345 ENTER();
14346
14347 /* clear previous assocAddIE */
14348 pWextState->assocAddIE.length = 0;
14349 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014350 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014351
14352 while (remLen >= 2)
14353 {
14354 v_U16_t eLen = 0;
14355 v_U8_t elementId;
14356 elementId = *genie++;
14357 eLen = *genie++;
14358 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014359
Nachiket Kukade4aba5f02017-06-09 15:43:48 +053014360 /* Sanity check on eLen */
14361 if (eLen > remLen) {
14362 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid IE length[%d] for IE[0x%X]",
14363 __func__, eLen, elementId);
14364 VOS_ASSERT(0);
14365 return -EINVAL;
14366 }
14367
Arif Hussain6d2a3322013-11-17 19:50:10 -080014368 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070014369 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014370
14371 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070014372 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014373 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014374 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 -070014375 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014376 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 "%s: Invalid WPA IE", __func__);
14378 return -EINVAL;
14379 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014380 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070014381 {
14382 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014383 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014384 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014385
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014386 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014387 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014388 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
14389 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014390 VOS_ASSERT(0);
14391 return -ENOMEM;
14392 }
14393 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14394 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14395 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014396
Jeff Johnson295189b2012-06-20 16:38:30 -070014397 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
14398 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14399 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14400 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014401 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
14402 {
Nachiket Kukade3d72b7e2017-06-09 16:58:24 +053014403 if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) {
14404 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid WPA RSN IE length[%d]",
14405 __func__, eLen);
14406 VOS_ASSERT(0);
14407 return -EINVAL;
14408 }
14409
Jeff Johnson295189b2012-06-20 16:38:30 -070014410 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
14411 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14412 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
14413 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
14414 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
14415 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014416 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053014417 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070014418 {
14419 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014420 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014421 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014422
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014423 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014424 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014425 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14426 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014427 VOS_ASSERT(0);
14428 return -ENOMEM;
14429 }
14430 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14431 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14432 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014433
Jeff Johnson295189b2012-06-20 16:38:30 -070014434 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14435 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14436 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014437#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014438 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
14439 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014440 /*Consider WFD IE, only for P2P Client */
14441 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
14442 {
14443 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014444 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014445 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014446
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014447 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014448 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014449 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14450 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014451 VOS_ASSERT(0);
14452 return -ENOMEM;
14453 }
14454 // WFD IE is saved to Additional IE ; it should be accumulated to handle
14455 // WPS IE + P2P IE + WFD IE
14456 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14457 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014458
Jeff Johnson295189b2012-06-20 16:38:30 -070014459 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14460 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14461 }
14462#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014463 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014464 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014465 HS20_OUI_TYPE_SIZE)) )
14466 {
14467 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014468 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014469 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014470
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014471 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014472 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014473 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14474 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014475 VOS_ASSERT(0);
14476 return -ENOMEM;
14477 }
14478 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14479 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014480
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014481 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14482 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14483 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014484 /* Appending OSEN Information Element in Assiciation Request */
14485 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
14486 OSEN_OUI_TYPE_SIZE)) )
14487 {
14488 v_U16_t curAddIELen = pWextState->assocAddIE.length;
14489 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
14490 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014491
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014492 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014493 {
14494 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14495 "Need bigger buffer space");
14496 VOS_ASSERT(0);
14497 return -ENOMEM;
14498 }
14499 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14500 pWextState->assocAddIE.length += eLen + 2;
14501
14502 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
14503 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14504 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14505 }
14506
Abhishek Singh4322e622015-06-10 15:42:54 +053014507 /* Update only for WPA IE */
14508 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
14509 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014510
14511 /* populating as ADDIE in beacon frames */
14512 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014513 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014514 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
14515 {
14516 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14517 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
14518 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14519 {
14520 hddLog(LOGE,
14521 "Coldn't pass "
14522 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
14523 }
14524 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
14525 else
14526 hddLog(LOGE,
14527 "Could not pass on "
14528 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
14529
14530 /* IBSS mode doesn't contain params->proberesp_ies still
14531 beaconIE's need to be populated in probe response frames */
14532 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
14533 {
14534 u16 rem_probe_resp_ie_len = eLen + 2;
14535 u8 probe_rsp_ie_len[3] = {0};
14536 u8 counter = 0;
14537
14538 /* Check Probe Resp Length if it is greater then 255 then
14539 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
14540 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
14541 not able Store More then 255 bytes into One Variable */
14542
14543 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
14544 {
14545 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
14546 {
14547 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
14548 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
14549 }
14550 else
14551 {
14552 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
14553 rem_probe_resp_ie_len = 0;
14554 }
14555 }
14556
14557 rem_probe_resp_ie_len = 0;
14558
14559 if (probe_rsp_ie_len[0] > 0)
14560 {
14561 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14562 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
14563 (tANI_U8*)(genie - 2),
14564 probe_rsp_ie_len[0], NULL,
14565 eANI_BOOLEAN_FALSE)
14566 == eHAL_STATUS_FAILURE)
14567 {
14568 hddLog(LOGE,
14569 "Could not pass"
14570 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
14571 }
14572 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
14573 }
14574
14575 if (probe_rsp_ie_len[1] > 0)
14576 {
14577 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14578 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
14579 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14580 probe_rsp_ie_len[1], NULL,
14581 eANI_BOOLEAN_FALSE)
14582 == eHAL_STATUS_FAILURE)
14583 {
14584 hddLog(LOGE,
14585 "Could not pass"
14586 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
14587 }
14588 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
14589 }
14590
14591 if (probe_rsp_ie_len[2] > 0)
14592 {
14593 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14594 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
14595 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14596 probe_rsp_ie_len[2], NULL,
14597 eANI_BOOLEAN_FALSE)
14598 == eHAL_STATUS_FAILURE)
14599 {
14600 hddLog(LOGE,
14601 "Could not pass"
14602 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
14603 }
14604 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
14605 }
14606
14607 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14608 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
14609 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14610 {
14611 hddLog(LOGE,
14612 "Could not pass"
14613 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
14614 }
14615 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014616 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070014617 break;
14618 case DOT11F_EID_RSN:
14619 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
14620 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14621 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
14622 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
14623 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
14624 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053014625
Abhishek Singhb16f3562016-01-20 11:08:32 +053014626 /* Appending extended capabilities with Interworking or
14627 * bsstransition bit set in Assoc Req.
Abhishek Singh15d95602015-03-24 15:52:57 +053014628 *
14629 * In assoc req this EXT Cap will only be taken into account if
Abhishek Singhb16f3562016-01-20 11:08:32 +053014630 * interworkingService or bsstransition bit is set to 1.
14631 * Driver is only interested in interworkingService and
14632 * bsstransition capability from supplicant.
14633 * If in future any other EXT Cap info is
Abhishek Singh15d95602015-03-24 15:52:57 +053014634 * required from supplicat, it needs to be handled while
14635 * sending Assoc Req in LIM.
14636 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014637 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014638 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014639 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014640 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014641 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014642
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014643 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014644 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014645 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14646 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014647 VOS_ASSERT(0);
14648 return -ENOMEM;
14649 }
14650 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14651 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014652
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014653 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14654 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14655 break;
14656 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014657#ifdef FEATURE_WLAN_WAPI
14658 case WLAN_EID_WAPI:
14659 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014660 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070014661 pAdapter->wapi_info.nWapiMode);
14662 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014663 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070014664 akmsuiteCount = WPA_GET_LE16(tmp);
14665 tmp = tmp + 1;
14666 akmlist = (int *)(tmp);
14667 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
14668 {
14669 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
14670 }
14671 else
14672 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014673 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070014674 VOS_ASSERT(0);
14675 return -EINVAL;
14676 }
14677
14678 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
14679 {
14680 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014681 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014682 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014683 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014684 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014685 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014686 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014687 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014688 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
14689 }
14690 break;
14691#endif
14692 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014693 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014695 /* when Unknown IE is received we should break and continue
14696 * to the next IE in the buffer instead we were returning
14697 * so changing this to break */
14698 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 }
14700 genie += eLen;
14701 remLen -= eLen;
14702 }
14703 EXIT();
14704 return 0;
14705}
14706
14707/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014708 * FUNCTION: hdd_isWPAIEPresent
14709 * Parse the received IE to find the WPA IE
14710 *
14711 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014712static bool hdd_isWPAIEPresent(
14713#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
14714 const u8 *ie,
14715#else
14716 u8 *ie,
14717#endif
14718 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014719{
14720 v_U8_t eLen = 0;
14721 v_U16_t remLen = ie_len;
14722 v_U8_t elementId = 0;
14723
14724 while (remLen >= 2)
14725 {
14726 elementId = *ie++;
14727 eLen = *ie++;
14728 remLen -= 2;
14729 if (eLen > remLen)
14730 {
14731 hddLog(VOS_TRACE_LEVEL_ERROR,
14732 "%s: IE length is wrong %d", __func__, eLen);
14733 return FALSE;
14734 }
14735 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
14736 {
14737 /* OUI - 0x00 0X50 0XF2
14738 WPA Information Element - 0x01
14739 WPA version - 0x01*/
14740 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
14741 return TRUE;
14742 }
14743 ie += eLen;
14744 remLen -= eLen;
14745 }
14746 return FALSE;
14747}
14748
14749/*
Jeff Johnson295189b2012-06-20 16:38:30 -070014750 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014751 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070014752 * parameters during connect operation.
14753 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014754int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014755 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014756 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014757{
14758 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014759 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014760 ENTER();
14761
14762 /*set wpa version*/
14763 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
14764
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014765 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014766 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053014767 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014768 {
14769 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
14770 }
14771 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
14772 {
14773 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
14774 }
14775 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014776
14777 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 pWextState->wpaVersion);
14779
14780 /*set authentication type*/
14781 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
14782
14783 if (0 > status)
14784 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014785 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014786 "%s: failed to set authentication type ", __func__);
14787 return status;
14788 }
14789
14790 /*set key mgmt type*/
14791 if (req->crypto.n_akm_suites)
14792 {
14793 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
14794 if (0 > status)
14795 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014796 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070014797 __func__);
14798 return status;
14799 }
14800 }
14801
14802 /*set pairwise cipher type*/
14803 if (req->crypto.n_ciphers_pairwise)
14804 {
14805 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
14806 req->crypto.ciphers_pairwise[0], true);
14807 if (0 > status)
14808 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014809 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014810 "%s: failed to set unicast cipher type", __func__);
14811 return status;
14812 }
14813 }
14814 else
14815 {
14816 /*Reset previous cipher suite to none*/
14817 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
14818 if (0 > status)
14819 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014820 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014821 "%s: failed to set unicast cipher type", __func__);
14822 return status;
14823 }
14824 }
14825
14826 /*set group cipher type*/
14827 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
14828 false);
14829
14830 if (0 > status)
14831 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014832 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070014833 __func__);
14834 return status;
14835 }
14836
Chet Lanctot186b5732013-03-18 10:26:30 -070014837#ifdef WLAN_FEATURE_11W
14838 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
14839#endif
14840
Jeff Johnson295189b2012-06-20 16:38:30 -070014841 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
14842 if (req->ie_len)
14843 {
14844 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
14845 if ( 0 > status)
14846 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014847 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070014848 __func__);
14849 return status;
14850 }
14851 }
14852
14853 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014854 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014855 {
14856 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
14857 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
14858 )
14859 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014860 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070014861 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
14862 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014863 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 __func__);
14865 return -EOPNOTSUPP;
14866 }
14867 else
14868 {
14869 u8 key_len = req->key_len;
14870 u8 key_idx = req->key_idx;
14871
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014872 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014873 && (CSR_MAX_NUM_KEY > key_idx)
14874 )
14875 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014876 hddLog(VOS_TRACE_LEVEL_INFO,
14877 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014878 __func__, key_idx, key_len);
14879 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014880 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070014881 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014882 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014883 (u8)key_len;
14884 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
14885 }
14886 }
14887 }
14888 }
14889
14890 return status;
14891}
14892
14893/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014894 * FUNCTION: wlan_hdd_try_disconnect
14895 * This function is used to disconnect from previous
14896 * connection
14897 */
Agrawal Ashishc407f192017-01-23 17:18:35 +053014898int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014899{
14900 long ret = 0;
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014901 int status, result = 0;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014902 hdd_station_ctx_t *pHddStaCtx;
14903 eMib_dot11DesiredBssType connectedBssType;
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014904 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014905
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014906 ret = wlan_hdd_validate_context(pHddCtx);
14907 if (0 != ret)
14908 {
14909 return ret;
14910 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014911 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14912
14913 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
14914
14915 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
14916 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
Abhishek Singh630ff592016-01-07 18:15:53 +053014917 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) ||
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014918 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
14919 {
Abhishek Singh9f4df782017-03-15 17:29:10 +053014920 /* Indicate disconnect to SME so that in-progress connection or preauth
14921 * can be aborted
14922 */
14923 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
14924 pAdapter->sessionId);
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014925 spin_lock_bh(&pAdapter->lock_for_active_session);
14926 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14927 {
14928 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14929 }
14930 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singhf7962582015-10-23 10:54:06 +053014931 hdd_connSetConnectionState(pHddStaCtx,
14932 eConnectionState_Disconnecting);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014933 /* Issue disconnect to CSR */
14934 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014935 status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014936 pAdapter->sessionId,
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014937 eCSR_DISCONNECT_REASON_UNSPECIFIED);
14938 if(eHAL_STATUS_CMD_NOT_QUEUED == status) {
14939 hddLog(LOG1,
14940 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
14941 } else if ( 0 != status ) {
14942 hddLog(LOGE,
14943 FL("csrRoamDisconnect failure, returned %d"),
14944 (int)status );
14945 result = -EINVAL;
14946 goto disconnected;
14947 }
14948 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014949 &pAdapter->disconnect_comp_var,
14950 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014951 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status)) {
14952 hddLog(LOGE,
14953 "%s: Failed to disconnect, timed out", __func__);
14954 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014955 }
14956 }
14957 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
14958 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014959 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014960 &pAdapter->disconnect_comp_var,
14961 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014962 if (!ret)
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014963 {
14964 hddLog(LOGE, FL("Failed to receive disconnect event"));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014965 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014966 }
14967 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014968disconnected:
14969 hddLog(LOG1,
14970 FL("Set HDD connState to eConnectionState_NotConnected"));
14971 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
14972 return result;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014973}
14974
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053014975/**
14976 * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present
14977 * @adapter: Pointer to the HDD adapter
14978 * @req: Pointer to the structure cfg_connect_params receieved from user space
14979 *
14980 * This function will start reassociation if bssid hint, channel hint and
14981 * previous bssid parameters are present in the connect request
14982 *
14983 * Return: success if reassociation is happening
14984 * Error code if reassociation is not permitted or not happening
14985 */
14986#ifdef CFG80211_CONNECT_PREV_BSSID
14987static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
14988 struct cfg80211_connect_params *req)
14989{
14990 int status = -EPERM;
14991 if (req->bssid_hint && req->channel_hint && req->prev_bssid) {
14992 hddLog(VOS_TRACE_LEVEL_INFO,
14993 FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR),
14994 req->channel_hint->hw_value,
14995 MAC_ADDR_ARRAY(req->bssid_hint));
14996 status = hdd_reassoc(adapter, req->bssid_hint,
14997 req->channel_hint->hw_value,
14998 CONNECT_CMD_USERSPACE);
14999 }
15000 return status;
15001}
15002#else
15003static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
15004 struct cfg80211_connect_params *req)
15005{
15006 return -EPERM;
15007}
15008#endif
15009
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015010/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053015011 * FUNCTION: __wlan_hdd_cfg80211_connect
15012 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015014static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015015 struct net_device *ndev,
15016 struct cfg80211_connect_params *req
15017 )
15018{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015019 int status;
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015020 u16 channel;
Edhar, Mahesh Kumar496c7f72016-03-18 12:47:44 +053015021#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
15022 defined(CFG80211_BSSID_HINT_BACKPORT)
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015023 const u8 *bssid_hint = req->bssid_hint;
15024#else
15025 const u8 *bssid_hint = NULL;
15026#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015027 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070015028 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053015029 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015030
15031 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015032
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015033 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15034 TRACE_CODE_HDD_CFG80211_CONNECT,
15035 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015036 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015037 "%s: device_mode = %s (%d)", __func__,
15038 hdd_device_modetoString(pAdapter->device_mode),
15039 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015040
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015041 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080015042 if (!pHddCtx)
15043 {
15044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15045 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053015046 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080015047 }
15048
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015049 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015050 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015051 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015052 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015053 }
15054
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053015055 status = wlan_hdd_reassoc_bssid_hint(pAdapter, req);
15056 if (0 == status)
15057 return status;
15058
Agarwal Ashish51325b52014-06-16 16:50:49 +053015059
Jeff Johnson295189b2012-06-20 16:38:30 -070015060#ifdef WLAN_BTAMP_FEATURE
15061 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015062 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070015063 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015064 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015065 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080015066 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070015067 }
15068#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015069
15070 //If Device Mode is Station Concurrent Sessions Exit BMps
15071 //P2P Mode will be taken care in Open/close adapter
15072 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053015073 (vos_concurrent_open_sessions_running())) {
15074 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
15075 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015076 }
15077
15078 /*Try disconnecting if already in connected state*/
15079 status = wlan_hdd_try_disconnect(pAdapter);
15080 if ( 0 > status)
15081 {
15082 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
15083 " connection"));
15084 return -EALREADY;
15085 }
Agrawal Ashish559530c2015-12-01 18:04:20 +053015086 /* Check for max concurrent connections after doing disconnect if any*/
15087 if (vos_max_concurrent_connections_reached()) {
15088 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15089 return -ECONNREFUSED;
15090 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015091
Jeff Johnson295189b2012-06-20 16:38:30 -070015092 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015093 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070015094
15095 if ( 0 > status)
15096 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015097 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070015098 __func__);
15099 return status;
15100 }
Sravan Kumar Kairam589c5722016-01-27 20:28:53 +053015101
15102 if (pHddCtx->spoofMacAddr.isEnabled)
15103 {
15104 hddLog(VOS_TRACE_LEVEL_INFO,
15105 "%s: MAC Spoofing enabled ", __func__);
15106 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
15107 * to fill TxBds for probe request during SSID scan which may happen
15108 * as part of connect command
15109 */
15110 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
15111 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
15112 if (status != VOS_STATUS_SUCCESS)
15113 return -ECONNREFUSED;
15114 }
15115
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015116 if (req->channel)
15117 channel = req->channel->hw_value;
Mohit Khanna765234a2012-09-11 15:08:35 -070015118 else
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015119 channel = 0;
Kapil Gupta312028a2016-10-25 14:15:20 +053015120
15121 /* Abort if any scan is going on */
15122 status = wlan_hdd_scan_abort(pAdapter);
15123 if (0 != status)
15124 hddLog(VOS_TRACE_LEVEL_ERROR, FL("scan abort failed"));
15125
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015126 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
15127 req->ssid_len, req->bssid,
15128 bssid_hint, channel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015129
Sushant Kaushikd7083982015-03-18 14:33:24 +053015130 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015131 {
15132 //ReEnable BMPS if disabled
15133 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
15134 (NULL != pHddCtx))
15135 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053015136 if (pHddCtx->hdd_wlan_suspended)
15137 {
15138 hdd_set_pwrparams(pHddCtx);
15139 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 //ReEnable Bmps and Imps back
15141 hdd_enable_bmps_imps(pHddCtx);
15142 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053015143 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015144 return status;
15145 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015146 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015147 EXIT();
15148 return status;
15149}
15150
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015151static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
15152 struct net_device *ndev,
15153 struct cfg80211_connect_params *req)
15154{
15155 int ret;
15156 vos_ssr_protect(__func__);
15157 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
15158 vos_ssr_unprotect(__func__);
15159
15160 return ret;
15161}
Jeff Johnson295189b2012-06-20 16:38:30 -070015162
15163/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015164 * FUNCTION: wlan_hdd_disconnect
15165 * This function is used to issue a disconnect request to SME
15166 */
15167int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
15168{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015169 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015170 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015171 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015172 long ret;
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015173 eConnectionState prev_conn_state;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015174
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015175 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015176
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015177 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015178 if (0 != status)
15179 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015180 return status;
15181 }
Abhishek Singh07e4a892015-11-23 11:29:57 +053015182 /* Indicate sme of disconnect so that in progress connection or preauth
15183 * can be aborted
15184 */
15185 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
Sushant Kaushikb4834d22015-07-15 15:29:05 +053015186 pAdapter->sessionId);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015187 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015188
Agarwal Ashish47d18112014-08-04 19:55:07 +053015189 /* Need to apply spin lock before decreasing active sessions
15190 * as there can be chance for double decrement if context switch
15191 * Calls hdd_DisConnectHandler.
15192 */
15193
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015194 prev_conn_state = pHddStaCtx->conn_info.connState;
15195
Agarwal Ashish47d18112014-08-04 19:55:07 +053015196 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015197 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
15198 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015199 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
15200 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053015201 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
15202 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015203
Abhishek Singhf4669da2014-05-26 15:07:49 +053015204 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053015205 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
15206
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015207 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015208
Mihir Shete182a0b22014-08-18 16:08:48 +053015209 /*
15210 * stop tx queues before deleting STA/BSS context from the firmware.
15211 * tx has to be disabled because the firmware can get busy dropping
15212 * the tx frames after BSS/STA has been deleted and will not send
15213 * back a response resulting in WDI timeout
15214 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053015215 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053015216 netif_tx_disable(pAdapter->dev);
15217 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053015218
Mihir Shete182a0b22014-08-18 16:08:48 +053015219 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015220 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
15221 pAdapter->sessionId, reason);
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015222 if((eHAL_STATUS_CMD_NOT_QUEUED == status) &&
15223 prev_conn_state != eConnectionState_Connecting)
15224 {
15225 hddLog(LOG1,
15226 FL("status = %d, already disconnected"), status);
15227 result = 0;
15228 goto disconnected;
15229 }
15230 /*
15231 * Wait here instead of returning directly, this will block the next
15232 * connect command and allow processing of the scan for ssid and
15233 * the previous connect command in CSR. Else we might hit some
15234 * race conditions leading to SME and HDD out of sync.
15235 */
15236 else if(eHAL_STATUS_CMD_NOT_QUEUED == status)
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015237 {
15238 hddLog(LOG1,
15239 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015240 }
15241 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015242 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015243 hddLog(LOGE,
15244 FL("csrRoamDisconnect failure, returned %d"),
15245 (int)status);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015246 result = -EINVAL;
15247 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015248 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015249 ret = wait_for_completion_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015250 &pAdapter->disconnect_comp_var,
15251 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015252 if (!ret && (eHAL_STATUS_CMD_NOT_QUEUED != status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015253 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015254 hddLog(LOGE,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053015255 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015256 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053015257 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015258disconnected:
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015259 hddLog(LOG1,
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015260 FL("Set HDD connState to eConnectionState_NotConnected"));
15261 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053015262#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
15263 /* Sending disconnect event to userspace for kernel version < 3.11
15264 * is handled by __cfg80211_disconnect call to __cfg80211_disconnected
15265 */
15266 hddLog(LOG1, FL("Send disconnected event to userspace"));
15267
Mahesh A Saptasagarf5859b12016-06-01 17:17:50 +053015268 wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true,
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053015269 WLAN_REASON_UNSPECIFIED);
15270#endif
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015271
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015272 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015273 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015274}
15275
15276
15277/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015278 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070015279 * This function is used to issue a disconnect request to SME
15280 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015281static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015282 struct net_device *dev,
15283 u16 reason
15284 )
15285{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015286 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015287 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015288 tCsrRoamProfile *pRoamProfile;
15289 hdd_station_ctx_t *pHddStaCtx;
15290 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015291#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015292 tANI_U8 staIdx;
15293#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015294
Jeff Johnson295189b2012-06-20 16:38:30 -070015295 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015296
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015297 if (!pAdapter) {
15298 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15299 return -EINVAL;
15300 }
15301
15302 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15303 if (!pHddStaCtx) {
15304 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
15305 return -EINVAL;
15306 }
15307
15308 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15309 status = wlan_hdd_validate_context(pHddCtx);
15310 if (0 != status)
15311 {
15312 return status;
15313 }
15314
15315 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
15316
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015317 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15318 TRACE_CODE_HDD_CFG80211_DISCONNECT,
15319 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015320 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
15321 __func__, hdd_device_modetoString(pAdapter->device_mode),
15322 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015323
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015324 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
15325 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070015326
Jeff Johnson295189b2012-06-20 16:38:30 -070015327 if (NULL != pRoamProfile)
15328 {
15329 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015330 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
15331 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070015332 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015333 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070015334 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015335 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070015336 switch(reason)
15337 {
15338 case WLAN_REASON_MIC_FAILURE:
15339 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
15340 break;
15341
15342 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
15343 case WLAN_REASON_DISASSOC_AP_BUSY:
15344 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
15345 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
15346 break;
15347
15348 case WLAN_REASON_PREV_AUTH_NOT_VALID:
15349 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053015350 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070015351 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
15352 break;
15353
Jeff Johnson295189b2012-06-20 16:38:30 -070015354 default:
15355 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
15356 break;
15357 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015358 pScanInfo = &pHddCtx->scan_info;
15359 if (pScanInfo->mScanPending)
15360 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015361 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015362 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053015363 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015364 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015365 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053015366 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015367#ifdef FEATURE_WLAN_TDLS
15368 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015369 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015370 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015371 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
15372 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015373 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015374 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015375 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015377 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015378 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015379 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015380 status = sme_DeleteTdlsPeerSta(
15381 WLAN_HDD_GET_HAL_CTX(pAdapter),
15382 pAdapter->sessionId,
15383 mac);
15384 if (status != eHAL_STATUS_SUCCESS) {
15385 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15386 return -EPERM;
15387 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015388 }
15389 }
15390#endif
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015391
15392 hddLog(LOG1, FL("Disconnecting with reasoncode:%u connState %d"),
15393 reasonCode,
15394 pHddStaCtx->conn_info.connState);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015395 status = wlan_hdd_disconnect(pAdapter, reasonCode);
15396 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070015397 {
15398 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015399 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015400 __func__, (int)status );
15401 return -EINVAL;
15402 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015403 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015404 else
15405 {
15406 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
15407 "called while in %d state", __func__,
15408 pHddStaCtx->conn_info.connState);
15409 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015410 }
15411 else
15412 {
15413 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
15414 }
15415
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015416 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 return status;
15418}
15419
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015420static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
15421 struct net_device *dev,
15422 u16 reason
15423 )
15424{
15425 int ret;
15426 vos_ssr_protect(__func__);
15427 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
15428 vos_ssr_unprotect(__func__);
15429
15430 return ret;
15431}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015432
Jeff Johnson295189b2012-06-20 16:38:30 -070015433/*
15434 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015435 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070015436 * settings in IBSS mode.
15437 */
15438static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015439 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070015440 struct cfg80211_ibss_params *params
15441 )
15442{
15443 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015444 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070015445 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
15446 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015447
Jeff Johnson295189b2012-06-20 16:38:30 -070015448 ENTER();
15449
15450 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070015451 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070015452
15453 if (params->ie_len && ( NULL != params->ie) )
15454 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015455 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
15456 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070015457 {
15458 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
15459 encryptionType = eCSR_ENCRYPT_TYPE_AES;
15460 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015461 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070015462 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015463 tDot11fIEWPA dot11WPAIE;
15464 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015465 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015466
Wilson Yang00256342013-10-10 23:13:38 -070015467 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015468 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
15469 params->ie_len, DOT11F_EID_WPA);
15470 if ( NULL != ie )
15471 {
15472 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
15473 // Unpack the WPA IE
15474 //Skip past the EID byte and length byte - and four byte WiFi OUI
15475 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
15476 &ie[2+4],
15477 ie[1] - 4,
15478 &dot11WPAIE);
15479 /*Extract the multicast cipher, the encType for unicast
15480 cipher for wpa-none is none*/
15481 encryptionType =
15482 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
15483 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015484 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015485
Jeff Johnson295189b2012-06-20 16:38:30 -070015486 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
15487
15488 if (0 > status)
15489 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015490 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070015491 __func__);
15492 return status;
15493 }
15494 }
15495
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015496 pWextState->roamProfile.AuthType.authType[0] =
15497 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070015498 eCSR_AUTH_TYPE_OPEN_SYSTEM;
15499
15500 if (params->privacy)
15501 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015502 /* Security enabled IBSS, At this time there is no information available
15503 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070015504 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015505 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070015506 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015507 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070015508 *enable privacy bit in beacons */
15509
15510 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
15511 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015512 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
15513 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015514 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
15515 pWextState->roamProfile.EncryptionType.numEntries = 1;
15516 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015517 return status;
15518}
15519
15520/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015521 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015522 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015523 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015524static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015525 struct net_device *dev,
15526 struct cfg80211_ibss_params *params
15527 )
15528{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015529 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070015530 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15531 tCsrRoamProfile *pRoamProfile;
15532 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015533 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15534 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015535 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070015536
15537 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015538
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015539 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15540 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
15541 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015542 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015543 "%s: device_mode = %s (%d)", __func__,
15544 hdd_device_modetoString(pAdapter->device_mode),
15545 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015546
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015547 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015548 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015549 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015550 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015551 }
15552
15553 if (NULL == pWextState)
15554 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015555 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015556 __func__);
15557 return -EIO;
15558 }
15559
Agarwal Ashish51325b52014-06-16 16:50:49 +053015560 if (vos_max_concurrent_connections_reached()) {
15561 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15562 return -ECONNREFUSED;
15563 }
15564
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015565 /*Try disconnecting if already in connected state*/
15566 status = wlan_hdd_try_disconnect(pAdapter);
15567 if ( 0 > status)
15568 {
15569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
15570 " IBSS connection"));
15571 return -EALREADY;
15572 }
15573
Jeff Johnson295189b2012-06-20 16:38:30 -070015574 pRoamProfile = &pWextState->roamProfile;
15575
15576 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
15577 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015578 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015579 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015580 return -EINVAL;
15581 }
15582
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015583 /* BSSID is provided by upper layers hence no need to AUTO generate */
15584 if (NULL != params->bssid) {
15585 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
15586 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
15587 hddLog (VOS_TRACE_LEVEL_ERROR,
15588 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
15589 return -EIO;
15590 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015591 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015592 }
krunal sonie9002db2013-11-25 14:24:17 -080015593 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
15594 {
15595 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
15596 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
15597 {
15598 hddLog (VOS_TRACE_LEVEL_ERROR,
15599 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
15600 return -EIO;
15601 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015602
15603 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080015604 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015605 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080015606 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015607
Jeff Johnson295189b2012-06-20 16:38:30 -070015608 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070015609 if (NULL !=
15610#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
15611 params->chandef.chan)
15612#else
15613 params->channel)
15614#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015615 {
15616 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015617 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
15618 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
15619 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15620 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070015621
15622 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015623 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070015624 ieee80211_frequency_to_channel(
15625#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
15626 params->chandef.chan->center_freq);
15627#else
15628 params->channel->center_freq);
15629#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015630
15631 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
15632 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070015633 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015634 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
15635 __func__);
15636 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070015637 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015638
15639 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015640 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015641 if (channelNum == validChan[indx])
15642 {
15643 break;
15644 }
15645 }
15646 if (indx >= numChans)
15647 {
15648 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015649 __func__, channelNum);
15650 return -EINVAL;
15651 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015652 /* Set the Operational Channel */
15653 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
15654 channelNum);
15655 pRoamProfile->ChannelInfo.numOfChannels = 1;
15656 pHddStaCtx->conn_info.operationChannel = channelNum;
15657 pRoamProfile->ChannelInfo.ChannelList =
15658 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070015659 }
15660
15661 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015662 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070015663 if (status < 0)
15664 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015665 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070015666 __func__);
15667 return status;
15668 }
15669
15670 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015671 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Abhishek Singh4d924682015-11-17 15:23:06 +053015672 params->ssid_len, (const u8 *)&bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015673 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015674
15675 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015676 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015677
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015678 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015679 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015680}
15681
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015682static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
15683 struct net_device *dev,
15684 struct cfg80211_ibss_params *params
15685 )
15686{
15687 int ret = 0;
15688
15689 vos_ssr_protect(__func__);
15690 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
15691 vos_ssr_unprotect(__func__);
15692
15693 return ret;
15694}
15695
Jeff Johnson295189b2012-06-20 16:38:30 -070015696/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015697 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015698 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015699 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015700static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015701 struct net_device *dev
15702 )
15703{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015704 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015705 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15706 tCsrRoamProfile *pRoamProfile;
15707 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015708 int status;
Abhishek Singh69de3302016-11-11 16:44:32 +053015709 eHalStatus hal_status;
Abhishek Singh7cd040e2016-01-07 10:51:04 +053015710#ifdef WLAN_FEATURE_RMC
15711 tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN] = {0};
15712#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015713
15714 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015715
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015716 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15717 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
15718 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015719 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015720 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015721 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015722 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015723 }
15724
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015725 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
15726 hdd_device_modetoString(pAdapter->device_mode),
15727 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015728 if (NULL == pWextState)
15729 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015730 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015731 __func__);
15732 return -EIO;
15733 }
15734
15735 pRoamProfile = &pWextState->roamProfile;
15736
15737 /* Issue disconnect only if interface type is set to IBSS */
15738 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
15739 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015740 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070015741 __func__);
15742 return -EINVAL;
15743 }
15744
Abhishek Singh7cd040e2016-01-07 10:51:04 +053015745#ifdef WLAN_FEATURE_RMC
15746 /* Clearing add IE of beacon */
15747 if (ccmCfgSetStr(pHddCtx->hHal,
15748 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0],
15749 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN,
15750 NULL, eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
15751 {
15752 hddLog (VOS_TRACE_LEVEL_ERROR,
15753 "%s: unable to clear PROBE_RSP_BCN_ADDNIE_DATA", __func__);
15754 return -EINVAL;
15755 }
15756 if (ccmCfgSetInt(pHddCtx->hHal,
15757 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0, NULL,
15758 eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
15759 {
15760 hddLog (VOS_TRACE_LEVEL_ERROR,
15761 "%s: unable to clear WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
15762 __func__);
15763 return -EINVAL;
15764 }
15765
15766 // Reset WNI_CFG_PROBE_RSP Flags
15767 wlan_hdd_reset_prob_rspies(pAdapter);
15768
15769 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
15770 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 0,NULL,
15771 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
15772 {
15773 hddLog (VOS_TRACE_LEVEL_ERROR,
15774 "%s: unable to clear WNI_CFG_PROBE_RSP_ADDNIE_FLAG",
15775 __func__);
15776 return -EINVAL;
15777 }
15778#endif
15779
Jeff Johnson295189b2012-06-20 16:38:30 -070015780 /* Issue Disconnect request */
15781 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singh69de3302016-11-11 16:44:32 +053015782 hal_status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
15783 pAdapter->sessionId,
15784 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
15785 if (!HAL_STATUS_SUCCESS(hal_status)) {
15786 hddLog(LOGE,
15787 FL("sme_RoamDisconnect failed hal_status(%d)"),
15788 hal_status);
15789 return -EAGAIN;
15790 }
15791 status = wait_for_completion_timeout(
15792 &pAdapter->disconnect_comp_var,
15793 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
15794 if (!status) {
15795 hddLog(LOGE,
15796 FL("wait on disconnect_comp_var failed"));
15797 return -ETIMEDOUT;
15798 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015799
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015800 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015801 return 0;
15802}
15803
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015804static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
15805 struct net_device *dev
15806 )
15807{
15808 int ret = 0;
15809
15810 vos_ssr_protect(__func__);
15811 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
15812 vos_ssr_unprotect(__func__);
15813
15814 return ret;
15815}
15816
Jeff Johnson295189b2012-06-20 16:38:30 -070015817/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015818 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070015819 * This function is used to set the phy parameters
15820 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
15821 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015822static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015823 u32 changed)
15824{
15825 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15826 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015827 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015828
15829 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015830
15831 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015832 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
15833 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015834
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015835 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015836 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015837 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015838 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015839 }
15840
Jeff Johnson295189b2012-06-20 16:38:30 -070015841 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
15842 {
15843 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
15844 WNI_CFG_RTS_THRESHOLD_STAMAX :
15845 wiphy->rts_threshold;
15846
15847 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015848 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070015849 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015850 hddLog(VOS_TRACE_LEVEL_ERROR,
15851 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015852 __func__, rts_threshold);
15853 return -EINVAL;
15854 }
15855
15856 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
15857 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015858 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015859 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015860 hddLog(VOS_TRACE_LEVEL_ERROR,
15861 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015862 __func__, rts_threshold);
15863 return -EIO;
15864 }
15865
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015866 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015867 rts_threshold);
15868 }
15869
15870 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
15871 {
15872 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
15873 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
15874 wiphy->frag_threshold;
15875
15876 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015877 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015878 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015879 hddLog(VOS_TRACE_LEVEL_ERROR,
15880 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015881 frag_threshold);
15882 return -EINVAL;
15883 }
15884
15885 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
15886 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015887 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015888 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015889 hddLog(VOS_TRACE_LEVEL_ERROR,
15890 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015891 __func__, frag_threshold);
15892 return -EIO;
15893 }
15894
15895 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
15896 frag_threshold);
15897 }
15898
15899 if ((changed & WIPHY_PARAM_RETRY_SHORT)
15900 || (changed & WIPHY_PARAM_RETRY_LONG))
15901 {
15902 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
15903 wiphy->retry_short :
15904 wiphy->retry_long;
15905
15906 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
15907 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
15908 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015909 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015910 __func__, retry_value);
15911 return -EINVAL;
15912 }
15913
15914 if (changed & WIPHY_PARAM_RETRY_SHORT)
15915 {
15916 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
15917 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015918 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015919 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015920 hddLog(VOS_TRACE_LEVEL_ERROR,
15921 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015922 __func__, retry_value);
15923 return -EIO;
15924 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015925 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015926 __func__, retry_value);
15927 }
15928 else if (changed & WIPHY_PARAM_RETRY_SHORT)
15929 {
15930 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
15931 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015932 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015933 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015934 hddLog(VOS_TRACE_LEVEL_ERROR,
15935 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015936 __func__, retry_value);
15937 return -EIO;
15938 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015939 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015940 __func__, retry_value);
15941 }
15942 }
15943
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015944 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015945 return 0;
15946}
15947
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015948static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
15949 u32 changed)
15950{
15951 int ret;
15952
15953 vos_ssr_protect(__func__);
15954 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
15955 vos_ssr_unprotect(__func__);
15956
15957 return ret;
15958}
15959
Jeff Johnson295189b2012-06-20 16:38:30 -070015960/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015961 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015962 * This function is used to set the txpower
15963 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015964static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015965#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15966 struct wireless_dev *wdev,
15967#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015968#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015969 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015970#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015971 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015972#endif
15973 int dbm)
15974{
15975 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015976 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015977 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
15978 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015979 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015980
15981 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015982
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015983 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15984 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
15985 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015986 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015987 if (0 != status)
15988 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015989 return status;
15990 }
15991
15992 hHal = pHddCtx->hHal;
15993
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015994 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
15995 dbm, ccmCfgSetCallback,
15996 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015997 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015998 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015999 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
16000 return -EIO;
16001 }
16002
16003 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
16004 dbm);
16005
16006 switch(type)
16007 {
16008 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
16009 /* Fall through */
16010 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
16011 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
16012 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016013 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
16014 __func__);
16015 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070016016 }
16017 break;
16018 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016019 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070016020 __func__);
16021 return -EOPNOTSUPP;
16022 break;
16023 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016024 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
16025 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070016026 return -EIO;
16027 }
16028
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016029 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016030 return 0;
16031}
16032
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016033static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
16034#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16035 struct wireless_dev *wdev,
16036#endif
16037#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
16038 enum tx_power_setting type,
16039#else
16040 enum nl80211_tx_power_setting type,
16041#endif
16042 int dbm)
16043{
16044 int ret;
16045 vos_ssr_protect(__func__);
16046 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
16047#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16048 wdev,
16049#endif
16050#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
16051 type,
16052#else
16053 type,
16054#endif
16055 dbm);
16056 vos_ssr_unprotect(__func__);
16057
16058 return ret;
16059}
16060
Jeff Johnson295189b2012-06-20 16:38:30 -070016061/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016062 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070016063 * This function is used to read the txpower
16064 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016065static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070016066#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16067 struct wireless_dev *wdev,
16068#endif
16069 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070016070{
16071
16072 hdd_adapter_t *pAdapter;
16073 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016074 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016075
Jeff Johnsone7245742012-09-05 17:12:55 -070016076 ENTER();
16077
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016078 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016079 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016080 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016081 *dbm = 0;
16082 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016083 }
16084
Jeff Johnson295189b2012-06-20 16:38:30 -070016085 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
16086 if (NULL == pAdapter)
16087 {
16088 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
16089 return -ENOENT;
16090 }
16091
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016092 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16093 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
16094 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070016095 wlan_hdd_get_classAstats(pAdapter);
16096 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
16097
Jeff Johnsone7245742012-09-05 17:12:55 -070016098 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016099 return 0;
16100}
16101
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016102static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
16103#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16104 struct wireless_dev *wdev,
16105#endif
16106 int *dbm)
16107{
16108 int ret;
16109
16110 vos_ssr_protect(__func__);
16111 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
16112#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16113 wdev,
16114#endif
16115 dbm);
16116 vos_ssr_unprotect(__func__);
16117
16118 return ret;
16119}
16120
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016121static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016122#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16123 const u8* mac,
16124#else
16125 u8* mac,
16126#endif
16127 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070016128{
16129 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
16130 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16131 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053016132 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070016133
16134 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
16135 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070016136
16137 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
16138 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
16139 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
16140 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
16141 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
16142 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
16143 tANI_U16 maxRate = 0;
16144 tANI_U16 myRate;
16145 tANI_U16 currentRate = 0;
16146 tANI_U8 maxSpeedMCS = 0;
16147 tANI_U8 maxMCSIdx = 0;
16148 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053016149 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070016150 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016151 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016152
Leo Chang6f8870f2013-03-26 18:11:36 -070016153#ifdef WLAN_FEATURE_11AC
16154 tANI_U32 vht_mcs_map;
16155 eDataRate11ACMaxMcs vhtMaxMcs;
16156#endif /* WLAN_FEATURE_11AC */
16157
Jeff Johnsone7245742012-09-05 17:12:55 -070016158 ENTER();
16159
Jeff Johnson295189b2012-06-20 16:38:30 -070016160 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
16161 (0 == ssidlen))
16162 {
16163 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
16164 " Invalid ssidlen, %d", __func__, ssidlen);
16165 /*To keep GUI happy*/
16166 return 0;
16167 }
16168
Mukul Sharma811205f2014-07-09 21:07:30 +053016169 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16170 {
16171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16172 "%s: Roaming in progress, so unable to proceed this request", __func__);
Sachin Ahuja81ab1812016-08-19 21:35:58 +053016173 /* return a cached value */
16174 sinfo->signal = pAdapter->rssi;
Mukul Sharma811205f2014-07-09 21:07:30 +053016175 return 0;
16176 }
16177
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016178 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016179 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016180 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016181 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016182 }
16183
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053016184 wlan_hdd_get_station_stats(pAdapter);
16185 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070016186
Kiet Lam3b17fc82013-09-27 05:24:08 +053016187 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
16188 sinfo->filled |= STATION_INFO_SIGNAL;
16189
c_hpothu09f19542014-05-30 21:53:31 +053016190 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053016191 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
16192 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053016193 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053016194 {
16195 rate_flags = pAdapter->maxRateFlags;
16196 }
c_hpothu44ff4e02014-05-08 00:13:57 +053016197
Jeff Johnson295189b2012-06-20 16:38:30 -070016198 //convert to the UI units of 100kbps
16199 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
16200
16201#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070016202 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 -070016203 sinfo->signal,
16204 pCfg->reportMaxLinkSpeed,
16205 myRate,
16206 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016207 (int) pCfg->linkSpeedRssiMid,
16208 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070016209 (int) rate_flags,
16210 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070016211#endif //LINKSPEED_DEBUG_ENABLED
16212
16213 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
16214 {
16215 // we do not want to necessarily report the current speed
16216 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
16217 {
16218 // report the max possible speed
16219 rssidx = 0;
16220 }
16221 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
16222 {
16223 // report the max possible speed with RSSI scaling
16224 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
16225 {
16226 // report the max possible speed
16227 rssidx = 0;
16228 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016229 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016230 {
16231 // report middle speed
16232 rssidx = 1;
16233 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016234 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
16235 {
16236 // report middle speed
16237 rssidx = 2;
16238 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016239 else
16240 {
16241 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016242 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070016243 }
16244 }
16245 else
16246 {
16247 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
16248 hddLog(VOS_TRACE_LEVEL_ERROR,
16249 "%s: Invalid value for reportMaxLinkSpeed: %u",
16250 __func__, pCfg->reportMaxLinkSpeed);
16251 rssidx = 0;
16252 }
16253
16254 maxRate = 0;
16255
16256 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016257 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
16258 OperationalRates, &ORLeng))
16259 {
16260 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16261 /*To keep GUI happy*/
16262 return 0;
16263 }
16264
Jeff Johnson295189b2012-06-20 16:38:30 -070016265 for (i = 0; i < ORLeng; i++)
16266 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016267 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016268 {
16269 /* Validate Rate Set */
16270 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
16271 {
16272 currentRate = supported_data_rate[j].supported_rate[rssidx];
16273 break;
16274 }
16275 }
16276 /* Update MAX rate */
16277 maxRate = (currentRate > maxRate)?currentRate:maxRate;
16278 }
16279
16280 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016281 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
16282 ExtendedRates, &ERLeng))
16283 {
16284 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16285 /*To keep GUI happy*/
16286 return 0;
16287 }
16288
Jeff Johnson295189b2012-06-20 16:38:30 -070016289 for (i = 0; i < ERLeng; i++)
16290 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016291 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016292 {
16293 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
16294 {
16295 currentRate = supported_data_rate[j].supported_rate[rssidx];
16296 break;
16297 }
16298 }
16299 /* Update MAX rate */
16300 maxRate = (currentRate > maxRate)?currentRate:maxRate;
16301 }
c_hpothu79aab322014-07-14 21:11:01 +053016302
Kiet Lamb69f8dc2013-11-15 15:34:27 +053016303 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053016304 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053016305 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053016306 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070016307 {
c_hpothu79aab322014-07-14 21:11:01 +053016308 if (rate_flags & eHAL_TX_RATE_VHT80)
16309 mode = 2;
16310 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
16311 mode = 1;
16312 else
16313 mode = 0;
16314
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016315 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
16316 MCSRates, &MCSLeng))
16317 {
16318 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16319 /*To keep GUI happy*/
16320 return 0;
16321 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016322 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070016323#ifdef WLAN_FEATURE_11AC
16324 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016325 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070016326 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016327 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016328 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070016329 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070016330 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016331 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070016332 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016333 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070016334 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016335 maxMCSIdx = 7;
16336 }
16337 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
16338 {
16339 maxMCSIdx = 8;
16340 }
16341 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
16342 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016343 //VHT20 is supporting 0~8
16344 if (rate_flags & eHAL_TX_RATE_VHT20)
16345 maxMCSIdx = 8;
16346 else
16347 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070016348 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016349
c_hpothu79aab322014-07-14 21:11:01 +053016350 if (0 != rssidx)/*check for scaled */
16351 {
16352 //get middle rate MCS index if rssi=1/2
16353 for (i=0; i <= maxMCSIdx; i++)
16354 {
16355 if (sinfo->signal <= rssiMcsTbl[mode][i])
16356 {
16357 maxMCSIdx = i;
16358 break;
16359 }
16360 }
16361 }
16362
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016363 if (rate_flags & eHAL_TX_RATE_VHT80)
16364 {
16365 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
16366 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
16367 }
16368 else if (rate_flags & eHAL_TX_RATE_VHT40)
16369 {
16370 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
16371 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
16372 }
16373 else if (rate_flags & eHAL_TX_RATE_VHT20)
16374 {
16375 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
16376 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
16377 }
16378
Leo Chang6f8870f2013-03-26 18:11:36 -070016379 maxSpeedMCS = 1;
16380 if (currentRate > maxRate)
16381 {
16382 maxRate = currentRate;
16383 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016384
Leo Chang6f8870f2013-03-26 18:11:36 -070016385 }
16386 else
16387#endif /* WLAN_FEATURE_11AC */
16388 {
16389 if (rate_flags & eHAL_TX_RATE_HT40)
16390 {
16391 rateFlag |= 1;
16392 }
16393 if (rate_flags & eHAL_TX_RATE_SGI)
16394 {
16395 rateFlag |= 2;
16396 }
16397
Girish Gowli01abcee2014-07-31 20:18:55 +053016398 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053016399 if (rssidx == 1 || rssidx == 2)
16400 {
16401 //get middle rate MCS index if rssi=1/2
16402 for (i=0; i <= 7; i++)
16403 {
16404 if (sinfo->signal <= rssiMcsTbl[mode][i])
16405 {
16406 temp = i+1;
16407 break;
16408 }
16409 }
16410 }
c_hpothu79aab322014-07-14 21:11:01 +053016411
16412 for (i = 0; i < MCSLeng; i++)
16413 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016414 for (j = 0; j < temp; j++)
16415 {
16416 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
16417 {
16418 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053016419 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070016420 break;
16421 }
16422 }
16423 if ((j < temp) && (currentRate > maxRate))
16424 {
16425 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070016426 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016427 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053016428 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070016429 }
16430 }
16431
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016432 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
16433 {
16434 maxRate = myRate;
16435 maxSpeedMCS = 1;
16436 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
16437 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016438 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053016439 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070016440 {
16441 maxRate = myRate;
16442 if (rate_flags & eHAL_TX_RATE_LEGACY)
16443 {
16444 maxSpeedMCS = 0;
16445 }
16446 else
16447 {
16448 maxSpeedMCS = 1;
16449 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
16450 }
16451 }
16452
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016453 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070016454 {
16455 sinfo->txrate.legacy = maxRate;
16456#ifdef LINKSPEED_DEBUG_ENABLED
16457 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
16458#endif //LINKSPEED_DEBUG_ENABLED
16459 }
16460 else
16461 {
16462 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070016463#ifdef WLAN_FEATURE_11AC
16464 sinfo->txrate.nss = 1;
16465 if (rate_flags & eHAL_TX_RATE_VHT80)
16466 {
16467 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016468 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070016469 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016470 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070016471 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016472 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16473 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16474 }
16475 else if (rate_flags & eHAL_TX_RATE_VHT20)
16476 {
16477 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16478 }
16479#endif /* WLAN_FEATURE_11AC */
16480 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
16481 {
16482 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
16483 if (rate_flags & eHAL_TX_RATE_HT40)
16484 {
16485 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16486 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016487 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016488 if (rate_flags & eHAL_TX_RATE_SGI)
16489 {
16490 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
16491 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016492
Jeff Johnson295189b2012-06-20 16:38:30 -070016493#ifdef LINKSPEED_DEBUG_ENABLED
16494 pr_info("Reporting MCS rate %d flags %x\n",
16495 sinfo->txrate.mcs,
16496 sinfo->txrate.flags );
16497#endif //LINKSPEED_DEBUG_ENABLED
16498 }
16499 }
16500 else
16501 {
16502 // report current rate instead of max rate
16503
16504 if (rate_flags & eHAL_TX_RATE_LEGACY)
16505 {
16506 //provide to the UI in units of 100kbps
16507 sinfo->txrate.legacy = myRate;
16508#ifdef LINKSPEED_DEBUG_ENABLED
16509 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
16510#endif //LINKSPEED_DEBUG_ENABLED
16511 }
16512 else
16513 {
16514 //must be MCS
16515 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070016516#ifdef WLAN_FEATURE_11AC
16517 sinfo->txrate.nss = 1;
16518 if (rate_flags & eHAL_TX_RATE_VHT80)
16519 {
16520 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16521 }
16522 else
16523#endif /* WLAN_FEATURE_11AC */
16524 {
16525 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
16526 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016527 if (rate_flags & eHAL_TX_RATE_SGI)
16528 {
16529 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
16530 }
16531 if (rate_flags & eHAL_TX_RATE_HT40)
16532 {
16533 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16534 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016535#ifdef WLAN_FEATURE_11AC
16536 else if (rate_flags & eHAL_TX_RATE_VHT80)
16537 {
16538 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
16539 }
16540#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070016541#ifdef LINKSPEED_DEBUG_ENABLED
16542 pr_info("Reporting actual MCS rate %d flags %x\n",
16543 sinfo->txrate.mcs,
16544 sinfo->txrate.flags );
16545#endif //LINKSPEED_DEBUG_ENABLED
16546 }
16547 }
16548 sinfo->filled |= STATION_INFO_TX_BITRATE;
16549
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070016550 sinfo->tx_packets =
16551 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
16552 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
16553 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
16554 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
16555
16556 sinfo->tx_retries =
16557 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
16558 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
16559 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
16560 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
16561
16562 sinfo->tx_failed =
16563 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
16564 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
16565 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
16566 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
16567
16568 sinfo->filled |=
16569 STATION_INFO_TX_PACKETS |
16570 STATION_INFO_TX_RETRIES |
16571 STATION_INFO_TX_FAILED;
16572
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053016573 sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt;
16574 sinfo->filled |= STATION_INFO_RX_PACKETS;
16575
16576 if (rate_flags & eHAL_TX_RATE_LEGACY)
16577 hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"),
16578 sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets,
16579 sinfo->rx_packets);
16580 else
16581 hddLog(LOG1,
16582 FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"),
16583 sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags,
16584 sinfo->tx_packets, sinfo->rx_packets);
16585
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016586 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16587 TRACE_CODE_HDD_CFG80211_GET_STA,
16588 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070016589 EXIT();
16590 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016591}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016592#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16593static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
16594 const u8* mac, struct station_info *sinfo)
16595#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016596static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
16597 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016598#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016599{
16600 int ret;
16601
16602 vos_ssr_protect(__func__);
16603 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
16604 vos_ssr_unprotect(__func__);
16605
16606 return ret;
16607}
16608
16609static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070016610 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070016611{
16612 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016613 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070016614 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016615 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016616
Jeff Johnsone7245742012-09-05 17:12:55 -070016617 ENTER();
16618
Jeff Johnson295189b2012-06-20 16:38:30 -070016619 if (NULL == pAdapter)
16620 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016621 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016622 return -ENODEV;
16623 }
16624
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016625 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16626 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
16627 pAdapter->sessionId, timeout));
16628
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016629 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016630 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016631 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016632 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016633 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016634 }
16635
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016636 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
16637 (TRUE == pHddCtx->hdd_wlan_suspended) &&
16638 (pHddCtx->cfg_ini->fhostArpOffload) &&
16639 (eConnectionState_Associated ==
16640 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
16641 {
Amar Singhald53568e2013-09-26 11:03:45 -070016642
16643 hddLog(VOS_TRACE_LEVEL_INFO,
16644 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053016645 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016646 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16647 {
16648 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080016649 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016650 __func__, vos_status);
16651 }
16652 }
16653
Jeff Johnson295189b2012-06-20 16:38:30 -070016654 /**The get power cmd from the supplicant gets updated by the nl only
16655 *on successful execution of the function call
16656 *we are oppositely mapped w.r.t mode in the driver
16657 **/
16658 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
16659
16660 if (VOS_STATUS_E_FAILURE == vos_status)
16661 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016662 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16663 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016664 return -EINVAL;
16665 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016666 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016667 return 0;
16668}
16669
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016670static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
16671 struct net_device *dev, bool mode, int timeout)
16672{
16673 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016674
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016675 vos_ssr_protect(__func__);
16676 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
16677 vos_ssr_unprotect(__func__);
16678
16679 return ret;
16680}
Sushant Kaushik084f6592015-09-10 13:11:56 +053016681
Jeff Johnson295189b2012-06-20 16:38:30 -070016682#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016683static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
16684 struct net_device *netdev,
16685 u8 key_index)
16686{
16687 ENTER();
16688 return 0;
16689}
16690
Jeff Johnson295189b2012-06-20 16:38:30 -070016691static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016692 struct net_device *netdev,
16693 u8 key_index)
16694{
16695 int ret;
16696 vos_ssr_protect(__func__);
16697 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
16698 vos_ssr_unprotect(__func__);
16699 return ret;
16700}
16701#endif //LINUX_VERSION_CODE
16702
16703#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16704static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16705 struct net_device *dev,
16706 struct ieee80211_txq_params *params)
16707{
16708 ENTER();
16709 return 0;
16710}
16711#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16712static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16713 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016714{
Jeff Johnsone7245742012-09-05 17:12:55 -070016715 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070016716 return 0;
16717}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016718#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070016719
16720#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16721static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016722 struct net_device *dev,
16723 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016724{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016725 int ret;
16726
16727 vos_ssr_protect(__func__);
16728 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
16729 vos_ssr_unprotect(__func__);
16730 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016731}
16732#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16733static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
16734 struct ieee80211_txq_params *params)
16735{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016736 int ret;
16737
16738 vos_ssr_protect(__func__);
16739 ret = __wlan_hdd_set_txq_params(wiphy, params);
16740 vos_ssr_unprotect(__func__);
16741 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016742}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016743#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016744
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016745static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016746 struct net_device *dev,
16747 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070016748{
16749 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016750 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016751 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016752 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016753 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016754 v_CONTEXT_t pVosContext = NULL;
16755 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016756
Jeff Johnsone7245742012-09-05 17:12:55 -070016757 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016758
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016759 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070016760 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016761 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016762 return -EINVAL;
16763 }
16764
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016765 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16766 TRACE_CODE_HDD_CFG80211_DEL_STA,
16767 pAdapter->sessionId, pAdapter->device_mode));
16768
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016769 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16770 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016771 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016772 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016773 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016774 }
16775
Jeff Johnson295189b2012-06-20 16:38:30 -070016776 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016777 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016778 )
16779 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016780 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
16781 pSapCtx = VOS_GET_SAP_CB(pVosContext);
16782 if(pSapCtx == NULL){
16783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16784 FL("psapCtx is NULL"));
16785 return -ENOENT;
16786 }
Agrawal Ashish306b75f2017-01-11 19:16:25 +053016787 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
16788 {
16789 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
16790 "Change reason code to eSIR_MAC_DISASSOC_LEAVING_BSS_REASON in sap auth offload");
16791 pDelStaParams->reason_code = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
16792 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016793 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070016794 {
16795 v_U16_t i;
16796 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
16797 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016798 if ((pSapCtx->aStaInfo[i].isUsed) &&
16799 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070016800 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016801 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016802 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016803 ETHER_ADDR_LEN);
16804
Jeff Johnson295189b2012-06-20 16:38:30 -070016805 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016806 "%s: Delete STA with MAC::"
16807 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016808 __func__,
16809 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
16810 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070016811 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016812 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016813 }
16814 }
16815 }
16816 else
16817 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016818
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016819 vos_status = hdd_softap_GetStaId(pAdapter,
16820 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016821 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16822 {
16823 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016824 "%s: Skip this DEL STA as this is not used::"
16825 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016826 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016827 return -ENOENT;
16828 }
16829
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016830 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016831 {
16832 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016833 "%s: Skip this DEL STA as deauth is in progress::"
16834 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016835 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016836 return -ENOENT;
16837 }
16838
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016839 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016840
Jeff Johnson295189b2012-06-20 16:38:30 -070016841 hddLog(VOS_TRACE_LEVEL_INFO,
16842 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016843 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016844 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016845 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016846
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016847 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016848 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16849 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016850 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016851 hddLog(VOS_TRACE_LEVEL_INFO,
16852 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016853 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016854 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016855 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016856 return -ENOENT;
16857 }
16858
Jeff Johnson295189b2012-06-20 16:38:30 -070016859 }
16860 }
16861
16862 EXIT();
16863
16864 return 0;
16865}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016866
16867#ifdef CFG80211_DEL_STA_V2
Kapil Gupta137ef892016-12-13 19:38:00 +053016868int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016869 struct net_device *dev,
16870 struct station_del_parameters *param)
16871#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016872#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
Kapil Gupta137ef892016-12-13 19:38:00 +053016873int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016874 struct net_device *dev, const u8 *mac)
16875#else
Kapil Gupta137ef892016-12-13 19:38:00 +053016876int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016877 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016878#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016879#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016880{
16881 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016882 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070016883
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016884 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016885
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016886#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016887 if (NULL == param) {
16888 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016889 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016890 return -EINVAL;
16891 }
16892
16893 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
16894 param->subtype, &delStaParams);
16895
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016896#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053016897 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016898 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016899#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016900 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
16901
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016902 vos_ssr_unprotect(__func__);
16903
16904 return ret;
16905}
16906
16907static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016908 struct net_device *dev,
16909#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16910 const u8 *mac,
16911#else
16912 u8 *mac,
16913#endif
16914 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016915{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016916 hdd_adapter_t *pAdapter;
16917 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016918 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016919#ifdef FEATURE_WLAN_TDLS
16920 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016921
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016922 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016923
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016924 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16925 if (NULL == pAdapter)
16926 {
16927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16928 "%s: Adapter is NULL",__func__);
16929 return -EINVAL;
16930 }
16931 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16932 status = wlan_hdd_validate_context(pHddCtx);
16933 if (0 != status)
16934 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016935 return status;
16936 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016937
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016938 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16939 TRACE_CODE_HDD_CFG80211_ADD_STA,
16940 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016941 mask = params->sta_flags_mask;
16942
16943 set = params->sta_flags_set;
16944
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016945 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016946 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
16947 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016948
16949 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
16950 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080016951 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016952 }
16953 }
16954#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016955 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016956 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016957}
16958
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016959#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16960static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16961 struct net_device *dev, const u8 *mac,
16962 struct station_parameters *params)
16963#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016964static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16965 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016966#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016967{
16968 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016969
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016970 vos_ssr_protect(__func__);
16971 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
16972 vos_ssr_unprotect(__func__);
16973
16974 return ret;
16975}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016976#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070016977
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016978static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070016979 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016980{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016981 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16982 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016983 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016984 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016985 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016986 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070016987
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016988 ENTER();
16989
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016990 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016991 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016992 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016993 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016994 return -EINVAL;
16995 }
16996
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016997 if (!pmksa) {
16998 hddLog(LOGE, FL("pmksa is NULL"));
16999 return -EINVAL;
17000 }
17001
17002 if (!pmksa->bssid || !pmksa->pmkid) {
17003 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
17004 pmksa->bssid, pmksa->pmkid);
17005 return -EINVAL;
17006 }
17007
17008 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
17009 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
17010
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017011 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17012 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017013 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017014 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017015 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017016 }
17017
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017018 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017019 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17020
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017021 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
17022 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017023
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017024 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017025 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017026 &pmk_id, 1, FALSE);
17027
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017028 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17029 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
17030 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017031
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017032 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017033 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017034}
17035
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017036static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
17037 struct cfg80211_pmksa *pmksa)
17038{
17039 int ret;
17040
17041 vos_ssr_protect(__func__);
17042 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
17043 vos_ssr_unprotect(__func__);
17044
17045 return ret;
17046}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017047
Wilson Yang6507c4e2013-10-01 20:11:19 -070017048
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017049static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070017050 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017051{
Wilson Yang6507c4e2013-10-01 20:11:19 -070017052 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17053 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017054 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080017055 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017056
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017057 ENTER();
17058
Wilson Yang6507c4e2013-10-01 20:11:19 -070017059 /* Validate pAdapter */
17060 if (NULL == pAdapter)
17061 {
17062 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
17063 return -EINVAL;
17064 }
17065
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017066 if (!pmksa) {
17067 hddLog(LOGE, FL("pmksa is NULL"));
17068 return -EINVAL;
17069 }
17070
17071 if (!pmksa->bssid) {
17072 hddLog(LOGE, FL("pmksa->bssid is NULL"));
17073 return -EINVAL;
17074 }
17075
Kiet Lam98c46a12014-10-31 15:34:57 -070017076 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
17077 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
17078
Wilson Yang6507c4e2013-10-01 20:11:19 -070017079 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17080 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070017081 if (0 != status)
17082 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070017083 return status;
17084 }
17085
17086 /*Retrieve halHandle*/
17087 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17088
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017089 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17090 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
17091 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017092 /* Delete the PMKID CSR cache */
17093 if (eHAL_STATUS_SUCCESS !=
17094 sme_RoamDelPMKIDfromCache(halHandle,
17095 pAdapter->sessionId, pmksa->bssid, FALSE)) {
17096 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
17097 MAC_ADDR_ARRAY(pmksa->bssid));
17098 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017099 }
17100
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017101 EXIT();
17102 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017103}
17104
Wilson Yang6507c4e2013-10-01 20:11:19 -070017105
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017106static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
17107 struct cfg80211_pmksa *pmksa)
17108{
17109 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017110
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017111 vos_ssr_protect(__func__);
17112 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
17113 vos_ssr_unprotect(__func__);
17114
17115 return ret;
17116
17117}
17118
17119static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017120{
Wilson Yang6507c4e2013-10-01 20:11:19 -070017121 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17122 tHalHandle halHandle;
17123 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080017124 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017125
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017126 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070017127
17128 /* Validate pAdapter */
17129 if (NULL == pAdapter)
17130 {
17131 hddLog(VOS_TRACE_LEVEL_ERROR,
17132 "%s: Invalid Adapter" ,__func__);
17133 return -EINVAL;
17134 }
17135
17136 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17137 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070017138 if (0 != status)
17139 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070017140 return status;
17141 }
17142
17143 /*Retrieve halHandle*/
17144 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17145
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017146 /* Flush the PMKID cache in CSR */
17147 if (eHAL_STATUS_SUCCESS !=
17148 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
17149 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
17150 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017151 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017152 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080017153 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017154}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017155
17156static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
17157{
17158 int ret;
17159
17160 vos_ssr_protect(__func__);
17161 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
17162 vos_ssr_unprotect(__func__);
17163
17164 return ret;
17165}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017166#endif
17167
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017168#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017169static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
17170 struct net_device *dev,
17171 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017172{
17173 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17174 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017175 hdd_context_t *pHddCtx;
17176 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017177
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017178 ENTER();
17179
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017180 if (NULL == pAdapter)
17181 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017182 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017183 return -ENODEV;
17184 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017185 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17186 ret = wlan_hdd_validate_context(pHddCtx);
17187 if (0 != ret)
17188 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017189 return ret;
17190 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017191 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017192 if (NULL == pHddStaCtx)
17193 {
17194 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
17195 return -EINVAL;
17196 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017197
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017198 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17199 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
17200 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017201 // Added for debug on reception of Re-assoc Req.
17202 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
17203 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017204 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017205 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080017206 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017207 }
17208
17209#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080017210 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017211 ftie->ie_len);
17212#endif
17213
17214 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053017215 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
17216 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017217 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017218
17219 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017220 return 0;
17221}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017222
17223static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
17224 struct net_device *dev,
17225 struct cfg80211_update_ft_ies_params *ftie)
17226{
17227 int ret;
17228
17229 vos_ssr_protect(__func__);
17230 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
17231 vos_ssr_unprotect(__func__);
17232
17233 return ret;
17234}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017235#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017236
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017237#ifdef FEATURE_WLAN_SCAN_PNO
17238
17239void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
17240 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
17241{
17242 int ret;
17243 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
17244 hdd_context_t *pHddCtx;
17245
Nirav Shah80830bf2013-12-31 16:35:12 +053017246 ENTER();
17247
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017248 if (NULL == pAdapter)
17249 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053017250 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017251 "%s: HDD adapter is Null", __func__);
17252 return ;
17253 }
17254
17255 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17256 if (NULL == pHddCtx)
17257 {
17258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17259 "%s: HDD context is Null!!!", __func__);
17260 return ;
17261 }
17262
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017263 spin_lock(&pHddCtx->schedScan_lock);
17264 if (TRUE == pHddCtx->isWiphySuspended)
17265 {
17266 pHddCtx->isSchedScanUpdatePending = TRUE;
17267 spin_unlock(&pHddCtx->schedScan_lock);
17268 hddLog(VOS_TRACE_LEVEL_INFO,
17269 "%s: Update cfg80211 scan database after it resume", __func__);
17270 return ;
17271 }
17272 spin_unlock(&pHddCtx->schedScan_lock);
17273
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017274 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
17275
17276 if (0 > ret)
17277 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053017278 else
17279 {
17280 /* Acquire wakelock to handle the case where APP's tries to suspend
17281 * immediatly after the driver gets connect request(i.e after pno)
17282 * from supplicant, this result in app's is suspending and not able
17283 * to process the connect request to AP */
17284 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
17285 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017286 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17288 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017289}
17290
17291/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017292 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017293 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017294 */
17295static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
17296{
17297 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
17298 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017299 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017300 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17301 int status = 0;
Agrawal Ashishcff31692016-12-16 17:17:50 +053017302
17303 if (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
17304 {
17305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17306 "%s: PNO is allowed only in STA interface", __func__);
17307 return eHAL_STATUS_FAILURE;
17308 }
17309
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017310 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
17311
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017312 /* The current firmware design does not allow PNO during any
Agrawal Ashishcff31692016-12-16 17:17:50 +053017313 * active sessions. PNO is allowed only in case when sap session
17314 * is present and sapo auth offload feature enabled in firmare.
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017315 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017316 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
17317 {
17318 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017319 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017320
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017321 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
17322 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
17323 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
17324 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
Agrawal Ashishcff31692016-12-16 17:17:50 +053017325 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode &&
17326 !pHddCtx->cfg_ini->enable_sap_auth_offload)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053017327 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017328 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017329 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017330 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017331 }
17332 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
17333 pAdapterNode = pNext;
17334 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017335 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017336}
17337
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017338void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
17339{
17340 hdd_adapter_t *pAdapter = callbackContext;
17341 hdd_context_t *pHddCtx;
17342
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017343 ENTER();
17344
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017345 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
17346 {
17347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17348 FL("Invalid adapter or adapter has invalid magic"));
17349 return;
17350 }
17351
17352 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17353 if (0 != wlan_hdd_validate_context(pHddCtx))
17354 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017355 return;
17356 }
17357
c_hpothub53c45d2014-08-18 16:53:14 +053017358 if (VOS_STATUS_SUCCESS != status)
17359 {
17360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017361 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053017362 pHddCtx->isPnoEnable = FALSE;
17363 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017364
17365 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
17366 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017367 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017368}
17369
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017370#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) || \
17371 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
17372/**
17373 * hdd_config_sched_scan_plan() - configures the sched scan plans
17374 * from the framework.
17375 * @pno_req: pointer to PNO scan request
17376 * @request: pointer to scan request from framework
17377 *
17378 * Return: None
17379 */
17380static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
17381 struct cfg80211_sched_scan_request *request,
17382 hdd_context_t *hdd_ctx)
17383{
17384 v_U32_t i = 0;
17385
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017386 pno_req->scanTimers.ucScanTimersCount = request->n_scan_plans;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017387 for (i = 0; i < request->n_scan_plans; i++)
17388 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017389 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
17390 request->scan_plans[i].iterations;
17391 pno_req->scanTimers.aTimerValues[i].uTimerValue =
17392 request->scan_plans[i].interval;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017393 }
17394}
17395#else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017396static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017397 struct cfg80211_sched_scan_request *request,
17398 hdd_context_t *hdd_ctx)
17399{
17400 v_U32_t i, temp_int;
17401 /* Driver gets only one time interval which is hardcoded in
17402 * supplicant for 10000ms. Taking power consumption into account 6
17403 * timers will be used, Timervalue is increased exponentially
17404 * i.e 10,20,40, 80,160,320 secs. And number of scan cycle for each
17405 * timer is configurable through INI param gPNOScanTimerRepeatValue.
17406 * If it is set to 0 only one timer will be used and PNO scan cycle
17407 * will be repeated after each interval specified by supplicant
17408 * till PNO is disabled.
17409 */
17410 if (0 == hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue)
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017411 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017412 HDD_PNO_SCAN_TIMERS_SET_ONE;
17413 else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017414 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017415 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
17416
17417 temp_int = (request->interval)/1000;
17418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17419 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
17420 temp_int, hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue);
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017421 for ( i = 0; i < pno_req->scanTimers.ucScanTimersCount; i++)
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017422 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017423 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017424 hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue;
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017425 pno_req->scanTimers.aTimerValues[i].uTimerValue = temp_int;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017426 temp_int *= 2;
17427 }
17428 //Repeat last timer until pno disabled.
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017429 pno_req->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017430}
17431#endif
17432
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017433/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017434 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
17435 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017436 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017437static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017438 struct net_device *dev, struct cfg80211_sched_scan_request *request)
17439{
17440 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017441 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017442 hdd_context_t *pHddCtx;
17443 tHalHandle hHal;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017444 v_U32_t i, indx, num_ch, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053017445 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
17446 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017447 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
17448 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017449 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017450 hdd_config_t *pConfig = NULL;
17451 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017452
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017453 ENTER();
17454
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017455 if (NULL == pAdapter)
17456 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017458 "%s: HDD adapter is Null", __func__);
17459 return -ENODEV;
17460 }
17461
17462 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017463 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017464
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017465 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017466 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017467 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017468 }
17469
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017470 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017471 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17472 if (NULL == hHal)
17473 {
17474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17475 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017476 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017477 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017478 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17479 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
17480 pAdapter->sessionId, pAdapter->device_mode));
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053017481 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053017482 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053017483 {
17484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17485 "%s: aborting the existing scan is unsuccessfull", __func__);
17486 return -EBUSY;
17487 }
17488
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017489 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017490 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017492 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017493 return -EBUSY;
17494 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017495
c_hpothu37f21312014-04-09 21:49:54 +053017496 if (TRUE == pHddCtx->isPnoEnable)
17497 {
17498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
17499 FL("already PNO is enabled"));
17500 return -EBUSY;
17501 }
c_hpothu225aa7c2014-10-22 17:45:13 +053017502
17503 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
17504 {
17505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17506 "%s: abort ROC failed ", __func__);
17507 return -EBUSY;
17508 }
17509
c_hpothu37f21312014-04-09 21:49:54 +053017510 pHddCtx->isPnoEnable = TRUE;
17511
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017512 pnoRequest.enable = 1; /*Enable PNO */
17513 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017514
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017515 if (( !pnoRequest.ucNetworksCount ) ||
17516 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017517 {
17518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017519 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017520 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017521 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017522 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017523 goto error;
17524 }
17525
17526 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
17527 {
17528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017529 "%s: Incorrect number of channels %d",
17530 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017531 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017532 goto error;
17533 }
17534
17535 /* Framework provides one set of channels(all)
17536 * common for all saved profile */
17537 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
17538 channels_allowed, &num_channels_allowed))
17539 {
17540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17541 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017542 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017543 goto error;
17544 }
17545 /* Checking each channel against allowed channel list */
17546 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053017547 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017548 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017549 char chList [(request->n_channels*5)+1];
17550 int len;
17551 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017552 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017553 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017554 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017555 if (request->channels[i]->hw_value == channels_allowed[indx])
17556 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017557 if ((!pConfig->enableDFSPnoChnlScan) &&
17558 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
17559 {
17560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17561 "%s : Dropping DFS channel : %d",
17562 __func__,channels_allowed[indx]);
17563 num_ignore_dfs_ch++;
17564 break;
17565 }
17566
Nirav Shah80830bf2013-12-31 16:35:12 +053017567 valid_ch[num_ch++] = request->channels[i]->hw_value;
17568 len += snprintf(chList+len, 5, "%d ",
17569 request->channels[i]->hw_value);
17570 break ;
17571 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017572 }
17573 }
Nirav Shah80830bf2013-12-31 16:35:12 +053017574 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017575
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017576 /*If all channels are DFS and dropped, then ignore the PNO request*/
17577 if (num_ignore_dfs_ch == request->n_channels)
17578 {
17579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17580 "%s : All requested channels are DFS channels", __func__);
17581 ret = -EINVAL;
17582 goto error;
17583 }
17584 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017585
17586 pnoRequest.aNetworks =
17587 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17588 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017589 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017590 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17591 FL("failed to allocate memory aNetworks %u"),
17592 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17593 goto error;
17594 }
17595 vos_mem_zero(pnoRequest.aNetworks,
17596 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17597
17598 /* Filling per profile params */
17599 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
17600 {
17601 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017602 request->match_sets[i].ssid.ssid_len;
17603
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017604 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
17605 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017606 {
17607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017608 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017609 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017610 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017611 goto error;
17612 }
17613
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017614 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017615 request->match_sets[i].ssid.ssid,
17616 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17618 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017619 i, pnoRequest.aNetworks[i].ssId.ssId);
17620 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
17621 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
17622 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017623
17624 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017625 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
17626 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017627
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017628 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017629 }
17630
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017631 for (i = 0; i < request->n_ssids; i++)
17632 {
17633 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017634 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017635 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017636 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017637 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017638 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017639 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017640 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017641 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017642 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017643 break;
17644 }
17645 j++;
17646 }
17647 }
17648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17649 "Number of hidden networks being Configured = %d",
17650 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080017652 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017653
17654 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
17655 if (pnoRequest.p24GProbeTemplate == NULL)
17656 {
17657 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17658 FL("failed to allocate memory p24GProbeTemplate %u"),
17659 SIR_PNO_MAX_PB_REQ_SIZE);
17660 goto error;
17661 }
17662
17663 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
17664 if (pnoRequest.p5GProbeTemplate == NULL)
17665 {
17666 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17667 FL("failed to allocate memory p5GProbeTemplate %u"),
17668 SIR_PNO_MAX_PB_REQ_SIZE);
17669 goto error;
17670 }
17671
17672 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
17673 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
17674
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053017675 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
17676 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017677 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017678 pnoRequest.us24GProbeTemplateLen = request->ie_len;
17679 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
17680 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017681
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017682 pnoRequest.us5GProbeTemplateLen = request->ie_len;
17683 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
17684 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017685 }
17686
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017687 hdd_config_sched_scan_plan(&pnoRequest, request, pHddCtx);
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017688
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017689 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017690
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017691 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017692 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17693 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017694 pAdapter->pno_req_status = 0;
17695
Nirav Shah80830bf2013-12-31 16:35:12 +053017696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17697 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017698 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
17699 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053017700
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017701 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017702 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017703 hdd_cfg80211_sched_scan_done_callback, pAdapter);
17704 if (eHAL_STATUS_SUCCESS != status)
17705 {
17706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017707 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017708 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017709 goto error;
17710 }
17711
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017712 ret = wait_for_completion_timeout(
17713 &pAdapter->pno_comp_var,
17714 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17715 if (0 >= ret)
17716 {
17717 // Did not receive the response for PNO enable in time.
17718 // Assuming the PNO enable was success.
17719 // Returning error from here, because we timeout, results
17720 // in side effect of Wifi (Wifi Setting) not to work.
17721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17722 FL("Timed out waiting for PNO to be Enabled"));
17723 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017724 }
17725
17726 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053017727 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017728
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017729error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017730 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17731 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053017732 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017733 if (pnoRequest.aNetworks)
17734 vos_mem_free(pnoRequest.aNetworks);
17735 if (pnoRequest.p24GProbeTemplate)
17736 vos_mem_free(pnoRequest.p24GProbeTemplate);
17737 if (pnoRequest.p5GProbeTemplate)
17738 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017739
17740 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017741 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017742}
17743
17744/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017745 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
17746 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017747 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017748static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
17749 struct net_device *dev, struct cfg80211_sched_scan_request *request)
17750{
17751 int ret;
17752
17753 vos_ssr_protect(__func__);
17754 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
17755 vos_ssr_unprotect(__func__);
17756
17757 return ret;
17758}
17759
17760/*
17761 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
17762 * Function to disable PNO
17763 */
17764static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017765 struct net_device *dev)
17766{
17767 eHalStatus status = eHAL_STATUS_FAILURE;
17768 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17769 hdd_context_t *pHddCtx;
17770 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017771 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017772 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017773
17774 ENTER();
17775
17776 if (NULL == pAdapter)
17777 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017779 "%s: HDD adapter is Null", __func__);
17780 return -ENODEV;
17781 }
17782
17783 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017784
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017785 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017786 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017787 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017788 "%s: HDD context is Null", __func__);
17789 return -ENODEV;
17790 }
17791
17792 /* The return 0 is intentional when isLogpInProgress and
17793 * isLoadUnloadInProgress. We did observe a crash due to a return of
17794 * failure in sched_scan_stop , especially for a case where the unload
17795 * of the happens at the same time. The function __cfg80211_stop_sched_scan
17796 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
17797 * success. If it returns a failure , then its next invocation due to the
17798 * clean up of the second interface will have the dev pointer corresponding
17799 * to the first one leading to a crash.
17800 */
17801 if (pHddCtx->isLogpInProgress)
17802 {
17803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17804 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053017805 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017806 return ret;
17807 }
17808
Mihir Shete18156292014-03-11 15:38:30 +053017809 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017810 {
17811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17812 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17813 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017814 }
17815
17816 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17817 if (NULL == hHal)
17818 {
17819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17820 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017821 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017822 }
17823
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017824 pnoRequest.enable = 0; /* Disable PNO */
17825 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017826
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017827 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17828 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
17829 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017830
17831 INIT_COMPLETION(pAdapter->pno_comp_var);
17832 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17833 pnoRequest.callbackContext = pAdapter;
17834 pAdapter->pno_req_status = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017835 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017836 pAdapter->sessionId,
17837 NULL, pAdapter);
17838 if (eHAL_STATUS_SUCCESS != status)
17839 {
17840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17841 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017842 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017843 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017844 }
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017845 ret = wait_for_completion_timeout(
17846 &pAdapter->pno_comp_var,
17847 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17848 if (0 >= ret)
17849 {
17850 // Did not receive the response for PNO disable in time.
17851 // Assuming the PNO disable was success.
17852 // Returning error from here, because we timeout, results
17853 // in side effect of Wifi (Wifi Setting) not to work.
Anurag Chouhan96b41cb2016-09-28 18:54:47 +053017854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017855 FL("Timed out waiting for PNO to be disabled"));
17856 ret = 0;
17857 }
17858
17859 ret = pAdapter->pno_req_status;
17860 pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017861
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017862error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017863 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017864 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017865
17866 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017867 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017868}
17869
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017870/*
17871 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
17872 * NL interface to disable PNO
17873 */
17874static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
17875 struct net_device *dev)
17876{
17877 int ret;
17878
17879 vos_ssr_protect(__func__);
17880 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
17881 vos_ssr_unprotect(__func__);
17882
17883 return ret;
17884}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017885#endif /*FEATURE_WLAN_SCAN_PNO*/
17886
17887
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017888#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017889#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017890static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17891 struct net_device *dev,
17892 u8 *peer, u8 action_code,
17893 u8 dialog_token,
17894 u16 status_code, u32 peer_capability,
17895 const u8 *buf, size_t len)
17896#else /* TDLS_MGMT_VERSION2 */
17897#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17898static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17899 struct net_device *dev,
17900 const u8 *peer, u8 action_code,
17901 u8 dialog_token, u16 status_code,
17902 u32 peer_capability, bool initiator,
17903 const u8 *buf, size_t len)
17904#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17905static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17906 struct net_device *dev,
17907 const u8 *peer, u8 action_code,
17908 u8 dialog_token, u16 status_code,
17909 u32 peer_capability, const u8 *buf,
17910 size_t len)
17911#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17912static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17913 struct net_device *dev,
17914 u8 *peer, u8 action_code,
17915 u8 dialog_token,
17916 u16 status_code, u32 peer_capability,
17917 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017918#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017919static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17920 struct net_device *dev,
17921 u8 *peer, u8 action_code,
17922 u8 dialog_token,
17923 u16 status_code, const u8 *buf,
17924 size_t len)
17925#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017926#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017927{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017928 hdd_adapter_t *pAdapter;
17929 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017930 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070017931 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080017932 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070017933 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017934 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053017935 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017936#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017937 u32 peer_capability = 0;
17938#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017939 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017940 hdd_station_ctx_t *pHddStaCtx = NULL;
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053017941 tdlsCtx_t *pHddTdlsCtx;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017942
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017943 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17944 if (NULL == pAdapter)
17945 {
17946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17947 "%s: Adapter is NULL",__func__);
17948 return -EINVAL;
17949 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017950 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17951 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
17952 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017953
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017954 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017955 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017956 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017957 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017958 "Invalid arguments");
17959 return -EINVAL;
17960 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017961
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017962 if (pHddCtx->isLogpInProgress)
17963 {
17964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17965 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053017966 wlan_hdd_tdls_set_link_status(pAdapter,
17967 peer,
17968 eTDLS_LINK_IDLE,
17969 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017970 return -EBUSY;
17971 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017972
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017973 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
17974 {
17975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17976 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17977 return -EAGAIN;
17978 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017979
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053017980 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
17981 if (!pHddTdlsCtx) {
17982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17983 "%s: pHddTdlsCtx not valid.", __func__);
17984 }
17985
Hoonki Lee27511902013-03-14 18:19:06 -070017986 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017987 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017988 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070017989 "%s: TDLS mode is disabled OR not enabled in FW."
17990 MAC_ADDRESS_STR " action %d declined.",
17991 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017992 return -ENOTSUPP;
17993 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017994
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017995 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17996
17997 if( NULL == pHddStaCtx )
17998 {
17999 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18000 "%s: HDD station context NULL ",__func__);
18001 return -EINVAL;
18002 }
18003
18004 /* STA should be connected and authenticated
18005 * before sending any TDLS frames
18006 */
18007 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
18008 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
18009 {
18010 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18011 "STA is not connected or unauthenticated. "
18012 "connState %u, uIsAuthenticated %u",
18013 pHddStaCtx->conn_info.connState,
18014 pHddStaCtx->conn_info.uIsAuthenticated);
18015 return -EAGAIN;
18016 }
18017
Hoonki Lee27511902013-03-14 18:19:06 -070018018 /* other than teardown frame, other mgmt frames are not sent if disabled */
18019 if (SIR_MAC_TDLS_TEARDOWN != action_code)
18020 {
18021 /* if tdls_mode is disabled to respond to peer's request */
18022 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
18023 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018024 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070018025 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070018026 " TDLS mode is disabled. action %d declined.",
18027 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070018028
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018029 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070018030 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053018031
18032 if (vos_max_concurrent_connections_reached())
18033 {
18034 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
18035 return -EINVAL;
18036 }
Hoonki Lee27511902013-03-14 18:19:06 -070018037 }
18038
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018039 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
18040 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053018041 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018042 {
18043 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018044 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070018045 " TDLS setup is ongoing. action %d declined.",
18046 __func__, MAC_ADDR_ARRAY(peer), action_code);
18047 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018048 }
18049 }
18050
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018051 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
18052 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080018053 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018054 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18055 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080018056 {
18057 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
18058 we return error code at 'add_station()'. Hence we have this
18059 check again in addtion to add_station().
18060 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018061 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080018062 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018063 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18064 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018065 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
18066 __func__, MAC_ADDR_ARRAY(peer), action_code,
18067 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053018068 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080018069 }
18070 else
18071 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018072 /* maximum reached. tweak to send error code to peer and return
18073 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080018074 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018075 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18076 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018077 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
18078 __func__, MAC_ADDR_ARRAY(peer), status_code,
18079 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070018080 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018081 /* fall through to send setup resp with failure status
18082 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080018083 }
18084 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018085 else
18086 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018087 mutex_lock(&pHddCtx->tdls_lock);
18088 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018089 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018090 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018091 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018092 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070018093 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
18094 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018095 return -EPERM;
18096 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018097 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018098 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018099 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018100
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018101 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053018102 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018103 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
18104 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018105
Hoonki Leea34dd892013-02-05 22:56:02 -080018106 /*Except teardown responder will not be used so just make 0*/
18107 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018108 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080018109 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018110
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018111 mutex_lock(&pHddCtx->tdls_lock);
18112 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018113
18114 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
18115 responder = pTdlsPeer->is_responder;
18116 else
Hoonki Leea34dd892013-02-05 22:56:02 -080018117 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018118 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053018119 "%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 -070018120 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
18121 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018122 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018123 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080018124 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018125 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018126 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018127
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053018128 /* Discard TDLS setup if peer is removed by user app */
18129 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
18130 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
18131 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
18132 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
18133
18134 mutex_lock(&pHddCtx->tdls_lock);
18135 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18136 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
18137 mutex_unlock(&pHddCtx->tdls_lock);
18138 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
18139 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
18140 MAC_ADDR_ARRAY(peer), action_code);
18141 return -EINVAL;
18142 }
18143 mutex_unlock(&pHddCtx->tdls_lock);
18144 }
18145
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053018146 /* For explicit trigger of DIS_REQ come out of BMPS for
18147 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070018148 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Deepthi Gowrif78f1f72016-03-21 13:13:28 +053018149 (SIR_MAC_TDLS_SETUP_CNF== action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053018150 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
18151 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070018152 {
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018153 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018154 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018155 "%s: Sending frame action_code %u.Disable BMPS", __func__,
18156 action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018157 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
18158 if (status != VOS_STATUS_SUCCESS) {
18159 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018160 } else {
18161 pHddTdlsCtx->is_tdls_disabled_bmps = true;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018162 }
Hoonki Lee14621352013-04-16 17:51:19 -070018163 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018164 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018165 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018166 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
18167 }
18168 }
Hoonki Lee14621352013-04-16 17:51:19 -070018169 }
18170
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018171 /* make sure doesn't call send_mgmt() while it is pending */
18172 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
18173 {
18174 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080018175 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018176 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018177 ret = -EBUSY;
18178 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018179 }
18180
18181 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018182 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
18183
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018184 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
18185 pAdapter->sessionId, peer, action_code, dialog_token,
18186 status_code, peer_capability, (tANI_U8 *)buf, len,
18187 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018188
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018189 if (VOS_STATUS_SUCCESS != status)
18190 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18192 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018193 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018194 ret = -EINVAL;
18195 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018196 }
18197
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18199 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
18200 WAIT_TIME_TDLS_MGMT);
18201
Hoonki Leed37cbb32013-04-20 00:31:14 -070018202 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
18203 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
18204
18205 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018206 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070018207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070018208 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070018209 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018210 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080018211
18212 if (pHddCtx->isLogpInProgress)
18213 {
18214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18215 "%s: LOGP in Progress. Ignore!!!", __func__);
18216 return -EAGAIN;
18217 }
Abhishek Singh837adf22015-10-01 17:37:37 +053018218 if (rc <= 0)
18219 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
18220 WLAN_LOG_INDICATOR_HOST_DRIVER,
18221 WLAN_LOG_REASON_HDD_TIME_OUT,
18222 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080018223
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018224 ret = -EINVAL;
18225 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018226 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018227 else
18228 {
18229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18230 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
18231 __func__, rc, pAdapter->mgmtTxCompletionStatus);
18232 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018233
Gopichand Nakkala05922802013-03-14 12:23:19 -070018234 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070018235 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018236 ret = max_sta_failed;
18237 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070018238 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018239
Hoonki Leea34dd892013-02-05 22:56:02 -080018240 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
18241 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018242 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018243 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
18244 }
Hoonki Leea34dd892013-02-05 22:56:02 -080018245 }
18246 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
18247 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018248 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
18250 }
Hoonki Leea34dd892013-02-05 22:56:02 -080018251 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018252
18253 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018254
18255tx_failed:
18256 /* add_station will be called before sending TDLS_SETUP_REQ and
18257 * TDLS_SETUP_RSP and as part of add_station driver will enable
18258 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
18259 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
18260 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
18261 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
18262 */
18263
18264 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
18265 (SIR_MAC_TDLS_SETUP_RSP == action_code))
18266 wlan_hdd_tdls_check_bmps(pAdapter);
18267 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018268}
18269
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018270#if TDLS_MGMT_VERSION2
18271static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
18272 u8 *peer, u8 action_code, u8 dialog_token,
18273 u16 status_code, u32 peer_capability,
18274 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018275#else /* TDLS_MGMT_VERSION2 */
18276#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
18277static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18278 struct net_device *dev,
18279 const u8 *peer, u8 action_code,
18280 u8 dialog_token, u16 status_code,
18281 u32 peer_capability, bool initiator,
18282 const u8 *buf, size_t len)
18283#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
18284static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18285 struct net_device *dev,
18286 const u8 *peer, u8 action_code,
18287 u8 dialog_token, u16 status_code,
18288 u32 peer_capability, const u8 *buf,
18289 size_t len)
18290#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
18291static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18292 struct net_device *dev,
18293 u8 *peer, u8 action_code,
18294 u8 dialog_token,
18295 u16 status_code, u32 peer_capability,
18296 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018297#else
18298static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
18299 u8 *peer, u8 action_code, u8 dialog_token,
18300 u16 status_code, const u8 *buf, size_t len)
18301#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018302#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018303{
18304 int ret;
18305
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018306 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018307#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018308 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18309 dialog_token, status_code,
18310 peer_capability, buf, len);
18311#else /* TDLS_MGMT_VERSION2 */
18312#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
18313 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18314 dialog_token, status_code,
18315 peer_capability, initiator,
18316 buf, len);
18317#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
18318 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18319 dialog_token, status_code,
18320 peer_capability, buf, len);
18321#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
18322 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18323 dialog_token, status_code,
18324 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018325#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018326 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18327 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018328#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018329#endif
18330 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018331
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018332 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018333}
Atul Mittal115287b2014-07-08 13:26:33 +053018334
18335int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018336#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18337 const u8 *peer,
18338#else
Atul Mittal115287b2014-07-08 13:26:33 +053018339 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018340#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018341 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053018342 cfg80211_exttdls_callback callback)
18343{
18344
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018345 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053018346 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018347 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053018348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18349 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
18350 __func__, MAC_ADDR_ARRAY(peer));
18351
18352 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
18353 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
18354
18355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018356 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
18357 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
18358 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053018359 return -ENOTSUPP;
18360 }
18361
18362 /* To cater the requirement of establishing the TDLS link
18363 * irrespective of the data traffic , get an entry of TDLS peer.
18364 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053018365 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018366 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
18367 if (pTdlsPeer == NULL) {
18368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18369 "%s: peer " MAC_ADDRESS_STR " not existing",
18370 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053018371 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018372 return -EINVAL;
18373 }
18374
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053018375 /* check FW TDLS Off Channel capability */
18376 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053018377 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053018378 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018379 {
18380 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
18381 pTdlsPeer->peerParams.global_operating_class =
18382 tdls_peer_params->global_operating_class;
18383 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
18384 pTdlsPeer->peerParams.min_bandwidth_kbps =
18385 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018386 /* check configured channel is valid, non dfs and
18387 * not current operating channel */
18388 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
18389 tdls_peer_params->channel)) &&
18390 (pHddStaCtx) &&
18391 (tdls_peer_params->channel !=
18392 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018393 {
18394 pTdlsPeer->isOffChannelConfigured = TRUE;
18395 }
18396 else
18397 {
18398 pTdlsPeer->isOffChannelConfigured = FALSE;
18399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18400 "%s: Configured Tdls Off Channel is not valid", __func__);
18401
18402 }
18403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018404 "%s: tdls_off_channel %d isOffChannelConfigured %d "
18405 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018406 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018407 pTdlsPeer->isOffChannelConfigured,
18408 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018409 }
18410 else
18411 {
18412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053018413 "%s: TDLS off channel FW capability %d, "
18414 "host capab %d or Invalid TDLS Peer Params", __func__,
18415 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
18416 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018417 }
18418
Atul Mittal115287b2014-07-08 13:26:33 +053018419 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
18420
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018421 mutex_unlock(&pHddCtx->tdls_lock);
18422
Atul Mittal115287b2014-07-08 13:26:33 +053018423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18424 " %s TDLS Add Force Peer Failed",
18425 __func__);
18426 return -EINVAL;
18427 }
18428 /*EXT TDLS*/
18429
18430 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018431 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18433 " %s TDLS set callback Failed",
18434 __func__);
18435 return -EINVAL;
18436 }
18437
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018438 mutex_unlock(&pHddCtx->tdls_lock);
18439
Atul Mittal115287b2014-07-08 13:26:33 +053018440 return(0);
18441
18442}
18443
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018444int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
18445#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18446 const u8 *peer
18447#else
18448 u8 *peer
18449#endif
18450)
Atul Mittal115287b2014-07-08 13:26:33 +053018451{
18452
18453 hddTdlsPeer_t *pTdlsPeer;
18454 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053018455
Atul Mittal115287b2014-07-08 13:26:33 +053018456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18457 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
18458 __func__, MAC_ADDR_ARRAY(peer));
18459
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053018460 if (0 != wlan_hdd_validate_context(pHddCtx)) {
18461 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
18462 return -EINVAL;
18463 }
18464
Atul Mittal115287b2014-07-08 13:26:33 +053018465 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
18466 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
18467
18468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018469 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
18470 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
18471 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053018472 return -ENOTSUPP;
18473 }
18474
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018475 mutex_lock(&pHddCtx->tdls_lock);
18476 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053018477
18478 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018479 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018480 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018481 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053018482 __func__, MAC_ADDR_ARRAY(peer));
18483 return -EINVAL;
18484 }
18485 else {
18486 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
18487 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053018488 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL,
18489 pTdlsPeer->peerMac);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018490 /* if channel switch is configured, reset
18491 the channel for this peer */
18492 if (TRUE == pTdlsPeer->isOffChannelConfigured)
18493 {
18494 pTdlsPeer->peerParams.channel = 0;
18495 pTdlsPeer->isOffChannelConfigured = FALSE;
18496 }
Atul Mittal115287b2014-07-08 13:26:33 +053018497 }
18498
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018499 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018500 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018501 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053018502 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018503 }
Atul Mittal115287b2014-07-08 13:26:33 +053018504
18505 /*EXT TDLS*/
18506
18507 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018508 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18510 " %s TDLS set callback Failed",
18511 __func__);
18512 return -EINVAL;
18513 }
Atul Mittal115287b2014-07-08 13:26:33 +053018514
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018515 mutex_unlock(&pHddCtx->tdls_lock);
18516
18517 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053018518}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018519static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018520#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18521 const u8 *peer,
18522#else
18523 u8 *peer,
18524#endif
18525 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018526{
18527 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18528 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018529 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018530 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018531
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018532 ENTER();
18533
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053018534 if (!pAdapter) {
18535 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
18536 return -EINVAL;
18537 }
18538
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018539 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18540 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
18541 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018542 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018543 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018544 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070018545 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018546 return -EINVAL;
18547 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018548
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018549 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018550 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018551 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018552 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018553 }
18554
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018555
18556 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018557 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018558 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018559 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018560 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
18561 "Cannot process TDLS commands",
18562 pHddCtx->cfg_ini->fEnableTDLSSupport,
18563 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018564 return -ENOTSUPP;
18565 }
18566
18567 switch (oper) {
18568 case NL80211_TDLS_ENABLE_LINK:
18569 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018570 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018571 long ret;
Hanumantha Reddy Pothulada389492016-02-11 17:29:27 +053018572 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams = { {0}, 0,
18573 0, 0, 0, 0, 0, 0, {0}, 0, {0} };
Agarwal Ashish16020c42014-12-29 22:01:11 +053018574 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018575 tANI_U16 numCurrTdlsPeers = 0;
18576 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018577 tANI_U8 suppChannelLen = 0;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018578 tSirMacAddr peerMac;
18579 int channel;
18580 tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018581
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018582 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18583 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
18584 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018585
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018586 mutex_lock(&pHddCtx->tdls_lock);
18587 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018588 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053018589 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018590 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018591 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18592 " (oper %d) not exsting. ignored",
18593 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18594 return -EINVAL;
18595 }
18596
18597 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18598 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18599 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18600 "NL80211_TDLS_ENABLE_LINK");
18601
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070018602 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
18603 {
18604 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
18605 MAC_ADDRESS_STR " failed",
18606 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018607 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070018608 return -EINVAL;
18609 }
18610
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018611 /* before starting tdls connection, set tdls
18612 * off channel established status to default value */
18613 pTdlsPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018614
18615 mutex_unlock(&pHddCtx->tdls_lock);
18616
Deepthi Gowri2d85bbf2016-07-25 15:43:31 +053018617 wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018618 /* TDLS Off Channel, Disable tdls channel switch,
18619 when there are more than one tdls link */
18620 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053018621 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018622 {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018623 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018624 /* get connected peer and send disable tdls off chan */
18625 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018626 if ((connPeer) &&
18627 (connPeer->isOffChannelSupported == TRUE) &&
18628 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018629 {
18630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18631 "%s: More then one peer connected, Disable "
18632 "TDLS channel switch", __func__);
18633
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018634 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018635 vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr));
18636 channel = connPeer->peerParams.channel;
18637
18638 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018639
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018640 ret = sme_SendTdlsChanSwitchReq(
18641 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018642 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018643 peerMac,
18644 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018645 TDLS_OFF_CHANNEL_BW_OFFSET,
18646 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018647 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018648 hddLog(VOS_TRACE_LEVEL_ERROR,
18649 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018650 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018651 }
18652 else
18653 {
18654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18655 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018656 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018657 "isOffChannelConfigured %d",
18658 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018659 (connPeer ? (connPeer->isOffChannelSupported)
18660 : -1),
18661 (connPeer ? (connPeer->isOffChannelConfigured)
18662 : -1));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018663 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018664 }
18665 }
18666
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018667 mutex_lock(&pHddCtx->tdls_lock);
18668 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18669 if ( NULL == pTdlsPeer ) {
18670 mutex_unlock(&pHddCtx->tdls_lock);
18671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18672 "%s: " MAC_ADDRESS_STR
18673 " (oper %d) peer got freed in other context. ignored",
18674 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18675 return -EINVAL;
18676 }
18677 peer_status = pTdlsPeer->link_status;
18678 mutex_unlock(&pHddCtx->tdls_lock);
18679
18680 if (eTDLS_LINK_CONNECTED != peer_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018681 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018682 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053018683
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018684 if (0 != wlan_hdd_tdls_get_link_establish_params(
18685 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018686 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018687 return -EINVAL;
18688 }
18689 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018690
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018691 ret = sme_SendTdlsLinkEstablishParams(
18692 WLAN_HDD_GET_HAL_CTX(pAdapter),
18693 pAdapter->sessionId, peer,
18694 &tdlsLinkEstablishParams);
18695 if (ret != VOS_STATUS_SUCCESS) {
18696 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
18697 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018698 /* Send TDLS peer UAPSD capabilities to the firmware and
18699 * register with the TL on after the response for this operation
18700 * is received .
18701 */
18702 ret = wait_for_completion_interruptible_timeout(
18703 &pAdapter->tdls_link_establish_req_comp,
18704 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Masti, Narayanraddie1892a52015-12-15 15:01:01 +053018705
18706 mutex_lock(&pHddCtx->tdls_lock);
18707 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18708 if ( NULL == pTdlsPeer ) {
18709 mutex_unlock(&pHddCtx->tdls_lock);
18710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18711 "%s %d: " MAC_ADDRESS_STR
18712 " (oper %d) peer got freed in other context. ignored",
18713 __func__, __LINE__, MAC_ADDR_ARRAY(peer),
18714 (int)oper);
18715 return -EINVAL;
18716 }
18717 peer_status = pTdlsPeer->link_status;
18718 mutex_unlock(&pHddCtx->tdls_lock);
18719
18720 if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING))
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018721 {
18722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018723 FL("Link Establish Request Failed Status %ld"),
18724 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018725 return -EINVAL;
18726 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018727 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018728
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018729 mutex_lock(&pHddCtx->tdls_lock);
18730 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18731 if ( NULL == pTdlsPeer ) {
18732 mutex_unlock(&pHddCtx->tdls_lock);
18733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18734 "%s: " MAC_ADDRESS_STR
18735 " (oper %d) peer got freed in other context. ignored",
18736 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18737 return -EINVAL;
18738 }
18739
Atul Mittal115287b2014-07-08 13:26:33 +053018740 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18741 eTDLS_LINK_CONNECTED,
18742 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018743 staDesc.ucSTAId = pTdlsPeer->staId;
18744 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053018745
18746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18747 "%s: tdlsLinkEstablishParams of peer "
18748 MAC_ADDRESS_STR "uapsdQueues: %d"
18749 "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d"
18750 "isResponder: %d peerstaId: %d",
18751 __func__,
18752 MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac),
18753 tdlsLinkEstablishParams.uapsdQueues,
18754 tdlsLinkEstablishParams.qos,
18755 tdlsLinkEstablishParams.maxSp,
18756 tdlsLinkEstablishParams.isBufSta,
18757 tdlsLinkEstablishParams.isOffChannelSupported,
18758 tdlsLinkEstablishParams.isResponder,
18759 pTdlsPeer->staId);
18760
18761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18762 "%s: StaDesc ucSTAId: %d ucQosEnabled: %d",
18763 __func__,
18764 staDesc.ucSTAId,
18765 staDesc.ucQosEnabled);
18766
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018767 ret = WLANTL_UpdateTdlsSTAClient(
18768 pHddCtx->pvosContext,
18769 &staDesc);
18770 if (ret != VOS_STATUS_SUCCESS) {
18771 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
18772 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053018773
Gopichand Nakkala471708b2013-06-04 20:03:01 +053018774 /* Mark TDLS client Authenticated .*/
18775 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
18776 pTdlsPeer->staId,
18777 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018778 if (VOS_STATUS_SUCCESS == status)
18779 {
Hoonki Lee14621352013-04-16 17:51:19 -070018780 if (pTdlsPeer->is_responder == 0)
18781 {
18782 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018783 tdlsConnInfo_t *tdlsInfo;
18784
18785 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
18786
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053018787 if (!vos_timer_is_initialized(
18788 &pTdlsPeer->initiatorWaitTimeoutTimer))
18789 {
18790 /* Initialize initiator wait callback */
18791 vos_timer_init(
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018792 &pTdlsPeer->initiatorWaitTimeoutTimer,
18793 VOS_TIMER_TYPE_SW,
18794 wlan_hdd_tdls_initiator_wait_cb,
18795 tdlsInfo);
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053018796 }
Hoonki Lee14621352013-04-16 17:51:19 -070018797 wlan_hdd_tdls_timer_restart(pAdapter,
18798 &pTdlsPeer->initiatorWaitTimeoutTimer,
18799 WAIT_TIME_TDLS_INITIATOR);
18800 /* suspend initiator TX until it receives direct packet from the
18801 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018802 ret = WLANTL_SuspendDataTx(
18803 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18804 &staId, NULL);
18805 if (ret != VOS_STATUS_SUCCESS) {
18806 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
18807 }
Hoonki Lee14621352013-04-16 17:51:19 -070018808 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018809
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018810 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018811 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018812 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018813 suppChannelLen =
18814 tdlsLinkEstablishParams.supportedChannelsLen;
18815
18816 if ((suppChannelLen > 0) &&
18817 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
18818 {
18819 tANI_U8 suppPeerChannel = 0;
18820 int i = 0;
18821 for (i = 0U; i < suppChannelLen; i++)
18822 {
18823 suppPeerChannel =
18824 tdlsLinkEstablishParams.supportedChannels[i];
18825
18826 pTdlsPeer->isOffChannelSupported = FALSE;
18827 if (suppPeerChannel ==
18828 pTdlsPeer->peerParams.channel)
18829 {
18830 pTdlsPeer->isOffChannelSupported = TRUE;
18831 break;
18832 }
18833 }
18834 }
18835 else
18836 {
18837 pTdlsPeer->isOffChannelSupported = FALSE;
18838 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018839 }
18840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18841 "%s: TDLS channel switch request for channel "
18842 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018843 "%d isOffChannelSupported %d", __func__,
18844 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018845 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018846 suppChannelLen,
18847 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018848
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018849 /* TDLS Off Channel, Enable tdls channel switch,
18850 when their is only one tdls link and it supports */
18851 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18852 if ((numCurrTdlsPeers == 1) &&
18853 (TRUE == pTdlsPeer->isOffChannelSupported) &&
18854 (TRUE == pTdlsPeer->isOffChannelConfigured))
18855 {
18856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18857 "%s: Send TDLS channel switch request for channel %d",
18858 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018859
18860 pTdlsPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018861 vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr));
18862 channel = pTdlsPeer->peerParams.channel;
18863
18864 mutex_unlock(&pHddCtx->tdls_lock);
18865
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018866 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
18867 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018868 peerMac,
18869 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018870 TDLS_OFF_CHANNEL_BW_OFFSET,
18871 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018872 if (ret != VOS_STATUS_SUCCESS) {
18873 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
18874 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018875 }
18876 else
18877 {
18878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18879 "%s: TDLS channel switch request not sent"
18880 " numCurrTdlsPeers %d "
18881 "isOffChannelSupported %d "
18882 "isOffChannelConfigured %d",
18883 __func__, numCurrTdlsPeers,
18884 pTdlsPeer->isOffChannelSupported,
18885 pTdlsPeer->isOffChannelConfigured);
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018886 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018887 }
18888
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018889 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018890 else
18891 mutex_unlock(&pHddCtx->tdls_lock);
18892
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018893 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018894
18895 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018896 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
18897 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018898 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018899 int ac;
18900 uint8 ucAc[4] = { WLANTL_AC_VO,
18901 WLANTL_AC_VI,
18902 WLANTL_AC_BK,
18903 WLANTL_AC_BE };
18904 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
18905 for(ac=0; ac < 4; ac++)
18906 {
18907 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18908 pTdlsPeer->staId, ucAc[ac],
18909 tlTid[ac], tlTid[ac], 0, 0,
18910 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018911 if (status != VOS_STATUS_SUCCESS) {
18912 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
18913 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018914 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018915 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018916 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018917
Bhargav Shah66896792015-10-01 18:17:37 +053018918 /* stop TCP delack timer if TDLS is enable */
18919 set_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
18920 hdd_manage_delack_timer(pHddCtx);
Abhishek Singh67fa6bc2016-01-05 15:57:19 +053018921 hdd_wlan_tdls_enable_link_event(peer,
18922 pTdlsPeer->isOffChannelSupported,
18923 pTdlsPeer->isOffChannelConfigured,
18924 pTdlsPeer->isOffChannelEstablished);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018925 }
18926 break;
18927 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080018928 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018929 tANI_U16 numCurrTdlsPeers = 0;
18930 hddTdlsPeer_t *connPeer = NULL;
18931
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18933 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
18934 __func__, MAC_ADDR_ARRAY(peer));
18935
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018936 mutex_lock(&pHddCtx->tdls_lock);
18937 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018938
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018939
Sunil Dutt41de4e22013-11-14 18:09:02 +053018940 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018941 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018942 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18943 " (oper %d) not exsting. ignored",
18944 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18945 return -EINVAL;
18946 }
18947
18948 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18949 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18950 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18951 "NL80211_TDLS_DISABLE_LINK");
18952
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018953 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080018954 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018955 long status;
18956
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018957 /* set tdls off channel status to false for this peer */
18958 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053018959 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18960 eTDLS_LINK_TEARING,
18961 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
18962 eTDLS_LINK_UNSPECIFIED:
18963 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018964 mutex_unlock(&pHddCtx->tdls_lock);
18965
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018966 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
18967
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018968 status = sme_DeleteTdlsPeerSta(
18969 WLAN_HDD_GET_HAL_CTX(pAdapter),
18970 pAdapter->sessionId, peer );
18971 if (status != VOS_STATUS_SUCCESS) {
18972 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
18973 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018974
18975 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
18976 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018977
18978 mutex_lock(&pHddCtx->tdls_lock);
18979 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18980 if ( NULL == pTdlsPeer ) {
18981 mutex_unlock(&pHddCtx->tdls_lock);
18982 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18983 " peer was freed in other context",
18984 __func__, MAC_ADDR_ARRAY(peer));
18985 return -EINVAL;
18986 }
18987
Atul Mittal271a7652014-09-12 13:18:22 +053018988 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053018989 eTDLS_LINK_IDLE,
18990 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018991 mutex_unlock(&pHddCtx->tdls_lock);
18992
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018993 if (status <= 0)
18994 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18996 "%s: Del station failed status %ld",
18997 __func__, status);
18998 return -EPERM;
18999 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019000
19001 /* TDLS Off Channel, Enable tdls channel switch,
19002 when their is only one tdls link and it supports */
19003 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
19004 if (numCurrTdlsPeers == 1)
19005 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019006 tSirMacAddr peerMac;
19007 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053019008
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019009 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019010 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053019011
19012 if (connPeer == NULL) {
19013 mutex_unlock(&pHddCtx->tdls_lock);
19014 hddLog(VOS_TRACE_LEVEL_ERROR,
19015 "%s connPeer is NULL", __func__);
19016 return -EINVAL;
19017 }
19018
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019019 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
19020 channel = connPeer->peerParams.channel;
19021
19022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19023 "%s: TDLS channel switch "
19024 "isOffChannelSupported %d "
19025 "isOffChannelConfigured %d "
19026 "isOffChannelEstablished %d",
19027 __func__,
19028 (connPeer ? connPeer->isOffChannelSupported : -1),
19029 (connPeer ? connPeer->isOffChannelConfigured : -1),
19030 (connPeer ? connPeer->isOffChannelEstablished : -1));
19031
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019032 if ((connPeer) &&
19033 (connPeer->isOffChannelSupported == TRUE) &&
19034 (connPeer->isOffChannelConfigured == TRUE))
19035 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053019036 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019037 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019038 status = sme_SendTdlsChanSwitchReq(
19039 WLAN_HDD_GET_HAL_CTX(pAdapter),
19040 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019041 peerMac,
19042 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019043 TDLS_OFF_CHANNEL_BW_OFFSET,
19044 TDLS_CHANNEL_SWITCH_ENABLE);
19045 if (status != VOS_STATUS_SUCCESS) {
19046 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
19047 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019048 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019049 else
19050 mutex_unlock(&pHddCtx->tdls_lock);
19051 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019052 else
19053 {
19054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19055 "%s: TDLS channel switch request not sent "
19056 "numCurrTdlsPeers %d ",
19057 __func__, numCurrTdlsPeers);
19058 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080019059 }
19060 else
19061 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019062 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19064 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080019065 }
Bhargav Shah66896792015-10-01 18:17:37 +053019066 if (numCurrTdlsPeers == 0) {
19067 /* start TCP delack timer if TDLS is disable */
19068 clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
19069 hdd_manage_delack_timer(pHddCtx);
19070 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080019071 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019072 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019073 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053019074 {
Atul Mittal115287b2014-07-08 13:26:33 +053019075 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019076
Atul Mittal115287b2014-07-08 13:26:33 +053019077 if (0 != status)
19078 {
19079 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019080 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053019081 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053019082 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053019083 break;
19084 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019085 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053019086 {
Atul Mittal115287b2014-07-08 13:26:33 +053019087 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
19088 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019089 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053019090 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019091
Atul Mittal115287b2014-07-08 13:26:33 +053019092 if (0 != status)
19093 {
19094 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019095 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053019096 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053019097 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053019098 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053019099 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019100 case NL80211_TDLS_DISCOVERY_REQ:
19101 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019103 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019104 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019105 return -ENOTSUPP;
19106 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19108 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019109 return -ENOTSUPP;
19110 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019111
19112 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019113 return 0;
19114}
Chilam NG571c65a2013-01-19 12:27:36 +053019115
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019116static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019117#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
19118 const u8 *peer,
19119#else
19120 u8 *peer,
19121#endif
19122 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019123{
19124 int ret;
19125
19126 vos_ssr_protect(__func__);
19127 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
19128 vos_ssr_unprotect(__func__);
19129
19130 return ret;
19131}
19132
Chilam NG571c65a2013-01-19 12:27:36 +053019133int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
19134 struct net_device *dev, u8 *peer)
19135{
Arif Hussaina7c8e412013-11-20 11:06:42 -080019136 hddLog(VOS_TRACE_LEVEL_INFO,
19137 "tdls send discover req: "MAC_ADDRESS_STR,
19138 MAC_ADDR_ARRAY(peer));
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053019139#if TDLS_MGMT_VERSION2
19140 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19141 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19142#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019143#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
19144 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19145 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
19146#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
19147 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19148 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19149#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
19150 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19151 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19152#else
Chilam NG571c65a2013-01-19 12:27:36 +053019153 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19154 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053019155#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019156#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053019157}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019158#endif
19159
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019160#ifdef WLAN_FEATURE_GTK_OFFLOAD
19161/*
19162 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
19163 * Callback rountine called upon receiving response for
19164 * get offload info
19165 */
19166void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
19167 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
19168{
19169
19170 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019171 tANI_U8 tempReplayCounter[8];
19172 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019173
19174 ENTER();
19175
19176 if (NULL == pAdapter)
19177 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053019178 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019179 "%s: HDD adapter is Null", __func__);
19180 return ;
19181 }
19182
19183 if (NULL == pGtkOffloadGetInfoRsp)
19184 {
19185 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19186 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
19187 return ;
19188 }
19189
19190 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
19191 {
19192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19193 "%s: wlan Failed to get replay counter value",
19194 __func__);
19195 return ;
19196 }
19197
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019198 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19199 /* Update replay counter */
19200 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
19201 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
19202
19203 {
19204 /* changing from little to big endian since supplicant
19205 * works on big endian format
19206 */
19207 int i;
19208 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
19209
19210 for (i = 0; i < 8; i++)
19211 {
19212 tempReplayCounter[7-i] = (tANI_U8)p[i];
19213 }
19214 }
19215
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019216 /* Update replay counter to NL */
19217 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019218 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019219}
19220
19221/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019222 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019223 * This function is used to offload GTK rekeying job to the firmware.
19224 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019225int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019226 struct cfg80211_gtk_rekey_data *data)
19227{
19228 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19229 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
19230 hdd_station_ctx_t *pHddStaCtx;
19231 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019232 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019233 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019234 eHalStatus status = eHAL_STATUS_FAILURE;
19235
19236 ENTER();
19237
19238 if (NULL == pAdapter)
19239 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019240 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019241 "%s: HDD adapter is Null", __func__);
19242 return -ENODEV;
19243 }
19244
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019245 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19246 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
19247 pAdapter->sessionId, pAdapter->device_mode));
19248
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019249 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019250 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019251 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019252 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019253 }
19254
19255 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19256 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
19257 if (NULL == hHal)
19258 {
19259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19260 "%s: HAL context is Null!!!", __func__);
19261 return -EAGAIN;
19262 }
19263
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019264 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
19265 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
19266 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
19267 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019268 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019269 {
19270 /* changing from big to little endian since driver
19271 * works on little endian format
19272 */
19273 tANI_U8 *p =
19274 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
19275 int i;
19276
19277 for (i = 0; i < 8; i++)
19278 {
19279 p[7-i] = data->replay_ctr[i];
19280 }
19281 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019282
19283 if (TRUE == pHddCtx->hdd_wlan_suspended)
19284 {
19285 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019286 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
19287 sizeof (tSirGtkOffloadParams));
19288 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019289 pAdapter->sessionId);
19290
19291 if (eHAL_STATUS_SUCCESS != status)
19292 {
19293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19294 "%s: sme_SetGTKOffload failed, returned %d",
19295 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053019296
19297 /* Need to clear any trace of key value in the memory.
19298 * Thus zero out the memory even though it is local
19299 * variable.
19300 */
19301 vos_mem_zero(&hddGtkOffloadReqParams,
19302 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019303 return status;
19304 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19306 "%s: sme_SetGTKOffload successfull", __func__);
19307 }
19308 else
19309 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19311 "%s: wlan not suspended GTKOffload request is stored",
19312 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019313 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019314
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053019315 /* Need to clear any trace of key value in the memory.
19316 * Thus zero out the memory even though it is local
19317 * variable.
19318 */
19319 vos_mem_zero(&hddGtkOffloadReqParams,
19320 sizeof(hddGtkOffloadReqParams));
19321
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019322 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019323 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019324}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019325
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019326int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
19327 struct cfg80211_gtk_rekey_data *data)
19328{
19329 int ret;
19330
19331 vos_ssr_protect(__func__);
19332 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
19333 vos_ssr_unprotect(__func__);
19334
19335 return ret;
19336}
19337#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019338/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019339 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019340 * This function is used to set access control policy
19341 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019342static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
19343 struct net_device *dev,
19344 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019345{
19346 int i;
19347 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19348 hdd_hostapd_state_t *pHostapdState;
19349 tsap_Config_t *pConfig;
19350 v_CONTEXT_t pVosContext = NULL;
19351 hdd_context_t *pHddCtx;
19352 int status;
19353
19354 ENTER();
19355
19356 if (NULL == pAdapter)
19357 {
19358 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19359 "%s: HDD adapter is Null", __func__);
19360 return -ENODEV;
19361 }
19362
19363 if (NULL == params)
19364 {
19365 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19366 "%s: params is Null", __func__);
19367 return -EINVAL;
19368 }
19369
19370 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19371 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019372 if (0 != status)
19373 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019374 return status;
19375 }
19376
19377 pVosContext = pHddCtx->pvosContext;
19378 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
19379
19380 if (NULL == pHostapdState)
19381 {
19382 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19383 "%s: pHostapdState is Null", __func__);
19384 return -EINVAL;
19385 }
19386
19387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
19388 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019389 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19390 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
19391 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019392
19393 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
19394 {
19395 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
19396
19397 /* default value */
19398 pConfig->num_accept_mac = 0;
19399 pConfig->num_deny_mac = 0;
19400
19401 /**
19402 * access control policy
19403 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
19404 * listed in hostapd.deny file.
19405 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
19406 * listed in hostapd.accept file.
19407 */
19408 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
19409 {
19410 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
19411 }
19412 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
19413 {
19414 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
19415 }
19416 else
19417 {
19418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19419 "%s:Acl Policy : %d is not supported",
19420 __func__, params->acl_policy);
19421 return -ENOTSUPP;
19422 }
19423
19424 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
19425 {
19426 pConfig->num_accept_mac = params->n_acl_entries;
19427 for (i = 0; i < params->n_acl_entries; i++)
19428 {
19429 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19430 "** Add ACL MAC entry %i in WhiletList :"
19431 MAC_ADDRESS_STR, i,
19432 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
19433
19434 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
19435 sizeof(qcmacaddr));
19436 }
19437 }
19438 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
19439 {
19440 pConfig->num_deny_mac = params->n_acl_entries;
19441 for (i = 0; i < params->n_acl_entries; i++)
19442 {
19443 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19444 "** Add ACL MAC entry %i in BlackList :"
19445 MAC_ADDRESS_STR, i,
19446 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
19447
19448 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
19449 sizeof(qcmacaddr));
19450 }
19451 }
19452
19453 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
19454 {
19455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19456 "%s: SAP Set Mac Acl fail", __func__);
19457 return -EINVAL;
19458 }
19459 }
19460 else
19461 {
19462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053019463 "%s: Invalid device_mode = %s (%d)",
19464 __func__, hdd_device_modetoString(pAdapter->device_mode),
19465 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019466 return -EINVAL;
19467 }
19468
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019469 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019470 return 0;
19471}
19472
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019473static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
19474 struct net_device *dev,
19475 const struct cfg80211_acl_data *params)
19476{
19477 int ret;
19478 vos_ssr_protect(__func__);
19479 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
19480 vos_ssr_unprotect(__func__);
19481
19482 return ret;
19483}
19484
Leo Chang9056f462013-08-01 19:21:11 -070019485#ifdef WLAN_NL80211_TESTMODE
19486#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070019487void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070019488(
19489 void *pAdapter,
19490 void *indCont
19491)
19492{
Leo Changd9df8aa2013-09-26 13:32:26 -070019493 tSirLPHBInd *lphbInd;
19494 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053019495 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070019496
19497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070019498 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070019499
c_hpothu73f35e62014-04-18 13:40:08 +053019500 if (pAdapter == NULL)
19501 {
19502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19503 "%s: pAdapter is NULL\n",__func__);
19504 return;
19505 }
19506
Leo Chang9056f462013-08-01 19:21:11 -070019507 if (NULL == indCont)
19508 {
19509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070019510 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070019511 return;
19512 }
19513
c_hpothu73f35e62014-04-18 13:40:08 +053019514 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070019515 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070019516 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053019517 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070019518 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070019519 GFP_ATOMIC);
19520 if (!skb)
19521 {
19522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19523 "LPHB timeout, NL buffer alloc fail");
19524 return;
19525 }
19526
Leo Changac3ba772013-10-07 09:47:04 -070019527 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070019528 {
19529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19530 "WLAN_HDD_TM_ATTR_CMD put fail");
19531 goto nla_put_failure;
19532 }
Leo Changac3ba772013-10-07 09:47:04 -070019533 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070019534 {
19535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19536 "WLAN_HDD_TM_ATTR_TYPE put fail");
19537 goto nla_put_failure;
19538 }
Leo Changac3ba772013-10-07 09:47:04 -070019539 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070019540 sizeof(tSirLPHBInd), lphbInd))
19541 {
19542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19543 "WLAN_HDD_TM_ATTR_DATA put fail");
19544 goto nla_put_failure;
19545 }
Leo Chang9056f462013-08-01 19:21:11 -070019546 cfg80211_testmode_event(skb, GFP_ATOMIC);
19547 return;
19548
19549nla_put_failure:
19550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19551 "NLA Put fail");
19552 kfree_skb(skb);
19553
19554 return;
19555}
19556#endif /* FEATURE_WLAN_LPHB */
19557
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019558static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070019559{
19560 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
19561 int err = 0;
19562#ifdef FEATURE_WLAN_LPHB
19563 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070019564 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019565
19566 ENTER();
19567
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019568 err = wlan_hdd_validate_context(pHddCtx);
19569 if (0 != err)
19570 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019571 return err;
19572 }
Leo Chang9056f462013-08-01 19:21:11 -070019573#endif /* FEATURE_WLAN_LPHB */
19574
19575 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
19576 if (err)
19577 {
19578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19579 "%s Testmode INV ATTR", __func__);
19580 return err;
19581 }
19582
19583 if (!tb[WLAN_HDD_TM_ATTR_CMD])
19584 {
19585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19586 "%s Testmode INV CMD", __func__);
19587 return -EINVAL;
19588 }
19589
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019590 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19591 TRACE_CODE_HDD_CFG80211_TESTMODE,
19592 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070019593 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
19594 {
19595#ifdef FEATURE_WLAN_LPHB
19596 /* Low Power Heartbeat configuration request */
19597 case WLAN_HDD_TM_CMD_WLAN_HB:
19598 {
19599 int buf_len;
19600 void *buf;
19601 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080019602 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070019603
19604 if (!tb[WLAN_HDD_TM_ATTR_DATA])
19605 {
19606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19607 "%s Testmode INV DATA", __func__);
19608 return -EINVAL;
19609 }
19610
19611 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
19612 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080019613
Manjeet Singh3c577442017-02-10 19:03:38 +053019614 if (buf_len > sizeof(*hb_params)) {
19615 hddLog(LOGE, FL("buf_len=%d exceeded hb_params size limit"),
19616 buf_len);
19617 return -ERANGE;
19618 }
19619
Amar Singhal05852702014-02-04 14:40:00 -080019620 hb_params_temp =(tSirLPHBReq *)buf;
19621 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
19622 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
19623 return -EINVAL;
19624
Leo Chang9056f462013-08-01 19:21:11 -070019625 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
19626 if (NULL == hb_params)
19627 {
19628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19629 "%s Request Buffer Alloc Fail", __func__);
19630 return -EINVAL;
19631 }
19632
19633 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070019634 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
19635 hb_params,
19636 wlan_hdd_cfg80211_lphb_ind_handler);
19637 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070019638 {
Leo Changd9df8aa2013-09-26 13:32:26 -070019639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19640 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070019641 vos_mem_free(hb_params);
19642 }
Leo Chang9056f462013-08-01 19:21:11 -070019643 return 0;
19644 }
19645#endif /* FEATURE_WLAN_LPHB */
19646 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19648 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070019649 return -EOPNOTSUPP;
19650 }
19651
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019652 EXIT();
19653 return err;
Leo Chang9056f462013-08-01 19:21:11 -070019654}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019655
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053019656static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
19657#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
19658 struct wireless_dev *wdev,
19659#endif
19660 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019661{
19662 int ret;
19663
19664 vos_ssr_protect(__func__);
19665 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
19666 vos_ssr_unprotect(__func__);
19667
19668 return ret;
19669}
Leo Chang9056f462013-08-01 19:21:11 -070019670#endif /* CONFIG_NL80211_TESTMODE */
19671
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019672extern void hdd_set_wlan_suspend_mode(bool suspend);
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019673static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019674 struct net_device *dev,
19675 int idx, struct survey_info *survey)
19676{
19677 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19678 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053019679 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019680 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053019681 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019682 v_S7_t snr,rssi;
19683 int status, i, j, filled = 0;
19684
19685 ENTER();
19686
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019687 if (NULL == pAdapter)
19688 {
19689 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19690 "%s: HDD adapter is Null", __func__);
19691 return -ENODEV;
19692 }
19693
19694 if (NULL == wiphy)
19695 {
19696 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19697 "%s: wiphy is Null", __func__);
19698 return -ENODEV;
19699 }
19700
19701 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19702 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019703 if (0 != status)
19704 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019705 return status;
19706 }
19707
Mihir Sheted9072e02013-08-21 17:02:29 +053019708 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19709
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019710 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053019711 0 != pAdapter->survey_idx ||
19712 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019713 {
19714 /* The survey dump ops when implemented completely is expected to
19715 * return a survey of all channels and the ops is called by the
19716 * kernel with incremental values of the argument 'idx' till it
19717 * returns -ENONET. But we can only support the survey for the
19718 * operating channel for now. survey_idx is used to track
19719 * that the ops is called only once and then return -ENONET for
19720 * the next iteration
19721 */
19722 pAdapter->survey_idx = 0;
19723 return -ENONET;
19724 }
19725
Mukul Sharma9d5233b2015-06-11 20:28:20 +053019726 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
19727 {
19728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19729 "%s: Roaming in progress, hence return ", __func__);
19730 return -ENONET;
19731 }
19732
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019733 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19734
19735 wlan_hdd_get_snr(pAdapter, &snr);
19736 wlan_hdd_get_rssi(pAdapter, &rssi);
19737
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019738 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19739 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
19740 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019741 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
19742 hdd_wlan_get_freq(channel, &freq);
19743
19744
19745 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
19746 {
19747 if (NULL == wiphy->bands[i])
19748 {
19749 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
19750 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
19751 continue;
19752 }
19753
19754 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
19755 {
19756 struct ieee80211_supported_band *band = wiphy->bands[i];
19757
19758 if (band->channels[j].center_freq == (v_U16_t)freq)
19759 {
19760 survey->channel = &band->channels[j];
19761 /* The Rx BDs contain SNR values in dB for the received frames
19762 * while the supplicant expects noise. So we calculate and
19763 * return the value of noise (dBm)
19764 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
19765 */
19766 survey->noise = rssi - snr;
19767 survey->filled = SURVEY_INFO_NOISE_DBM;
19768 filled = 1;
19769 }
19770 }
19771 }
19772
19773 if (filled)
19774 pAdapter->survey_idx = 1;
19775 else
19776 {
19777 pAdapter->survey_idx = 0;
19778 return -ENONET;
19779 }
19780
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019781 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019782 return 0;
19783}
19784
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019785static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
19786 struct net_device *dev,
19787 int idx, struct survey_info *survey)
19788{
19789 int ret;
19790
19791 vos_ssr_protect(__func__);
19792 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
19793 vos_ssr_unprotect(__func__);
19794
19795 return ret;
19796}
19797
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019798/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019799 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019800 * this is called when cfg80211 driver resume
19801 * driver updates latest sched_scan scan result(if any) to cfg80211 database
19802 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019803int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019804{
19805 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
19806 hdd_adapter_t *pAdapter;
19807 hdd_adapter_list_node_t *pAdapterNode, *pNext;
19808 VOS_STATUS status = VOS_STATUS_SUCCESS;
19809
19810 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019811
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019812 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019813 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019814 return 0;
19815 }
19816
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019817 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
19818 NO_SESSION, pHddCtx->isWiphySuspended));
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019819
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053019820 if (pHddCtx->is_ap_mode_wow_supported)
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019821 {
19822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19823 "%s: Resume SoftAP", __func__);
19824 hdd_set_wlan_suspend_mode(false);
19825 }
19826
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019827 spin_lock(&pHddCtx->schedScan_lock);
19828 pHddCtx->isWiphySuspended = FALSE;
19829 if (TRUE != pHddCtx->isSchedScanUpdatePending)
19830 {
19831 spin_unlock(&pHddCtx->schedScan_lock);
19832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19833 "%s: Return resume is not due to PNO indication", __func__);
19834 return 0;
19835 }
19836 // Reset flag to avoid updatating cfg80211 data old results again
19837 pHddCtx->isSchedScanUpdatePending = FALSE;
19838 spin_unlock(&pHddCtx->schedScan_lock);
19839
19840 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
19841
19842 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
19843 {
19844 pAdapter = pAdapterNode->pAdapter;
19845 if ( (NULL != pAdapter) &&
19846 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
19847 {
19848 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019849 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
19851 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019852 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019853 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019854 {
19855 /* Acquire wakelock to handle the case where APP's tries to
19856 * suspend immediately after updating the scan results. Whis
19857 * results in app's is in suspended state and not able to
19858 * process the connect request to AP
19859 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053019860 hdd_prevent_suspend_timeout(2000,
19861 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019862 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019863 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019864
19865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19866 "%s : cfg80211 scan result database updated", __func__);
19867
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019868 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019869 return 0;
19870
19871 }
19872 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
19873 pAdapterNode = pNext;
19874 }
19875
19876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19877 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019878 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019879 return 0;
19880}
19881
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019882int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
19883{
19884 int ret;
19885
19886 vos_ssr_protect(__func__);
19887 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
19888 vos_ssr_unprotect(__func__);
19889
19890 return ret;
19891}
19892
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019893/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019894 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019895 * this is called when cfg80211 driver suspends
19896 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019897int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019898 struct cfg80211_wowlan *wow)
19899{
19900 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019901 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019902
19903 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019904
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019905 ret = wlan_hdd_validate_context(pHddCtx);
19906 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019907 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019908 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019909 }
19910
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053019911 if (pHddCtx->is_ap_mode_wow_supported) {
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19913 "%s: Suspend SoftAP", __func__);
19914 hdd_set_wlan_suspend_mode(true);
19915 }
19916
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019917
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019918 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19919 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
19920 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019921 pHddCtx->isWiphySuspended = TRUE;
19922
19923 EXIT();
19924
19925 return 0;
19926}
19927
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019928int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
19929 struct cfg80211_wowlan *wow)
19930{
19931 int ret;
19932
19933 vos_ssr_protect(__func__);
19934 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
19935 vos_ssr_unprotect(__func__);
19936
19937 return ret;
19938}
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019939
19940#ifdef FEATURE_OEM_DATA_SUPPORT
19941static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019942 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019943{
19944 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19945
19946 ENTER();
19947
19948 if (wlan_hdd_validate_context(pHddCtx)) {
19949 return;
19950 }
19951 if (!pMsg)
19952 {
19953 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
19954 return;
19955 }
19956
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019957 send_oem_data_rsp_msg(evLen, pMsg);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019958
19959 EXIT();
19960 return;
19961
19962}
19963
19964void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019965 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019966{
19967 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19968
19969 ENTER();
19970
19971 if (wlan_hdd_validate_context(pHddCtx)) {
19972 return;
19973 }
19974
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019975 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d) evLen %d"), evType, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019976
19977 switch(evType) {
19978 case SIR_HAL_START_OEM_DATA_RSP_IND_NEW:
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019979 wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019980 break;
19981 default:
19982 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
19983 break;
19984 }
19985 EXIT();
19986}
19987#endif
19988
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019989#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
19990 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019991/**
19992 * __wlan_hdd_cfg80211_abort_scan() - cfg80211 abort scan api
19993 * @wiphy: Pointer to wiphy
19994 * @wdev: Pointer to wireless device structure
19995 *
19996 * This function is used to abort an ongoing scan
19997 *
19998 * Return: None
19999 */
20000static void __wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
20001 struct wireless_dev *wdev)
20002{
20003 struct net_device *dev = wdev->netdev;
20004 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
20005 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
20006 int ret;
20007
20008 ENTER();
20009
20010 if (NULL == adapter) {
20011 hddLog(VOS_TRACE_LEVEL_FATAL, FL("HDD adapter is NULL"));
20012 return;
20013 }
20014
20015 ret = wlan_hdd_validate_context(hdd_ctx);
20016 if (0 != ret)
20017 return;
20018
20019 wlan_hdd_scan_abort(adapter);
20020
20021 return;
20022}
20023
20024/**
20025 * wlan_hdd_cfg80211_abort_scan - cfg80211 abort scan api
20026 * @wiphy: Pointer to wiphy
20027 * @wdev: Pointer to wireless device structure
20028 *
20029 * Return: None
20030 */
20031void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
20032 struct wireless_dev *wdev)
20033{
20034 vos_ssr_protect(__func__);
20035 __wlan_hdd_cfg80211_abort_scan(wiphy, wdev);
20036 vos_ssr_unprotect(__func__);
20037
20038 return;
20039}
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020040#endif
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053020041
Jeff Johnson295189b2012-06-20 16:38:30 -070020042/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053020043static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070020044{
20045 .add_virtual_intf = wlan_hdd_add_virtual_intf,
20046 .del_virtual_intf = wlan_hdd_del_virtual_intf,
20047 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
20048 .change_station = wlan_hdd_change_station,
20049#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
20050 .add_beacon = wlan_hdd_cfg80211_add_beacon,
20051 .del_beacon = wlan_hdd_cfg80211_del_beacon,
20052 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070020053#else
20054 .start_ap = wlan_hdd_cfg80211_start_ap,
20055 .change_beacon = wlan_hdd_cfg80211_change_beacon,
20056 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070020057#endif
20058 .change_bss = wlan_hdd_cfg80211_change_bss,
20059 .add_key = wlan_hdd_cfg80211_add_key,
20060 .get_key = wlan_hdd_cfg80211_get_key,
20061 .del_key = wlan_hdd_cfg80211_del_key,
20062 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080020063#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070020064 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080020065#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070020066 .scan = wlan_hdd_cfg80211_scan,
20067 .connect = wlan_hdd_cfg80211_connect,
20068 .disconnect = wlan_hdd_cfg80211_disconnect,
20069 .join_ibss = wlan_hdd_cfg80211_join_ibss,
20070 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
20071 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
20072 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
20073 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070020074 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
20075 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053020076 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070020077#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
20078 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
20079 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
20080 .set_txq_params = wlan_hdd_set_txq_params,
20081#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070020082 .get_station = wlan_hdd_cfg80211_get_station,
20083 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
20084 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070020085 .add_station = wlan_hdd_cfg80211_add_station,
20086#ifdef FEATURE_WLAN_LFR
20087 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
20088 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
20089 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
20090#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070020091#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
20092 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
20093#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020094#ifdef FEATURE_WLAN_TDLS
20095 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
20096 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
20097#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053020098#ifdef WLAN_FEATURE_GTK_OFFLOAD
20099 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
20100#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020101#ifdef FEATURE_WLAN_SCAN_PNO
20102 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
20103 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
20104#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020105 .resume = wlan_hdd_cfg80211_resume_wlan,
20106 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020107 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070020108#ifdef WLAN_NL80211_TESTMODE
20109 .testmode_cmd = wlan_hdd_cfg80211_testmode,
20110#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020111 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020112#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
20113 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053020114 .abort_scan = wlan_hdd_cfg80211_abort_scan,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020115#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070020116};
20117