blob: 1d44d6e8f2ec2d56a3e9ff4b1c0080386a385e20 [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] = {
6542 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
6543};
6544
6545/**
6546 * wlan_hdd_cfg80211_get_link_properties() - This function is used to
6547 * get link properties like nss, rate flags and operating frequency for
6548 * the connection with the given peer.
6549 * @wiphy: WIPHY structure pointer
6550 * @wdev: Wireless device structure pointer
6551 * @data: Pointer to the data received
6552 * @data_len: Length of the data received
6553 *
6554 * This function return the above link properties on success.
6555 *
6556 * Return: 0 on success and errno on failure
6557 */
6558static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
6559 struct wireless_dev *wdev,
6560 const void *data,
6561 int data_len)
6562{
6563 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6564 struct net_device *dev = wdev->netdev;
6565 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6566 hdd_station_ctx_t *hdd_sta_ctx;
6567 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1];
6568 uint8_t peer_mac[VOS_MAC_ADDR_SIZE];
6569 uint32_t sta_id;
6570 struct sk_buff *reply_skb;
6571 uint32_t rate_flags = 0;
6572 uint8_t nss;
6573 uint8_t final_rate_flags = 0;
6574 uint32_t freq;
6575 v_CONTEXT_t pVosContext = NULL;
6576 ptSapContext pSapCtx = NULL;
6577
6578 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
6579 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
6580 return -EINVAL;
6581 }
6582
6583 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
6584 qca_wlan_vendor_attr_policy)) {
6585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute"));
6586 return -EINVAL;
6587 }
6588
6589 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6590 hddLog(VOS_TRACE_LEVEL_ERROR,
6591 FL("Attribute peerMac not provided for mode=%d"),
6592 adapter->device_mode);
6593 return -EINVAL;
6594 }
6595
6596 memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6597 sizeof(peer_mac));
6598 hddLog(VOS_TRACE_LEVEL_INFO,
6599 FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"),
6600 MAC_ADDR_ARRAY(peer_mac), adapter->device_mode);
6601
6602 if (adapter->device_mode == WLAN_HDD_INFRA_STATION ||
6603 adapter->device_mode == WLAN_HDD_P2P_CLIENT) {
6604 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6605 if ((hdd_sta_ctx->conn_info.connState !=
6606 eConnectionState_Associated) ||
6607 !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac,
6608 VOS_MAC_ADDRESS_LEN)) {
6609 hddLog(VOS_TRACE_LEVEL_ERROR,
6610 FL("Not Associated to mac "MAC_ADDRESS_STR),
6611 MAC_ADDR_ARRAY(peer_mac));
6612 return -EINVAL;
6613 }
6614
6615 nss = 1; //pronto supports only one spatial stream
6616 freq = vos_chan_to_freq(
6617 hdd_sta_ctx->conn_info.operationChannel);
6618 rate_flags = hdd_sta_ctx->conn_info.rate_flags;
6619
6620 } else if (adapter->device_mode == WLAN_HDD_P2P_GO ||
6621 adapter->device_mode == WLAN_HDD_SOFTAP) {
6622
6623 pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext;
6624 pSapCtx = VOS_GET_SAP_CB(pVosContext);
6625 if(pSapCtx == NULL){
6626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6627 FL("psapCtx is NULL"));
6628 return -ENOENT;
6629 }
6630
6631
6632 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
6633 if (pSapCtx->aStaInfo[sta_id].isUsed &&
6634 !vos_is_macaddr_broadcast(
6635 &pSapCtx->aStaInfo[sta_id].macAddrSTA) &&
6636 vos_mem_compare(
6637 &pSapCtx->aStaInfo[sta_id].macAddrSTA,
6638 peer_mac, VOS_MAC_ADDRESS_LEN))
6639 break;
6640 }
6641
6642 if (WLAN_MAX_STA_COUNT == sta_id) {
6643 hddLog(VOS_TRACE_LEVEL_ERROR,
6644 FL("No active peer with mac="MAC_ADDRESS_STR),
6645 MAC_ADDR_ARRAY(peer_mac));
6646 return -EINVAL;
6647 }
6648
6649 nss = 1; //pronto supports only one spatial stream
6650 freq = vos_chan_to_freq(
6651 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel);
6652 rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags;
6653 } else {
6654 hddLog(VOS_TRACE_LEVEL_ERROR,
6655 FL("Not Associated! with mac"MAC_ADDRESS_STR),
6656 MAC_ADDR_ARRAY(peer_mac));
6657 return -EINVAL;
6658 }
6659
6660 if (!(rate_flags & eHAL_TX_RATE_LEGACY)) {
6661 if (rate_flags & eHAL_TX_RATE_VHT80) {
6662 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
6663 final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
6664 } else if (rate_flags & eHAL_TX_RATE_VHT40) {
6665 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
6666 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6667 } else if (rate_flags & eHAL_TX_RATE_VHT20) {
6668 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
6669 } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) {
6670 final_rate_flags |= RATE_INFO_FLAGS_MCS;
6671 if (rate_flags & eHAL_TX_RATE_HT40)
6672 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6673 }
6674
6675 if (rate_flags & eHAL_TX_RATE_SGI) {
6676 if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS))
6677 final_rate_flags |= RATE_INFO_FLAGS_MCS;
6678 final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI;
6679 }
6680 }
6681
6682 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6683 sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN);
6684
6685 if (NULL == reply_skb) {
6686 hddLog(VOS_TRACE_LEVEL_ERROR,
6687 FL("getLinkProperties: skb alloc failed"));
6688 return -EINVAL;
6689 }
6690
6691 if (nla_put_u8(reply_skb,
6692 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS,
6693 nss) ||
6694 nla_put_u8(reply_skb,
6695 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS,
6696 final_rate_flags) ||
6697 nla_put_u32(reply_skb,
6698 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ,
6699 freq)) {
6700 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed"));
6701 kfree_skb(reply_skb);
6702 return -EINVAL;
6703 }
6704
6705 return cfg80211_vendor_cmd_reply(reply_skb);
6706}
6707
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05306708#define BEACON_MISS_THRESH_2_4 \
6709 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24
6710#define BEACON_MISS_THRESH_5_0 \
6711 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306712#define PARAM_WIFICONFIG_MAX QCA_WLAN_VENDOR_ATTR_CONFIG_MAX
6713#define PARAM_MODULATED_DTIM QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM
6714#define PARAM_STATS_AVG_FACTOR QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR
6715#define PARAM_GUARD_TIME QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05306716#define PARAM_BCNMISS_PENALTY_PARAM_COUNT \
6717 QCA_WLAN_VENDOR_ATTR_CONFIG_PENALIZE_AFTER_NCONS_BEACON_MISS
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306718
6719/**
6720 * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
6721 * vendor command
6722 *
6723 * @wiphy: wiphy device pointer
6724 * @wdev: wireless device pointer
6725 * @data: Vendor command data buffer
6726 * @data_len: Buffer length
6727 *
6728 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
6729 *
6730 * Return: EOK or other error codes.
6731 */
6732
6733static int __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
6734 struct wireless_dev *wdev,
6735 const void *data,
6736 int data_len)
6737{
6738 struct net_device *dev = wdev->netdev;
6739 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6740 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6741 hdd_station_ctx_t *pHddStaCtx;
6742 struct nlattr *tb[PARAM_WIFICONFIG_MAX + 1];
6743 tpSetWifiConfigParams pReq;
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05306744 tModifyRoamParamsReqParams modifyRoamParamsReq;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306745 eHalStatus status;
6746 int ret_val;
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05306747 uint8_t hb_thresh_val;
6748
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306749 static const struct nla_policy policy[PARAM_WIFICONFIG_MAX + 1] = {
6750 [PARAM_STATS_AVG_FACTOR] = { .type = NLA_U16 },
6751 [PARAM_MODULATED_DTIM] = { .type = NLA_U32 },
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05306752 [PARAM_GUARD_TIME] = { .type = NLA_U32},
6753 [PARAM_BCNMISS_PENALTY_PARAM_COUNT] =
6754 { .type = NLA_U32},
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05306755 [BEACON_MISS_THRESH_2_4] = { .type = NLA_U8 },
6756 [BEACON_MISS_THRESH_5_0] = { .type = NLA_U8 },
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306757 };
6758
6759 ENTER();
6760
6761 if (VOS_FTM_MODE == hdd_get_conparam()) {
6762 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6763 return -EINVAL;
6764 }
6765
6766 ret_val = wlan_hdd_validate_context(pHddCtx);
6767 if (ret_val) {
6768 return ret_val;
6769 }
6770
6771 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6772
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306773 if (nla_parse(tb, PARAM_WIFICONFIG_MAX, data, data_len, policy)) {
6774 hddLog(LOGE, FL("Invalid ATTR"));
6775 return -EINVAL;
6776 }
6777
6778 /* check the Wifi Capability */
6779 if ( (TRUE != pHddCtx->cfg_ini->fEnableWifiConfig) &&
6780 (TRUE != sme_IsFeatureSupportedByFW(WIFI_CONFIG)))
6781 {
6782 hddLog(VOS_TRACE_LEVEL_ERROR,
6783 FL("WIFICONFIG not supported by Firmware"));
6784 return -EINVAL;
6785 }
6786
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05306787 if (tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]) {
6788 modifyRoamParamsReq.param = WIFI_CONFIG_SET_BCNMISS_PENALTY_COUNT;
6789 modifyRoamParamsReq.value =
6790 nla_get_u32(tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]);
6791
6792 if (eHAL_STATUS_SUCCESS !=
6793 sme_setBcnMissPenaltyCount(pHddCtx->hHal,&modifyRoamParamsReq))
6794 {
6795 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed", __func__);
6796 ret_val = -EINVAL;
6797 }
6798 return ret_val;
6799 }
6800
6801 /* Moved this down in order to provide provision to set beacon
6802 * miss penalty count irrespective of connection state.
6803 */
6804 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6805 hddLog(LOGE, FL("Not in Connected state!"));
6806 return -ENOTSUPP;
6807 }
6808
6809 pReq = vos_mem_malloc(sizeof(tSetWifiConfigParams));
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306810
6811 if (!pReq) {
6812 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6813 "%s: Not able to allocate memory for tSetWifiConfigParams",
6814 __func__);
6815 return eHAL_STATUS_E_MALLOC_FAILED;
6816 }
6817
6818 vos_mem_set(pReq, sizeof(tSetWifiConfigParams), 0);
6819
6820 pReq->sessionId = pAdapter->sessionId;
6821 vos_mem_copy( &pReq->bssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6822
6823 if (tb[PARAM_MODULATED_DTIM]) {
6824 pReq->paramValue = nla_get_u32(
6825 tb[PARAM_MODULATED_DTIM]);
6826 hddLog(LOG1, FL("Modulated DTIM: pReq->paramValue:%d "),
6827 pReq->paramValue);
Arun Khandavalli876886f2015-11-23 11:42:27 +05306828 pHddCtx->cfg_ini->enableDynamicDTIM = pReq->paramValue;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306829 hdd_set_pwrparams(pHddCtx);
6830 if (BMPS == pmcGetPmcState(pHddCtx->hHal)) {
6831 hddLog( LOG1, FL("WifiConfig: Requesting FullPower!"));
6832
6833 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
6834 iw_full_power_cbfn, pAdapter,
6835 eSME_FULL_PWR_NEEDED_BY_HDD);
6836 }
6837 else
6838 {
6839 hddLog( LOG1, FL("WifiConfig Not in BMPS state"));
6840 }
6841 }
6842
6843 if (tb[PARAM_STATS_AVG_FACTOR]) {
6844 pReq->paramType = WIFI_CONFIG_SET_AVG_STATS_FACTOR;
6845 pReq->paramValue = nla_get_u16(
6846 tb[PARAM_STATS_AVG_FACTOR]);
6847 hddLog(LOG1, FL("AVG_STATS_FACTOR pReq->paramType:%d,pReq->paramValue:%d "),
6848 pReq->paramType, pReq->paramValue);
6849 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
6850
6851 if (eHAL_STATUS_SUCCESS != status)
6852 {
6853 vos_mem_free(pReq);
6854 pReq = NULL;
6855 ret_val = -EPERM;
6856 return ret_val;
6857 }
6858 }
6859
6860
6861 if (tb[PARAM_GUARD_TIME]) {
6862 pReq->paramType = WIFI_CONFIG_SET_GUARD_TIME;
6863 pReq->paramValue = nla_get_u32(
6864 tb[PARAM_GUARD_TIME]);
6865 hddLog(LOG1, FL("GUARD_TIME pReq->paramType:%d,pReq->paramValue:%d "),
6866 pReq->paramType, pReq->paramValue);
6867 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
6868
6869 if (eHAL_STATUS_SUCCESS != status)
6870 {
6871 vos_mem_free(pReq);
6872 pReq = NULL;
6873 ret_val = -EPERM;
6874 return ret_val;
6875 }
6876
6877 }
6878
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05306879 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]) {
6880 hb_thresh_val = nla_get_u8(
6881 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]);
6882
6883 hddLog(LOG1, "WLAN set heartbeat threshold for 2.4Ghz %d",
6884 hb_thresh_val);
6885 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
6886 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
6887 NULL, eANI_BOOLEAN_FALSE);
6888
6889 status = sme_update_hb_threshold(
6890 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
6891 WNI_CFG_HEART_BEAT_THRESHOLD,
6892 hb_thresh_val, eCSR_BAND_24);
6893 if (eHAL_STATUS_SUCCESS != status) {
6894 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
6895 vos_mem_free(pReq);
6896 pReq = NULL;
6897 return -EPERM;
6898 }
6899 }
6900
6901 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]) {
6902 hb_thresh_val = nla_get_u8(
6903 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]);
6904
6905 hddLog(LOG1, "WLAN set heartbeat threshold for 5Ghz %d",
6906 hb_thresh_val);
6907 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
6908 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
6909 NULL, eANI_BOOLEAN_FALSE);
6910
6911 status = sme_update_hb_threshold(
6912 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
6913 WNI_CFG_HEART_BEAT_THRESHOLD,
6914 hb_thresh_val, eCSR_BAND_5G);
6915 if (eHAL_STATUS_SUCCESS != status) {
6916 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
6917 vos_mem_free(pReq);
6918 pReq = NULL;
6919 return -EPERM;
6920 }
6921 }
6922
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05306923 EXIT();
6924 return ret_val;
6925}
6926
6927/**
6928 * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
6929 * vendor command
6930 *
6931 * @wiphy: wiphy device pointer
6932 * @wdev: wireless device pointer
6933 * @data: Vendor command data buffer
6934 * @data_len: Buffer length
6935 *
6936 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
6937 *
6938 * Return: EOK or other error codes.
6939 */
6940static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
6941 struct wireless_dev *wdev,
6942 const void *data,
6943 int data_len)
6944{
6945 int ret;
6946
6947 vos_ssr_protect(__func__);
6948 ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev,
6949 data, data_len);
6950 vos_ssr_unprotect(__func__);
6951
6952 return ret;
6953}
Anurag Chouhan6ee81542017-02-09 18:09:27 +05306954
6955/*
6956 * define short names for the global vendor params
6957 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
6958 */
6959#define STATS_SET_INVALID \
6960 QCA_ATTR_NUD_STATS_SET_INVALID
6961#define STATS_SET_START \
6962 QCA_ATTR_NUD_STATS_SET_START
6963#define STATS_GW_IPV4 \
6964 QCA_ATTR_NUD_STATS_GW_IPV4
6965#define STATS_SET_MAX \
6966 QCA_ATTR_NUD_STATS_SET_MAX
6967
6968const struct nla_policy
6969qca_wlan_vendor_set_nud_stats[STATS_SET_MAX +1] =
6970{
6971 [STATS_SET_START] = {.type = NLA_FLAG },
6972 [STATS_GW_IPV4] = {.type = NLA_U32 },
6973};
6974
6975/**
6976 * hdd_set_nud_stats_cb() - hdd callback api to get status
6977 * @data: pointer to adapter
6978 * @rsp: status
6979 *
6980 * Return: None
6981 */
6982static void hdd_set_nud_stats_cb(void *data, VOS_STATUS rsp)
6983{
6984
6985 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
6986
6987 if (NULL == adapter)
6988 return;
6989
6990 if (VOS_STATUS_SUCCESS == rsp) {
6991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6992 "%s success received STATS_SET_START", __func__);
6993 } else {
6994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6995 "%s STATS_SET_START Failed!!", __func__);
6996 }
6997 return;
6998}
6999
7000/**
7001 * __wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
7002 * @wiphy: pointer to wireless wiphy structure.
7003 * @wdev: pointer to wireless_dev structure.
7004 * @data: pointer to apfind configuration data.
7005 * @data_len: the length in byte of apfind data.
7006 *
7007 * This is called when wlan driver needs to send arp stats to
7008 * firmware.
7009 *
7010 * Return: An error code or 0 on success.
7011 */
7012static int __wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
7013 struct wireless_dev *wdev,
7014 const void *data, int data_len)
7015{
7016 struct nlattr *tb[STATS_SET_MAX + 1];
7017 struct net_device *dev = wdev->netdev;
7018 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7019 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05307020 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307021 setArpStatsParams arp_stats_params;
7022 int err = 0;
7023
7024 ENTER();
7025
7026 err = wlan_hdd_validate_context(hdd_ctx);
7027 if (0 != err)
7028 return err;
7029
7030 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
7031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7032 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
7033 return -EINVAL;
7034 }
7035
7036 err = nla_parse(tb, STATS_SET_MAX, data, data_len,
7037 qca_wlan_vendor_set_nud_stats);
7038 if (err)
7039 {
7040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7041 "%s STATS_SET_START ATTR", __func__);
7042 return err;
7043 }
7044
7045 if (tb[STATS_SET_START])
7046 {
7047 if (!tb[STATS_GW_IPV4]) {
7048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7049 "%s STATS_SET_START CMD", __func__);
7050 return -EINVAL;
7051 }
7052 arp_stats_params.flag = true;
7053 arp_stats_params.ip_addr = nla_get_u32(tb[STATS_GW_IPV4]);
7054 } else {
7055 arp_stats_params.flag = false;
7056 }
Anurag Chouhan630c5562017-03-23 14:51:47 +05307057 if (arp_stats_params.flag)
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7059 "%s STATS_SET_START Cleared!!", __func__);
Anurag Chouhan630c5562017-03-23 14:51:47 +05307060 vos_mem_zero(&adapter->hdd_stats.hddArpStats,
7061 sizeof(adapter->hdd_stats.hddArpStats));
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307062
7063 arp_stats_params.pkt_type = 1; // ARP packet type
7064
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05307065 if (arp_stats_params.flag) {
7066 hdd_ctx->track_arp_ip = arp_stats_params.ip_addr;
7067 WLANTL_SetARPFWDatapath(pVosContext, true);
7068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7069 "%s Set FW in data path for ARP with tgt IP :%d",
7070 __func__, hdd_ctx->track_arp_ip);
7071 }
7072 else {
7073 WLANTL_SetARPFWDatapath(pVosContext, false);
7074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7075 "%s Remove FW from data path", __func__);
7076 }
7077
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307078 arp_stats_params.rsp_cb_fn = hdd_set_nud_stats_cb;
7079 arp_stats_params.data_ctx = adapter;
7080
7081 if (eHAL_STATUS_SUCCESS !=
7082 sme_set_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
7083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7084 "%s STATS_SET_START CMD Failed!!", __func__);
7085 return -EINVAL;
7086 }
7087
7088 EXIT();
7089
7090 return err;
7091}
7092
7093/**
7094 * wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
7095 * @wiphy: pointer to wireless wiphy structure.
7096 * @wdev: pointer to wireless_dev structure.
7097 * @data: pointer to apfind configuration data.
7098 * @data_len: the length in byte of apfind data.
7099 *
7100 * This is called when wlan driver needs to send arp stats to
7101 * firmware.
7102 *
7103 * Return: An error code or 0 on success.
7104 */
7105static int wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
7106 struct wireless_dev *wdev,
7107 const void *data, int data_len)
7108{
7109 int ret;
7110
7111 vos_ssr_protect(__func__);
7112 ret = __wlan_hdd_cfg80211_set_nud_stats(wiphy, wdev, data, data_len);
7113 vos_ssr_unprotect(__func__);
7114
7115 return ret;
7116}
7117#undef STATS_SET_INVALID
7118#undef STATS_SET_START
7119#undef STATS_GW_IPV4
7120#undef STATS_SET_MAX
7121
7122/*
7123 * define short names for the global vendor params
7124 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
7125 */
7126#define STATS_GET_INVALID \
7127 QCA_ATTR_NUD_STATS_SET_INVALID
7128#define COUNT_FROM_NETDEV \
7129 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
7130#define COUNT_TO_LOWER_MAC \
7131 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
7132#define RX_COUNT_BY_LOWER_MAC \
7133 QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
7134#define COUNT_TX_SUCCESS \
7135 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
7136#define RSP_RX_COUNT_BY_LOWER_MAC \
7137 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
7138#define RSP_RX_COUNT_BY_UPPER_MAC \
7139 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
7140#define RSP_COUNT_TO_NETDEV \
7141 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
7142#define RSP_COUNT_OUT_OF_ORDER_DROP \
7143 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
7144#define AP_LINK_ACTIVE \
7145 QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
7146#define AP_LINK_DAD \
7147 QCA_ATTR_NUD_STATS_AP_LINK_DAD
7148#define STATS_GET_MAX \
7149 QCA_ATTR_NUD_STATS_GET_MAX
7150
7151const struct nla_policy
7152qca_wlan_vendor_get_nud_stats[STATS_GET_MAX +1] =
7153{
7154 [COUNT_FROM_NETDEV] = {.type = NLA_U16 },
7155 [COUNT_TO_LOWER_MAC] = {.type = NLA_U16 },
7156 [RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
7157 [COUNT_TX_SUCCESS] = {.type = NLA_U16 },
7158 [RSP_RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
7159 [RSP_RX_COUNT_BY_UPPER_MAC] = {.type = NLA_U16 },
7160 [RSP_COUNT_TO_NETDEV] = {.type = NLA_U16 },
7161 [RSP_COUNT_OUT_OF_ORDER_DROP] = {.type = NLA_U16 },
7162 [AP_LINK_ACTIVE] = {.type = NLA_FLAG },
7163 [AP_LINK_DAD] = {.type = NLA_FLAG },
7164};
7165
7166static void hdd_get_nud_stats_cb(void *data, rsp_stats *rsp)
7167{
7168
7169 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
7170 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
7171 struct hdd_nud_stats_context *context;
7172 int status;
7173
7174 ENTER();
7175
7176 if (NULL == adapter)
7177 return;
7178
7179 status = wlan_hdd_validate_context(hdd_ctx);
7180 if (0 != status) {
7181 return;
7182 }
7183
7184 if (!rsp) {
7185 hddLog(LOGE, FL("data is null"));
7186 return;
7187 }
7188
7189 adapter->hdd_stats.hddArpStats.tx_fw_cnt = rsp->tx_fw_cnt;
7190 adapter->hdd_stats.hddArpStats.rx_fw_cnt = rsp->rx_fw_cnt;
7191 adapter->hdd_stats.hddArpStats.tx_ack_cnt = rsp->tx_ack_cnt;
7192 adapter->dad |= rsp->dad;
7193
7194 spin_lock(&hdd_context_lock);
7195 context = &hdd_ctx->nud_stats_context;
7196 complete(&context->response_event);
7197 spin_unlock(&hdd_context_lock);
7198
7199 return;
7200}
7201static int __wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
7202 struct wireless_dev *wdev,
7203 const void *data, int data_len)
7204{
7205 int err = 0;
7206 unsigned long rc;
7207 struct hdd_nud_stats_context *context;
7208 struct net_device *dev = wdev->netdev;
7209 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7210 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7211 getArpStatsParams arp_stats_params;
7212 struct sk_buff *skb;
7213
7214 ENTER();
7215
7216 err = wlan_hdd_validate_context(hdd_ctx);
7217 if (0 != err)
7218 return err;
7219
7220 arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE;
7221 arp_stats_params.get_rsp_cb_fn = hdd_get_nud_stats_cb;
7222 arp_stats_params.data_ctx = adapter;
7223
7224 spin_lock(&hdd_context_lock);
7225 context = &hdd_ctx->nud_stats_context;
7226 INIT_COMPLETION(context->response_event);
7227 spin_unlock(&hdd_context_lock);
7228
7229 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
7230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7231 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
7232 return -EINVAL;
7233 }
7234
7235 if (eHAL_STATUS_SUCCESS !=
7236 sme_get_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
7237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7238 "%s STATS_SET_START CMD Failed!!", __func__);
7239 return -EINVAL;
7240 }
7241
7242 rc = wait_for_completion_timeout(&context->response_event,
7243 msecs_to_jiffies(WLAN_WAIT_TIME_NUD_STATS));
7244 if (!rc)
7245 {
7246 hddLog(LOGE,
7247 FL("Target response timed out request "));
7248 return -ETIMEDOUT;
7249 }
7250
7251 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7252 WLAN_NUD_STATS_LEN);
7253 if (!skb)
7254 {
7255 hddLog(VOS_TRACE_LEVEL_ERROR,
7256 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
7257 __func__);
7258 return -ENOMEM;
7259 }
7260
7261 if (nla_put_u16(skb, COUNT_FROM_NETDEV,
7262 adapter->hdd_stats.hddArpStats.txCount) ||
7263 nla_put_u16(skb, COUNT_TO_LOWER_MAC,
7264 adapter->hdd_stats.hddArpStats.tx_host_fw_sent) ||
7265 nla_put_u16(skb, RX_COUNT_BY_LOWER_MAC,
7266 adapter->hdd_stats.hddArpStats.tx_fw_cnt) ||
7267 nla_put_u16(skb, COUNT_TX_SUCCESS,
7268 adapter->hdd_stats.hddArpStats.tx_ack_cnt) ||
7269 nla_put_u16(skb, RSP_RX_COUNT_BY_LOWER_MAC,
7270 adapter->hdd_stats.hddArpStats.rx_fw_cnt) ||
7271 nla_put_u16(skb, RSP_RX_COUNT_BY_UPPER_MAC,
7272 adapter->hdd_stats.hddArpStats.rxCount) ||
7273 nla_put_u16(skb, RSP_COUNT_TO_NETDEV,
7274 adapter->hdd_stats.hddArpStats.rxDelivered) ||
7275 nla_put_u16(skb, RSP_COUNT_OUT_OF_ORDER_DROP,
7276 adapter->hdd_stats.hddArpStats.rx_host_drop_reorder)) {
7277 hddLog(LOGE, FL("nla put fail"));
7278 kfree_skb(skb);
7279 return -EINVAL;
7280 }
7281 if (adapter->con_status)
7282 nla_put_flag(skb, AP_LINK_ACTIVE);
7283 if (adapter->dad)
7284 nla_put_flag(skb, AP_LINK_DAD);
7285
7286 cfg80211_vendor_cmd_reply(skb);
7287 return err;
7288}
7289
7290static int wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
7291 struct wireless_dev *wdev,
7292 const void *data, int data_len)
7293{
7294 int ret;
7295
7296 vos_ssr_protect(__func__);
7297 ret = __wlan_hdd_cfg80211_get_nud_stats(wiphy, wdev, data, data_len);
7298 vos_ssr_unprotect(__func__);
7299
7300 return ret;
7301}
7302
7303#undef QCA_ATTR_NUD_STATS_SET_INVALID
7304#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
7305#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
7306#undef QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
7307#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
7308#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
7309#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
7310#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
7311#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
7312#undef QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
7313#undef QCA_ATTR_NUD_STATS_GET_MAX
7314
7315
7316
Kapil Guptaee33bf12016-12-20 18:27:37 +05307317#ifdef WLAN_FEATURE_APFIND
7318/**
7319 * __wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
7320 * @wiphy: pointer to wireless wiphy structure.
7321 * @wdev: pointer to wireless_dev structure.
7322 * @data: pointer to apfind configuration data.
7323 * @data_len: the length in byte of apfind data.
7324 *
7325 * This is called when wlan driver needs to send APFIND configurations to
7326 * firmware.
7327 *
7328 * Return: An error code or 0 on success.
7329 */
7330static int __wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
7331 struct wireless_dev *wdev,
7332 const void *data, int data_len)
7333{
7334 struct sme_ap_find_request_req apfind_req;
7335 VOS_STATUS status;
7336 int ret_val;
7337 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7338
7339 ENTER();
7340
7341 ret_val = wlan_hdd_validate_context(hdd_ctx);
7342 if (ret_val)
7343 return ret_val;
7344
7345 if (VOS_FTM_MODE == hdd_get_conparam()) {
7346 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7347 return -EPERM;
7348 }
7349
7350 apfind_req.request_data_len = data_len;
7351 apfind_req.request_data = data;
7352
7353 status = sme_apfind_set_cmd(&apfind_req);
7354 if (VOS_STATUS_SUCCESS != status) {
7355 ret_val = -EIO;
7356 }
7357 return ret_val;
7358}
7359
7360/**
7361 * wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
7362 * @wiphy: pointer to wireless wiphy structure.
7363 * @wdev: pointer to wireless_dev structure.
7364 * @data: pointer to apfind configuration data.
7365 * @data_len: the length in byte of apfind data.
7366 *
7367 * This is called when wlan driver needs to send APFIND configurations to
7368 * firmware.
7369 *
7370 * Return: An error code or 0 on success.
7371 */
7372static int wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
7373 struct wireless_dev *wdev,
7374 const void *data, int data_len)
7375{
7376 int ret;
7377
7378 vos_ssr_protect(__func__);
7379 ret = __wlan_hdd_cfg80211_apfind_cmd(wiphy, wdev, data, data_len);
7380 vos_ssr_unprotect(__func__);
7381
7382 return ret;
7383}
7384#endif /* WLAN_FEATURE_APFIND */
Sunil Duttc69bccb2014-05-26 21:30:20 +05307385const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
7386{
Mukul Sharma2a271632014-10-13 14:59:01 +05307387 {
7388 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7389 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
7390 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7391 WIPHY_VENDOR_CMD_NEED_NETDEV |
7392 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307393 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05307394 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05307395
7396 {
7397 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7398 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
7399 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7400 WIPHY_VENDOR_CMD_NEED_NETDEV |
7401 WIPHY_VENDOR_CMD_NEED_RUNNING,
7402 .doit = wlan_hdd_cfg80211_nan_request
7403 },
7404
Sunil Duttc69bccb2014-05-26 21:30:20 +05307405#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7406 {
7407 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7408 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
7409 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7410 WIPHY_VENDOR_CMD_NEED_NETDEV |
7411 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307412 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05307413 },
7414
7415 {
7416 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7417 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
7418 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7419 WIPHY_VENDOR_CMD_NEED_NETDEV |
7420 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307421 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05307422 },
7423
7424 {
7425 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7426 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
7427 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7428 WIPHY_VENDOR_CMD_NEED_NETDEV |
7429 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307430 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05307431 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307432#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307433#ifdef WLAN_FEATURE_EXTSCAN
7434 {
7435 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7436 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
7437 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7438 WIPHY_VENDOR_CMD_NEED_NETDEV |
7439 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307440 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05307441 },
7442 {
7443 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7444 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
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_stop
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_GET_VALID_CHANNELS,
7453 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7454 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307455 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05307456 },
7457 {
7458 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7459 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
7460 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7461 WIPHY_VENDOR_CMD_NEED_NETDEV |
7462 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307463 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
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_CACHED_RESULTS,
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_cached_results
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_SET_BSSID_HOTLIST,
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_set_bssid_hotlist
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_RESET_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_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307488 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307489#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307490/*EXT TDLS*/
7491 {
7492 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7493 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
7494 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7495 WIPHY_VENDOR_CMD_NEED_NETDEV |
7496 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307497 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05307498 },
7499 {
7500 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7501 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
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_disable
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_GET_STATUS,
7510 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7511 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307512 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05307513 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05307514 {
7515 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7516 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
7517 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7518 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307519 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05307520 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05307521 {
7522 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7523 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
7524 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7525 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307526 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05307527 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307528 {
7529 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7530 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
7531 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7532 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307533 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307534 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307535 {
7536 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7537 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
7538 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7539 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307540 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307541 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307542 {
7543 .info.vendor_id = QCA_NL80211_VENDOR_ID,
c_manjeecfd1efb2015-09-25 19:32:34 +05307544 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP,
7545 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7546 WIPHY_VENDOR_CMD_NEED_NETDEV |
7547 WIPHY_VENDOR_CMD_NEED_RUNNING,
7548 .doit = wlan_hdd_cfg80211_get_fw_mem_dump
7549 },
7550 {
7551 .info.vendor_id = QCA_NL80211_VENDOR_ID,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307552 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
7553 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7554 WIPHY_VENDOR_CMD_NEED_NETDEV |
7555 WIPHY_VENDOR_CMD_NEED_RUNNING,
7556 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05307557 },
7558 {
7559 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7560 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
7561 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7562 WIPHY_VENDOR_CMD_NEED_NETDEV,
7563 .doit = wlan_hdd_cfg80211_wifi_logger_start
7564 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05307565 {
7566 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7567 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
7568 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7569 WIPHY_VENDOR_CMD_NEED_NETDEV|
7570 WIPHY_VENDOR_CMD_NEED_RUNNING,
7571 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307572 },
7573 {
7574 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7575 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
7576 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7577 WIPHY_VENDOR_CMD_NEED_NETDEV |
7578 WIPHY_VENDOR_CMD_NEED_RUNNING,
7579 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307580 },
7581 {
7582 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7583 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
7584 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7585 WIPHY_VENDOR_CMD_NEED_NETDEV |
7586 WIPHY_VENDOR_CMD_NEED_RUNNING,
7587 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307588 },
7589#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
7590 {
7591 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7592 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
7593 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7594 WIPHY_VENDOR_CMD_NEED_NETDEV |
7595 WIPHY_VENDOR_CMD_NEED_RUNNING,
7596 .doit = wlan_hdd_cfg80211_offloaded_packets
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307597 },
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307598#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307599 {
7600 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7601 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
7602 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7603 WIPHY_VENDOR_CMD_NEED_NETDEV |
7604 WIPHY_VENDOR_CMD_NEED_RUNNING,
7605 .doit = wlan_hdd_cfg80211_get_link_properties
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307606 },
7607 {
7608 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7609 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION,
7610 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7611 WIPHY_VENDOR_CMD_NEED_NETDEV |
7612 WIPHY_VENDOR_CMD_NEED_RUNNING,
7613 .doit = wlan_hdd_cfg80211_wifi_configuration_set
Kapil Guptaee33bf12016-12-20 18:27:37 +05307614 },
7615#ifdef WLAN_FEATURE_APFIND
7616 {
7617 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7618 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_APFIND,
7619 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7620 WIPHY_VENDOR_CMD_NEED_NETDEV,
7621 .doit = wlan_hdd_cfg80211_apfind_cmd
7622 },
7623#endif /* WLAN_FEATURE_APFIND */
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307624 {
7625 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7626 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_SET,
7627 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7628 WIPHY_VENDOR_CMD_NEED_NETDEV |
7629 WIPHY_VENDOR_CMD_NEED_RUNNING,
7630 .doit = wlan_hdd_cfg80211_set_nud_stats
7631 },
7632 {
7633 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7634 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
7635 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7636 WIPHY_VENDOR_CMD_NEED_NETDEV |
7637 WIPHY_VENDOR_CMD_NEED_RUNNING,
7638 .doit = wlan_hdd_cfg80211_get_nud_stats
7639 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307640};
7641
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007642/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05307643static const
7644struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007645{
7646#ifdef FEATURE_WLAN_CH_AVOID
7647 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05307648 .vendor_id = QCA_NL80211_VENDOR_ID,
7649 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007650 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307651#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
7652#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7653 {
7654 /* Index = 1*/
7655 .vendor_id = QCA_NL80211_VENDOR_ID,
7656 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
7657 },
7658 {
7659 /* Index = 2*/
7660 .vendor_id = QCA_NL80211_VENDOR_ID,
7661 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
7662 },
7663 {
7664 /* Index = 3*/
7665 .vendor_id = QCA_NL80211_VENDOR_ID,
7666 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
7667 },
7668 {
7669 /* Index = 4*/
7670 .vendor_id = QCA_NL80211_VENDOR_ID,
7671 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
7672 },
7673 {
7674 /* Index = 5*/
7675 .vendor_id = QCA_NL80211_VENDOR_ID,
7676 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
7677 },
7678 {
7679 /* Index = 6*/
7680 .vendor_id = QCA_NL80211_VENDOR_ID,
7681 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
7682 },
7683#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307684#ifdef WLAN_FEATURE_EXTSCAN
7685 {
7686 .vendor_id = QCA_NL80211_VENDOR_ID,
7687 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
7688 },
7689 {
7690 .vendor_id = QCA_NL80211_VENDOR_ID,
7691 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
7692 },
7693 {
7694 .vendor_id = QCA_NL80211_VENDOR_ID,
7695 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
7696 },
7697 {
7698 .vendor_id = QCA_NL80211_VENDOR_ID,
7699 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
7700 },
7701 {
7702 .vendor_id = QCA_NL80211_VENDOR_ID,
7703 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
7704 },
7705 {
7706 .vendor_id = QCA_NL80211_VENDOR_ID,
7707 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
7708 },
7709 {
7710 .vendor_id = QCA_NL80211_VENDOR_ID,
7711 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
7712 },
7713 {
7714 .vendor_id = QCA_NL80211_VENDOR_ID,
7715 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
7716 },
7717 {
7718 .vendor_id = QCA_NL80211_VENDOR_ID,
7719 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
7720 },
7721 {
7722 .vendor_id = QCA_NL80211_VENDOR_ID,
7723 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
7724 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307725#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307726/*EXT TDLS*/
7727 {
7728 .vendor_id = QCA_NL80211_VENDOR_ID,
7729 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
7730 },
c_manjeecfd1efb2015-09-25 19:32:34 +05307731 [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = {
7732 .vendor_id = QCA_NL80211_VENDOR_ID,
7733 .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP
7734 },
7735
Srinivas Dasari030bad32015-02-18 23:23:54 +05307736
Srinivas Dasaribd1cf642017-01-23 14:54:41 +05307737 [QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX] = {
Srinivas Dasari030bad32015-02-18 23:23:54 +05307738 .vendor_id = QCA_NL80211_VENDOR_ID,
7739 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
7740 },
7741
Sushant Kaushik084f6592015-09-10 13:11:56 +05307742 {
7743 .vendor_id = QCA_NL80211_VENDOR_ID,
7744 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307745 },
7746 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
7747 .vendor_id = QCA_NL80211_VENDOR_ID,
7748 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
7749 },
Padma, Santhosh Kumar7bbc7d92015-12-08 20:23:19 +05307750 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = {
7751 .vendor_id = QCA_NL80211_VENDOR_ID,
7752 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST
7753 },
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307754 [QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET_INDEX] = {
7755 .vendor_id = QCA_NL80211_VENDOR_ID,
7756 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
7757 },
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007758};
7759
Jeff Johnson295189b2012-06-20 16:38:30 -07007760/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307761 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307762 * This function is called by hdd_wlan_startup()
7763 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307764 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07007765 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307766struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07007767{
7768 struct wiphy *wiphy;
7769 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307770 /*
7771 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07007772 */
7773 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
7774
7775 if (!wiphy)
7776 {
7777 /* Print error and jump into err label and free the memory */
7778 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
7779 return NULL;
7780 }
7781
Sunil Duttc69bccb2014-05-26 21:30:20 +05307782
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 return wiphy;
7784}
7785
Anurag Chouhan343af7e2016-12-16 13:11:19 +05307786#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,4,0)) || \
7787 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
7788/**
7789 * hdd_config_sched_scan_plans_to_wiphy() - configure sched scan plans to wiphy
7790 * @wiphy: pointer to wiphy
7791 * @config: pointer to config
7792 *
7793 * Return: None
7794 */
7795static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
7796 hdd_config_t *config)
7797{
7798 wiphy->max_sched_scan_plans = MAX_SCHED_SCAN_PLANS;
7799 if (config->max_sched_scan_plan_interval)
7800 wiphy->max_sched_scan_plan_interval =
7801 config->max_sched_scan_plan_interval;
7802 if (config->max_sched_scan_plan_iterations)
7803 wiphy->max_sched_scan_plan_iterations =
7804 config->max_sched_scan_plan_iterations;
7805}
7806#else
7807static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
7808 hdd_config_t *config)
7809{
7810}
7811#endif
7812
Jeff Johnson295189b2012-06-20 16:38:30 -07007813/*
7814 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307815 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07007816 * private ioctl to change the band value
7817 */
7818int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
7819{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307820 int i, j;
7821 eNVChannelEnabledType channelEnabledState;
7822
Jeff Johnsone7245742012-09-05 17:12:55 -07007823 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307824
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307825 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307827
7828 if (NULL == wiphy->bands[i])
7829 {
7830 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
7831 __func__, i);
7832 continue;
7833 }
7834
7835 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
7836 {
7837 struct ieee80211_supported_band *band = wiphy->bands[i];
7838
7839 channelEnabledState = vos_nv_getChannelEnabledState(
7840 band->channels[j].hw_value);
7841
7842 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
7843 {
Abhishek Singh678227a2014-11-04 10:52:38 +05307844 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307845 continue;
7846 }
7847 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
7848 {
7849 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7850 continue;
7851 }
7852
7853 if (NV_CHANNEL_DISABLE == channelEnabledState ||
7854 NV_CHANNEL_INVALID == channelEnabledState)
7855 {
7856 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7857 }
7858 else if (NV_CHANNEL_DFS == channelEnabledState)
7859 {
7860 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
7861 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
7862 }
7863 else
7864 {
7865 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
7866 |IEEE80211_CHAN_RADAR);
7867 }
7868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007869 }
7870 return 0;
7871}
7872/*
7873 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307874 * This function is called by hdd_wlan_startup()
7875 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07007876 * This function is used to initialize and register wiphy structure.
7877 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307878int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 struct wiphy *wiphy,
7880 hdd_config_t *pCfg
7881 )
7882{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307883 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05307884 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7885
Jeff Johnsone7245742012-09-05 17:12:55 -07007886 ENTER();
7887
Jeff Johnson295189b2012-06-20 16:38:30 -07007888 /* Now bind the underlying wlan device with wiphy */
7889 set_wiphy_dev(wiphy, dev);
7890
7891 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007892
Kiet Lam6c583332013-10-14 05:37:09 +05307893#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07007894 /* the flag for the other case would be initialzed in
7895 vos_init_wiphy_from_nv_bin */
Manjeet Singh9e19de62016-08-18 18:26:41 +05307896#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7897 wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
7898#else
Amar Singhal0a402232013-10-11 20:57:16 -07007899 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05307900#endif
Manjeet Singh9e19de62016-08-18 18:26:41 +05307901#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007902
Amar Singhalfddc28c2013-09-05 13:03:40 -07007903 /* This will disable updating of NL channels from passive to
7904 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307905#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7906 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
7907#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07007908 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307909#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07007910
Amar Singhala49cbc52013-10-08 18:37:44 -07007911
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007912#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07007913 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
7914 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
7915 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07007916 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307917#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Rajeev Kumar Sirasanagandla0d6dd752016-08-17 15:01:39 +05307918 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307919#else
7920 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
7921#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007922#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007923
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007924#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007925 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08007926#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007927 || pCfg->isFastRoamIniFeatureEnabled
7928#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007929#ifdef FEATURE_WLAN_ESE
7930 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007931#endif
7932 )
7933 {
7934 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
7935 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08007936#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007937#ifdef FEATURE_WLAN_TDLS
7938 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
7939 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
7940#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307941#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05307942 if (pCfg->configPNOScanSupport)
7943 {
7944 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
7945 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
7946 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
7947 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
7948 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307949#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007950
Abhishek Singh10d85972015-04-17 10:27:23 +05307951#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7952 wiphy->features |= NL80211_FEATURE_HT_IBSS;
7953#endif
7954
Amar Singhalfddc28c2013-09-05 13:03:40 -07007955#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007956 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
7957 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07007958 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007959 driver need to determine what to do with both
7960 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07007961
7962 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07007963#else
7964 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007965#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007966
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307967 wiphy->max_scan_ssids = MAX_SCAN_SSID;
7968
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05307969 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07007970
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307971 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
7972
Jeff Johnson295189b2012-06-20 16:38:30 -07007973 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05307974 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
7975 | BIT(NL80211_IFTYPE_ADHOC)
7976 | BIT(NL80211_IFTYPE_P2P_CLIENT)
7977 | BIT(NL80211_IFTYPE_P2P_GO)
7978 | BIT(NL80211_IFTYPE_AP);
7979
7980 if (VOS_MONITOR_MODE == hdd_get_conparam())
7981 {
7982 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
7983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007984
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307985 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007986 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307987#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7988 if( pCfg->enableMCC )
7989 {
7990 /* Currently, supports up to two channels */
7991 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007992
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307993 if( !pCfg->allowMCCGODiffBI )
7994 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007995
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307996 }
7997 wiphy->iface_combinations = &wlan_hdd_iface_combination;
7998 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007999#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308000 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008001
Jeff Johnson295189b2012-06-20 16:38:30 -07008002 /* Before registering we need to update the ht capabilitied based
8003 * on ini values*/
8004 if( !pCfg->ShortGI20MhzEnable )
8005 {
8006 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
8007 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
Jeff Johnson295189b2012-06-20 16:38:30 -07008008 }
8009
8010 if( !pCfg->ShortGI40MhzEnable )
8011 {
8012 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
8013 }
8014
8015 if( !pCfg->nChannelBondingMode5GHz )
8016 {
8017 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
8018 }
Agrawal Ashish97dec502015-11-26 20:20:58 +05308019 /*
8020 * In case of static linked driver at the time of driver unload,
8021 * module exit doesn't happens. Module cleanup helps in cleaning
8022 * of static memory.
8023 * If driver load happens statically, at the time of driver unload,
8024 * wiphy flags don't get reset because of static memory.
8025 * It's better not to store channel in static memory.
8026 */
8027 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
8028 wiphy->bands[IEEE80211_BAND_2GHZ]->channels =
8029 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_2_4_GHZ));
8030 if (wiphy->bands[IEEE80211_BAND_2GHZ]->channels == NULL)
8031 {
8032 hddLog(VOS_TRACE_LEVEL_ERROR,
8033 FL("Not enough memory to allocate channels"));
8034 return -ENOMEM;
8035 }
8036 vos_mem_copy(wiphy->bands[IEEE80211_BAND_2GHZ]->channels,
8037 &hdd_channels_2_4_GHZ[0],
8038 sizeof(hdd_channels_2_4_GHZ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008039
Agrawal Ashish97dec502015-11-26 20:20:58 +05308040 if (true == hdd_is_5g_supported(pHddCtx))
8041 {
8042 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
8043 wiphy->bands[IEEE80211_BAND_5GHZ]->channels =
8044 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_5_GHZ));
8045 if (wiphy->bands[IEEE80211_BAND_5GHZ]->channels == NULL)
8046 {
8047 hddLog(VOS_TRACE_LEVEL_ERROR,
8048 FL("Not enough memory to allocate channels"));
8049 vos_mem_free(wiphy->bands[IEEE80211_BAND_2GHZ]->channels);
8050 wiphy->bands[IEEE80211_BAND_2GHZ]->channels = NULL;
8051 return -ENOMEM;
8052 }
8053 vos_mem_copy(wiphy->bands[IEEE80211_BAND_5GHZ]->channels,
8054 &hdd_channels_5_GHZ[0],
8055 sizeof(hdd_channels_5_GHZ));
8056 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308057
8058 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8059 {
8060
8061 if (NULL == wiphy->bands[i])
8062 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05308063 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308064 __func__, i);
8065 continue;
8066 }
8067
8068 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8069 {
8070 struct ieee80211_supported_band *band = wiphy->bands[i];
8071
8072 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
8073 {
8074 // Enable social channels for P2P
8075 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
8076 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
8077 else
8078 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8079 continue;
8080 }
8081 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
8082 {
8083 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8084 continue;
8085 }
8086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 }
8088 /*Initialise the supported cipher suite details*/
8089 wiphy->cipher_suites = hdd_cipher_suites;
8090 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
8091
8092 /*signal strength in mBm (100*dBm) */
8093 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
8094
8095#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05308096 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07008097#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008098
Sunil Duttc69bccb2014-05-26 21:30:20 +05308099 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
8100 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008101 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
8102 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
8103
Anurag Chouhan343af7e2016-12-16 13:11:19 +05308104 hdd_config_sched_scan_plans_to_wiphy(wiphy, pCfg);
8105
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308106 EXIT();
8107 return 0;
8108}
8109
8110/* In this function we are registering wiphy. */
8111int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
8112{
8113 ENTER();
8114 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008115 if (0 > wiphy_register(wiphy))
8116 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308117 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
8119 return -EIO;
8120 }
8121
8122 EXIT();
8123 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308124}
Jeff Johnson295189b2012-06-20 16:38:30 -07008125
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308126/* In this function we are updating channel list when,
8127 regulatory domain is FCC and country code is US.
8128 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
8129 As per FCC smart phone is not a indoor device.
8130 GO should not opeate on indoor channels */
8131void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
8132{
8133 int j;
8134 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8135 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
8136 //Default counrtycode from NV at the time of wiphy initialization.
8137 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
8138 &defaultCountryCode[0]))
8139 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008140 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308141 }
8142 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
8143 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308144 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
8145 {
8146 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
8147 return;
8148 }
8149 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
8150 {
8151 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
8152 // Mark UNII -1 band channel as passive
8153 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
8154 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
8155 }
8156 }
8157}
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308158/* This function registers for all frame which supplicant is interested in */
8159void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008160{
Jeff Johnson295189b2012-06-20 16:38:30 -07008161 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8162 /* Register for all P2P action, public action etc frames */
8163 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
Jeff Johnsone7245742012-09-05 17:12:55 -07008164 ENTER();
Abhishek Singh16e05762015-11-30 14:29:27 +05308165 /* Register frame indication call back */
8166 sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame);
Jeff Johnson295189b2012-06-20 16:38:30 -07008167 /* Right now we are registering these frame when driver is getting
8168 initialized. Once we will move to 2.6.37 kernel, in which we have
8169 frame register ops, we will move this code as a part of that */
8170 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308171 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07008172 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8173
8174 /* GAS Initial Response */
8175 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8176 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308177
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 /* GAS Comeback Request */
8179 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8180 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8181
8182 /* GAS Comeback Response */
8183 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8184 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8185
8186 /* P2P Public Action */
8187 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308188 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 P2P_PUBLIC_ACTION_FRAME_SIZE );
8190
8191 /* P2P Action */
8192 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8193 (v_U8_t*)P2P_ACTION_FRAME,
8194 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07008195
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05308196 /* WNM BSS Transition Request frame */
8197 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8198 (v_U8_t*)WNM_BSS_ACTION_FRAME,
8199 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008200
8201 /* WNM-Notification */
8202 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8203 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8204 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008205}
8206
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308207void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008208{
Jeff Johnson295189b2012-06-20 16:38:30 -07008209 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8210 /* Register for all P2P action, public action etc frames */
8211 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
8212
Jeff Johnsone7245742012-09-05 17:12:55 -07008213 ENTER();
8214
Jeff Johnson295189b2012-06-20 16:38:30 -07008215 /* Right now we are registering these frame when driver is getting
8216 initialized. Once we will move to 2.6.37 kernel, in which we have
8217 frame register ops, we will move this code as a part of that */
8218 /* GAS Initial Request */
8219
8220 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8221 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8222
8223 /* GAS Initial Response */
8224 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8225 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308226
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 /* GAS Comeback Request */
8228 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8229 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8230
8231 /* GAS Comeback Response */
8232 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8233 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8234
8235 /* P2P Public Action */
8236 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308237 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008238 P2P_PUBLIC_ACTION_FRAME_SIZE );
8239
8240 /* P2P Action */
8241 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8242 (v_U8_t*)P2P_ACTION_FRAME,
8243 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008244 /* WNM-Notification */
8245 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8246 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8247 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008248}
8249
8250#ifdef FEATURE_WLAN_WAPI
8251void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05308252 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07008253{
8254 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8255 tCsrRoamSetKey setKey;
8256 v_BOOL_t isConnected = TRUE;
8257 int status = 0;
8258 v_U32_t roamId= 0xFF;
8259 tANI_U8 *pKeyPtr = NULL;
8260 int n = 0;
8261
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308262 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
8263 __func__, hdd_device_modetoString(pAdapter->device_mode),
8264 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008265
Gopichand Nakkalae7480202013-02-11 15:24:22 +05308266 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 setKey.keyId = key_index; // Store Key ID
8268 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
8269 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
8270 setKey.paeRole = 0 ; // the PAE role
8271 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
8272 {
8273 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
8274 }
8275 else
8276 {
8277 isConnected = hdd_connIsConnected(pHddStaCtx);
8278 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
8279 }
8280 setKey.keyLength = key_Len;
8281 pKeyPtr = setKey.Key;
8282 memcpy( pKeyPtr, key, key_Len);
8283
Arif Hussain6d2a3322013-11-17 19:50:10 -08008284 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07008285 __func__, key_Len);
8286 for (n = 0 ; n < key_Len; n++)
8287 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
8288 __func__,n,setKey.Key[n]);
8289
8290 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8291 if ( isConnected )
8292 {
8293 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8294 pAdapter->sessionId, &setKey, &roamId );
8295 }
8296 if ( status != 0 )
8297 {
8298 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8299 "[%4d] sme_RoamSetKey returned ERROR status= %d",
8300 __LINE__, status );
8301 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8302 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308303 /* Need to clear any trace of key value in the memory.
8304 * Thus zero out the memory even though it is local
8305 * variable.
8306 */
8307 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008308}
8309#endif /* FEATURE_WLAN_WAPI*/
8310
8311#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308312int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 beacon_data_t **ppBeacon,
8314 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008315#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308316int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008317 beacon_data_t **ppBeacon,
8318 struct cfg80211_beacon_data *params,
8319 int dtim_period)
8320#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308321{
Jeff Johnson295189b2012-06-20 16:38:30 -07008322 int size;
8323 beacon_data_t *beacon = NULL;
8324 beacon_data_t *old = NULL;
Kapil Gupta137ef892016-12-13 19:38:00 +05308325 int head_len, tail_len, proberesp_ies_len, assocresp_ies_len;
8326 const u8 *head, *tail, *proberesp_ies, *assocresp_ies;
Jeff Johnson295189b2012-06-20 16:38:30 -07008327
Jeff Johnsone7245742012-09-05 17:12:55 -07008328 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008329 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308330 {
8331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8332 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008333 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008335
8336 old = pAdapter->sessionCtx.ap.beacon;
8337
8338 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308339 {
8340 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8341 FL("session(%d) old and new heads points to NULL"),
8342 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008343 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308344 }
8345
8346 if (params->tail && !params->tail_len)
8347 {
8348 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8349 FL("tail_len is zero but tail is not NULL"));
8350 return -EINVAL;
8351 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008352
Jeff Johnson295189b2012-06-20 16:38:30 -07008353#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
8354 /* Kernel 3.0 is not updating dtim_period for set beacon */
8355 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308356 {
8357 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8358 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008359 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308360 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008361#endif
8362
Kapil Gupta137ef892016-12-13 19:38:00 +05308363 if (params->head)
8364 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008365 head_len = params->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308366 head = params->head;
8367 } else
8368 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 head_len = old->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308370 head = old->head;
8371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008372
Kapil Gupta137ef892016-12-13 19:38:00 +05308373 if (params->tail || !old)
8374 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008375 tail_len = params->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308376 tail = params->tail;
8377 } else
8378 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008379 tail_len = old->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308380 tail = old->tail;
8381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008382
Kapil Gupta137ef892016-12-13 19:38:00 +05308383 if (params->proberesp_ies || !old)
8384 {
8385 proberesp_ies_len = params->proberesp_ies_len;
8386 proberesp_ies = params->proberesp_ies;
8387 } else
8388 {
8389 proberesp_ies_len = old->proberesp_ies_len;
8390 proberesp_ies = old->proberesp_ies;
8391 }
8392
8393 if (params->assocresp_ies || !old)
8394 {
8395 assocresp_ies_len = params->assocresp_ies_len;
8396 assocresp_ies = params->assocresp_ies;
8397 } else
8398 {
8399 assocresp_ies_len = old->assocresp_ies_len;
8400 assocresp_ies = old->assocresp_ies;
8401 }
8402
8403 size = sizeof(beacon_data_t) + head_len + tail_len +
8404 proberesp_ies_len + assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07008405
8406 beacon = kzalloc(size, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07008407 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308408 {
8409 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8410 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008411 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008413
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008414#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Kapil Gupta137ef892016-12-13 19:38:00 +05308415 if (params->dtim_period)
Jeff Johnson295189b2012-06-20 16:38:30 -07008416 beacon->dtim_period = params->dtim_period;
8417 else
8418 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008419#else
Kapil Gupta137ef892016-12-13 19:38:00 +05308420 if (dtim_period)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008421 beacon->dtim_period = dtim_period;
8422 else
8423 beacon->dtim_period = old->dtim_period;
8424#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308425
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
8427 beacon->tail = beacon->head + head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308428 beacon->proberesp_ies = beacon->tail + tail_len;
8429 beacon->assocresp_ies = beacon->proberesp_ies + proberesp_ies_len;
8430
Jeff Johnson295189b2012-06-20 16:38:30 -07008431 beacon->head_len = head_len;
8432 beacon->tail_len = tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308433 beacon->proberesp_ies_len = proberesp_ies_len;
8434 beacon->assocresp_ies_len= assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07008435
c_manjee527ecac2017-01-25 12:25:27 +05308436 if (head && head_len)
8437 memcpy(beacon->head, head, head_len);
8438 if (tail && tail_len)
8439 memcpy(beacon->tail, tail, tail_len);
8440 if (proberesp_ies && proberesp_ies_len)
8441 memcpy(beacon->proberesp_ies, proberesp_ies, proberesp_ies_len);
8442 if (assocresp_ies && assocresp_ies_len)
8443 memcpy(beacon->assocresp_ies, assocresp_ies, assocresp_ies_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008444
8445 *ppBeacon = beacon;
8446
8447 kfree(old);
8448
8449 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008450}
Jeff Johnson295189b2012-06-20 16:38:30 -07008451
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308452v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
8453#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
8454 const v_U8_t *pIes,
8455#else
8456 v_U8_t *pIes,
8457#endif
8458 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008459{
8460 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308461 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07008462 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308463
Jeff Johnson295189b2012-06-20 16:38:30 -07008464 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308465 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008466 elem_id = ptr[0];
8467 elem_len = ptr[1];
8468 left -= 2;
8469 if(elem_len > left)
8470 {
8471 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07008472 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 eid,elem_len,left);
8474 return NULL;
8475 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308476 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 {
8478 return ptr;
8479 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308480
Jeff Johnson295189b2012-06-20 16:38:30 -07008481 left -= elem_len;
8482 ptr += (elem_len + 2);
8483 }
8484 return NULL;
8485}
8486
Jeff Johnson295189b2012-06-20 16:38:30 -07008487/* Check if rate is 11g rate or not */
8488static int wlan_hdd_rate_is_11g(u8 rate)
8489{
Sanjay Devnani28322e22013-06-21 16:13:40 -07008490 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008491 u8 i;
8492 for (i = 0; i < 8; i++)
8493 {
8494 if(rate == gRateArray[i])
8495 return TRUE;
8496 }
8497 return FALSE;
8498}
8499
8500/* Check for 11g rate and set proper 11g only mode */
8501static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
8502 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
8503{
8504 u8 i, num_rates = pIe[0];
8505
8506 pIe += 1;
8507 for ( i = 0; i < num_rates; i++)
8508 {
8509 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
8510 {
8511 /* If rate set have 11g rate than change the mode to 11G */
8512 *pSapHw_mode = eSAP_DOT11_MODE_11g;
8513 if (pIe[i] & BASIC_RATE_MASK)
8514 {
8515 /* If we have 11g rate as basic rate, it means mode
8516 is 11g only mode.
8517 */
8518 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
8519 *pCheckRatesfor11g = FALSE;
8520 }
8521 }
8522 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
8523 {
8524 *require_ht = TRUE;
8525 }
8526 }
8527 return;
8528}
8529
8530static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
8531{
8532 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
8533 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8534 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
8535 u8 checkRatesfor11g = TRUE;
8536 u8 require_ht = FALSE;
8537 u8 *pIe=NULL;
8538
8539 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
8540
8541 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
8542 pBeacon->head_len, WLAN_EID_SUPP_RATES);
8543 if (pIe != NULL)
8544 {
8545 pIe += 1;
8546 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8547 &pConfig->SapHw_mode);
8548 }
8549
8550 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8551 WLAN_EID_EXT_SUPP_RATES);
8552 if (pIe != NULL)
8553 {
8554
8555 pIe += 1;
8556 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8557 &pConfig->SapHw_mode);
8558 }
8559
8560 if( pConfig->channel > 14 )
8561 {
8562 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
8563 }
8564
8565 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8566 WLAN_EID_HT_CAPABILITY);
8567
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308568 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 {
8570 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
8571 if(require_ht)
8572 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
8573 }
8574}
8575
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308576static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
8577 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
8578{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008579 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308580 v_U8_t *pIe = NULL;
8581 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8582
8583 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
8584 pBeacon->tail, pBeacon->tail_len);
8585
8586 if (pIe)
8587 {
8588 ielen = pIe[1] + 2;
8589 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8590 {
8591 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
8592 }
8593 else
8594 {
8595 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
8596 return -EINVAL;
8597 }
8598 *total_ielen += ielen;
8599 }
8600 return 0;
8601}
8602
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008603static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
8604 v_U8_t *genie, v_U8_t *total_ielen)
8605{
8606 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8607 int left = pBeacon->tail_len;
8608 v_U8_t *ptr = pBeacon->tail;
8609 v_U8_t elem_id, elem_len;
8610 v_U16_t ielen = 0;
8611
8612 if ( NULL == ptr || 0 == left )
8613 return;
8614
8615 while (left >= 2)
8616 {
8617 elem_id = ptr[0];
8618 elem_len = ptr[1];
8619 left -= 2;
8620 if (elem_len > left)
8621 {
8622 hddLog( VOS_TRACE_LEVEL_ERROR,
8623 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
8624 elem_id, elem_len, left);
8625 return;
8626 }
8627 if (IE_EID_VENDOR == elem_id)
8628 {
8629 /* skipping the VSIE's which we don't want to include or
8630 * it will be included by existing code
8631 */
8632 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
8633#ifdef WLAN_FEATURE_WFD
8634 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
8635#endif
8636 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8637 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8638 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
8639 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8640 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
8641 {
8642 ielen = ptr[1] + 2;
8643 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8644 {
8645 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
8646 *total_ielen += ielen;
8647 }
8648 else
8649 {
8650 hddLog( VOS_TRACE_LEVEL_ERROR,
8651 "IE Length is too big "
8652 "IEs eid=%d elem_len=%d total_ie_lent=%d",
8653 elem_id, elem_len, *total_ielen);
8654 }
8655 }
8656 }
8657
8658 left -= elem_len;
8659 ptr += (elem_len + 2);
8660 }
8661 return;
8662}
8663
Kapil Gupta137ef892016-12-13 19:38:00 +05308664int wlan_hdd_cfg80211_update_apies(hdd_adapter_t *pHostapdAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008665{
8666 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308667 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07008669 int ret = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +05308670 beacon_data_t *pBeacon = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008671
8672 genie = vos_mem_malloc(MAX_GENIE_LEN);
8673
8674 if(genie == NULL) {
8675
8676 return -ENOMEM;
8677 }
8678
Kapil Gupta137ef892016-12-13 19:38:00 +05308679 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308680 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8681 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308683 hddLog(LOGE,
8684 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308685 ret = -EINVAL;
8686 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 }
8688
8689#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308690 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8691 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
8692 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308693 hddLog(LOGE,
8694 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308695 ret = -EINVAL;
8696 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008697 }
8698#endif
8699
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308700 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8701 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008702 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308703 hddLog(LOGE,
8704 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308705 ret = -EINVAL;
8706 goto done;
8707 }
8708
8709 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
8710 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008711 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008713
8714 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8715 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
8716 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
8717 {
8718 hddLog(LOGE,
8719 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008720 ret = -EINVAL;
8721 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008722 }
8723
8724 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8725 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
8726 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8727 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8728 ==eHAL_STATUS_FAILURE)
8729 {
8730 hddLog(LOGE,
8731 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008732 ret = -EINVAL;
8733 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008734 }
8735
8736 // Added for ProResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +05308737 if ((pBeacon->proberesp_ies != NULL) && (pBeacon->proberesp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008738 {
Kapil Gupta137ef892016-12-13 19:38:00 +05308739 u16 rem_probe_resp_ie_len = pBeacon->proberesp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07008740 u8 probe_rsp_ie_len[3] = {0};
8741 u8 counter = 0;
8742 /* Check Probe Resp Length if it is greater then 255 then Store
8743 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
8744 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
8745 Store More then 255 bytes into One Variable.
8746 */
8747 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
8748 {
8749 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
8750 {
8751 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
8752 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
8753 }
8754 else
8755 {
8756 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
8757 rem_probe_resp_ie_len = 0;
8758 }
8759 }
8760
8761 rem_probe_resp_ie_len = 0;
8762
8763 if (probe_rsp_ie_len[0] > 0)
8764 {
8765 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8766 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
Kapil Gupta137ef892016-12-13 19:38:00 +05308767 (tANI_U8*)&pBeacon->
8768 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 probe_rsp_ie_len[0], NULL,
8770 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8771 {
8772 hddLog(LOGE,
8773 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008774 ret = -EINVAL;
8775 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008776 }
8777 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
8778 }
8779
8780 if (probe_rsp_ie_len[1] > 0)
8781 {
8782 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8783 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
Kapil Gupta137ef892016-12-13 19:38:00 +05308784 (tANI_U8*)&pBeacon->
8785 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 probe_rsp_ie_len[1], NULL,
8787 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8788 {
8789 hddLog(LOGE,
8790 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008791 ret = -EINVAL;
8792 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008793 }
8794 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
8795 }
8796
8797 if (probe_rsp_ie_len[2] > 0)
8798 {
8799 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8800 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
Kapil Gupta137ef892016-12-13 19:38:00 +05308801 (tANI_U8*)&pBeacon->
8802 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -07008803 probe_rsp_ie_len[2], NULL,
8804 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8805 {
8806 hddLog(LOGE,
8807 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008808 ret = -EINVAL;
8809 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008810 }
8811 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
8812 }
8813
8814 if (probe_rsp_ie_len[1] == 0 )
8815 {
8816 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8817 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
8818 eANI_BOOLEAN_FALSE) )
8819 {
8820 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008821 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008822 }
8823 }
8824
8825 if (probe_rsp_ie_len[2] == 0 )
8826 {
8827 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8828 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
8829 eANI_BOOLEAN_FALSE) )
8830 {
8831 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008832 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008833 }
8834 }
8835
8836 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8837 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
8838 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8839 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8840 == eHAL_STATUS_FAILURE)
8841 {
8842 hddLog(LOGE,
8843 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008844 ret = -EINVAL;
8845 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008846 }
8847 }
8848 else
8849 {
8850 // Reset WNI_CFG_PROBE_RSP Flags
8851 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
8852
8853 hddLog(VOS_TRACE_LEVEL_INFO,
8854 "%s: No Probe Response IE received in set beacon",
8855 __func__);
8856 }
8857
8858 // Added for AssocResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +05308859 if ((pBeacon->assocresp_ies != NULL) && (pBeacon->assocresp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008860 {
8861 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
Kapil Gupta137ef892016-12-13 19:38:00 +05308862 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)pBeacon->assocresp_ies,
8863 pBeacon->assocresp_ies_len, NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -07008864 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8865 {
8866 hddLog(LOGE,
8867 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008868 ret = -EINVAL;
8869 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008870 }
8871
8872 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8873 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
8874 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8875 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8876 == eHAL_STATUS_FAILURE)
8877 {
8878 hddLog(LOGE,
8879 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008880 ret = -EINVAL;
8881 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008882 }
8883 }
8884 else
8885 {
8886 hddLog(VOS_TRACE_LEVEL_INFO,
8887 "%s: No Assoc Response IE received in set beacon",
8888 __func__);
8889
8890 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8891 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
8892 eANI_BOOLEAN_FALSE) )
8893 {
8894 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008895 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 }
8897 }
8898
Jeff Johnsone7245742012-09-05 17:12:55 -07008899done:
Jeff Johnson295189b2012-06-20 16:38:30 -07008900 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308901 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008902}
Jeff Johnson295189b2012-06-20 16:38:30 -07008903
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308904/*
Jeff Johnson295189b2012-06-20 16:38:30 -07008905 * FUNCTION: wlan_hdd_validate_operation_channel
8906 * called by wlan_hdd_cfg80211_start_bss() and
8907 * wlan_hdd_cfg80211_set_channel()
8908 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308909 * channel list.
8910 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008911VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008912{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308913
Jeff Johnson295189b2012-06-20 16:38:30 -07008914 v_U32_t num_ch = 0;
8915 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
8916 u32 indx = 0;
8917 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308918 v_U8_t fValidChannel = FALSE, count = 0;
8919 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308920
Jeff Johnson295189b2012-06-20 16:38:30 -07008921 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8922
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308923 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008924 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308925 /* Validate the channel */
8926 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008927 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308928 if ( channel == rfChannels[count].channelNum )
8929 {
8930 fValidChannel = TRUE;
8931 break;
8932 }
8933 }
8934 if (fValidChannel != TRUE)
8935 {
8936 hddLog(VOS_TRACE_LEVEL_ERROR,
8937 "%s: Invalid Channel [%d]", __func__, channel);
8938 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008939 }
8940 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308941 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008942 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308943 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8944 valid_ch, &num_ch))
8945 {
8946 hddLog(VOS_TRACE_LEVEL_ERROR,
8947 "%s: failed to get valid channel list", __func__);
8948 return VOS_STATUS_E_FAILURE;
8949 }
8950 for (indx = 0; indx < num_ch; indx++)
8951 {
8952 if (channel == valid_ch[indx])
8953 {
8954 break;
8955 }
8956 }
8957
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05308958 if (indx >= num_ch)
8959 {
8960 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
8961 {
8962 eCsrBand band;
8963 unsigned int freq;
8964
8965 sme_GetFreqBand(hHal, &band);
8966
8967 if (eCSR_BAND_5G == band)
8968 {
8969#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
8970 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
8971 {
8972 freq = ieee80211_channel_to_frequency(channel,
8973 IEEE80211_BAND_2GHZ);
8974 }
8975 else
8976 {
8977 freq = ieee80211_channel_to_frequency(channel,
8978 IEEE80211_BAND_5GHZ);
8979 }
8980#else
8981 freq = ieee80211_channel_to_frequency(channel);
8982#endif
8983 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
8984 return VOS_STATUS_SUCCESS;
8985 }
8986 }
8987
8988 hddLog(VOS_TRACE_LEVEL_ERROR,
8989 "%s: Invalid Channel [%d]", __func__, channel);
8990 return VOS_STATUS_E_FAILURE;
8991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008992 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05308993
Jeff Johnson295189b2012-06-20 16:38:30 -07008994 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308995
Jeff Johnson295189b2012-06-20 16:38:30 -07008996}
8997
Viral Modi3a32cc52013-02-08 11:14:52 -08008998/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308999 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08009000 * This function is used to set the channel number
9001 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309002static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08009003 struct ieee80211_channel *chan,
9004 enum nl80211_channel_type channel_type
9005 )
9006{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309007 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08009008 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07009009 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08009010 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309011 hdd_context_t *pHddCtx;
9012 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009013
9014 ENTER();
9015
9016 if( NULL == dev )
9017 {
9018 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009019 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009020 return -ENODEV;
9021 }
9022 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309023
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309024 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9025 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
9026 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08009027 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309028 "%s: device_mode = %s (%d) freq = %d", __func__,
9029 hdd_device_modetoString(pAdapter->device_mode),
9030 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309031
9032 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9033 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309034 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08009035 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309036 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009037 }
9038
9039 /*
9040 * Do freq to chan conversion
9041 * TODO: for 11a
9042 */
9043
9044 channel = ieee80211_frequency_to_channel(freq);
9045
9046 /* Check freq range */
9047 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
9048 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
9049 {
9050 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009051 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08009052 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
9053 WNI_CFG_CURRENT_CHANNEL_STAMAX);
9054 return -EINVAL;
9055 }
9056
9057 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
9058
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05309059 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
9060 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08009061 {
9062 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
9063 {
9064 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009065 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08009066 return -EINVAL;
9067 }
9068 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9069 "%s: set channel to [%d] for device mode =%d",
9070 __func__, channel,pAdapter->device_mode);
9071 }
9072 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08009073 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08009074 )
9075 {
9076 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9077 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
9078 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9079
9080 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
9081 {
9082 /* Link is up then return cant set channel*/
9083 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009084 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009085 return -EINVAL;
9086 }
9087
9088 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
9089 pHddStaCtx->conn_info.operationChannel = channel;
9090 pRoamProfile->ChannelInfo.ChannelList =
9091 &pHddStaCtx->conn_info.operationChannel;
9092 }
9093 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08009094 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08009095 )
9096 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309097 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
9098 {
9099 if(VOS_STATUS_SUCCESS !=
9100 wlan_hdd_validate_operation_channel(pAdapter,channel))
9101 {
9102 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009103 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309104 return -EINVAL;
9105 }
9106 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9107 }
9108 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08009109 {
9110 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
9111
9112 /* If auto channel selection is configured as enable/ 1 then ignore
9113 channel set by supplicant
9114 */
9115 if ( cfg_param->apAutoChannelSelection )
9116 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309117 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
9118 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08009119 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309120 "%s: set channel to auto channel (0) for device mode =%s (%d)",
9121 __func__, hdd_device_modetoString(pAdapter->device_mode),
9122 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08009123 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309124 else
9125 {
9126 if(VOS_STATUS_SUCCESS !=
9127 wlan_hdd_validate_operation_channel(pAdapter,channel))
9128 {
9129 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009130 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309131 return -EINVAL;
9132 }
9133 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9134 }
Viral Modi3a32cc52013-02-08 11:14:52 -08009135 }
9136 }
9137 else
9138 {
9139 hddLog(VOS_TRACE_LEVEL_FATAL,
9140 "%s: Invalid device mode failed to set valid channel", __func__);
9141 return -EINVAL;
9142 }
9143 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309144 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009145}
9146
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309147static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
9148 struct net_device *dev,
9149 struct ieee80211_channel *chan,
9150 enum nl80211_channel_type channel_type
9151 )
9152{
9153 int ret;
9154
9155 vos_ssr_protect(__func__);
9156 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
9157 vos_ssr_unprotect(__func__);
9158
9159 return ret;
9160}
9161
Anurag Chouhan83026002016-12-13 22:46:21 +05309162#ifdef DHCP_SERVER_OFFLOAD
9163void hdd_dhcp_server_offload_done(void *fw_dhcp_srv_offload_cb_context,
9164 VOS_STATUS status)
9165{
9166 hdd_adapter_t* adapter = (hdd_adapter_t*)fw_dhcp_srv_offload_cb_context;
9167
9168 ENTER();
9169
9170 if (NULL == adapter)
9171 {
9172 hddLog(VOS_TRACE_LEVEL_ERROR,
9173 "%s: adapter is NULL",__func__);
9174 return;
9175 }
9176
9177 adapter->dhcp_status.dhcp_offload_status = status;
9178 vos_event_set(&adapter->dhcp_status.vos_event);
9179 return;
9180}
9181
9182/**
9183 * wlan_hdd_set_dhcp_server_offload() - set dhcp server offload
9184 * @hostapd_adapter: pointer to hostapd adapter.
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309185 * @re_init: flag set if api called post ssr
Anurag Chouhan83026002016-12-13 22:46:21 +05309186 *
9187 * Return: None
9188 */
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309189VOS_STATUS wlan_hdd_set_dhcp_server_offload(hdd_adapter_t *hostapd_adapter,
9190 bool re_init)
Anurag Chouhan83026002016-12-13 22:46:21 +05309191{
9192 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(hostapd_adapter);
9193 sir_dhcp_srv_offload_info dhcp_srv_info;
9194 tANI_U8 num_entries = 0;
9195 tANI_U8 srv_ip[IPADDR_NUM_ENTRIES];
9196 tANI_U8 num;
9197 tANI_U32 temp;
9198 VOS_STATUS ret;
9199
9200 ENTER();
9201
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309202 if (!re_init) {
9203 ret = wlan_hdd_validate_context(hdd_ctx);
9204 if (0 != ret)
9205 return VOS_STATUS_E_INVAL;
9206 }
Anurag Chouhan83026002016-12-13 22:46:21 +05309207
9208 /* Prepare the request to send to SME */
9209 dhcp_srv_info = vos_mem_malloc(sizeof(*dhcp_srv_info));
9210 if (NULL == dhcp_srv_info) {
9211 hddLog(VOS_TRACE_LEVEL_ERROR,
9212 "%s: could not allocate tDhcpSrvOffloadInfo!", __func__);
9213 return VOS_STATUS_E_NOMEM;
9214 }
9215
9216 vos_mem_zero(dhcp_srv_info, sizeof(*dhcp_srv_info));
9217
9218 dhcp_srv_info->bssidx = hostapd_adapter->sessionId;
9219 dhcp_srv_info->dhcp_srv_offload_enabled = TRUE;
9220 dhcp_srv_info->dhcp_client_num = hdd_ctx->cfg_ini->dhcp_max_num_clients;
9221 dhcp_srv_info->start_lsb = hdd_ctx->cfg_ini->dhcp_start_lsb;
9222 dhcp_srv_info->dhcp_offload_callback = hdd_dhcp_server_offload_done;
9223 dhcp_srv_info->dhcp_server_offload_cb_context = hostapd_adapter;
9224
9225 hdd_string_to_u8_array(hdd_ctx->cfg_ini->dhcp_srv_ip,
9226 srv_ip,
9227 &num_entries,
Anurag Chouhanac145c22016-11-22 16:51:47 +05309228 IPADDR_NUM_ENTRIES, ".");
Anurag Chouhan83026002016-12-13 22:46:21 +05309229 if (num_entries != IPADDR_NUM_ENTRIES) {
9230 hddLog(VOS_TRACE_LEVEL_ERROR,
9231 "%s: incorrect IP address (%s) assigned for DHCP server!",
9232 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9233 vos_mem_free(dhcp_srv_info);
9234 return VOS_STATUS_E_FAILURE;
9235 }
9236
9237 if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) {
9238 hddLog(VOS_TRACE_LEVEL_ERROR,
9239 "%s: invalid IP address (%s)! It could NOT be multicast IP address!",
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[IPADDR_NUM_ENTRIES-1] >= DHCP_START_POOL_ADDRESS) {
9246 hddLog(VOS_TRACE_LEVEL_ERROR,
9247 "%s: invalid IP address (%s)! The last field must be less than 100!",
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 for (num = 0; num < num_entries; num++) {
9254 temp = srv_ip[num];
9255 dhcp_srv_info->dhcp_srv_ip |= (temp << (8 * num));
9256 }
9257
9258 if (eHAL_STATUS_SUCCESS !=
9259 sme_set_dhcp_srv_offload(hdd_ctx->hHal, dhcp_srv_info)) {
9260 hddLog(VOS_TRACE_LEVEL_ERROR,
9261 "%s: sme_set_dhcp_srv_offload fail!", __func__);
9262 vos_mem_free(dhcp_srv_info);
9263 return VOS_STATUS_E_FAILURE;
9264 }
9265
9266 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9267 "%s: enable DHCP Server offload successfully!", __func__);
9268
9269 vos_mem_free(dhcp_srv_info);
9270 return 0;
9271}
9272#endif /* DHCP_SERVER_OFFLOAD */
9273
Jeff Johnson295189b2012-06-20 16:38:30 -07009274#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9275static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9276 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009277#else
9278static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9279 struct cfg80211_beacon_data *params,
9280 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309281 enum nl80211_hidden_ssid hidden_ssid,
9282 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009283#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009284{
9285 tsap_Config_t *pConfig;
9286 beacon_data_t *pBeacon = NULL;
9287 struct ieee80211_mgmt *pMgmt_frame;
9288 v_U8_t *pIe=NULL;
9289 v_U16_t capab_info;
9290 eCsrAuthType RSNAuthType;
9291 eCsrEncryptionType RSNEncryptType;
9292 eCsrEncryptionType mcRSNEncryptType;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309293 int status = VOS_STATUS_SUCCESS, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009294 tpWLAN_SAPEventCB pSapEventCallback;
9295 hdd_hostapd_state_t *pHostapdState;
Jeff Johnson295189b2012-06-20 16:38:30 -07009296 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309297 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009298 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309299 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07009300 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08009301 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05309302 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07009303 v_BOOL_t MFPCapable = VOS_FALSE;
9304 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309305 v_BOOL_t sapEnable11AC =
9306 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Kapil Gupta137ef892016-12-13 19:38:00 +05309307 u_int16_t prev_rsn_length = 0;
9308
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 ENTER();
9310
Nitesh Shah9b066282017-06-06 18:05:52 +05309311 wlan_hdd_tdls_disable_offchan_and_teardown_links(pHddCtx);
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309312 iniConfig = pHddCtx->cfg_ini;
9313
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
9315
9316 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9317
9318 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9319
9320 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9321
9322 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
9323
9324 //channel is already set in the set_channel Call back
9325 //pConfig->channel = pCommitConfig->channel;
9326
9327 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309328 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07009329 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
9330
9331 pConfig->dtim_period = pBeacon->dtim_period;
9332
Arif Hussain6d2a3322013-11-17 19:50:10 -08009333 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 pConfig->dtim_period);
9335
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08009336 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07009337 {
9338 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009339 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05309340 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
9341 {
9342 tANI_BOOLEAN restartNeeded;
9343 pConfig->ieee80211d = 1;
9344 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
9345 sme_setRegInfo(hHal, pConfig->countryCode);
9346 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
9347 }
9348 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009349 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07009350 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07009351 pConfig->ieee80211d = 1;
9352 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
9353 sme_setRegInfo(hHal, pConfig->countryCode);
9354 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07009355 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009356 else
9357 {
9358 pConfig->ieee80211d = 0;
9359 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309360 /*
9361 * If auto channel is configured i.e. channel is 0,
9362 * so skip channel validation.
9363 */
9364 if( AUTO_CHANNEL_SELECT != pConfig->channel )
9365 {
9366 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
9367 {
9368 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009369 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309370 return -EINVAL;
9371 }
9372 }
9373 else
9374 {
9375 if(1 != pHddCtx->is_dynamic_channel_range_set)
9376 {
9377 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
9378 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
9379 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
9380 }
9381 pHddCtx->is_dynamic_channel_range_set = 0;
9382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009383 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009384 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009385 {
9386 pConfig->ieee80211d = 0;
9387 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309388
9389#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9390 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9391 pConfig->authType = eSAP_OPEN_SYSTEM;
9392 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9393 pConfig->authType = eSAP_SHARED_KEY;
9394 else
9395 pConfig->authType = eSAP_AUTO_SWITCH;
9396#else
9397 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9398 pConfig->authType = eSAP_OPEN_SYSTEM;
9399 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9400 pConfig->authType = eSAP_SHARED_KEY;
9401 else
9402 pConfig->authType = eSAP_AUTO_SWITCH;
9403#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009404
9405 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309406
9407 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07009408 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05309409#ifdef SAP_AUTH_OFFLOAD
9410 /* In case of sap offload, hostapd.conf is configuted with open mode and
9411 * security is configured from ini file. Due to open mode in hostapd.conf
9412 * privacy bit is set to false which will result in not sending,
9413 * data packets as encrypted.
9414 * If enable_sap_auth_offload is enabled in ini and
9415 * sap_auth_offload_sec_type is type of WPA2-PSK,
9416 * driver will set privacy bit to 1.
9417 */
9418 if (pHddCtx->cfg_ini->enable_sap_auth_offload &&
9419 pHddCtx->cfg_ini->sap_auth_offload_sec_type)
9420 pConfig->privacy = VOS_TRUE;
9421#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009422
9423 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
9424
9425 /*Set wps station to configured*/
9426 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
9427
9428 if(pIe)
9429 {
9430 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
9431 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009432 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 return -EINVAL;
9434 }
9435 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
9436 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009437 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 /* Check 15 bit of WPS IE as it contain information for wps state
9439 * WPS state
9440 */
9441 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
9442 {
9443 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
9444 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
9445 {
9446 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
9447 }
9448 }
9449 }
9450 else
9451 {
9452 pConfig->wps_state = SAP_WPS_DISABLED;
9453 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309454 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07009455
c_hpothufe599e92014-06-16 11:38:55 +05309456 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9457 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9458 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
9459 eCSR_ENCRYPT_TYPE_NONE;
9460
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 pConfig->RSNWPAReqIELength = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +05309462 memset(&pConfig->RSNWPAReqIE[0], 0, sizeof(pConfig->RSNWPAReqIE));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309463 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009464 WLAN_EID_RSN);
9465 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309466 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +05309468 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
9469 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
9470 pConfig->RSNWPAReqIELength);
9471 else
9472 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
9473 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309474 /* The actual processing may eventually be more extensive than
9475 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07009476 * by the app.
9477 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309478 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009479 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9480 &RSNEncryptType,
9481 &mcRSNEncryptType,
9482 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009483 &MFPCapable,
9484 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +05309485 pConfig->RSNWPAReqIE[1]+2,
9486 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009487
9488 if( VOS_STATUS_SUCCESS == status )
9489 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309490 /* Now copy over all the security attributes you have
9491 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009492 * */
9493 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9494 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9495 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9496 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309497 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009498 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9500 }
9501 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309502
Jeff Johnson295189b2012-06-20 16:38:30 -07009503 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9504 pBeacon->tail, pBeacon->tail_len);
9505
9506 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
9507 {
Kapil Gupta137ef892016-12-13 19:38:00 +05309508 if (pConfig->RSNWPAReqIE[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07009509 {
9510 /*Mixed mode WPA/WPA2*/
Kapil Gupta137ef892016-12-13 19:38:00 +05309511 prev_rsn_length = pConfig->RSNWPAReqIELength;
Jeff Johnson295189b2012-06-20 16:38:30 -07009512 pConfig->RSNWPAReqIELength += pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +05309513 if (pConfig->RSNWPAReqIELength <=
9514 (sizeof(pConfig->RSNWPAReqIE) - prev_rsn_length))
9515 memcpy(&pConfig->RSNWPAReqIE[0] + prev_rsn_length, pIe,
9516 pIe[1] + 2);
9517 else
9518 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
9519 pConfig->RSNWPAReqIELength);
9520
Jeff Johnson295189b2012-06-20 16:38:30 -07009521 }
9522 else
9523 {
9524 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +05309525 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
9526 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
9527 pConfig->RSNWPAReqIELength);
9528 else
9529 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
9530 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309531 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9533 &RSNEncryptType,
9534 &mcRSNEncryptType,
9535 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009536 &MFPCapable,
9537 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +05309538 pConfig->RSNWPAReqIE[1]+2,
9539 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009540
9541 if( VOS_STATUS_SUCCESS == status )
9542 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309543 /* Now copy over all the security attributes you have
9544 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 * */
9546 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9547 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9548 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9549 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309550 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009551 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9553 }
9554 }
9555 }
9556
Kapil Gupta137ef892016-12-13 19:38:00 +05309557 if (pConfig->RSNWPAReqIELength > sizeof(pConfig->RSNWPAReqIE)) {
Jeff Johnson4416a782013-03-25 14:17:50 -07009558 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
9559 return -EINVAL;
9560 }
9561
Jeff Johnson295189b2012-06-20 16:38:30 -07009562 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
9563
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009564#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 if (params->ssid != NULL)
9566 {
9567 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
9568 pConfig->SSIDinfo.ssid.length = params->ssid_len;
9569 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9570 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9571 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009572#else
9573 if (ssid != NULL)
9574 {
9575 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
9576 pConfig->SSIDinfo.ssid.length = ssid_len;
9577 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9578 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9579 }
9580#endif
9581
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309582 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07009583 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309584
Jeff Johnson295189b2012-06-20 16:38:30 -07009585 /* default value */
9586 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
9587 pConfig->num_accept_mac = 0;
9588 pConfig->num_deny_mac = 0;
9589
9590 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9591 pBeacon->tail, pBeacon->tail_len);
9592
9593 /* pIe for black list is following form:
9594 type : 1 byte
9595 length : 1 byte
9596 OUI : 4 bytes
9597 acl type : 1 byte
9598 no of mac addr in black list: 1 byte
9599 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309600 */
9601 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 {
9603 pConfig->SapMacaddr_acl = pIe[6];
9604 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009605 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009606 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309607 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
9608 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9610 for (i = 0; i < pConfig->num_deny_mac; i++)
9611 {
9612 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9613 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009615 }
9616 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9617 pBeacon->tail, pBeacon->tail_len);
9618
9619 /* pIe for white list is following form:
9620 type : 1 byte
9621 length : 1 byte
9622 OUI : 4 bytes
9623 acl type : 1 byte
9624 no of mac addr in white list: 1 byte
9625 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309626 */
9627 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009628 {
9629 pConfig->SapMacaddr_acl = pIe[6];
9630 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009631 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309633 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
9634 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009635 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9636 for (i = 0; i < pConfig->num_accept_mac; i++)
9637 {
9638 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9639 acl_entry++;
9640 }
9641 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309642
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 wlan_hdd_set_sapHwmode(pHostapdAdapter);
9644
Jeff Johnsone7245742012-09-05 17:12:55 -07009645#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009646 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309647 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
9648 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05309649 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
9650 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009651 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
9652 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309653 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
9654 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009655 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309656 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07009657 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309658 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009659
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309660 /* If ACS disable and selected channel <= 14
9661 * OR
9662 * ACS enabled and ACS operating band is choosen as 2.4
9663 * AND
9664 * VHT in 2.4G Disabled
9665 * THEN
9666 * Fallback to 11N mode
9667 */
9668 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
9669 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05309670 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309671 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009672 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309673 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
9674 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009675 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
9676 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009677 }
9678#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309679
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 // ht_capab is not what the name conveys,this is used for protection bitmap
9681 pConfig->ht_capab =
9682 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
9683
Kapil Gupta137ef892016-12-13 19:38:00 +05309684 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -07009685 {
9686 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
9687 return -EINVAL;
9688 }
9689
9690 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309691 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
9693 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309694 pConfig->obssProtEnabled =
9695 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07009696
Chet Lanctot8cecea22014-02-11 19:09:36 -08009697#ifdef WLAN_FEATURE_11W
9698 pConfig->mfpCapable = MFPCapable;
9699 pConfig->mfpRequired = MFPRequired;
9700 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
9701 pConfig->mfpCapable, pConfig->mfpRequired);
9702#endif
9703
Arif Hussain6d2a3322013-11-17 19:50:10 -08009704 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009705 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08009706 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
9707 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
9708 (int)pConfig->channel);
9709 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
9710 pConfig->SapHw_mode, pConfig->privacy,
9711 pConfig->authType);
9712 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
9713 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
9714 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
9715 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009716
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309717 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 {
9719 //Bss already started. just return.
9720 //TODO Probably it should update some beacon params.
9721 hddLog( LOGE, "Bss Already started...Ignore the request");
9722 EXIT();
9723 return 0;
9724 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309725
Agarwal Ashish51325b52014-06-16 16:50:49 +05309726 if (vos_max_concurrent_connections_reached()) {
9727 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9728 return -EINVAL;
9729 }
9730
Jeff Johnson295189b2012-06-20 16:38:30 -07009731 pConfig->persona = pHostapdAdapter->device_mode;
9732
Peng Xu2446a892014-09-05 17:21:18 +05309733 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
9734 if ( NULL != psmeConfig)
9735 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309736 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05309737 sme_GetConfigParam(hHal, psmeConfig);
9738 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309739#ifdef WLAN_FEATURE_AP_HT40_24G
9740 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
9741 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
9742 && pHddCtx->cfg_ini->apHT40_24GEnabled)
9743 {
9744 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
9745 sme_UpdateConfig (hHal, psmeConfig);
9746 }
9747#endif
Peng Xu2446a892014-09-05 17:21:18 +05309748 vos_mem_free(psmeConfig);
9749 }
Peng Xuafc34e32014-09-25 13:23:55 +05309750 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05309751
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309752 set_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
9753
Jeff Johnson295189b2012-06-20 16:38:30 -07009754 pSapEventCallback = hdd_hostapd_SAPEventCB;
9755 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
9756 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
9757 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009758 hddLog(LOGE,FL("SAP Start Bss fail"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309759 ret = -EINVAL;
9760 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009761 }
9762
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309763 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07009764 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
9765
9766 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309767
Jeff Johnson295189b2012-06-20 16:38:30 -07009768 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309769 {
9770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009771 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07009772 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009773 VOS_ASSERT(0);
9774 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309775
Jeff Johnson295189b2012-06-20 16:38:30 -07009776 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Nishank Aggarwalc11826c2016-12-15 18:54:10 +05309777 if (WLANSAP_get_sessionId(pVosContext, &pHostapdAdapter->sessionId) !=
9778 VOS_STATUS_SUCCESS)
9779 {
9780 hddLog(LOGE,FL("Fail to get Softap sessionID"));
9781 VOS_ASSERT(0);
9782 }
Kaushik, Sushantf6070802014-10-15 15:09:23 +05309783 /* Initialize WMM configuation */
9784 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309785 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009786
Anurag Chouhan83026002016-12-13 22:46:21 +05309787#ifdef DHCP_SERVER_OFFLOAD
9788 /* set dhcp server offload */
9789 if (iniConfig->enable_dhcp_srv_offload &&
9790 sme_IsFeatureSupportedByFW(SAP_OFFLOADS)) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309791 vos_event_reset(&pHostapdAdapter->dhcp_status.vos_event);
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309792 status = wlan_hdd_set_dhcp_server_offload(pHostapdAdapter, false);
Anurag Chouhan83026002016-12-13 22:46:21 +05309793 if (!VOS_IS_STATUS_SUCCESS(status))
9794 {
9795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9796 ("HDD DHCP Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309797 vos_event_reset(&pHostapdState->vosEvent);
9798 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
9799 status = vos_wait_single_event(&pHostapdState->vosEvent,
9800 10000);
9801 if (!VOS_IS_STATUS_SUCCESS(status)) {
9802 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309803 ret = -EINVAL;
9804 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309805 }
9806 }
Anurag Chouhan83026002016-12-13 22:46:21 +05309807 }
Anurag Chouhan83026002016-12-13 22:46:21 +05309808 status = vos_wait_single_event(&pHostapdAdapter->dhcp_status.vos_event, 2000);
9809 if (!VOS_IS_STATUS_SUCCESS(status) || pHostapdAdapter->dhcp_status.dhcp_offload_status)
9810 {
9811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9812 ("ERROR: DHCP HDD vos wait for single_event failed!! %d"),
9813 pHostapdAdapter->dhcp_status.dhcp_offload_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309814 vos_event_reset(&pHostapdState->vosEvent);
9815 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
9816 status = vos_wait_single_event(&pHostapdState->vosEvent,
9817 10000);
9818 if (!VOS_IS_STATUS_SUCCESS(status)) {
9819 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309820 ret = -EINVAL;
9821 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309822 }
9823 }
Anurag Chouhan83026002016-12-13 22:46:21 +05309824 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +05309825#ifdef MDNS_OFFLOAD
9826 if (iniConfig->enable_mdns_offload) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309827 vos_event_reset(&pHostapdAdapter->mdns_status.vos_event);
Anurag Chouhan0b29de02016-12-16 13:18:40 +05309828 status = wlan_hdd_set_mdns_offload(pHostapdAdapter);
9829 if (VOS_IS_STATUS_SUCCESS(status))
9830 {
9831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9832 ("HDD MDNS Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309833 vos_event_reset(&pHostapdState->vosEvent);
9834 if (VOS_STATUS_SUCCESS ==
9835 WLANSAP_StopBss(pHddCtx->pvosContext)) {
9836 status = vos_wait_single_event(&pHostapdState->vosEvent,
9837 10000);
9838 if (!VOS_IS_STATUS_SUCCESS(status)) {
9839 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309840 ret = -EINVAL;
9841 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309842 }
9843 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +05309844 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +05309845 status = vos_wait_single_event(&pHostapdAdapter->
9846 mdns_status.vos_event, 2000);
9847 if (!VOS_IS_STATUS_SUCCESS(status) ||
9848 pHostapdAdapter->mdns_status.mdns_enable_status ||
9849 pHostapdAdapter->mdns_status.mdns_fqdn_status ||
9850 pHostapdAdapter->mdns_status.mdns_resp_status)
9851 {
9852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9853 ("MDNS HDD vos wait for single_event failed!! enable %d fqdn %d resp %d"),
9854 pHostapdAdapter->mdns_status.mdns_enable_status,
9855 pHostapdAdapter->mdns_status.mdns_fqdn_status,
9856 pHostapdAdapter->mdns_status.mdns_resp_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309857 vos_event_reset(&pHostapdState->vosEvent);
9858 if (VOS_STATUS_SUCCESS ==
9859 WLANSAP_StopBss(pHddCtx->pvosContext)) {
9860 status = vos_wait_single_event(&pHostapdState->vosEvent,
9861 10000);
9862 if (!VOS_IS_STATUS_SUCCESS(status)) {
9863 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309864 ret = -EINVAL;
9865 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +05309866 }
9867 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +05309868 }
9869 }
9870#endif /* MDNS_OFFLOAD */
9871 } else {
9872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9873 ("DHCP Disabled ini %d, FW %d"),
9874 iniConfig->enable_dhcp_srv_offload,
9875 sme_IsFeatureSupportedByFW(SAP_OFFLOADS));
Anurag Chouhan83026002016-12-13 22:46:21 +05309876 }
9877#endif /* DHCP_SERVER_OFFLOAD */
9878
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009879#ifdef WLAN_FEATURE_P2P_DEBUG
9880 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
9881 {
9882 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
9883 {
9884 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9885 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009886 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009887 }
9888 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
9889 {
9890 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9891 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009892 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009893 }
9894 }
9895#endif
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05309896 /* Check and restart SAP if it is on Unsafe channel */
9897 hdd_check_for_unsafe_ch(pHostapdAdapter, pHddCtx);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009898
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 pHostapdState->bCommit = TRUE;
9900 EXIT();
9901
9902 return 0;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309903error:
9904 clear_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
9905 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009906}
9907
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009908#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309909static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309910 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009911 struct beacon_parameters *params)
9912{
9913 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309914 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309915 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009916
9917 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309918
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309919 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9920 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
9921 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309922 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
9923 hdd_device_modetoString(pAdapter->device_mode),
9924 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009925
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309926 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9927 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309928 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009929 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309930 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009931 }
9932
Agarwal Ashish51325b52014-06-16 16:50:49 +05309933 if (vos_max_concurrent_connections_reached()) {
9934 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9935 return -EINVAL;
9936 }
9937
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309938 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009939 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009940 )
9941 {
9942 beacon_data_t *old,*new;
9943
9944 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309945
Jeff Johnson295189b2012-06-20 16:38:30 -07009946 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309947 {
9948 hddLog(VOS_TRACE_LEVEL_WARN,
9949 FL("already beacon info added to session(%d)"),
9950 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009951 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009953
9954 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9955
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309956 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07009957 {
9958 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009959 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009960 return -EINVAL;
9961 }
9962
9963 pAdapter->sessionCtx.ap.beacon = new;
9964
9965 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9966 }
9967
9968 EXIT();
9969 return status;
9970}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309971
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309972static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
9973 struct net_device *dev,
9974 struct beacon_parameters *params)
9975{
9976 int ret;
9977
9978 vos_ssr_protect(__func__);
9979 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
9980 vos_ssr_unprotect(__func__);
9981
9982 return ret;
9983}
9984
9985static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009986 struct net_device *dev,
9987 struct beacon_parameters *params)
9988{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309989 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309990 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9991 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309992 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009993
9994 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309995
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309996 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9997 TRACE_CODE_HDD_CFG80211_SET_BEACON,
9998 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
9999 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10000 __func__, hdd_device_modetoString(pAdapter->device_mode),
10001 pAdapter->device_mode);
10002
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010003 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10004 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010005 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010006 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010007 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010008 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010009
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010010 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010011 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010012 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010013 {
10014 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010015
Jeff Johnson295189b2012-06-20 16:38:30 -070010016 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010017
Jeff Johnson295189b2012-06-20 16:38:30 -070010018 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010019 {
10020 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10021 FL("session(%d) old and new heads points to NULL"),
10022 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010023 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010024 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010025
10026 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
10027
10028 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010029 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010030 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 return -EINVAL;
10032 }
10033
10034 pAdapter->sessionCtx.ap.beacon = new;
10035
10036 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
10037 }
10038
10039 EXIT();
10040 return status;
10041}
10042
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010043static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
10044 struct net_device *dev,
10045 struct beacon_parameters *params)
10046{
10047 int ret;
10048
10049 vos_ssr_protect(__func__);
10050 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
10051 vos_ssr_unprotect(__func__);
10052
10053 return ret;
10054}
10055
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010056#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10057
10058#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010059static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010060 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010061#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010062static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010063 struct net_device *dev)
10064#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010065{
10066 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -070010067 hdd_context_t *pHddCtx = NULL;
10068 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010069 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010070 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010071
10072 ENTER();
10073
10074 if (NULL == pAdapter)
10075 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010076 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010077 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010078 return -ENODEV;
10079 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010080
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010081 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10082 TRACE_CODE_HDD_CFG80211_STOP_AP,
10083 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010084 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10085 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010086 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010087 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010088 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -070010089 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010090
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010091 pScanInfo = &pHddCtx->scan_info;
10092
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010093 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10094 __func__, hdd_device_modetoString(pAdapter->device_mode),
10095 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010096
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010097 ret = wlan_hdd_scan_abort(pAdapter);
10098
Girish Gowli4bf7a632014-06-12 13:42:11 +053010099 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -070010100 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010101 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10102 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010103
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010104 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -070010105 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10107 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -080010108
Jeff Johnsone7245742012-09-05 17:12:55 -070010109 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010110 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -070010111 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010112 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010113 }
10114
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010115 /* Delete all associated STAs before stopping AP/P2P GO */
10116 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +053010117 hdd_hostapd_stop(dev);
10118
Jeff Johnson295189b2012-06-20 16:38:30 -070010119 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010120 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010121 )
10122 {
10123 beacon_data_t *old;
10124
10125 old = pAdapter->sessionCtx.ap.beacon;
10126
10127 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010128 {
10129 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10130 FL("session(%d) beacon data points to NULL"),
10131 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010134
Jeff Johnson295189b2012-06-20 16:38:30 -070010135 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010136
10137 mutex_lock(&pHddCtx->sap_lock);
10138 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
10139 {
Jeff Johnson4416a782013-03-25 14:17:50 -070010140 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010141 {
10142 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
10143
10144 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
10145
10146 if (!VOS_IS_STATUS_SUCCESS(status))
10147 {
10148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010149 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010150 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010151 }
10152 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010153 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +053010154 /* BSS stopped, clear the active sessions for this device mode */
10155 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010156 }
10157 mutex_unlock(&pHddCtx->sap_lock);
10158
10159 if(status != VOS_STATUS_SUCCESS)
10160 {
10161 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010162 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010163 return -EINVAL;
10164 }
10165
Jeff Johnson4416a782013-03-25 14:17:50 -070010166 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070010167 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
10168 ==eHAL_STATUS_FAILURE)
10169 {
10170 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010171 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010172 }
10173
Jeff Johnson4416a782013-03-25 14:17:50 -070010174 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070010175 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
10176 eANI_BOOLEAN_FALSE) )
10177 {
10178 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010179 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010180 }
10181
10182 // Reset WNI_CFG_PROBE_RSP Flags
10183 wlan_hdd_reset_prob_rspies(pAdapter);
10184
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010185 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
10186
Jeff Johnson295189b2012-06-20 16:38:30 -070010187 pAdapter->sessionCtx.ap.beacon = NULL;
10188 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010189#ifdef WLAN_FEATURE_P2P_DEBUG
10190 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
10191 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
10192 {
10193 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
10194 "GO got removed");
10195 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
10196 }
10197#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010198 }
10199 EXIT();
10200 return status;
10201}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010202
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010203#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10204static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
10205 struct net_device *dev)
10206{
10207 int ret;
10208
10209 vos_ssr_protect(__func__);
10210 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
10211 vos_ssr_unprotect(__func__);
10212
10213 return ret;
10214}
10215#else
10216static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
10217 struct net_device *dev)
10218{
10219 int ret;
10220
10221 vos_ssr_protect(__func__);
10222 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
10223 vos_ssr_unprotect(__func__);
10224
10225 return ret;
10226}
10227#endif
10228
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010229#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
10230
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010231static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010232 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010233 struct cfg80211_ap_settings *params)
10234{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010235 hdd_adapter_t *pAdapter;
10236 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010237 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010238
10239 ENTER();
10240
Girish Gowlib143d7a2015-02-18 19:39:55 +053010241 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010242 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010243 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +053010244 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010245 return -ENODEV;
10246 }
10247
10248 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10249 if (NULL == pAdapter)
10250 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010251 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010252 "%s: HDD adapter is Null", __func__);
10253 return -ENODEV;
10254 }
10255
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010256 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10257 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
10258 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010259 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
10260 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010261 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010262 "%s: HDD adapter magic is invalid", __func__);
10263 return -ENODEV;
10264 }
10265
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010266 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
10267
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010268 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010269 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010270 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010271 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010272 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010273 }
10274
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010275 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
10276 __func__, hdd_device_modetoString(pAdapter->device_mode),
10277 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010278
10279 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010280 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010281 )
10282 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010283 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010284
10285 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010286
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010287 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010288 {
10289 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10290 FL("already beacon info added to session(%d)"),
10291 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010292 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010293 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010294
Girish Gowlib143d7a2015-02-18 19:39:55 +053010295#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10296 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10297 &new,
10298 &params->beacon);
10299#else
10300 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10301 &new,
10302 &params->beacon,
10303 params->dtim_period);
10304#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010305
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010306 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010307 {
10308 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010309 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010310 return -EINVAL;
10311 }
10312 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -080010313#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -070010314 wlan_hdd_cfg80211_set_channel(wiphy, dev,
10315#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
10316 params->channel, params->channel_type);
10317#else
10318 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
10319#endif
Viral Modi3a32cc52013-02-08 11:14:52 -080010320#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010321 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010322 params->ssid_len, params->hidden_ssid,
10323 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010324 }
10325
10326 EXIT();
10327 return status;
10328}
10329
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010330static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
10331 struct net_device *dev,
10332 struct cfg80211_ap_settings *params)
10333{
10334 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010335
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010336 vos_ssr_protect(__func__);
10337 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
10338 vos_ssr_unprotect(__func__);
10339
10340 return ret;
10341}
10342
10343static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010344 struct net_device *dev,
10345 struct cfg80211_beacon_data *params)
10346{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010347 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010348 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010349 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010350
10351 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010352
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010353 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10354 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
10355 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -080010356 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010357 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010358
10359 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10360 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010361 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010362 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010363 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010364 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010365
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010366 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010367 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010368 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010369 {
10370 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010371
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010372 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010373
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010374 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010375 {
10376 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10377 FL("session(%d) beacon data points to NULL"),
10378 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010379 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010380 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010381
10382 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
10383
10384 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010385 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010386 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010387 return -EINVAL;
10388 }
10389
10390 pAdapter->sessionCtx.ap.beacon = new;
10391
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010392 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
10393 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010394 }
10395
10396 EXIT();
10397 return status;
10398}
10399
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010400static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
10401 struct net_device *dev,
10402 struct cfg80211_beacon_data *params)
10403{
10404 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010405
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010406 vos_ssr_protect(__func__);
10407 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
10408 vos_ssr_unprotect(__func__);
10409
10410 return ret;
10411}
10412
10413#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010414
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010415static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 struct net_device *dev,
10417 struct bss_parameters *params)
10418{
10419 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010420 hdd_context_t *pHddCtx;
10421 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010422
10423 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010424
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010425 if (NULL == pAdapter)
10426 {
10427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10428 "%s: HDD adapter is Null", __func__);
10429 return -ENODEV;
10430 }
10431 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010432 ret = wlan_hdd_validate_context(pHddCtx);
10433 if (0 != ret)
10434 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010435 return ret;
10436 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010437 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10438 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
10439 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010440 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10441 __func__, hdd_device_modetoString(pAdapter->device_mode),
10442 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010443
10444 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010445 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010446 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010447 {
10448 /* ap_isolate == -1 means that in change bss, upper layer doesn't
10449 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010450 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -070010451 {
10452 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010453 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010454 }
10455
10456 EXIT();
10457 return 0;
10458}
10459
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010460static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
10461 struct net_device *dev,
10462 struct bss_parameters *params)
10463{
10464 int ret;
10465
10466 vos_ssr_protect(__func__);
10467 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
10468 vos_ssr_unprotect(__func__);
10469
10470 return ret;
10471}
Kiet Lam10841362013-11-01 11:36:50 +053010472/* FUNCTION: wlan_hdd_change_country_code_cd
10473* to wait for contry code completion
10474*/
10475void* wlan_hdd_change_country_code_cb(void *pAdapter)
10476{
10477 hdd_adapter_t *call_back_pAdapter = pAdapter;
10478 complete(&call_back_pAdapter->change_country_code);
10479 return NULL;
10480}
10481
Jeff Johnson295189b2012-06-20 16:38:30 -070010482/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010483 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -070010484 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
10485 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010486int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010487 struct net_device *ndev,
10488 enum nl80211_iftype type,
10489 u32 *flags,
10490 struct vif_params *params
10491 )
10492{
10493 struct wireless_dev *wdev;
10494 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010495 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -070010496 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010497 tCsrRoamProfile *pRoamProfile = NULL;
10498 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010499 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010500 eMib_dot11DesiredBssType connectedBssType;
10501 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010502 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010503
10504 ENTER();
10505
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010506 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010507 {
10508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10509 "%s: Adapter context is null", __func__);
10510 return VOS_STATUS_E_FAILURE;
10511 }
10512
10513 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10514 if (!pHddCtx)
10515 {
10516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10517 "%s: HDD context is null", __func__);
10518 return VOS_STATUS_E_FAILURE;
10519 }
10520
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010521 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10522 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
10523 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010524 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010525 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010526 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010527 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010528 }
10529
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010530 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10531 __func__, hdd_device_modetoString(pAdapter->device_mode),
10532 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010533
Agarwal Ashish51325b52014-06-16 16:50:49 +053010534 if (vos_max_concurrent_connections_reached()) {
10535 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10536 return -EINVAL;
10537 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010538 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070010539 wdev = ndev->ieee80211_ptr;
10540
10541#ifdef WLAN_BTAMP_FEATURE
10542 if((NL80211_IFTYPE_P2P_CLIENT == type)||
10543 (NL80211_IFTYPE_ADHOC == type)||
10544 (NL80211_IFTYPE_AP == type)||
10545 (NL80211_IFTYPE_P2P_GO == type))
10546 {
10547 pHddCtx->isAmpAllowed = VOS_FALSE;
10548 // stop AMP traffic
10549 status = WLANBAP_StopAmp();
10550 if(VOS_STATUS_SUCCESS != status )
10551 {
10552 pHddCtx->isAmpAllowed = VOS_TRUE;
10553 hddLog(VOS_TRACE_LEVEL_FATAL,
10554 "%s: Failed to stop AMP", __func__);
10555 return -EINVAL;
10556 }
10557 }
10558#endif //WLAN_BTAMP_FEATURE
10559 /* Reset the current device mode bit mask*/
10560 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
10561
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053010562 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
10563 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
10564 (type == NL80211_IFTYPE_P2P_GO)))
10565 {
10566 /* Notify Mode change in case of concurrency.
10567 * Below function invokes TDLS teardown Functionality Since TDLS is
10568 * not Supported in case of concurrency i.e Once P2P session
10569 * is detected disable offchannel and teardown TDLS links
10570 */
10571 hddLog(LOG1,
10572 FL("Device mode = %d Interface type = %d"),
10573 pAdapter->device_mode, type);
10574 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
10575 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053010576
Jeff Johnson295189b2012-06-20 16:38:30 -070010577 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070010578 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070010579 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010580 )
10581 {
10582 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010583 if (!pWextState)
10584 {
10585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10586 "%s: pWextState is null", __func__);
10587 return VOS_STATUS_E_FAILURE;
10588 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010589 pRoamProfile = &pWextState->roamProfile;
10590 LastBSSType = pRoamProfile->BSSType;
10591
10592 switch (type)
10593 {
10594 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010595 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010596 hddLog(VOS_TRACE_LEVEL_INFO,
10597 "%s: setting interface Type to INFRASTRUCTURE", __func__);
10598 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010599#ifdef WLAN_FEATURE_11AC
10600 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
10601 {
10602 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
10603 }
10604#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010605 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070010606 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010607 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010608 //Check for sub-string p2p to confirm its a p2p interface
10609 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010610 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053010611#ifdef FEATURE_WLAN_TDLS
10612 mutex_lock(&pHddCtx->tdls_lock);
10613 wlan_hdd_tdls_exit(pAdapter, TRUE);
10614 mutex_unlock(&pHddCtx->tdls_lock);
10615#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010616 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10617 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10618 }
10619 else
10620 {
10621 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010622 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010623 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010624 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053010625
Jeff Johnson295189b2012-06-20 16:38:30 -070010626 case NL80211_IFTYPE_ADHOC:
10627 hddLog(VOS_TRACE_LEVEL_INFO,
10628 "%s: setting interface Type to ADHOC", __func__);
10629 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
10630 pRoamProfile->phyMode =
10631 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070010632 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010633 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053010634 hdd_set_ibss_ops( pAdapter );
10635 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053010636
10637 status = hdd_sta_id_hash_attach(pAdapter);
10638 if (VOS_STATUS_SUCCESS != status) {
10639 hddLog(VOS_TRACE_LEVEL_ERROR,
10640 FL("Failed to initialize hash for IBSS"));
10641 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010642 break;
10643
10644 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010645 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010646 {
10647 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10648 "%s: setting interface Type to %s", __func__,
10649 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
10650
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010651 //Cancel any remain on channel for GO mode
10652 if (NL80211_IFTYPE_P2P_GO == type)
10653 {
10654 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
10655 }
Mohit Khanna0f232092012-09-11 14:46:08 -070010656 if (NL80211_IFTYPE_AP == type)
10657 {
10658 /* As Loading WLAN Driver one interface being created for p2p device
10659 * address. This will take one HW STA and the max number of clients
10660 * that can connect to softAP will be reduced by one. so while changing
10661 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
10662 * interface as it is not required in SoftAP mode.
10663 */
10664
10665 // Get P2P Adapter
10666 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
10667
10668 if (pP2pAdapter)
10669 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +053010670 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +053010671 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -070010672 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
10673 }
10674 }
Swaroop Goltia2e32212014-04-09 23:37:33 +053010675 //Disable IMPS & BMPS for SAP/GO
10676 if(VOS_STATUS_E_FAILURE ==
10677 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
10678 {
10679 //Fail to Exit BMPS
10680 VOS_ASSERT(0);
10681 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053010682
10683 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
10684
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010685#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070010686
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010687 /* A Mutex Lock is introduced while changing the mode to
10688 * protect the concurrent access for the Adapters by TDLS
10689 * module.
10690 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010691 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010692#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010693 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053010694 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010695 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070010696 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10697 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010698#ifdef FEATURE_WLAN_TDLS
10699 mutex_unlock(&pHddCtx->tdls_lock);
10700#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010701 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
10702 (pConfig->apRandomBssidEnabled))
10703 {
10704 /* To meet Android requirements create a randomized
10705 MAC address of the form 02:1A:11:Fx:xx:xx */
10706 get_random_bytes(&ndev->dev_addr[3], 3);
10707 ndev->dev_addr[0] = 0x02;
10708 ndev->dev_addr[1] = 0x1A;
10709 ndev->dev_addr[2] = 0x11;
10710 ndev->dev_addr[3] |= 0xF0;
10711 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
10712 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080010713 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
10714 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010715 }
10716
Jeff Johnson295189b2012-06-20 16:38:30 -070010717 hdd_set_ap_ops( pAdapter->dev );
10718
Kiet Lam10841362013-11-01 11:36:50 +053010719 /* This is for only SAP mode where users can
10720 * control country through ini.
10721 * P2P GO follows station country code
10722 * acquired during the STA scanning. */
10723 if((NL80211_IFTYPE_AP == type) &&
10724 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
10725 {
10726 int status = 0;
10727 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
10728 "%s: setting country code from INI ", __func__);
10729 init_completion(&pAdapter->change_country_code);
10730 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
10731 (void *)(tSmeChangeCountryCallback)
10732 wlan_hdd_change_country_code_cb,
10733 pConfig->apCntryCode, pAdapter,
10734 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053010735 eSIR_FALSE,
10736 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053010737 if (eHAL_STATUS_SUCCESS == status)
10738 {
10739 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010740 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053010741 &pAdapter->change_country_code,
10742 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010743 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053010744 {
10745 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010746 FL("SME Timed out while setting country code %ld"),
10747 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080010748
10749 if (pHddCtx->isLogpInProgress)
10750 {
10751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10752 "%s: LOGP in Progress. Ignore!!!", __func__);
10753 return -EAGAIN;
10754 }
Kiet Lam10841362013-11-01 11:36:50 +053010755 }
10756 }
10757 else
10758 {
10759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010760 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053010761 return -EINVAL;
10762 }
10763 }
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +053010764 status = hdd_init_ap_mode(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -070010765 if(status != VOS_STATUS_SUCCESS)
10766 {
10767 hddLog(VOS_TRACE_LEVEL_FATAL,
10768 "%s: Error initializing the ap mode", __func__);
10769 return -EINVAL;
10770 }
10771 hdd_set_conparam(1);
10772
Nirav Shah7e3c8132015-06-22 23:51:42 +053010773 status = hdd_sta_id_hash_attach(pAdapter);
10774 if (VOS_STATUS_SUCCESS != status)
10775 {
10776 hddLog(VOS_TRACE_LEVEL_ERROR,
10777 FL("Failed to initialize hash for AP"));
10778 return -EINVAL;
10779 }
10780
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 /*interface type changed update in wiphy structure*/
10782 if(wdev)
10783 {
10784 wdev->iftype = type;
10785 pHddCtx->change_iface = type;
10786 }
10787 else
10788 {
10789 hddLog(VOS_TRACE_LEVEL_ERROR,
10790 "%s: ERROR !!!! Wireless dev is NULL", __func__);
10791 return -EINVAL;
10792 }
10793 goto done;
10794 }
10795
10796 default:
10797 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10798 __func__);
10799 return -EOPNOTSUPP;
10800 }
10801 }
10802 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010803 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010804 )
10805 {
10806 switch(type)
10807 {
10808 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010809 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010810 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053010811
10812 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010813#ifdef FEATURE_WLAN_TDLS
10814
10815 /* A Mutex Lock is introduced while changing the mode to
10816 * protect the concurrent access for the Adapters by TDLS
10817 * module.
10818 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010819 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010820#endif
c_hpothu002231a2015-02-05 14:58:51 +053010821 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010822 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010823 //Check for sub-string p2p to confirm its a p2p interface
10824 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010825 {
10826 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10827 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10828 }
10829 else
10830 {
10831 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010833 }
Agrawal Ashishcfe83282016-09-29 13:03:45 +053010834
10835 /* set con_mode to STA only when no SAP concurrency mode */
10836 if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO)))
10837 hdd_set_conparam(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010838 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010839 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
10840 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010841#ifdef FEATURE_WLAN_TDLS
10842 mutex_unlock(&pHddCtx->tdls_lock);
10843#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053010844 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070010845 if( VOS_STATUS_SUCCESS != status )
10846 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070010847 /* In case of JB, for P2P-GO, only change interface will be called,
10848 * This is the right place to enable back bmps_imps()
10849 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053010850 if (pHddCtx->hdd_wlan_suspended)
10851 {
10852 hdd_set_pwrparams(pHddCtx);
10853 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010854 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010855 goto done;
10856 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010857 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010858 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010859 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10860 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010861 goto done;
10862 default:
10863 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10864 __func__);
10865 return -EOPNOTSUPP;
10866
10867 }
10868
10869 }
10870 else
10871 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010872 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
10873 __func__, hdd_device_modetoString(pAdapter->device_mode),
10874 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010875 return -EOPNOTSUPP;
10876 }
10877
10878
10879 if(pRoamProfile)
10880 {
10881 if ( LastBSSType != pRoamProfile->BSSType )
10882 {
10883 /*interface type changed update in wiphy structure*/
10884 wdev->iftype = type;
10885
10886 /*the BSS mode changed, We need to issue disconnect
10887 if connected or in IBSS disconnect state*/
10888 if ( hdd_connGetConnectedBssType(
10889 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
10890 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
10891 {
10892 /*need to issue a disconnect to CSR.*/
10893 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10894 if( eHAL_STATUS_SUCCESS ==
10895 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10896 pAdapter->sessionId,
10897 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
10898 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010899 ret = wait_for_completion_interruptible_timeout(
10900 &pAdapter->disconnect_comp_var,
10901 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10902 if (ret <= 0)
10903 {
10904 hddLog(VOS_TRACE_LEVEL_ERROR,
10905 FL("wait on disconnect_comp_var failed %ld"), ret);
10906 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010907 }
10908 }
10909 }
10910 }
10911
10912done:
10913 /*set bitmask based on updated value*/
10914 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070010915
10916 /* Only STA mode support TM now
10917 * all other mode, TM feature should be disabled */
10918 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
10919 (~VOS_STA & pHddCtx->concurrency_mode) )
10920 {
10921 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
10922 }
10923
Jeff Johnson295189b2012-06-20 16:38:30 -070010924#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010925 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053010926 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010927 {
10928 //we are ok to do AMP
10929 pHddCtx->isAmpAllowed = VOS_TRUE;
10930 }
10931#endif //WLAN_BTAMP_FEATURE
10932 EXIT();
10933 return 0;
10934}
10935
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010936/*
10937 * FUNCTION: wlan_hdd_cfg80211_change_iface
10938 * wrapper function to protect the actual implementation from SSR.
10939 */
10940int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
10941 struct net_device *ndev,
10942 enum nl80211_iftype type,
10943 u32 *flags,
10944 struct vif_params *params
10945 )
10946{
10947 int ret;
10948
10949 vos_ssr_protect(__func__);
10950 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
10951 vos_ssr_unprotect(__func__);
10952
10953 return ret;
10954}
10955
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010956#ifdef FEATURE_WLAN_TDLS
10957static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010958 struct net_device *dev,
10959#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10960 const u8 *mac,
10961#else
10962 u8 *mac,
10963#endif
10964 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010965{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010966 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010967 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010968 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010969 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010970 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010971 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010972
10973 ENTER();
10974
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010975 if (!dev) {
10976 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
10977 return -EINVAL;
10978 }
10979
10980 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10981 if (!pAdapter) {
10982 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
10983 return -EINVAL;
10984 }
10985
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010986 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010987 {
10988 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10989 "Invalid arguments");
10990 return -EINVAL;
10991 }
Hoonki Lee27511902013-03-14 18:19:06 -070010992
10993 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
10994 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
10995 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010996 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070010997 "%s: TDLS mode is disabled OR not enabled in FW."
10998 MAC_ADDRESS_STR " Request declined.",
10999 __func__, MAC_ADDR_ARRAY(mac));
11000 return -ENOTSUPP;
11001 }
11002
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011003 if (pHddCtx->isLogpInProgress)
11004 {
11005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11006 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053011007 wlan_hdd_tdls_set_link_status(pAdapter,
11008 mac,
11009 eTDLS_LINK_IDLE,
11010 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011011 return -EBUSY;
11012 }
11013
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053011014 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053011015 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011016
11017 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011018 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011019 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
11020 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053011021 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011022 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011023 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011024
11025 /* in add station, we accept existing valid staId if there is */
11026 if ((0 == update) &&
11027 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
11028 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011029 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011030 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011031 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011032 " link_status %d. staId %d. add station ignored.",
11033 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011034 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011035 return 0;
11036 }
11037 /* in change station, we accept only when staId is valid */
11038 if ((1 == update) &&
11039 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
11040 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
11041 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011042 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011043 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011044 "%s: " MAC_ADDRESS_STR
11045 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011046 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
11047 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
11048 mutex_unlock(&pHddCtx->tdls_lock);
11049 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011050 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011051 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011052
11053 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053011054 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011055 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011056 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11057 "%s: " MAC_ADDRESS_STR
11058 " TDLS setup is ongoing. Request declined.",
11059 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070011060 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011061 }
11062
11063 /* first to check if we reached to maximum supported TDLS peer.
11064 TODO: for now, return -EPERM looks working fine,
11065 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011066 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
11067 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011068 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011069 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11070 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011071 " TDLS Max peer already connected. Request declined."
11072 " Num of peers (%d), Max allowed (%d).",
11073 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
11074 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070011075 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011076 }
11077 else
11078 {
11079 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011080 mutex_lock(&pHddCtx->tdls_lock);
11081 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011082 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011083 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011084 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011085 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11086 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
11087 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011088 return -EPERM;
11089 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011090 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011091 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011092 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053011093 wlan_hdd_tdls_set_link_status(pAdapter,
11094 mac,
11095 eTDLS_LINK_CONNECTING,
11096 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011097
Jeff Johnsond75fe012013-04-06 10:53:06 -070011098 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053011099 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011100 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011102 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070011103 if(StaParams->htcap_present)
11104 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011106 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011108 "ht_capa->extended_capabilities: %0x",
11109 StaParams->HTCap.extendedHtCapInfo);
11110 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011112 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011114 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070011115 if(StaParams->vhtcap_present)
11116 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011118 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
11119 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
11120 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
11121 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011122 {
11123 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011124 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011125 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011127 "[%d]: %x ", i, StaParams->supported_rates[i]);
11128 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070011129 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053011130 else if ((1 == update) && (NULL == StaParams))
11131 {
11132 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11133 "%s : update is true, but staParams is NULL. Error!", __func__);
11134 return -EPERM;
11135 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011136
11137 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
11138
11139 if (!update)
11140 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053011141 /*Before adding sta make sure that device exited from BMPS*/
11142 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
11143 {
11144 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11145 "%s: Adding tdls peer sta. Disable BMPS", __func__);
11146 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
11147 if (status != VOS_STATUS_SUCCESS) {
11148 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
11149 }
11150 }
11151
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011152 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011153 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011154 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053011155 hddLog(VOS_TRACE_LEVEL_ERROR,
11156 FL("Failed to add TDLS peer STA. Enable Bmps"));
11157 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011158 return -EPERM;
11159 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011160 }
11161 else
11162 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011163 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011164 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011165 if (ret != eHAL_STATUS_SUCCESS) {
11166 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
11167 return -EPERM;
11168 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011169 }
11170
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011171 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011172 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
11173
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053011174 mutex_lock(&pHddCtx->tdls_lock);
11175 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
11176
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011177 if ((pTdlsPeer != NULL) &&
11178 (pTdlsPeer->link_status == eTDLS_LINK_TEARING))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011179 {
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011180 hddLog(VOS_TRACE_LEVEL_ERROR,
11181 FL("peer link status %u"), pTdlsPeer->link_status);
11182 mutex_unlock(&pHddCtx->tdls_lock);
11183 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011184 }
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053011185 mutex_unlock(&pHddCtx->tdls_lock);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011186
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011187 if (ret <= 0)
11188 {
11189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11190 "%s: timeout waiting for tdls add station indication %ld",
11191 __func__, ret);
11192 goto error;
11193 }
11194
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011195 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
11196 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011198 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011199 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011200 }
11201
11202 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070011203
11204error:
Atul Mittal115287b2014-07-08 13:26:33 +053011205 wlan_hdd_tdls_set_link_status(pAdapter,
11206 mac,
11207 eTDLS_LINK_IDLE,
11208 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070011209 return -EPERM;
11210
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011211}
11212#endif
11213
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011214static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011215 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011216#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11217 const u8 *mac,
11218#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011219 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011220#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011221 struct station_parameters *params)
11222{
11223 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011224 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011225 hdd_context_t *pHddCtx;
11226 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011227 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011228 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011229#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011230 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011231 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011232 tANI_U8 isOffChannelSupported = 0;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011233 tANI_U8 isQosWmmSta = FALSE;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011234#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011235
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011236 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011237
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011238 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011239 if ((NULL == pAdapter))
11240 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011242 "invalid adapter ");
11243 return -EINVAL;
11244 }
11245
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011246 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11247 TRACE_CODE_HDD_CHANGE_STATION,
11248 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053011249 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011250
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011251 ret = wlan_hdd_validate_context(pHddCtx);
11252 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053011253 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011254 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011255 }
11256
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011257 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11258
11259 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011260 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11262 "invalid HDD station context");
11263 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011264 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011265 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
11266
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011267 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
11268 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070011269 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011270 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070011271 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011272 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070011273 WLANTL_STA_AUTHENTICATED);
11274
Gopichand Nakkala29149562013-05-10 21:43:41 +053011275 if (status != VOS_STATUS_SUCCESS)
11276 {
11277 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11278 "%s: Not able to change TL state to AUTHENTICATED", __func__);
11279 return -EINVAL;
11280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011281 }
11282 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070011283 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
11284 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011285#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011286 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
11287 StaParams.capability = params->capability;
11288 StaParams.uapsd_queues = params->uapsd_queues;
11289 StaParams.max_sp = params->max_sp;
11290
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011291 /* Convert (first channel , number of channels) tuple to
11292 * the total list of channels. This goes with the assumption
11293 * that if the first channel is < 14, then the next channels
11294 * are an incremental of 1 else an incremental of 4 till the number
11295 * of channels.
11296 */
11297 if (0 != params->supported_channels_len) {
11298 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
11299 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
11300 {
11301 int wifi_chan_index;
11302 StaParams.supported_channels[j] = params->supported_channels[i];
11303 wifi_chan_index =
11304 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
11305 no_of_channels = params->supported_channels[i+1];
11306 for(k=1; k <= no_of_channels; k++)
11307 {
11308 StaParams.supported_channels[j+1] =
11309 StaParams.supported_channels[j] + wifi_chan_index;
11310 j+=1;
11311 }
11312 }
11313 StaParams.supported_channels_len = j;
11314 }
SaidiReddy Yenuga0f1a1592017-04-05 13:18:26 +053011315 if (params->supported_oper_classes_len >
11316 SIR_MAC_MAX_SUPP_OPER_CLASSES) {
11317 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11318 "received oper classes:%d, resetting it to max supported %d",
11319 params->supported_oper_classes_len,
11320 SIR_MAC_MAX_SUPP_OPER_CLASSES);
11321 params->supported_oper_classes_len =
11322 SIR_MAC_MAX_SUPP_OPER_CLASSES;
11323 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011324 vos_mem_copy(StaParams.supported_oper_classes,
11325 params->supported_oper_classes,
11326 params->supported_oper_classes_len);
11327 StaParams.supported_oper_classes_len =
11328 params->supported_oper_classes_len;
11329
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053011330 if (params->ext_capab_len > sizeof(StaParams.extn_capability)) {
11331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11332 "received extn capabilities:%d, resetting it to max supported",
11333 params->ext_capab_len);
11334 params->ext_capab_len = sizeof(StaParams.extn_capability);
11335 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011336 if (0 != params->ext_capab_len)
11337 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053011338 params->ext_capab_len);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011339
11340 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011341 {
11342 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011343 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011344 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011345
11346 StaParams.supported_rates_len = params->supported_rates_len;
11347
11348 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
11349 * The supported_rates array , for all the structures propogating till Add Sta
11350 * to the firmware has to be modified , if the supplicant (ieee80211) is
11351 * modified to send more rates.
11352 */
11353
11354 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
11355 */
11356 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
11357 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
11358
11359 if (0 != StaParams.supported_rates_len) {
11360 int i = 0;
11361 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
11362 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011363 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011364 "Supported Rates with Length %d", StaParams.supported_rates_len);
11365 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011366 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011367 "[%d]: %0x", i, StaParams.supported_rates[i]);
11368 }
11369
11370 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011371 {
11372 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011373 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011374 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011375
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011376 if (0 != params->ext_capab_len ) {
11377 /*Define A Macro : TODO Sunil*/
11378 if ((1<<4) & StaParams.extn_capability[3]) {
11379 isBufSta = 1;
11380 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011381 /* TDLS Channel Switching Support */
11382 if ((1<<6) & StaParams.extn_capability[3]) {
11383 isOffChannelSupported = 1;
11384 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011385 }
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011386
11387 if (pHddCtx->cfg_ini->fEnableTDLSWmmMode &&
Nitesh Shah48df4c02016-08-12 16:27:33 +053011388 (params->ht_capa || params->vht_capa ||
11389 (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME))))
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011390 /* TDLS Peer is WME/QoS capable */
11391 isQosWmmSta = TRUE;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011392
11393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11394 "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d",
11395 __func__, isQosWmmSta, StaParams.htcap_present);
11396
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011397 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
11398 &StaParams, isBufSta,
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011399 isOffChannelSupported,
11400 isQosWmmSta);
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011401
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011402 if (VOS_STATUS_SUCCESS != status) {
11403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11404 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
11405 return -EINVAL;
11406 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011407 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
11408
11409 if (VOS_STATUS_SUCCESS != status) {
11410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11411 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
11412 return -EINVAL;
11413 }
11414 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011415#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053011416 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011417 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011418 return status;
11419}
11420
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011421#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
11422static int wlan_hdd_change_station(struct wiphy *wiphy,
11423 struct net_device *dev,
11424 const u8 *mac,
11425 struct station_parameters *params)
11426#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011427static int wlan_hdd_change_station(struct wiphy *wiphy,
11428 struct net_device *dev,
11429 u8 *mac,
11430 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011431#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011432{
11433 int ret;
11434
11435 vos_ssr_protect(__func__);
11436 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
11437 vos_ssr_unprotect(__func__);
11438
11439 return ret;
11440}
11441
Jeff Johnson295189b2012-06-20 16:38:30 -070011442/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011443 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 * This function is used to initialize the key information
11445 */
11446#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011447static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011448 struct net_device *ndev,
11449 u8 key_index, bool pairwise,
11450 const u8 *mac_addr,
11451 struct key_params *params
11452 )
11453#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011454static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011455 struct net_device *ndev,
11456 u8 key_index, const u8 *mac_addr,
11457 struct key_params *params
11458 )
11459#endif
11460{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011461 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 tCsrRoamSetKey setKey;
11463 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011464 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011465 v_U32_t roamId= 0xFF;
11466 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011467 hdd_hostapd_state_t *pHostapdState;
11468 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011469 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011470 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011471
11472 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011473
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011474 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11475 TRACE_CODE_HDD_CFG80211_ADD_KEY,
11476 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011477 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11478 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011479 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011480 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011481 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011482 }
11483
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011484 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11485 __func__, hdd_device_modetoString(pAdapter->device_mode),
11486 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011487
11488 if (CSR_MAX_NUM_KEY <= key_index)
11489 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011490 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011491 key_index);
11492
11493 return -EINVAL;
11494 }
11495
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011496 if (CSR_MAX_KEY_LEN < params->key_len)
11497 {
11498 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
11499 params->key_len);
11500
11501 return -EINVAL;
11502 }
11503
11504 hddLog(VOS_TRACE_LEVEL_INFO,
11505 "%s: called with key index = %d & key length %d",
11506 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011507
11508 /*extract key idx, key len and key*/
11509 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11510 setKey.keyId = key_index;
11511 setKey.keyLength = params->key_len;
11512 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
11513
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011514 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011515 {
11516 case WLAN_CIPHER_SUITE_WEP40:
11517 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
11518 break;
11519
11520 case WLAN_CIPHER_SUITE_WEP104:
11521 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
11522 break;
11523
11524 case WLAN_CIPHER_SUITE_TKIP:
11525 {
11526 u8 *pKey = &setKey.Key[0];
11527 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
11528
11529 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
11530
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011531 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070011532
11533 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011534 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011535 |--------------|----------|----------|
11536 <---16bytes---><--8bytes--><--8bytes-->
11537
11538 */
11539 /*Sme expects the 32 bytes key to be in the below order
11540
11541 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011542 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011543 |--------------|----------|----------|
11544 <---16bytes---><--8bytes--><--8bytes-->
11545 */
11546 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011547 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011548
11549 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011550 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011551
11552 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011553 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011554
11555
11556 break;
11557 }
11558
11559 case WLAN_CIPHER_SUITE_CCMP:
11560 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
11561 break;
11562
11563#ifdef FEATURE_WLAN_WAPI
11564 case WLAN_CIPHER_SUITE_SMS4:
11565 {
11566 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11567 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
11568 params->key, params->key_len);
11569 return 0;
11570 }
11571#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011572
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011573#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011574 case WLAN_CIPHER_SUITE_KRK:
11575 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
11576 break;
11577#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011578
11579#ifdef WLAN_FEATURE_11W
11580 case WLAN_CIPHER_SUITE_AES_CMAC:
11581 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070011582 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070011583#endif
11584
Jeff Johnson295189b2012-06-20 16:38:30 -070011585 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011586 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011587 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011588 status = -EOPNOTSUPP;
11589 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011590 }
11591
11592 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
11593 __func__, setKey.encType);
11594
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011595 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070011596#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11597 (!pairwise)
11598#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011599 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070011600#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011601 )
11602 {
11603 /* set group key*/
11604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11605 "%s- %d: setting Broadcast key",
11606 __func__, __LINE__);
11607 setKey.keyDirection = eSIR_RX_ONLY;
11608 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11609 }
11610 else
11611 {
11612 /* set pairwise key*/
11613 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11614 "%s- %d: setting pairwise key",
11615 __func__, __LINE__);
11616 setKey.keyDirection = eSIR_TX_RX;
11617 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11618 }
11619 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
11620 {
11621 setKey.keyDirection = eSIR_TX_RX;
11622 /*Set the group key*/
11623 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11624 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011625
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011626 if ( 0 != status )
11627 {
11628 hddLog(VOS_TRACE_LEVEL_ERROR,
11629 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011630 status = -EINVAL;
11631 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011632 }
11633 /*Save the keys here and call sme_RoamSetKey for setting
11634 the PTK after peer joins the IBSS network*/
11635 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
11636 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011637 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011638 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053011639 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
11640 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
11641 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011642 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011643 if( pHostapdState->bssState == BSS_START )
11644 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011645 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11646 vos_status = wlan_hdd_check_ula_done(pAdapter);
11647
11648 if ( vos_status != VOS_STATUS_SUCCESS )
11649 {
11650 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11651 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11652 __LINE__, vos_status );
11653
11654 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11655
11656 status = -EINVAL;
11657 goto end;
11658 }
11659
Jeff Johnson295189b2012-06-20 16:38:30 -070011660 status = WLANSAP_SetKeySta( pVosContext, &setKey);
11661
11662 if ( status != eHAL_STATUS_SUCCESS )
11663 {
11664 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11665 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11666 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011667 status = -EINVAL;
11668 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011669 }
11670 }
11671
11672 /* Saving WEP keys */
11673 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
11674 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
11675 {
11676 //Save the wep key in ap context. Issue setkey after the BSS is started.
11677 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
11678 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
11679 }
11680 else
11681 {
11682 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011683 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011684 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
11685 }
11686 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011687 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
11688 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011689 {
11690 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11691 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11692
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011693#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11694 if (!pairwise)
11695#else
11696 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
11697#endif
11698 {
11699 /* set group key*/
11700 if (pHddStaCtx->roam_info.deferKeyComplete)
11701 {
11702 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11703 "%s- %d: Perform Set key Complete",
11704 __func__, __LINE__);
11705 hdd_PerformRoamSetKeyComplete(pAdapter);
11706 }
11707 }
11708
Jeff Johnson295189b2012-06-20 16:38:30 -070011709 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
11710
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080011711 pWextState->roamProfile.Keys.defaultIndex = key_index;
11712
11713
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011714 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011715 params->key, params->key_len);
11716
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011717
Jeff Johnson295189b2012-06-20 16:38:30 -070011718 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11719
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011720 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011721 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011722 __func__, setKey.peerMac[0], setKey.peerMac[1],
11723 setKey.peerMac[2], setKey.peerMac[3],
11724 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011725 setKey.keyDirection);
11726
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011727 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053011728
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011729 if ( vos_status != VOS_STATUS_SUCCESS )
11730 {
11731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011732 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11733 __LINE__, vos_status );
11734
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011735 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011736
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011737 status = -EINVAL;
11738 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011739
11740 }
11741
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011742#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011743 /* The supplicant may attempt to set the PTK once pre-authentication
11744 is done. Save the key in the UMAC and include it in the ADD BSS
11745 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011746 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011747 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011748 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011749 hddLog(VOS_TRACE_LEVEL_INFO_MED,
11750 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011751 status = 0;
11752 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011753 }
11754 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
11755 {
11756 hddLog(VOS_TRACE_LEVEL_ERROR,
11757 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011758 status = -EINVAL;
11759 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011760 }
11761#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070011762
11763 /* issue set key request to SME*/
11764 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11765 pAdapter->sessionId, &setKey, &roamId );
11766
11767 if ( 0 != status )
11768 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011769 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011770 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
11771 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011772 status = -EINVAL;
11773 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011774 }
11775
11776
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011777 /* in case of IBSS as there was no information available about WEP keys during
11778 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070011779 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011780 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
11781 !( ( IW_AUTH_KEY_MGMT_802_1X
11782 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070011783 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
11784 )
11785 &&
11786 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
11787 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
11788 )
11789 )
11790 {
11791 setKey.keyDirection = eSIR_RX_ONLY;
11792 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11793
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011794 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011795 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011796 __func__, setKey.peerMac[0], setKey.peerMac[1],
11797 setKey.peerMac[2], setKey.peerMac[3],
11798 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 setKey.keyDirection);
11800
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011801 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011802 pAdapter->sessionId, &setKey, &roamId );
11803
11804 if ( 0 != status )
11805 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011806 hddLog(VOS_TRACE_LEVEL_ERROR,
11807 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011808 __func__, status);
11809 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011810 status = -EINVAL;
11811 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011812 }
11813 }
11814 }
11815
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011816end:
11817 /* Need to clear any trace of key value in the memory.
11818 * Thus zero out the memory even though it is local
11819 * variable.
11820 */
11821 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011822 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011823 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011824}
11825
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011826#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11827static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11828 struct net_device *ndev,
11829 u8 key_index, bool pairwise,
11830 const u8 *mac_addr,
11831 struct key_params *params
11832 )
11833#else
11834static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11835 struct net_device *ndev,
11836 u8 key_index, const u8 *mac_addr,
11837 struct key_params *params
11838 )
11839#endif
11840{
11841 int ret;
11842 vos_ssr_protect(__func__);
11843#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11844 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
11845 mac_addr, params);
11846#else
11847 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
11848 params);
11849#endif
11850 vos_ssr_unprotect(__func__);
11851
11852 return ret;
11853}
11854
Jeff Johnson295189b2012-06-20 16:38:30 -070011855/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011856 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011857 * This function is used to get the key information
11858 */
11859#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011860static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011861 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011862 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011863 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011864 const u8 *mac_addr, void *cookie,
11865 void (*callback)(void *cookie, struct key_params*)
11866 )
11867#else
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,
11871 u8 key_index, const u8 *mac_addr, void *cookie,
11872 void (*callback)(void *cookie, struct key_params*)
11873 )
11874#endif
11875{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011876 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011877 hdd_wext_state_t *pWextState = NULL;
11878 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011879 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011880 hdd_context_t *pHddCtx;
11881 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011882
11883 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011884
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011885 if (NULL == pAdapter)
11886 {
11887 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11888 "%s: HDD adapter is Null", __func__);
11889 return -ENODEV;
11890 }
11891
11892 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11893 ret = wlan_hdd_validate_context(pHddCtx);
11894 if (0 != ret)
11895 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011896 return ret;
11897 }
11898
11899 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11900 pRoamProfile = &(pWextState->roamProfile);
11901
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011902 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11903 __func__, hdd_device_modetoString(pAdapter->device_mode),
11904 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011905
Jeff Johnson295189b2012-06-20 16:38:30 -070011906 memset(&params, 0, sizeof(params));
11907
11908 if (CSR_MAX_NUM_KEY <= key_index)
11909 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011910 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070011911 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011912 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011913
11914 switch(pRoamProfile->EncryptionType.encryptionType[0])
11915 {
11916 case eCSR_ENCRYPT_TYPE_NONE:
11917 params.cipher = IW_AUTH_CIPHER_NONE;
11918 break;
11919
11920 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
11921 case eCSR_ENCRYPT_TYPE_WEP40:
11922 params.cipher = WLAN_CIPHER_SUITE_WEP40;
11923 break;
11924
11925 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
11926 case eCSR_ENCRYPT_TYPE_WEP104:
11927 params.cipher = WLAN_CIPHER_SUITE_WEP104;
11928 break;
11929
11930 case eCSR_ENCRYPT_TYPE_TKIP:
11931 params.cipher = WLAN_CIPHER_SUITE_TKIP;
11932 break;
11933
11934 case eCSR_ENCRYPT_TYPE_AES:
11935 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
11936 break;
11937
11938 default:
11939 params.cipher = IW_AUTH_CIPHER_NONE;
11940 break;
11941 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011942
c_hpothuaaf19692014-05-17 17:01:48 +053011943 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11944 TRACE_CODE_HDD_CFG80211_GET_KEY,
11945 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011946
Jeff Johnson295189b2012-06-20 16:38:30 -070011947 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
11948 params.seq_len = 0;
11949 params.seq = NULL;
11950 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
11951 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011952 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011953 return 0;
11954}
11955
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011956#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11957static int wlan_hdd_cfg80211_get_key(
11958 struct wiphy *wiphy,
11959 struct net_device *ndev,
11960 u8 key_index, bool pairwise,
11961 const u8 *mac_addr, void *cookie,
11962 void (*callback)(void *cookie, struct key_params*)
11963 )
11964#else
11965static int wlan_hdd_cfg80211_get_key(
11966 struct wiphy *wiphy,
11967 struct net_device *ndev,
11968 u8 key_index, const u8 *mac_addr, void *cookie,
11969 void (*callback)(void *cookie, struct key_params*)
11970 )
11971#endif
11972{
11973 int ret;
11974
11975 vos_ssr_protect(__func__);
11976#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11977 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
11978 mac_addr, cookie, callback);
11979#else
11980 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
11981 callback);
11982#endif
11983 vos_ssr_unprotect(__func__);
11984
11985 return ret;
11986}
11987
Jeff Johnson295189b2012-06-20 16:38:30 -070011988/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011989 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011990 * This function is used to delete the key information
11991 */
11992#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011993static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011994 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011995 u8 key_index,
11996 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011997 const u8 *mac_addr
11998 )
11999#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012000static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012001 struct net_device *ndev,
12002 u8 key_index,
12003 const u8 *mac_addr
12004 )
12005#endif
12006{
12007 int status = 0;
12008
12009 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012010 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070012011 //it is observed that this is invalidating peer
12012 //key index whenever re-key is done. This is affecting data link.
12013 //It should be ok to ignore del_key.
12014#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012015 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
12016 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070012017 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
12018 tCsrRoamSetKey setKey;
12019 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012020
Jeff Johnson295189b2012-06-20 16:38:30 -070012021 ENTER();
12022
12023 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
12024 __func__,pAdapter->device_mode);
12025
12026 if (CSR_MAX_NUM_KEY <= key_index)
12027 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012028 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012029 key_index);
12030
12031 return -EINVAL;
12032 }
12033
12034 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12035 setKey.keyId = key_index;
12036
12037 if (mac_addr)
12038 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
12039 else
12040 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
12041
12042 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
12043
12044 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012045 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012046 )
12047 {
12048
12049 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070012050 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
12051 if( pHostapdState->bssState == BSS_START)
12052 {
12053 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012054
Jeff Johnson295189b2012-06-20 16:38:30 -070012055 if ( status != eHAL_STATUS_SUCCESS )
12056 {
12057 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12058 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
12059 __LINE__, status );
12060 }
12061 }
12062 }
12063 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012064 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070012065 )
12066 {
12067 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12068
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012069 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
12070
12071 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070012072 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012073 __func__, setKey.peerMac[0], setKey.peerMac[1],
12074 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070012075 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012076 if(pAdapter->sessionCtx.station.conn_info.connState ==
12077 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070012078 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012079 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012081
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 if ( 0 != status )
12083 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012084 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012085 "%s: sme_RoamSetKey failure, returned %d",
12086 __func__, status);
12087 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
12088 return -EINVAL;
12089 }
12090 }
12091 }
12092#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012093 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012094 return status;
12095}
12096
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012097#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12098static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
12099 struct net_device *ndev,
12100 u8 key_index,
12101 bool pairwise,
12102 const u8 *mac_addr
12103 )
12104#else
12105static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
12106 struct net_device *ndev,
12107 u8 key_index,
12108 const u8 *mac_addr
12109 )
12110#endif
12111{
12112 int ret;
12113
12114 vos_ssr_protect(__func__);
12115#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12116 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
12117 mac_addr);
12118#else
12119 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
12120#endif
12121 vos_ssr_unprotect(__func__);
12122
12123 return ret;
12124}
12125
Jeff Johnson295189b2012-06-20 16:38:30 -070012126/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012127 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070012128 * This function is used to set the default tx key index
12129 */
12130#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012131static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012132 struct net_device *ndev,
12133 u8 key_index,
12134 bool unicast, bool multicast)
12135#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012136static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012137 struct net_device *ndev,
12138 u8 key_index)
12139#endif
12140{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012141 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012142 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053012143 hdd_wext_state_t *pWextState;
12144 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012145 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012146
12147 ENTER();
12148
Gopichand Nakkala29149562013-05-10 21:43:41 +053012149 if ((NULL == pAdapter))
12150 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053012152 "invalid adapter");
12153 return -EINVAL;
12154 }
12155
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012156 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12157 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
12158 pAdapter->sessionId, key_index));
12159
Gopichand Nakkala29149562013-05-10 21:43:41 +053012160 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12161 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12162
12163 if ((NULL == pWextState) || (NULL == pHddStaCtx))
12164 {
12165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
12166 "invalid Wext state or HDD context");
12167 return -EINVAL;
12168 }
12169
Arif Hussain6d2a3322013-11-17 19:50:10 -080012170 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012171 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012172
Jeff Johnson295189b2012-06-20 16:38:30 -070012173 if (CSR_MAX_NUM_KEY <= key_index)
12174 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012175 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012176 key_index);
12177
12178 return -EINVAL;
12179 }
12180
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012181 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12182 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012183 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012184 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012185 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012186 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012187
Jeff Johnson295189b2012-06-20 16:38:30 -070012188 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070012189 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012190 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012191 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053012192 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080012193 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012194 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080012195 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070012196 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012197 {
12198 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012200
Jeff Johnson295189b2012-06-20 16:38:30 -070012201 tCsrRoamSetKey setKey;
12202 v_U32_t roamId= 0xFF;
12203 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012204
12205 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012206 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012207
Jeff Johnson295189b2012-06-20 16:38:30 -070012208 Keys->defaultIndex = (u8)key_index;
12209 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12210 setKey.keyId = key_index;
12211 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012212
12213 vos_mem_copy(&setKey.Key[0],
12214 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012215 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012216
Gopichand Nakkala29149562013-05-10 21:43:41 +053012217 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012218
12219 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 &pHddStaCtx->conn_info.bssId[0],
12221 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012222
Gopichand Nakkala29149562013-05-10 21:43:41 +053012223 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
12224 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
12225 eCSR_ENCRYPT_TYPE_WEP104)
12226 {
12227 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
12228 even though ap is configured for WEP-40 encryption. In this canse the key length
12229 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
12230 type(104) and switching encryption type to 40*/
12231 pWextState->roamProfile.EncryptionType.encryptionType[0] =
12232 eCSR_ENCRYPT_TYPE_WEP40;
12233 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
12234 eCSR_ENCRYPT_TYPE_WEP40;
12235 }
12236
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012237 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012238 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012239
Jeff Johnson295189b2012-06-20 16:38:30 -070012240 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012241 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012242 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012243
Jeff Johnson295189b2012-06-20 16:38:30 -070012244 if ( 0 != status )
12245 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012246 hddLog(VOS_TRACE_LEVEL_ERROR,
12247 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012248 status);
12249 return -EINVAL;
12250 }
12251 }
12252 }
12253
12254 /* In SoftAp mode setting key direction for default mode */
12255 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
12256 {
12257 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
12258 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
12259 (eCSR_ENCRYPT_TYPE_AES !=
12260 pWextState->roamProfile.EncryptionType.encryptionType[0])
12261 )
12262 {
12263 /* Saving key direction for default key index to TX default */
12264 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
12265 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
12266 }
12267 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012268 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 return status;
12270}
12271
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012272#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12273static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12274 struct net_device *ndev,
12275 u8 key_index,
12276 bool unicast, bool multicast)
12277#else
12278static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12279 struct net_device *ndev,
12280 u8 key_index)
12281#endif
12282{
12283 int ret;
12284 vos_ssr_protect(__func__);
12285#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12286 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
12287 multicast);
12288#else
12289 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
12290#endif
12291 vos_ssr_unprotect(__func__);
12292
12293 return ret;
12294}
12295
Jeff Johnson295189b2012-06-20 16:38:30 -070012296/*
12297 * FUNCTION: wlan_hdd_cfg80211_inform_bss
12298 * This function is used to inform the BSS details to nl80211 interface.
12299 */
12300static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
12301 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
12302{
12303 struct net_device *dev = pAdapter->dev;
12304 struct wireless_dev *wdev = dev->ieee80211_ptr;
12305 struct wiphy *wiphy = wdev->wiphy;
12306 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
12307 int chan_no;
12308 int ie_length;
12309 const char *ie;
12310 unsigned int freq;
12311 struct ieee80211_channel *chan;
12312 int rssi = 0;
12313 struct cfg80211_bss *bss = NULL;
12314
Jeff Johnson295189b2012-06-20 16:38:30 -070012315 if( NULL == pBssDesc )
12316 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012317 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012318 return bss;
12319 }
12320
12321 chan_no = pBssDesc->channelId;
12322 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
12323 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
12324
12325 if( NULL == ie )
12326 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012327 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012328 return bss;
12329 }
12330
12331#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
12332 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
12333 {
12334 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12335 }
12336 else
12337 {
12338 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12339 }
12340#else
12341 freq = ieee80211_channel_to_frequency(chan_no);
12342#endif
12343
12344 chan = __ieee80211_get_channel(wiphy, freq);
12345
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053012346 if (!chan) {
12347 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
12348 return NULL;
12349 }
12350
Abhishek Singhaee43942014-06-16 18:55:47 +053012351 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070012352
Anand N Sunkad9f80b742015-07-30 20:05:51 +053012353 return cfg80211_inform_bss(wiphy, chan,
12354#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12355 CFG80211_BSS_FTYPE_UNKNOWN,
12356#endif
12357 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012358 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070012359 pBssDesc->capabilityInfo,
12360 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053012361 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070012362}
12363
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012364/*
12365 * wlan_hdd_cfg80211_update_bss_list :to inform nl80211
12366 * interface that BSS might have been lost.
12367 * @pAdapter: adaptor
12368 * @bssid: bssid which might have been lost
12369 *
12370 * Return: bss which is unlinked from kernel cache
12371 */
12372struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_list(
12373 hdd_adapter_t *pAdapter, tSirMacAddr bssid)
12374{
12375 struct net_device *dev = pAdapter->dev;
12376 struct wireless_dev *wdev = dev->ieee80211_ptr;
12377 struct wiphy *wiphy = wdev->wiphy;
12378 struct cfg80211_bss *bss = NULL;
12379
Abhishek Singh5a597e62016-12-05 15:16:30 +053012380 bss = hdd_get_bss_entry(wiphy,
12381 NULL, bssid,
12382 NULL, 0);
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012383 if (bss == NULL) {
12384 hddLog(LOGE, FL("BSS not present"));
12385 } else {
12386 hddLog(LOG1, FL("cfg80211_unlink_bss called for BSSID "
12387 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(bssid));
12388 cfg80211_unlink_bss(wiphy, bss);
12389 }
12390 return bss;
12391}
Jeff Johnson295189b2012-06-20 16:38:30 -070012392
12393
12394/*
12395 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
12396 * This function is used to inform the BSS details to nl80211 interface.
12397 */
12398struct cfg80211_bss*
12399wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
12400 tSirBssDescription *bss_desc
12401 )
12402{
12403 /*
12404 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
12405 already exists in bss data base of cfg80211 for that particular BSS ID.
12406 Using cfg80211_inform_bss_frame to update the bss entry instead of
12407 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
12408 now there is no possibility to get the mgmt(probe response) frame from PE,
12409 converting bss_desc to ieee80211_mgmt(probe response) and passing to
12410 cfg80211_inform_bss_frame.
12411 */
12412 struct net_device *dev = pAdapter->dev;
12413 struct wireless_dev *wdev = dev->ieee80211_ptr;
12414 struct wiphy *wiphy = wdev->wiphy;
12415 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012416#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12417 qcom_ie_age *qie_age = NULL;
12418 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
12419#else
Jeff Johnson295189b2012-06-20 16:38:30 -070012420 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012421#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012422 const char *ie =
12423 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
12424 unsigned int freq;
12425 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012426 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012427 struct cfg80211_bss *bss_status = NULL;
12428 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
12429 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070012430 hdd_context_t *pHddCtx;
12431 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070012432#ifdef WLAN_OPEN_SOURCE
12433 struct timespec ts;
12434#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012435
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012436
Wilson Yangf80a0542013-10-07 13:02:37 -070012437 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12438 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070012439 if (0 != status)
12440 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012441 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012442 }
12443
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012444 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070012445 if (!mgmt)
12446 {
12447 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12448 "%s: memory allocation failed ", __func__);
12449 return NULL;
12450 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012451
Jeff Johnson295189b2012-06-20 16:38:30 -070012452 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012453
12454#ifdef WLAN_OPEN_SOURCE
12455 /* Android does not want the timestamp from the frame.
12456 Instead it wants a monotonic increasing value */
12457 get_monotonic_boottime(&ts);
12458 mgmt->u.probe_resp.timestamp =
12459 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
12460#else
12461 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
12463 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070012464
12465#endif
12466
Jeff Johnson295189b2012-06-20 16:38:30 -070012467 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
12468 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012469
12470#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12471 /* GPS Requirement: need age ie per entry. Using vendor specific. */
12472 /* Assuming this is the last IE, copy at the end */
12473 ie_length -=sizeof(qcom_ie_age);
12474 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
12475 qie_age->element_id = QCOM_VENDOR_IE_ID;
12476 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
12477 qie_age->oui_1 = QCOM_OUI1;
12478 qie_age->oui_2 = QCOM_OUI2;
12479 qie_age->oui_3 = QCOM_OUI3;
12480 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
Selvaraj, Sridhar4b3a8362016-10-12 12:34:08 +053012481 /* Lowi expects the timestamp of bss in units of 1/10 ms. In driver all
12482 * bss related timestamp is in units of ms. Due to this when scan results
12483 * are sent to lowi the scan age is high.To address this, send age in units
12484 * of 1/10 ms.
12485 */
12486 qie_age->age = (vos_timer_get_system_time() -
12487 bss_desc->nReceivedTime)/10;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012488#endif
12489
Jeff Johnson295189b2012-06-20 16:38:30 -070012490 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053012491 if (bss_desc->fProbeRsp)
12492 {
12493 mgmt->frame_control |=
12494 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
12495 }
12496 else
12497 {
12498 mgmt->frame_control |=
12499 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
12500 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012501
12502#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012503 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012504 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
12505 {
12506 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12507 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012508 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012509 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
12510
12511 {
12512 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12513 }
12514 else
12515 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012516 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
12517 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070012518 kfree(mgmt);
12519 return NULL;
12520 }
12521#else
12522 freq = ieee80211_channel_to_frequency(chan_no);
12523#endif
12524 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012525 /*when the band is changed on the fly using the GUI, three things are done
12526 * 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)
12527 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
12528 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
12529 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
12530 * and discards the channels correponding to previous band and calls back with zero bss results.
12531 * 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
12532 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
12533 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
12534 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
12535 * So drop the bss and continue to next bss.
12536 */
12537 if(chan == NULL)
12538 {
Deepthi Gowri306657b2016-04-28 17:10:41 +053012539 hddLog(VOS_TRACE_LEVEL_ERROR,
12540 FL("chan pointer is NULL, chan_no: %d freq: %d"),
12541 chan_no, freq);
Chilam Ngc4244af2013-04-01 15:37:32 -070012542 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012543 return NULL;
12544 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053012545 /*To keep the rssi icon of the connected AP in the scan window
12546 *and the rssi icon of the wireless networks in sync
12547 * */
12548 if (( eConnectionState_Associated ==
12549 pAdapter->sessionCtx.station.conn_info.connState ) &&
12550 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
12551 pAdapter->sessionCtx.station.conn_info.bssId,
12552 WNI_CFG_BSSID_LEN)) &&
12553 (pHddCtx->hdd_wlan_suspended == FALSE))
12554 {
12555 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
12556 rssi = (pAdapter->rssi * 100);
12557 }
12558 else
12559 {
12560 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
12561 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012562
Nirav Shah20ac06f2013-12-12 18:14:06 +053012563 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053012564 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
12565 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053012566
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
12568 frame_len, rssi, GFP_KERNEL);
12569 kfree(mgmt);
12570 return bss_status;
12571}
12572
12573/*
12574 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
12575 * This function is used to update the BSS data base of CFG8011
12576 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012577struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012578 tCsrRoamInfo *pRoamInfo
12579 )
12580{
12581 tCsrRoamConnectedProfile roamProfile;
12582 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12583 struct cfg80211_bss *bss = NULL;
12584
12585 ENTER();
12586
12587 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
12588 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
12589
12590 if (NULL != roamProfile.pBssDesc)
12591 {
Girish Gowlif4b68022014-08-28 23:18:57 +053012592 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12593 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012594
12595 if (NULL == bss)
12596 {
12597 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
12598 __func__);
12599 }
12600
12601 sme_RoamFreeConnectProfile(hHal, &roamProfile);
12602 }
12603 else
12604 {
12605 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
12606 __func__);
12607 }
12608 return bss;
12609}
12610
12611/*
12612 * FUNCTION: wlan_hdd_cfg80211_update_bss
12613 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012614static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
12615 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070012616 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012617{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012618 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012619 tCsrScanResultInfo *pScanResult;
12620 eHalStatus status = 0;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012621 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012622 tScanResultHandle pResult;
12623 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012624 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012625 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012627
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012628 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12629 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
12630 NO_SESSION, pAdapter->sessionId));
12631
Wilson Yangf80a0542013-10-07 13:02:37 -070012632 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012633 ret = wlan_hdd_validate_context(pHddCtx);
12634 if (0 != ret)
Jeff Johnson295189b2012-06-20 16:38:30 -070012635 {
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012636 return ret;
Wilson Yangf80a0542013-10-07 13:02:37 -070012637 }
12638
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012639 if (pAdapter->request != NULL)
12640 {
12641 if ((pAdapter->request->n_ssids == 1)
12642 && (pAdapter->request->ssids != NULL)
12643 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
12644 is_p2p_scan = true;
12645 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012646 /*
12647 * start getting scan results and populate cgf80211 BSS database
12648 */
12649 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
12650
12651 /* no scan results */
12652 if (NULL == pResult)
12653 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012654 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
12655 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053012656 wlan_hdd_get_frame_logs(pAdapter,
12657 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 return status;
12659 }
12660
12661 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
12662
12663 while (pScanResult)
12664 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012665 /*
12666 * cfg80211_inform_bss() is not updating ie field of bss entry, if
12667 * entry already exists in bss data base of cfg80211 for that
12668 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
12669 * bss entry instead of cfg80211_inform_bss, But this call expects
12670 * mgmt packet as input. As of now there is no possibility to get
12671 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070012672 * ieee80211_mgmt(probe response) and passing to c
12673 * fg80211_inform_bss_frame.
12674 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012675 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
12676 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
12677 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012678 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12679 continue; //Skip the non p2p bss entries
12680 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12682 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012683
Jeff Johnson295189b2012-06-20 16:38:30 -070012684
12685 if (NULL == bss_status)
12686 {
12687 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012688 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 }
12690 else
12691 {
Yue Maf49ba872013-08-19 12:04:25 -070012692 cfg80211_put_bss(
12693#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
12694 wiphy,
12695#endif
12696 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012697 }
12698
12699 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12700 }
12701
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012702 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012703 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012704 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012705}
12706
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012707void
12708hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
12709{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012710 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080012711 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012712} /****** end hddPrintMacAddr() ******/
12713
12714void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012715hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012716{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012717 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012718 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012719 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
12720 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
12721 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012722} /****** end hddPrintPmkId() ******/
12723
12724//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
12725//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
12726
12727//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
12728//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
12729
12730#define dump_bssid(bssid) \
12731 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012732 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
12733 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012734 }
12735
12736#define dump_pmkid(pMac, pmkid) \
12737 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012738 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
12739 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012740 }
12741
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070012742#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012743/*
12744 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
12745 * This function is used to notify the supplicant of a new PMKSA candidate.
12746 */
12747int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012748 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012749 int index, bool preauth )
12750{
Jeff Johnsone7245742012-09-05 17:12:55 -070012751#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012752 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012753 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012754
12755 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070012756 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012757
12758 if( NULL == pRoamInfo )
12759 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012760 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012761 return -EINVAL;
12762 }
12763
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012764 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
12765 {
12766 dump_bssid(pRoamInfo->bssid);
12767 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012768 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012769 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012770#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012771 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012772}
12773#endif //FEATURE_WLAN_LFR
12774
Yue Maef608272013-04-08 23:09:17 -070012775#ifdef FEATURE_WLAN_LFR_METRICS
12776/*
12777 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
12778 * 802.11r/LFR metrics reporting function to report preauth initiation
12779 *
12780 */
12781#define MAX_LFR_METRICS_EVENT_LENGTH 100
12782VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
12783 tCsrRoamInfo *pRoamInfo)
12784{
12785 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12786 union iwreq_data wrqu;
12787
12788 ENTER();
12789
12790 if (NULL == pAdapter)
12791 {
12792 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12793 return VOS_STATUS_E_FAILURE;
12794 }
12795
12796 /* create the event */
12797 memset(&wrqu, 0, sizeof(wrqu));
12798 memset(metrics_notification, 0, sizeof(metrics_notification));
12799
12800 wrqu.data.pointer = metrics_notification;
12801 wrqu.data.length = scnprintf(metrics_notification,
12802 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
12803 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12804
12805 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12806
12807 EXIT();
12808
12809 return VOS_STATUS_SUCCESS;
12810}
12811
12812/*
12813 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
12814 * 802.11r/LFR metrics reporting function to report preauth completion
12815 * or failure
12816 */
12817VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
12818 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
12819{
12820 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12821 union iwreq_data wrqu;
12822
12823 ENTER();
12824
12825 if (NULL == pAdapter)
12826 {
12827 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12828 return VOS_STATUS_E_FAILURE;
12829 }
12830
12831 /* create the event */
12832 memset(&wrqu, 0, sizeof(wrqu));
12833 memset(metrics_notification, 0, sizeof(metrics_notification));
12834
12835 scnprintf(metrics_notification, sizeof(metrics_notification),
12836 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
12837 MAC_ADDR_ARRAY(pRoamInfo->bssid));
12838
12839 if (1 == preauth_status)
12840 strncat(metrics_notification, " TRUE", 5);
12841 else
12842 strncat(metrics_notification, " FALSE", 6);
12843
12844 wrqu.data.pointer = metrics_notification;
12845 wrqu.data.length = strlen(metrics_notification);
12846
12847 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12848
12849 EXIT();
12850
12851 return VOS_STATUS_SUCCESS;
12852}
12853
12854/*
12855 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
12856 * 802.11r/LFR metrics reporting function to report handover initiation
12857 *
12858 */
12859VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
12860 tCsrRoamInfo *pRoamInfo)
12861{
12862 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12863 union iwreq_data wrqu;
12864
12865 ENTER();
12866
12867 if (NULL == pAdapter)
12868 {
12869 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12870 return VOS_STATUS_E_FAILURE;
12871 }
12872
12873 /* create the event */
12874 memset(&wrqu, 0, sizeof(wrqu));
12875 memset(metrics_notification, 0, sizeof(metrics_notification));
12876
12877 wrqu.data.pointer = metrics_notification;
12878 wrqu.data.length = scnprintf(metrics_notification,
12879 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
12880 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12881
12882 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12883
12884 EXIT();
12885
12886 return VOS_STATUS_SUCCESS;
12887}
12888#endif
12889
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053012890
12891/**
12892 * wlan_hdd_cfg80211_validate_scan_req - validate scan request
12893 * @scan_req: scan request to be checked
12894 *
12895 * Return: true or false
12896 */
12897#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
12898static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
12899 cfg80211_scan_request
12900 *scan_req)
12901{
12902 if (!scan_req || !scan_req->wiphy) {
12903 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
12904 return false;
12905 }
12906 if (vos_is_load_unload_in_progress(VOS_MODULE_ID_HDD, NULL)) {
12907 hddLog(VOS_TRACE_LEVEL_ERROR, "Load/Unload in progress");
12908 return false;
12909 }
12910 return true;
12911}
12912#else
12913static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
12914 cfg80211_scan_request
12915 *scan_req)
12916{
12917 if (!scan_req || !scan_req->wiphy) {
12918 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
12919 return false;
12920 }
12921 return true;
12922}
12923#endif
12924
12925
Jeff Johnson295189b2012-06-20 16:38:30 -070012926/*
12927 * FUNCTION: hdd_cfg80211_scan_done_callback
12928 * scanning callback function, called after finishing scan
12929 *
12930 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012931static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070012932 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
12933{
12934 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012935 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070012936 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012937 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012938 struct cfg80211_scan_request *req = NULL;
12939 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012940 bool aborted = false;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012941#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12942 bool iface_down = false;
12943#endif
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012944 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012945 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012946 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012947
12948 ENTER();
12949
c_manjee1b4ab9a2016-10-26 11:36:55 +053012950 if (!pAdapter || pAdapter->magic != WLAN_HDD_ADAPTER_MAGIC ||
12951 !pAdapter->dev) {
12952 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Adapter is not valid"));
12953 return 0;
12954 }
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012955 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053012956 if (NULL == pHddCtx) {
12957 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012958 return 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012959 }
12960
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012961#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12962 if (!(pAdapter->dev->flags & IFF_UP))
12963 {
12964 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012965 iface_down = true;
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012966 }
12967#endif
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012968 pScanInfo = &pHddCtx->scan_info;
12969
Jeff Johnson295189b2012-06-20 16:38:30 -070012970 hddLog(VOS_TRACE_LEVEL_INFO,
12971 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080012972 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012973 __func__, halHandle, pContext, (int) scanId, (int) status);
12974
Kiet Lamac06e2c2013-10-23 16:25:07 +053012975 pScanInfo->mScanPendingCounter = 0;
12976
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012978 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070012979 &pScanInfo->scan_req_completion_event,
12980 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012981 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070012982 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012983 hddLog(VOS_TRACE_LEVEL_ERROR,
12984 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070012985 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012986 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 }
12988
Yue Maef608272013-04-08 23:09:17 -070012989 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070012990 {
12991 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012992 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 }
12994
12995 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012996 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070012997 {
12998 hddLog(VOS_TRACE_LEVEL_INFO,
12999 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080013000 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013001 (int) scanId);
13002 }
13003
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053013004#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013005 if (!iface_down)
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053013006#endif
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013007 {
13008 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
13009 pAdapter);
13010 if (0 > ret)
13011 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053013012 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013013
Jeff Johnson295189b2012-06-20 16:38:30 -070013014 /* If any client wait scan result through WEXT
13015 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013016 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070013017 {
13018 /* The other scan request waiting for current scan finish
13019 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013020 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013022 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 }
13024 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013025 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070013026 {
13027 struct net_device *dev = pAdapter->dev;
13028 union iwreq_data wrqu;
13029 int we_event;
13030 char *msg;
13031
13032 memset(&wrqu, '\0', sizeof(wrqu));
13033 we_event = SIOCGIWSCAN;
13034 msg = NULL;
13035 wireless_send_event(dev, we_event, &wrqu, msg);
13036 }
13037 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013038 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013039
13040 /* Get the Scan Req */
13041 req = pAdapter->request;
mukul sharmae7041822015-12-03 15:09:21 +053013042 pAdapter->request = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013043
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013044 /* Scan is no longer pending */
13045 pScanInfo->mScanPending = VOS_FALSE;
13046
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013047 if (!wlan_hdd_cfg80211_validate_scan_req(req))
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013049#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13050 hddLog(VOS_TRACE_LEVEL_ERROR, FL("interface state %s"),
13051 iface_down ? "up" : "down");
13052#endif
13053
13054 if (pAdapter->dev) {
13055 hddLog(VOS_TRACE_LEVEL_ERROR, FL("device name %s"),
13056 pAdapter->dev->name);
13057 }
mukul sharmae7041822015-12-03 15:09:21 +053013058 complete(&pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -070013059 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070013060 }
13061
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013062 /* last_scan_timestamp is used to decide if new scan
13063 * is needed or not on station interface. If last station
13064 * scan time and new station scan time is less then
13065 * last_scan_timestamp ; driver will return cached scan.
13066 */
13067 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
13068 {
13069 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
13070
13071 if ( req->n_channels )
13072 {
13073 for (i = 0; i < req->n_channels ; i++ )
13074 {
13075 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
13076 }
13077 /* store no of channel scanned */
13078 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
13079 }
13080
13081 }
13082
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070013083 /*
13084 * cfg80211_scan_done informing NL80211 about completion
13085 * of scanning
13086 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053013087 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
13088 {
13089 aborted = true;
13090 }
mukul sharmae7041822015-12-03 15:09:21 +053013091
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013092#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13093 if (!iface_down)
13094#endif
13095 cfg80211_scan_done(req, aborted);
mukul sharmae7041822015-12-03 15:09:21 +053013096
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080013097 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070013098
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013099allow_suspend:
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053013100 if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
13101 ) && (pHddCtx->spoofMacAddr.isEnabled
13102 || pHddCtx->spoofMacAddr.isReqDeferred)) {
Siddharth Bhal76972212014-10-15 16:22:51 +053013103 /* Generate new random mac addr for next scan */
13104 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +053013105
13106 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
13107 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhal76972212014-10-15 16:22:51 +053013108 }
13109
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070013110 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013111 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013112
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070013113 /* Acquire wakelock to handle the case where APP's tries to suspend
13114 * immediatly after the driver gets connect request(i.e after scan)
13115 * from supplicant, this result in app's is suspending and not able
13116 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013117 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070013118
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013119#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13120 if (!iface_down)
13121#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070013122#ifdef FEATURE_WLAN_TDLS
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013123 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070013124#endif
13125
Jeff Johnson295189b2012-06-20 16:38:30 -070013126 EXIT();
13127 return 0;
13128}
13129
13130/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053013131 * FUNCTION: hdd_isConnectionInProgress
13132 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013133 *
13134 */
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013135v_BOOL_t hdd_isConnectionInProgress(hdd_context_t *pHddCtx, v_U8_t *session_id,
13136 scan_reject_states *reason)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013137{
13138 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
13139 hdd_station_ctx_t *pHddStaCtx = NULL;
13140 hdd_adapter_t *pAdapter = NULL;
13141 VOS_STATUS status = 0;
13142 v_U8_t staId = 0;
13143 v_U8_t *staMac = NULL;
13144
13145 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
13146
13147 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
13148 {
13149 pAdapter = pAdapterNode->pAdapter;
13150
13151 if( pAdapter )
13152 {
13153 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013154 "%s: Adapter with device mode %s (%d) exists",
13155 __func__, hdd_device_modetoString(pAdapter->device_mode),
13156 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013157 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053013158 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13159 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
13160 (eConnectionState_Connecting ==
13161 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13162 {
13163 hddLog(VOS_TRACE_LEVEL_ERROR,
13164 "%s: %p(%d) Connection is in progress", __func__,
13165 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013166 if (session_id && reason)
13167 {
13168 *session_id = pAdapter->sessionId;
13169 *reason = eHDD_CONNECTION_IN_PROGRESS;
13170 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013171 return VOS_TRUE;
13172 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013173 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013174 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013175 {
13176 hddLog(VOS_TRACE_LEVEL_ERROR,
13177 "%s: %p(%d) Reassociation is in progress", __func__,
13178 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013179 if (session_id && reason)
13180 {
13181 *session_id = pAdapter->sessionId;
13182 *reason = eHDD_REASSOC_IN_PROGRESS;
13183 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013184 return VOS_TRUE;
13185 }
13186 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013187 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13188 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013189 {
13190 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13191 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013192 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013193 {
13194 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
13195 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080013196 "%s: client " MAC_ADDRESS_STR
13197 " is in the middle of WPS/EAPOL exchange.", __func__,
13198 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013199 if (session_id && reason)
13200 {
13201 *session_id = pAdapter->sessionId;
13202 *reason = eHDD_EAPOL_IN_PROGRESS;
13203 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013204 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013205 }
13206 }
13207 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
13208 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
13209 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013210 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13211 ptSapContext pSapCtx = NULL;
13212 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13213 if(pSapCtx == NULL){
13214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13215 FL("psapCtx is NULL"));
13216 return VOS_FALSE;
13217 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013218 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
13219 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013220 if ((pSapCtx->aStaInfo[staId].isUsed) &&
13221 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013222 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013223 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013224
13225 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080013226 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
13227 "middle of WPS/EAPOL exchange.", __func__,
13228 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013229 if (session_id && reason)
13230 {
13231 *session_id = pAdapter->sessionId;
13232 *reason = eHDD_SAP_EAPOL_IN_PROGRESS;
13233 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013234 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013235 }
13236 }
13237 }
13238 }
13239 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
13240 pAdapterNode = pNext;
13241 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013242 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013243}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013244
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053013245/**
13246 * csr_scan_request_assign_bssid() - Set the BSSID received from Supplicant
13247 * to the Scan request
13248 * @scanRequest: Pointer to the csr scan request
13249 * @request: Pointer to the scan request from supplicant
13250 *
13251 * Return: None
13252 */
13253#ifdef CFG80211_SCAN_BSSID
13254static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13255 struct cfg80211_scan_request *request)
13256{
13257 vos_mem_copy(scanRequest->bssid, request->bssid, VOS_MAC_ADDR_SIZE);
13258}
13259#else
13260static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13261 struct cfg80211_scan_request *request)
13262{
13263}
13264#endif
13265
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013266/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013267 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070013268 * this scan respond to scan trigger and update cfg80211 scan database
13269 * later, scan dump command can be used to recieve scan results
13270 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013271int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080013272#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13273 struct net_device *dev,
13274#endif
13275 struct cfg80211_scan_request *request)
13276{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013277 hdd_adapter_t *pAdapter = NULL;
13278 hdd_context_t *pHddCtx = NULL;
13279 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013280 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 tCsrScanRequest scanRequest;
13282 tANI_U8 *channelList = NULL, i;
13283 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013284 int status;
13285 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013286 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013287 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053013288 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013289 bool is_p2p_scan = false;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013290 v_U8_t curr_session_id;
13291 scan_reject_states curr_reason;
Jeff Johnson295189b2012-06-20 16:38:30 -070013292
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013293#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
13294 struct net_device *dev = NULL;
13295 if (NULL == request)
13296 {
13297 hddLog(VOS_TRACE_LEVEL_ERROR,
13298 "%s: scan req param null", __func__);
13299 return -EINVAL;
13300 }
13301 dev = request->wdev->netdev;
13302#endif
13303
13304 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13305 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
13306 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13307
Jeff Johnson295189b2012-06-20 16:38:30 -070013308 ENTER();
13309
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013310 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13311 __func__, hdd_device_modetoString(pAdapter->device_mode),
13312 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013313
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013314 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013315 if (0 != status)
13316 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013317 return status;
13318 }
13319
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013320 if (NULL == pwextBuf)
13321 {
13322 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
13323 __func__);
13324 return -EIO;
13325 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013326 cfg_param = pHddCtx->cfg_ini;
13327 pScanInfo = &pHddCtx->scan_info;
13328
Jeff Johnson295189b2012-06-20 16:38:30 -070013329#ifdef WLAN_BTAMP_FEATURE
13330 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013331 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070013332 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013333 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013334 "%s: No scanning when AMP is on", __func__);
13335 return -EOPNOTSUPP;
13336 }
13337#endif
13338 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013339 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013340 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013341 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013342 "%s: Not scanning on device_mode = %s (%d)",
13343 __func__, hdd_device_modetoString(pAdapter->device_mode),
13344 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 return -EOPNOTSUPP;
13346 }
13347
13348 if (TRUE == pScanInfo->mScanPending)
13349 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013350 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
13351 {
13352 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
13353 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013354 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013355 }
13356
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053013357 // Don't allow scan if PNO scan is going on.
13358 if (pHddCtx->isPnoEnable)
13359 {
13360 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13361 FL("pno scan in progress"));
13362 return -EBUSY;
13363 }
13364
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013365 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070013366 //Channel and action frame is pending
13367 //Otherwise Cancel Remain On Channel and allow Scan
13368 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013369 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070013370 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013371 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070013372 return -EBUSY;
13373 }
13374
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
13376 {
13377 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080013378 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013379 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013380 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013381 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
13382 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013383 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 "%s: MAX TM Level Scan not allowed", __func__);
13385 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013386 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013387 }
13388 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
13389
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013390 /* Check if scan is allowed at this point of time.
13391 */
Hanumanth Reddy Pothulaec960842016-09-14 19:04:26 +053013392 if (TRUE == pHddCtx->btCoexModeSet)
13393 {
13394 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13395 FL("BTCoex Mode operation in progress"));
13396 return -EBUSY;
13397 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013398 if (hdd_isConnectionInProgress(pHddCtx, &curr_session_id, &curr_reason))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013399 {
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053013400 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Scan not allowed"));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013401 if (pHddCtx->last_scan_reject_session_id != curr_session_id ||
13402 pHddCtx->last_scan_reject_reason != curr_reason ||
13403 !pHddCtx->last_scan_reject_timestamp)
13404 {
13405 pHddCtx->last_scan_reject_session_id = curr_session_id;
13406 pHddCtx->last_scan_reject_reason = curr_reason;
Sreelakshmi Konamkif0646d52016-12-09 12:35:31 +053013407 pHddCtx->last_scan_reject_timestamp = jiffies_to_msecs(jiffies);
Abhishek Singhe4b12562017-06-20 16:53:39 +053013408 pHddCtx->scan_reject_cnt = 0;
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053013409 }
Abhishek Singhe4b12562017-06-20 16:53:39 +053013410 else
13411 {
13412 pHddCtx->scan_reject_cnt++;
13413
13414 hddLog(LOGE, FL("Reject cnt %d time delta %lu ms"), pHddCtx->scan_reject_cnt,
13415 (jiffies_to_msecs(jiffies) -
13416 pHddCtx->last_scan_reject_timestamp));
13417
13418 if ((pHddCtx->scan_reject_cnt >=
13419 SCAN_REJECT_THRESHOLD) &&
13420 (jiffies_to_msecs(jiffies) -
13421 pHddCtx->last_scan_reject_timestamp) >=
13422 SCAN_REJECT_THRESHOLD_TIME)
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013423 {
13424 pHddCtx->last_scan_reject_timestamp = 0;
Abhishek Singhe4b12562017-06-20 16:53:39 +053013425 pHddCtx->scan_reject_cnt = 0;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013426 if (pHddCtx->cfg_ini->enableFatalEvent)
13427 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
13428 WLAN_LOG_INDICATOR_HOST_DRIVER,
13429 WLAN_LOG_REASON_SCAN_NOT_ALLOWED,
13430 FALSE, FALSE);
13431 else
13432 {
13433 hddLog(LOGE, FL("Triggering SSR"));
13434 vos_wlanRestart();
13435 }
13436 }
13437 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013438 return -EBUSY;
13439 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013440 pHddCtx->last_scan_reject_timestamp = 0;
13441 pHddCtx->last_scan_reject_session_id = 0xFF;
13442 pHddCtx->last_scan_reject_reason = 0;
Abhishek Singhe4b12562017-06-20 16:53:39 +053013443 pHddCtx->scan_reject_cnt = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013444
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 vos_mem_zero( &scanRequest, sizeof(scanRequest));
13446
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013447 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
13448 * Becasue of this, driver is assuming that this is not wildcard scan and so
13449 * is not aging out the scan results.
13450 */
13451 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070013452 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013453 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013454 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013455
13456 if ((request->ssids) && (0 < request->n_ssids))
13457 {
13458 tCsrSSIDInfo *SsidInfo;
13459 int j;
13460 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
13461 /* Allocate num_ssid tCsrSSIDInfo structure */
13462 SsidInfo = scanRequest.SSIDs.SSIDList =
13463 ( tCsrSSIDInfo *)vos_mem_malloc(
13464 request->n_ssids*sizeof(tCsrSSIDInfo));
13465
13466 if(NULL == scanRequest.SSIDs.SSIDList)
13467 {
13468 hddLog(VOS_TRACE_LEVEL_ERROR,
13469 "%s: memory alloc failed SSIDInfo buffer", __func__);
13470 return -ENOMEM;
13471 }
13472
13473 /* copy all the ssid's and their length */
13474 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
13475 {
13476 /* get the ssid length */
13477 SsidInfo->SSID.length = request->ssids[j].ssid_len;
13478 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
13479 SsidInfo->SSID.length);
13480 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
13481 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
13482 j, SsidInfo->SSID.ssId);
13483 }
13484 /* set the scan type to active */
13485 scanRequest.scanType = eSIR_ACTIVE_SCAN;
13486 }
13487 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013488 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013489 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13490 TRACE_CODE_HDD_CFG80211_SCAN,
13491 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 /* set the scan type to active */
13493 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070013494 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013495 else
13496 {
13497 /*Set the scan type to default type, in this case it is ACTIVE*/
13498 scanRequest.scanType = pScanInfo->scan_mode;
13499 }
13500 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
13501 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070013502
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053013503 csr_scan_request_assign_bssid(&scanRequest, request);
13504
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 /* set BSSType to default type */
13506 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
13507
13508 /*TODO: scan the requested channels only*/
13509
13510 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013511 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070013512 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013513 hddLog(VOS_TRACE_LEVEL_WARN,
13514 "No of Scan Channels exceeded limit: %d", request->n_channels);
13515 request->n_channels = MAX_CHANNEL;
13516 }
13517
13518 hddLog(VOS_TRACE_LEVEL_INFO,
13519 "No of Scan Channels: %d", request->n_channels);
13520
13521
13522 if( request->n_channels )
13523 {
13524 char chList [(request->n_channels*5)+1];
13525 int len;
13526 channelList = vos_mem_malloc( request->n_channels );
13527 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053013528 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013529 hddLog(VOS_TRACE_LEVEL_ERROR,
13530 "%s: memory alloc failed channelList", __func__);
13531 status = -ENOMEM;
13532 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053013533 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013534
13535 for( i = 0, len = 0; i < request->n_channels ; i++ )
13536 {
13537 channelList[i] = request->channels[i]->hw_value;
13538 len += snprintf(chList+len, 5, "%d ", channelList[i]);
13539 }
13540
Nirav Shah20ac06f2013-12-12 18:14:06 +053013541 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013542 "Channel-List: %s ", chList);
13543 }
c_hpothu53512302014-04-15 18:49:53 +053013544
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013545 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
13546 scanRequest.ChannelInfo.ChannelList = channelList;
13547
13548 /* set requestType to full scan */
13549 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
13550
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013551 /* if there is back to back scan happening in driver with in
13552 * nDeferScanTimeInterval interval driver should defer new scan request
13553 * and should provide last cached scan results instead of new channel list.
13554 * This rule is not applicable if scan is p2p scan.
13555 * This condition will work only in case when last request no of channels
13556 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053013557 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053013558 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013559 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013560
Sushant Kaushik86592172015-04-27 16:35:03 +053013561 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
13562 /* if wps ie is NULL , then only defer scan */
13563 if ( pWpsIe == NULL &&
13564 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053013565 {
13566 if ( pScanInfo->last_scan_timestamp !=0 &&
13567 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
13568 {
13569 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
13570 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
13571 vos_mem_compare(pScanInfo->last_scan_channelList,
13572 channelList, pScanInfo->last_scan_numChannels))
13573 {
13574 hddLog(VOS_TRACE_LEVEL_WARN,
13575 " New and old station scan time differ is less then %u",
13576 pHddCtx->cfg_ini->nDeferScanTimeInterval);
13577
13578 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013579 pAdapter);
13580
Agarwal Ashish57e84372014-12-05 18:26:53 +053013581 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013582 "Return old cached scan as all channels and no of channels are same");
13583
Agarwal Ashish57e84372014-12-05 18:26:53 +053013584 if (0 > ret)
13585 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013586
Agarwal Ashish57e84372014-12-05 18:26:53 +053013587 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013588
13589 status = eHAL_STATUS_SUCCESS;
13590 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053013591 }
13592 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013593 }
13594
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013595 /* Flush the scan results(only p2p beacons) for STA scan and P2P
13596 * search (Flush on both full scan and social scan but not on single
13597 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
13598 */
13599
13600 /* Supplicant does single channel scan after 8-way handshake
13601 * and in that case driver shoudnt flush scan results. If
13602 * driver flushes the scan results here and unfortunately if
13603 * the AP doesnt respond to our probe req then association
13604 * fails which is not desired
13605 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013606 if ((request->n_ssids == 1)
13607 && (request->ssids != NULL)
13608 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
13609 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013610
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013611 if( is_p2p_scan ||
13612 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013613 {
13614 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
13615 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
13616 pAdapter->sessionId );
13617 }
13618
13619 if( request->ie_len )
13620 {
13621 /* save this for future association (join requires this) */
13622 /*TODO: Array needs to be converted to dynamic allocation,
13623 * as multiple ie.s can be sent in cfg80211_scan_request structure
13624 * CR 597966
13625 */
13626 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
13627 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
13628 pScanInfo->scanAddIE.length = request->ie_len;
13629
13630 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13631 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13632 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013634 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013636 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
13637 memcpy( pwextBuf->roamProfile.addIEScan,
13638 request->ie, request->ie_len);
13639 }
13640 else
13641 {
13642 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
13643 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 }
13645
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013646 }
13647 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
13648 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
13649
13650 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
13651 request->ie_len);
13652 if (pP2pIe != NULL)
13653 {
13654#ifdef WLAN_FEATURE_P2P_DEBUG
13655 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
13656 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
13657 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053013658 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013659 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
13660 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13661 "Go nego completed to Connection is started");
13662 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13663 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053013664 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013665 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
13666 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013667 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013668 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
13669 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13670 "Disconnected state to Connection is started");
13671 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13672 "for 4way Handshake");
13673 }
13674#endif
13675
13676 /* no_cck will be set during p2p find to disable 11b rates */
13677 if(TRUE == request->no_cck)
13678 {
13679 hddLog(VOS_TRACE_LEVEL_INFO,
13680 "%s: This is a P2P Search", __func__);
13681 scanRequest.p2pSearch = 1;
13682
13683 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053013684 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013685 /* set requestType to P2P Discovery */
13686 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
13687 }
13688
13689 /*
13690 Skip Dfs Channel in case of P2P Search
13691 if it is set in ini file
13692 */
13693 if(cfg_param->skipDfsChnlInP2pSearch)
13694 {
13695 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013696 }
13697 else
13698 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013699 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013700 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013701
Agarwal Ashish4f616132013-12-30 23:32:50 +053013702 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013703 }
13704 }
13705
13706 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
13707
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013708#ifdef FEATURE_WLAN_TDLS
13709 /* if tdls disagree scan right now, return immediately.
13710 tdls will schedule the scan when scan is allowed. (return SUCCESS)
13711 or will reject the scan if any TDLS is in progress. (return -EBUSY)
13712 */
13713 status = wlan_hdd_tdls_scan_callback (pAdapter,
13714 wiphy,
13715#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13716 dev,
13717#endif
13718 request);
Abhishek Singhe2b63952016-01-05 18:27:29 +053013719 if (status <= 0)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013720 {
Abhishek Singhe2b63952016-01-05 18:27:29 +053013721 if (!status)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013722 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
13723 "scan rejected %d", __func__, status);
13724 else
13725 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
13726 __func__, status);
Abhishek Singhe2b63952016-01-05 18:27:29 +053013727 hdd_wlan_block_scan_by_tdls();
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053013728 goto free_mem;
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013729 }
13730#endif
13731
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070013732 /* acquire the wakelock to avoid the apps suspend during the scan. To
13733 * address the following issues.
13734 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
13735 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
13736 * for long time, this result in apps running at full power for long time.
13737 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
13738 * be stuck in full power because of resume BMPS
13739 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013740 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013741
Nirav Shah20ac06f2013-12-12 18:14:06 +053013742 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
13743 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013744 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
13745 scanRequest.requestType, scanRequest.scanType,
13746 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053013747 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
13748
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053013749 if (pHddCtx->spoofMacAddr.isEnabled &&
13750 pHddCtx->cfg_ini->enableMacSpoofing == 1)
Siddharth Bhal76972212014-10-15 16:22:51 +053013751 {
13752 hddLog(VOS_TRACE_LEVEL_INFO,
13753 "%s: MAC Spoofing enabled for current scan", __func__);
13754 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
13755 * to fill TxBds for probe request during current scan
13756 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013757 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053013758 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013759
13760 if(status != VOS_STATUS_SUCCESS)
13761 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013762 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013763 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053013764#ifdef FEATURE_WLAN_TDLS
13765 wlan_hdd_tdls_scan_done_callback(pAdapter);
13766#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013767 goto free_mem;
13768 }
Siddharth Bhal76972212014-10-15 16:22:51 +053013769 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053013770 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070013771 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 pAdapter->sessionId, &scanRequest, &scanId,
13773 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070013774
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 if (eHAL_STATUS_SUCCESS != status)
13776 {
13777 hddLog(VOS_TRACE_LEVEL_ERROR,
13778 "%s: sme_ScanRequest returned error %d", __func__, status);
13779 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013780 if(eHAL_STATUS_RESOURCES == status)
13781 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013782 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
13783 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013784 status = -EBUSY;
13785 } else {
13786 status = -EIO;
13787 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013788 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013789
13790#ifdef FEATURE_WLAN_TDLS
13791 wlan_hdd_tdls_scan_done_callback(pAdapter);
13792#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 goto free_mem;
13794 }
13795
13796 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053013797 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013798 pAdapter->request = request;
13799 pScanInfo->scanId = scanId;
13800
13801 complete(&pScanInfo->scan_req_completion_event);
13802
13803free_mem:
13804 if( scanRequest.SSIDs.SSIDList )
13805 {
13806 vos_mem_free(scanRequest.SSIDs.SSIDList);
13807 }
13808
13809 if( channelList )
13810 vos_mem_free( channelList );
13811
13812 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013813 return status;
13814}
13815
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013816int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
13817#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13818 struct net_device *dev,
13819#endif
13820 struct cfg80211_scan_request *request)
13821{
13822 int ret;
13823
13824 vos_ssr_protect(__func__);
13825 ret = __wlan_hdd_cfg80211_scan(wiphy,
13826#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13827 dev,
13828#endif
13829 request);
13830 vos_ssr_unprotect(__func__);
13831
13832 return ret;
13833}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013834
13835void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
13836{
13837 v_U8_t iniDot11Mode =
13838 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
13839 eHddDot11Mode hddDot11Mode = iniDot11Mode;
13840
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013841 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
13842 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013843 switch ( iniDot11Mode )
13844 {
13845 case eHDD_DOT11_MODE_AUTO:
13846 case eHDD_DOT11_MODE_11ac:
13847 case eHDD_DOT11_MODE_11ac_ONLY:
13848#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053013849 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
13850 sme_IsFeatureSupportedByFW(DOT11AC) )
13851 hddDot11Mode = eHDD_DOT11_MODE_11ac;
13852 else
13853 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013854#else
13855 hddDot11Mode = eHDD_DOT11_MODE_11n;
13856#endif
13857 break;
13858 case eHDD_DOT11_MODE_11n:
13859 case eHDD_DOT11_MODE_11n_ONLY:
13860 hddDot11Mode = eHDD_DOT11_MODE_11n;
13861 break;
13862 default:
13863 hddDot11Mode = iniDot11Mode;
13864 break;
13865 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013866#ifdef WLAN_FEATURE_AP_HT40_24G
13867 if (operationChannel > SIR_11B_CHANNEL_END)
13868#endif
13869 {
13870 /* This call decides required channel bonding mode */
13871 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013872 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
13873 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013874 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013875}
13876
Jeff Johnson295189b2012-06-20 16:38:30 -070013877/*
13878 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013879 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070013880 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013881int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013882 const u8 *ssid, size_t ssid_len, const u8 *bssid,
13883 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070013884{
13885 int status = 0;
13886 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080013887 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013888 v_U32_t roamId;
13889 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070013890 eCsrAuthType RSNAuthType;
13891
13892 ENTER();
13893
13894 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080013895 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13896
13897 status = wlan_hdd_validate_context(pHddCtx);
13898 if (status)
13899 {
Yue Mae36e3552014-03-05 17:06:20 -080013900 return status;
13901 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013902
Jeff Johnson295189b2012-06-20 16:38:30 -070013903 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
13904 {
13905 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
13906 return -EINVAL;
13907 }
13908
Nitesh Shah9b066282017-06-06 18:05:52 +053013909 wlan_hdd_tdls_disable_offchan_and_teardown_links(pHddCtx);
13910
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 pRoamProfile = &pWextState->roamProfile;
13912
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013913 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070013914 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013915 hdd_station_ctx_t *pHddStaCtx;
13916 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Abhishek Singh6782c9e2017-06-06 13:37:45 +053013917 pHddStaCtx->get_mgmt_log_sent = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013918
Siddharth Bhalda0d1622015-04-24 15:47:49 +053013919 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
13920
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013921 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
13923 {
13924 /*QoS not enabled in cfg file*/
13925 pRoamProfile->uapsd_mask = 0;
13926 }
13927 else
13928 {
13929 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013930 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070013931 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
13932 }
13933
13934 pRoamProfile->SSIDs.numOfSSIDs = 1;
13935 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
13936 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013937 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070013938 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
13939 ssid, ssid_len);
13940
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013941 vos_mem_zero(pRoamProfile->BSSIDs.bssid, WNI_CFG_BSSID_LEN);
13942 vos_mem_zero(pRoamProfile->bssid_hint, WNI_CFG_BSSID_LEN);
13943
Jeff Johnson295189b2012-06-20 16:38:30 -070013944 if (bssid)
13945 {
13946 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013947 vos_mem_copy(pRoamProfile->BSSIDs.bssid, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013949 /* Save BSSID in seperate variable as well, as RoamProfile
13950 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070013951 case of join failure we should send valid BSSID to supplicant
13952 */
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013953 vos_mem_copy(pWextState->req_bssId, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 WNI_CFG_BSSID_LEN);
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013955
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 }
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013957 else if (bssid_hint)
Dhanashri Atre51981c62013-06-13 11:47:57 -070013958 {
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013959 /* Store bssid_hint to use in the scan filter. */
13960 vos_mem_copy(pRoamProfile->bssid_hint, bssid_hint,
13961 WNI_CFG_BSSID_LEN);
13962 /*
13963 * Save BSSID in seperate variable as well, as RoamProfile
13964 * BSSID is getting zeroed out in the association process. And in
13965 * case of join failure we should send valid BSSID to supplicant
13966 */
13967 vos_mem_copy(pWextState->req_bssId, bssid_hint,
13968 WNI_CFG_BSSID_LEN);
13969 hddLog(LOG1, FL(" bssid_hint: "MAC_ADDRESS_STR),
13970 MAC_ADDR_ARRAY(pRoamProfile->bssid_hint));
Dhanashri Atre51981c62013-06-13 11:47:57 -070013971 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013972
Abhishek Singhb3e376c2017-01-04 15:27:13 +053013973
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013974 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
13975 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070013976 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
13977 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013978 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 /*set gen ie*/
13980 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
13981 /*set auth*/
13982 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
13983 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013984#ifdef FEATURE_WLAN_WAPI
13985 if (pAdapter->wapi_info.nWapiMode)
13986 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013987 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 switch (pAdapter->wapi_info.wapiAuthMode)
13989 {
13990 case WAPI_AUTH_MODE_PSK:
13991 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013992 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013993 pAdapter->wapi_info.wapiAuthMode);
13994 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
13995 break;
13996 }
13997 case WAPI_AUTH_MODE_CERT:
13998 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013999 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 pAdapter->wapi_info.wapiAuthMode);
14001 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
14002 break;
14003 }
14004 } // End of switch
14005 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
14006 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
14007 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014008 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 pRoamProfile->AuthType.numEntries = 1;
14010 pRoamProfile->EncryptionType.numEntries = 1;
14011 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
14012 pRoamProfile->mcEncryptionType.numEntries = 1;
14013 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
14014 }
14015 }
14016#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014017#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014018 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014019 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
14020 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
14021 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014022 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
14023 sizeof (tSirGtkOffloadParams));
14024 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014025 }
14026#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 pRoamProfile->csrPersona = pAdapter->device_mode;
14028
Jeff Johnson32d95a32012-09-10 13:15:23 -070014029 if( operatingChannel )
14030 {
14031 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
14032 pRoamProfile->ChannelInfo.numOfChannels = 1;
14033 }
Chet Lanctot186b5732013-03-18 10:26:30 -070014034 else
14035 {
14036 pRoamProfile->ChannelInfo.ChannelList = NULL;
14037 pRoamProfile->ChannelInfo.numOfChannels = 0;
14038 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014039 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
14040 {
14041 hdd_select_cbmode(pAdapter,operatingChannel);
14042 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014043
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014044 /*
14045 * Change conn_state to connecting before sme_RoamConnect(),
14046 * because sme_RoamConnect() has a direct path to call
14047 * hdd_smeRoamCallback(), which will change the conn_state
14048 * If direct path, conn_state will be accordingly changed
14049 * to NotConnected or Associated by either
14050 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
14051 * in sme_RoamCallback()
14052 * if sme_RomConnect is to be queued,
14053 * Connecting state will remain until it is completed.
14054 * If connection state is not changed,
14055 * connection state will remain in eConnectionState_NotConnected state.
14056 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
14057 * if conn state is eConnectionState_NotConnected.
14058 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
14059 * informed of connect result indication which is an issue.
14060 */
14061
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053014062 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
14063 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053014064 {
14065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014066 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080014067 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
14068 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053014069 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014070 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 pAdapter->sessionId, pRoamProfile, &roamId);
14072
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053014073 if ((eHAL_STATUS_SUCCESS != status) &&
14074 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
14075 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014076
14077 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014078 hddLog(VOS_TRACE_LEVEL_ERROR,
14079 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
14080 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080014081 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014082 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080014083 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014084 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080014085
14086 pRoamProfile->ChannelInfo.ChannelList = NULL;
14087 pRoamProfile->ChannelInfo.numOfChannels = 0;
14088
Jeff Johnson295189b2012-06-20 16:38:30 -070014089 }
14090 else
14091 {
14092 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
14093 return -EINVAL;
14094 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080014095 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014096 return status;
14097}
14098
14099/*
14100 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
14101 * This function is used to set the authentication type (OPEN/SHARED).
14102 *
14103 */
14104static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
14105 enum nl80211_auth_type auth_type)
14106{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014107 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014108 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14109
14110 ENTER();
14111
14112 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014113 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070014114 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014115 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014116 hddLog(VOS_TRACE_LEVEL_INFO,
14117 "%s: set authentication type to AUTOSWITCH", __func__);
14118 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
14119 break;
14120
14121 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014122#ifdef WLAN_FEATURE_VOWIFI_11R
14123 case NL80211_AUTHTYPE_FT:
14124#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014125 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 "%s: set authentication type to OPEN", __func__);
14127 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
14128 break;
14129
14130 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014131 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014132 "%s: set authentication type to SHARED", __func__);
14133 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
14134 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014135#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014137 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014138 "%s: set authentication type to CCKM WPA", __func__);
14139 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
14140 break;
14141#endif
14142
14143
14144 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014145 hddLog(VOS_TRACE_LEVEL_ERROR,
14146 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014147 auth_type);
14148 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
14149 return -EINVAL;
14150 }
14151
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014152 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014153 pHddStaCtx->conn_info.authType;
14154 return 0;
14155}
14156
14157/*
14158 * FUNCTION: wlan_hdd_set_akm_suite
14159 * This function is used to set the key mgmt type(PSK/8021x).
14160 *
14161 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014162static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014163 u32 key_mgmt
14164 )
14165{
14166 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14167 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053014168 /* Should be in ieee802_11_defs.h */
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053014169#ifndef WLAN_AKM_SUITE_8021X_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053014170#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053014171#endif
14172#ifndef WLAN_AKM_SUITE_PSK_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053014173#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053014174#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014175 /*set key mgmt type*/
14176 switch(key_mgmt)
14177 {
14178 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053014179 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014180#ifdef WLAN_FEATURE_VOWIFI_11R
14181 case WLAN_AKM_SUITE_FT_PSK:
14182#endif
14183 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070014184 __func__);
14185 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
14186 break;
14187
14188 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053014189 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014190#ifdef WLAN_FEATURE_VOWIFI_11R
14191 case WLAN_AKM_SUITE_FT_8021X:
14192#endif
14193 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070014194 __func__);
14195 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
14196 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014197#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014198#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
14199#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
14200 case WLAN_AKM_SUITE_CCKM:
14201 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
14202 __func__);
14203 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
14204 break;
14205#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070014206#ifndef WLAN_AKM_SUITE_OSEN
14207#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
14208 case WLAN_AKM_SUITE_OSEN:
14209 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
14210 __func__);
14211 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
14212 break;
14213#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014214
14215 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014216 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014217 __func__, key_mgmt);
14218 return -EINVAL;
14219
14220 }
14221 return 0;
14222}
14223
14224/*
14225 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014226 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070014227 * (NONE/WEP40/WEP104/TKIP/CCMP).
14228 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014229static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
14230 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070014231 bool ucast
14232 )
14233{
14234 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014235 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014236 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14237
14238 ENTER();
14239
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014240 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070014241 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053014242 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070014243 __func__, cipher);
14244 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14245 }
14246 else
14247 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014248
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014250 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070014251 {
14252 case IW_AUTH_CIPHER_NONE:
14253 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14254 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014255
Jeff Johnson295189b2012-06-20 16:38:30 -070014256 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014257 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070014258 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014259
Jeff Johnson295189b2012-06-20 16:38:30 -070014260 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014261 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070014262 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014263
Jeff Johnson295189b2012-06-20 16:38:30 -070014264 case WLAN_CIPHER_SUITE_TKIP:
14265 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
14266 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014267
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 case WLAN_CIPHER_SUITE_CCMP:
14269 encryptionType = eCSR_ENCRYPT_TYPE_AES;
14270 break;
14271#ifdef FEATURE_WLAN_WAPI
14272 case WLAN_CIPHER_SUITE_SMS4:
14273 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
14274 break;
14275#endif
14276
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014277#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014278 case WLAN_CIPHER_SUITE_KRK:
14279 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
14280 break;
14281#endif
14282 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014283 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014284 __func__, cipher);
14285 return -EOPNOTSUPP;
14286 }
14287 }
14288
14289 if (ucast)
14290 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014291 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014292 __func__, encryptionType);
14293 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
14294 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014295 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014296 encryptionType;
14297 }
14298 else
14299 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014300 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014301 __func__, encryptionType);
14302 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
14303 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
14304 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
14305 }
14306
14307 return 0;
14308}
14309
14310
14311/*
14312 * FUNCTION: wlan_hdd_cfg80211_set_ie
14313 * This function is used to parse WPA/RSN IE's.
14314 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014315int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014316#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14317 const u8 *ie,
14318#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014319 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014320#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014321 size_t ie_len
14322 )
14323{
14324 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014325#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14326 const u8 *genie = ie;
14327#else
Jeff Johnson295189b2012-06-20 16:38:30 -070014328 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014329#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014330 v_U16_t remLen = ie_len;
14331#ifdef FEATURE_WLAN_WAPI
14332 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
14333 u16 *tmp;
14334 v_U16_t akmsuiteCount;
14335 int *akmlist;
14336#endif
14337 ENTER();
14338
14339 /* clear previous assocAddIE */
14340 pWextState->assocAddIE.length = 0;
14341 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014342 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014343
14344 while (remLen >= 2)
14345 {
14346 v_U16_t eLen = 0;
14347 v_U8_t elementId;
14348 elementId = *genie++;
14349 eLen = *genie++;
14350 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014351
Nachiket Kukade4aba5f02017-06-09 15:43:48 +053014352 /* Sanity check on eLen */
14353 if (eLen > remLen) {
14354 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid IE length[%d] for IE[0x%X]",
14355 __func__, eLen, elementId);
14356 VOS_ASSERT(0);
14357 return -EINVAL;
14358 }
14359
Arif Hussain6d2a3322013-11-17 19:50:10 -080014360 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070014361 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014362
14363 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014365 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014366 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 -070014367 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014368 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014369 "%s: Invalid WPA IE", __func__);
14370 return -EINVAL;
14371 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014372 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070014373 {
14374 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014375 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014376 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014377
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014378 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014379 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014380 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
14381 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014382 VOS_ASSERT(0);
14383 return -ENOMEM;
14384 }
14385 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14386 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14387 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014388
Jeff Johnson295189b2012-06-20 16:38:30 -070014389 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
14390 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14391 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14392 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014393 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
14394 {
Nachiket Kukade3d72b7e2017-06-09 16:58:24 +053014395 if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) {
14396 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid WPA RSN IE length[%d]",
14397 __func__, eLen);
14398 VOS_ASSERT(0);
14399 return -EINVAL;
14400 }
14401
Jeff Johnson295189b2012-06-20 16:38:30 -070014402 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
14403 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14404 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
14405 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
14406 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
14407 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014408 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053014409 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070014410 {
14411 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014412 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014413 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014414
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014415 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014416 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014417 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14418 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014419 VOS_ASSERT(0);
14420 return -ENOMEM;
14421 }
14422 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14423 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14424 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014425
Jeff Johnson295189b2012-06-20 16:38:30 -070014426 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14427 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14428 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014429#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014430 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
14431 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014432 /*Consider WFD IE, only for P2P Client */
14433 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
14434 {
14435 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014436 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014437 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014438
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014439 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014440 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014441 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14442 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014443 VOS_ASSERT(0);
14444 return -ENOMEM;
14445 }
14446 // WFD IE is saved to Additional IE ; it should be accumulated to handle
14447 // WPS IE + P2P IE + WFD IE
14448 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14449 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014450
Jeff Johnson295189b2012-06-20 16:38:30 -070014451 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14452 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14453 }
14454#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014455 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014456 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014457 HS20_OUI_TYPE_SIZE)) )
14458 {
14459 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014460 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014461 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014462
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014463 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014464 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014465 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14466 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014467 VOS_ASSERT(0);
14468 return -ENOMEM;
14469 }
14470 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14471 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014472
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014473 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14474 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14475 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014476 /* Appending OSEN Information Element in Assiciation Request */
14477 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
14478 OSEN_OUI_TYPE_SIZE)) )
14479 {
14480 v_U16_t curAddIELen = pWextState->assocAddIE.length;
14481 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
14482 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014483
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014484 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014485 {
14486 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14487 "Need bigger buffer space");
14488 VOS_ASSERT(0);
14489 return -ENOMEM;
14490 }
14491 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14492 pWextState->assocAddIE.length += eLen + 2;
14493
14494 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
14495 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14496 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14497 }
14498
Abhishek Singh4322e622015-06-10 15:42:54 +053014499 /* Update only for WPA IE */
14500 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
14501 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014502
14503 /* populating as ADDIE in beacon frames */
14504 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014505 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014506 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
14507 {
14508 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14509 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
14510 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14511 {
14512 hddLog(LOGE,
14513 "Coldn't pass "
14514 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
14515 }
14516 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
14517 else
14518 hddLog(LOGE,
14519 "Could not pass on "
14520 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
14521
14522 /* IBSS mode doesn't contain params->proberesp_ies still
14523 beaconIE's need to be populated in probe response frames */
14524 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
14525 {
14526 u16 rem_probe_resp_ie_len = eLen + 2;
14527 u8 probe_rsp_ie_len[3] = {0};
14528 u8 counter = 0;
14529
14530 /* Check Probe Resp Length if it is greater then 255 then
14531 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
14532 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
14533 not able Store More then 255 bytes into One Variable */
14534
14535 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
14536 {
14537 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
14538 {
14539 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
14540 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
14541 }
14542 else
14543 {
14544 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
14545 rem_probe_resp_ie_len = 0;
14546 }
14547 }
14548
14549 rem_probe_resp_ie_len = 0;
14550
14551 if (probe_rsp_ie_len[0] > 0)
14552 {
14553 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14554 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
14555 (tANI_U8*)(genie - 2),
14556 probe_rsp_ie_len[0], NULL,
14557 eANI_BOOLEAN_FALSE)
14558 == eHAL_STATUS_FAILURE)
14559 {
14560 hddLog(LOGE,
14561 "Could not pass"
14562 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
14563 }
14564 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
14565 }
14566
14567 if (probe_rsp_ie_len[1] > 0)
14568 {
14569 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14570 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
14571 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14572 probe_rsp_ie_len[1], NULL,
14573 eANI_BOOLEAN_FALSE)
14574 == eHAL_STATUS_FAILURE)
14575 {
14576 hddLog(LOGE,
14577 "Could not pass"
14578 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
14579 }
14580 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
14581 }
14582
14583 if (probe_rsp_ie_len[2] > 0)
14584 {
14585 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14586 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
14587 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14588 probe_rsp_ie_len[2], NULL,
14589 eANI_BOOLEAN_FALSE)
14590 == eHAL_STATUS_FAILURE)
14591 {
14592 hddLog(LOGE,
14593 "Could not pass"
14594 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
14595 }
14596 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
14597 }
14598
14599 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14600 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
14601 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14602 {
14603 hddLog(LOGE,
14604 "Could not pass"
14605 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
14606 }
14607 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014608 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070014609 break;
14610 case DOT11F_EID_RSN:
14611 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
14612 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14613 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
14614 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
14615 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
14616 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053014617
Abhishek Singhb16f3562016-01-20 11:08:32 +053014618 /* Appending extended capabilities with Interworking or
14619 * bsstransition bit set in Assoc Req.
Abhishek Singh15d95602015-03-24 15:52:57 +053014620 *
14621 * In assoc req this EXT Cap will only be taken into account if
Abhishek Singhb16f3562016-01-20 11:08:32 +053014622 * interworkingService or bsstransition bit is set to 1.
14623 * Driver is only interested in interworkingService and
14624 * bsstransition capability from supplicant.
14625 * If in future any other EXT Cap info is
Abhishek Singh15d95602015-03-24 15:52:57 +053014626 * required from supplicat, it needs to be handled while
14627 * sending Assoc Req in LIM.
14628 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014629 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014630 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014631 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014632 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014633 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014634
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014635 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014636 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014637 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14638 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014639 VOS_ASSERT(0);
14640 return -ENOMEM;
14641 }
14642 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14643 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014644
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014645 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14646 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14647 break;
14648 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014649#ifdef FEATURE_WLAN_WAPI
14650 case WLAN_EID_WAPI:
14651 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014652 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070014653 pAdapter->wapi_info.nWapiMode);
14654 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014655 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070014656 akmsuiteCount = WPA_GET_LE16(tmp);
14657 tmp = tmp + 1;
14658 akmlist = (int *)(tmp);
14659 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
14660 {
14661 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
14662 }
14663 else
14664 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014665 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070014666 VOS_ASSERT(0);
14667 return -EINVAL;
14668 }
14669
14670 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
14671 {
14672 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014673 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014674 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014675 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014676 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014677 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014678 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014679 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014680 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
14681 }
14682 break;
14683#endif
14684 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014685 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014686 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014687 /* when Unknown IE is received we should break and continue
14688 * to the next IE in the buffer instead we were returning
14689 * so changing this to break */
14690 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 }
14692 genie += eLen;
14693 remLen -= eLen;
14694 }
14695 EXIT();
14696 return 0;
14697}
14698
14699/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014700 * FUNCTION: hdd_isWPAIEPresent
14701 * Parse the received IE to find the WPA IE
14702 *
14703 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014704static bool hdd_isWPAIEPresent(
14705#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
14706 const u8 *ie,
14707#else
14708 u8 *ie,
14709#endif
14710 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014711{
14712 v_U8_t eLen = 0;
14713 v_U16_t remLen = ie_len;
14714 v_U8_t elementId = 0;
14715
14716 while (remLen >= 2)
14717 {
14718 elementId = *ie++;
14719 eLen = *ie++;
14720 remLen -= 2;
14721 if (eLen > remLen)
14722 {
14723 hddLog(VOS_TRACE_LEVEL_ERROR,
14724 "%s: IE length is wrong %d", __func__, eLen);
14725 return FALSE;
14726 }
14727 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
14728 {
14729 /* OUI - 0x00 0X50 0XF2
14730 WPA Information Element - 0x01
14731 WPA version - 0x01*/
14732 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
14733 return TRUE;
14734 }
14735 ie += eLen;
14736 remLen -= eLen;
14737 }
14738 return FALSE;
14739}
14740
14741/*
Jeff Johnson295189b2012-06-20 16:38:30 -070014742 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014743 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070014744 * parameters during connect operation.
14745 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014746int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014747 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014748 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014749{
14750 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014751 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014752 ENTER();
14753
14754 /*set wpa version*/
14755 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
14756
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014757 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014758 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053014759 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014760 {
14761 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
14762 }
14763 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
14764 {
14765 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
14766 }
14767 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014768
14769 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014770 pWextState->wpaVersion);
14771
14772 /*set authentication type*/
14773 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
14774
14775 if (0 > status)
14776 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014777 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 "%s: failed to set authentication type ", __func__);
14779 return status;
14780 }
14781
14782 /*set key mgmt type*/
14783 if (req->crypto.n_akm_suites)
14784 {
14785 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
14786 if (0 > status)
14787 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014788 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070014789 __func__);
14790 return status;
14791 }
14792 }
14793
14794 /*set pairwise cipher type*/
14795 if (req->crypto.n_ciphers_pairwise)
14796 {
14797 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
14798 req->crypto.ciphers_pairwise[0], true);
14799 if (0 > status)
14800 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014801 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014802 "%s: failed to set unicast cipher type", __func__);
14803 return status;
14804 }
14805 }
14806 else
14807 {
14808 /*Reset previous cipher suite to none*/
14809 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
14810 if (0 > status)
14811 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014812 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014813 "%s: failed to set unicast cipher type", __func__);
14814 return status;
14815 }
14816 }
14817
14818 /*set group cipher type*/
14819 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
14820 false);
14821
14822 if (0 > status)
14823 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014824 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070014825 __func__);
14826 return status;
14827 }
14828
Chet Lanctot186b5732013-03-18 10:26:30 -070014829#ifdef WLAN_FEATURE_11W
14830 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
14831#endif
14832
Jeff Johnson295189b2012-06-20 16:38:30 -070014833 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
14834 if (req->ie_len)
14835 {
14836 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
14837 if ( 0 > status)
14838 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014839 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070014840 __func__);
14841 return status;
14842 }
14843 }
14844
14845 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014846 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014847 {
14848 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
14849 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
14850 )
14851 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014852 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070014853 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
14854 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014855 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070014856 __func__);
14857 return -EOPNOTSUPP;
14858 }
14859 else
14860 {
14861 u8 key_len = req->key_len;
14862 u8 key_idx = req->key_idx;
14863
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014864 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014865 && (CSR_MAX_NUM_KEY > key_idx)
14866 )
14867 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014868 hddLog(VOS_TRACE_LEVEL_INFO,
14869 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014870 __func__, key_idx, key_len);
14871 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014872 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070014873 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014874 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014875 (u8)key_len;
14876 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
14877 }
14878 }
14879 }
14880 }
14881
14882 return status;
14883}
14884
14885/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014886 * FUNCTION: wlan_hdd_try_disconnect
14887 * This function is used to disconnect from previous
14888 * connection
14889 */
Agrawal Ashishc407f192017-01-23 17:18:35 +053014890int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014891{
14892 long ret = 0;
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014893 int status, result = 0;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014894 hdd_station_ctx_t *pHddStaCtx;
14895 eMib_dot11DesiredBssType connectedBssType;
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014896 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014897
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014898 ret = wlan_hdd_validate_context(pHddCtx);
14899 if (0 != ret)
14900 {
14901 return ret;
14902 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014903 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14904
14905 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
14906
14907 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
14908 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
Abhishek Singh630ff592016-01-07 18:15:53 +053014909 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) ||
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014910 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
14911 {
Abhishek Singh9f4df782017-03-15 17:29:10 +053014912 /* Indicate disconnect to SME so that in-progress connection or preauth
14913 * can be aborted
14914 */
14915 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
14916 pAdapter->sessionId);
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014917 spin_lock_bh(&pAdapter->lock_for_active_session);
14918 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14919 {
14920 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14921 }
14922 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singhf7962582015-10-23 10:54:06 +053014923 hdd_connSetConnectionState(pHddStaCtx,
14924 eConnectionState_Disconnecting);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014925 /* Issue disconnect to CSR */
14926 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014927 status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014928 pAdapter->sessionId,
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014929 eCSR_DISCONNECT_REASON_UNSPECIFIED);
14930 if(eHAL_STATUS_CMD_NOT_QUEUED == status) {
14931 hddLog(LOG1,
14932 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
14933 } else if ( 0 != status ) {
14934 hddLog(LOGE,
14935 FL("csrRoamDisconnect failure, returned %d"),
14936 (int)status );
14937 result = -EINVAL;
14938 goto disconnected;
14939 }
14940 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014941 &pAdapter->disconnect_comp_var,
14942 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014943 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status)) {
14944 hddLog(LOGE,
14945 "%s: Failed to disconnect, timed out", __func__);
14946 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014947 }
14948 }
14949 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
14950 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014951 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014952 &pAdapter->disconnect_comp_var,
14953 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014954 if (!ret)
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014955 {
14956 hddLog(LOGE, FL("Failed to receive disconnect event"));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014957 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014958 }
14959 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014960disconnected:
14961 hddLog(LOG1,
14962 FL("Set HDD connState to eConnectionState_NotConnected"));
14963 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
14964 return result;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014965}
14966
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053014967/**
14968 * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present
14969 * @adapter: Pointer to the HDD adapter
14970 * @req: Pointer to the structure cfg_connect_params receieved from user space
14971 *
14972 * This function will start reassociation if bssid hint, channel hint and
14973 * previous bssid parameters are present in the connect request
14974 *
14975 * Return: success if reassociation is happening
14976 * Error code if reassociation is not permitted or not happening
14977 */
14978#ifdef CFG80211_CONNECT_PREV_BSSID
14979static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
14980 struct cfg80211_connect_params *req)
14981{
14982 int status = -EPERM;
14983 if (req->bssid_hint && req->channel_hint && req->prev_bssid) {
14984 hddLog(VOS_TRACE_LEVEL_INFO,
14985 FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR),
14986 req->channel_hint->hw_value,
14987 MAC_ADDR_ARRAY(req->bssid_hint));
14988 status = hdd_reassoc(adapter, req->bssid_hint,
14989 req->channel_hint->hw_value,
14990 CONNECT_CMD_USERSPACE);
14991 }
14992 return status;
14993}
14994#else
14995static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
14996 struct cfg80211_connect_params *req)
14997{
14998 return -EPERM;
14999}
15000#endif
15001
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015002/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053015003 * FUNCTION: __wlan_hdd_cfg80211_connect
15004 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070015005 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015006static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 struct net_device *ndev,
15008 struct cfg80211_connect_params *req
15009 )
15010{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015011 int status;
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015012 u16 channel;
Edhar, Mahesh Kumar496c7f72016-03-18 12:47:44 +053015013#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
15014 defined(CFG80211_BSSID_HINT_BACKPORT)
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015015 const u8 *bssid_hint = req->bssid_hint;
15016#else
15017 const u8 *bssid_hint = NULL;
15018#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015019 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070015020 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053015021 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015022
15023 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015024
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015025 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15026 TRACE_CODE_HDD_CFG80211_CONNECT,
15027 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015028 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015029 "%s: device_mode = %s (%d)", __func__,
15030 hdd_device_modetoString(pAdapter->device_mode),
15031 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015032
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015033 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080015034 if (!pHddCtx)
15035 {
15036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15037 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053015038 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080015039 }
15040
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015041 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015042 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015043 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015044 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015045 }
15046
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053015047 status = wlan_hdd_reassoc_bssid_hint(pAdapter, req);
15048 if (0 == status)
15049 return status;
15050
Agarwal Ashish51325b52014-06-16 16:50:49 +053015051
Jeff Johnson295189b2012-06-20 16:38:30 -070015052#ifdef WLAN_BTAMP_FEATURE
15053 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015054 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070015055 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015056 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015057 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080015058 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070015059 }
15060#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015061
15062 //If Device Mode is Station Concurrent Sessions Exit BMps
15063 //P2P Mode will be taken care in Open/close adapter
15064 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053015065 (vos_concurrent_open_sessions_running())) {
15066 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
15067 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015068 }
15069
15070 /*Try disconnecting if already in connected state*/
15071 status = wlan_hdd_try_disconnect(pAdapter);
15072 if ( 0 > status)
15073 {
15074 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
15075 " connection"));
15076 return -EALREADY;
15077 }
Agrawal Ashish559530c2015-12-01 18:04:20 +053015078 /* Check for max concurrent connections after doing disconnect if any*/
15079 if (vos_max_concurrent_connections_reached()) {
15080 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15081 return -ECONNREFUSED;
15082 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015083
Jeff Johnson295189b2012-06-20 16:38:30 -070015084 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015085 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070015086
15087 if ( 0 > status)
15088 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015089 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070015090 __func__);
15091 return status;
15092 }
Sravan Kumar Kairam589c5722016-01-27 20:28:53 +053015093
15094 if (pHddCtx->spoofMacAddr.isEnabled)
15095 {
15096 hddLog(VOS_TRACE_LEVEL_INFO,
15097 "%s: MAC Spoofing enabled ", __func__);
15098 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
15099 * to fill TxBds for probe request during SSID scan which may happen
15100 * as part of connect command
15101 */
15102 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
15103 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
15104 if (status != VOS_STATUS_SUCCESS)
15105 return -ECONNREFUSED;
15106 }
15107
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015108 if (req->channel)
15109 channel = req->channel->hw_value;
Mohit Khanna765234a2012-09-11 15:08:35 -070015110 else
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015111 channel = 0;
Kapil Gupta312028a2016-10-25 14:15:20 +053015112
15113 /* Abort if any scan is going on */
15114 status = wlan_hdd_scan_abort(pAdapter);
15115 if (0 != status)
15116 hddLog(VOS_TRACE_LEVEL_ERROR, FL("scan abort failed"));
15117
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015118 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
15119 req->ssid_len, req->bssid,
15120 bssid_hint, channel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015121
Sushant Kaushikd7083982015-03-18 14:33:24 +053015122 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015123 {
15124 //ReEnable BMPS if disabled
15125 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
15126 (NULL != pHddCtx))
15127 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053015128 if (pHddCtx->hdd_wlan_suspended)
15129 {
15130 hdd_set_pwrparams(pHddCtx);
15131 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015132 //ReEnable Bmps and Imps back
15133 hdd_enable_bmps_imps(pHddCtx);
15134 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053015135 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015136 return status;
15137 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015138 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015139 EXIT();
15140 return status;
15141}
15142
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015143static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
15144 struct net_device *ndev,
15145 struct cfg80211_connect_params *req)
15146{
15147 int ret;
15148 vos_ssr_protect(__func__);
15149 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
15150 vos_ssr_unprotect(__func__);
15151
15152 return ret;
15153}
Jeff Johnson295189b2012-06-20 16:38:30 -070015154
15155/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015156 * FUNCTION: wlan_hdd_disconnect
15157 * This function is used to issue a disconnect request to SME
15158 */
15159int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
15160{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015161 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015162 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015163 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015164 long ret;
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015165 eConnectionState prev_conn_state;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015166
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015167 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015168
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015169 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015170 if (0 != status)
15171 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015172 return status;
15173 }
Abhishek Singh07e4a892015-11-23 11:29:57 +053015174 /* Indicate sme of disconnect so that in progress connection or preauth
15175 * can be aborted
15176 */
15177 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
Sushant Kaushikb4834d22015-07-15 15:29:05 +053015178 pAdapter->sessionId);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015179 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015180
Agarwal Ashish47d18112014-08-04 19:55:07 +053015181 /* Need to apply spin lock before decreasing active sessions
15182 * as there can be chance for double decrement if context switch
15183 * Calls hdd_DisConnectHandler.
15184 */
15185
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015186 prev_conn_state = pHddStaCtx->conn_info.connState;
15187
Agarwal Ashish47d18112014-08-04 19:55:07 +053015188 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015189 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
15190 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015191 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
15192 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053015193 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
15194 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015195
Abhishek Singhf4669da2014-05-26 15:07:49 +053015196 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053015197 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
15198
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015199 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015200
Mihir Shete182a0b22014-08-18 16:08:48 +053015201 /*
15202 * stop tx queues before deleting STA/BSS context from the firmware.
15203 * tx has to be disabled because the firmware can get busy dropping
15204 * the tx frames after BSS/STA has been deleted and will not send
15205 * back a response resulting in WDI timeout
15206 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053015207 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053015208 netif_tx_disable(pAdapter->dev);
15209 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053015210
Mihir Shete182a0b22014-08-18 16:08:48 +053015211 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015212 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
15213 pAdapter->sessionId, reason);
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015214 if((eHAL_STATUS_CMD_NOT_QUEUED == status) &&
15215 prev_conn_state != eConnectionState_Connecting)
15216 {
15217 hddLog(LOG1,
15218 FL("status = %d, already disconnected"), status);
15219 result = 0;
15220 goto disconnected;
15221 }
15222 /*
15223 * Wait here instead of returning directly, this will block the next
15224 * connect command and allow processing of the scan for ssid and
15225 * the previous connect command in CSR. Else we might hit some
15226 * race conditions leading to SME and HDD out of sync.
15227 */
15228 else if(eHAL_STATUS_CMD_NOT_QUEUED == status)
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015229 {
15230 hddLog(LOG1,
15231 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015232 }
15233 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015234 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015235 hddLog(LOGE,
15236 FL("csrRoamDisconnect failure, returned %d"),
15237 (int)status);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015238 result = -EINVAL;
15239 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015240 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015241 ret = wait_for_completion_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015242 &pAdapter->disconnect_comp_var,
15243 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015244 if (!ret && (eHAL_STATUS_CMD_NOT_QUEUED != status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015245 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015246 hddLog(LOGE,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053015247 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015248 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053015249 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015250disconnected:
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015251 hddLog(LOG1,
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015252 FL("Set HDD connState to eConnectionState_NotConnected"));
15253 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053015254#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
15255 /* Sending disconnect event to userspace for kernel version < 3.11
15256 * is handled by __cfg80211_disconnect call to __cfg80211_disconnected
15257 */
15258 hddLog(LOG1, FL("Send disconnected event to userspace"));
15259
Mahesh A Saptasagarf5859b12016-06-01 17:17:50 +053015260 wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true,
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053015261 WLAN_REASON_UNSPECIFIED);
15262#endif
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015263
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015264 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015265 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015266}
15267
15268
15269/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015270 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070015271 * This function is used to issue a disconnect request to SME
15272 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015273static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015274 struct net_device *dev,
15275 u16 reason
15276 )
15277{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015278 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015279 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015280 tCsrRoamProfile *pRoamProfile;
15281 hdd_station_ctx_t *pHddStaCtx;
15282 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015283#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015284 tANI_U8 staIdx;
15285#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015286
Jeff Johnson295189b2012-06-20 16:38:30 -070015287 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015288
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015289 if (!pAdapter) {
15290 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15291 return -EINVAL;
15292 }
15293
15294 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15295 if (!pHddStaCtx) {
15296 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
15297 return -EINVAL;
15298 }
15299
15300 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15301 status = wlan_hdd_validate_context(pHddCtx);
15302 if (0 != status)
15303 {
15304 return status;
15305 }
15306
15307 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
15308
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015309 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15310 TRACE_CODE_HDD_CFG80211_DISCONNECT,
15311 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015312 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
15313 __func__, hdd_device_modetoString(pAdapter->device_mode),
15314 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015315
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015316 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
15317 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070015318
Jeff Johnson295189b2012-06-20 16:38:30 -070015319 if (NULL != pRoamProfile)
15320 {
15321 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015322 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
15323 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070015324 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015325 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070015326 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015327 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070015328 switch(reason)
15329 {
15330 case WLAN_REASON_MIC_FAILURE:
15331 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
15332 break;
15333
15334 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
15335 case WLAN_REASON_DISASSOC_AP_BUSY:
15336 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
15337 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
15338 break;
15339
15340 case WLAN_REASON_PREV_AUTH_NOT_VALID:
15341 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053015342 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070015343 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
15344 break;
15345
Jeff Johnson295189b2012-06-20 16:38:30 -070015346 default:
15347 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
15348 break;
15349 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015350 pScanInfo = &pHddCtx->scan_info;
15351 if (pScanInfo->mScanPending)
15352 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015353 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015354 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053015355 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015356 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015357 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053015358 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015359#ifdef FEATURE_WLAN_TDLS
15360 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015361 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015362 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015363 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
15364 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015365 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015366 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015367 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015369 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015370 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015371 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015372 status = sme_DeleteTdlsPeerSta(
15373 WLAN_HDD_GET_HAL_CTX(pAdapter),
15374 pAdapter->sessionId,
15375 mac);
15376 if (status != eHAL_STATUS_SUCCESS) {
15377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15378 return -EPERM;
15379 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015380 }
15381 }
15382#endif
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015383
15384 hddLog(LOG1, FL("Disconnecting with reasoncode:%u connState %d"),
15385 reasonCode,
15386 pHddStaCtx->conn_info.connState);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015387 status = wlan_hdd_disconnect(pAdapter, reasonCode);
15388 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070015389 {
15390 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015391 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015392 __func__, (int)status );
15393 return -EINVAL;
15394 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015395 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015396 else
15397 {
15398 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
15399 "called while in %d state", __func__,
15400 pHddStaCtx->conn_info.connState);
15401 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015402 }
15403 else
15404 {
15405 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
15406 }
15407
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015408 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015409 return status;
15410}
15411
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015412static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
15413 struct net_device *dev,
15414 u16 reason
15415 )
15416{
15417 int ret;
15418 vos_ssr_protect(__func__);
15419 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
15420 vos_ssr_unprotect(__func__);
15421
15422 return ret;
15423}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015424
Jeff Johnson295189b2012-06-20 16:38:30 -070015425/*
15426 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015427 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070015428 * settings in IBSS mode.
15429 */
15430static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015431 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070015432 struct cfg80211_ibss_params *params
15433 )
15434{
15435 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015436 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070015437 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
15438 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015439
Jeff Johnson295189b2012-06-20 16:38:30 -070015440 ENTER();
15441
15442 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070015443 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070015444
15445 if (params->ie_len && ( NULL != params->ie) )
15446 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015447 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
15448 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070015449 {
15450 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
15451 encryptionType = eCSR_ENCRYPT_TYPE_AES;
15452 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015453 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015455 tDot11fIEWPA dot11WPAIE;
15456 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015457 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015458
Wilson Yang00256342013-10-10 23:13:38 -070015459 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015460 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
15461 params->ie_len, DOT11F_EID_WPA);
15462 if ( NULL != ie )
15463 {
15464 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
15465 // Unpack the WPA IE
15466 //Skip past the EID byte and length byte - and four byte WiFi OUI
15467 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
15468 &ie[2+4],
15469 ie[1] - 4,
15470 &dot11WPAIE);
15471 /*Extract the multicast cipher, the encType for unicast
15472 cipher for wpa-none is none*/
15473 encryptionType =
15474 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
15475 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015476 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015477
Jeff Johnson295189b2012-06-20 16:38:30 -070015478 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
15479
15480 if (0 > status)
15481 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015482 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070015483 __func__);
15484 return status;
15485 }
15486 }
15487
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015488 pWextState->roamProfile.AuthType.authType[0] =
15489 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070015490 eCSR_AUTH_TYPE_OPEN_SYSTEM;
15491
15492 if (params->privacy)
15493 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015494 /* Security enabled IBSS, At this time there is no information available
15495 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070015496 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015497 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070015498 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015499 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070015500 *enable privacy bit in beacons */
15501
15502 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
15503 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015504 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
15505 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015506 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
15507 pWextState->roamProfile.EncryptionType.numEntries = 1;
15508 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015509 return status;
15510}
15511
15512/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015513 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015514 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015515 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015516static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015517 struct net_device *dev,
15518 struct cfg80211_ibss_params *params
15519 )
15520{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015521 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070015522 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15523 tCsrRoamProfile *pRoamProfile;
15524 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015525 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15526 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015527 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070015528
15529 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015530
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015531 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15532 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
15533 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015534 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015535 "%s: device_mode = %s (%d)", __func__,
15536 hdd_device_modetoString(pAdapter->device_mode),
15537 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015538
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015539 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015540 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015541 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015542 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015543 }
15544
15545 if (NULL == pWextState)
15546 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015547 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015548 __func__);
15549 return -EIO;
15550 }
15551
Agarwal Ashish51325b52014-06-16 16:50:49 +053015552 if (vos_max_concurrent_connections_reached()) {
15553 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15554 return -ECONNREFUSED;
15555 }
15556
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015557 /*Try disconnecting if already in connected state*/
15558 status = wlan_hdd_try_disconnect(pAdapter);
15559 if ( 0 > status)
15560 {
15561 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
15562 " IBSS connection"));
15563 return -EALREADY;
15564 }
15565
Jeff Johnson295189b2012-06-20 16:38:30 -070015566 pRoamProfile = &pWextState->roamProfile;
15567
15568 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
15569 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015570 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015571 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015572 return -EINVAL;
15573 }
15574
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015575 /* BSSID is provided by upper layers hence no need to AUTO generate */
15576 if (NULL != params->bssid) {
15577 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
15578 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
15579 hddLog (VOS_TRACE_LEVEL_ERROR,
15580 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
15581 return -EIO;
15582 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015583 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015584 }
krunal sonie9002db2013-11-25 14:24:17 -080015585 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
15586 {
15587 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
15588 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
15589 {
15590 hddLog (VOS_TRACE_LEVEL_ERROR,
15591 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
15592 return -EIO;
15593 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015594
15595 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080015596 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015597 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080015598 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015599
Jeff Johnson295189b2012-06-20 16:38:30 -070015600 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070015601 if (NULL !=
15602#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
15603 params->chandef.chan)
15604#else
15605 params->channel)
15606#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015607 {
15608 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015609 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
15610 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
15611 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15612 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070015613
15614 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015615 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070015616 ieee80211_frequency_to_channel(
15617#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
15618 params->chandef.chan->center_freq);
15619#else
15620 params->channel->center_freq);
15621#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015622
15623 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
15624 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070015625 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015626 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
15627 __func__);
15628 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070015629 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015630
15631 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015632 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015633 if (channelNum == validChan[indx])
15634 {
15635 break;
15636 }
15637 }
15638 if (indx >= numChans)
15639 {
15640 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015641 __func__, channelNum);
15642 return -EINVAL;
15643 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015644 /* Set the Operational Channel */
15645 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
15646 channelNum);
15647 pRoamProfile->ChannelInfo.numOfChannels = 1;
15648 pHddStaCtx->conn_info.operationChannel = channelNum;
15649 pRoamProfile->ChannelInfo.ChannelList =
15650 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070015651 }
15652
15653 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015654 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070015655 if (status < 0)
15656 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015657 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070015658 __func__);
15659 return status;
15660 }
15661
15662 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015663 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Abhishek Singh4d924682015-11-17 15:23:06 +053015664 params->ssid_len, (const u8 *)&bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015665 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015666
15667 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015668 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015669
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015670 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015671 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015672}
15673
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015674static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
15675 struct net_device *dev,
15676 struct cfg80211_ibss_params *params
15677 )
15678{
15679 int ret = 0;
15680
15681 vos_ssr_protect(__func__);
15682 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
15683 vos_ssr_unprotect(__func__);
15684
15685 return ret;
15686}
15687
Jeff Johnson295189b2012-06-20 16:38:30 -070015688/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015689 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015690 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015691 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015692static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015693 struct net_device *dev
15694 )
15695{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015696 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015697 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15698 tCsrRoamProfile *pRoamProfile;
15699 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015700 int status;
Abhishek Singh69de3302016-11-11 16:44:32 +053015701 eHalStatus hal_status;
Abhishek Singh7cd040e2016-01-07 10:51:04 +053015702#ifdef WLAN_FEATURE_RMC
15703 tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN] = {0};
15704#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015705
15706 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015707
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015708 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15709 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
15710 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015711 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015712 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015713 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015714 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015715 }
15716
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015717 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
15718 hdd_device_modetoString(pAdapter->device_mode),
15719 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015720 if (NULL == pWextState)
15721 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015722 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015723 __func__);
15724 return -EIO;
15725 }
15726
15727 pRoamProfile = &pWextState->roamProfile;
15728
15729 /* Issue disconnect only if interface type is set to IBSS */
15730 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
15731 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015732 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070015733 __func__);
15734 return -EINVAL;
15735 }
15736
Abhishek Singh7cd040e2016-01-07 10:51:04 +053015737#ifdef WLAN_FEATURE_RMC
15738 /* Clearing add IE of beacon */
15739 if (ccmCfgSetStr(pHddCtx->hHal,
15740 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0],
15741 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN,
15742 NULL, eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
15743 {
15744 hddLog (VOS_TRACE_LEVEL_ERROR,
15745 "%s: unable to clear PROBE_RSP_BCN_ADDNIE_DATA", __func__);
15746 return -EINVAL;
15747 }
15748 if (ccmCfgSetInt(pHddCtx->hHal,
15749 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0, NULL,
15750 eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
15751 {
15752 hddLog (VOS_TRACE_LEVEL_ERROR,
15753 "%s: unable to clear WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
15754 __func__);
15755 return -EINVAL;
15756 }
15757
15758 // Reset WNI_CFG_PROBE_RSP Flags
15759 wlan_hdd_reset_prob_rspies(pAdapter);
15760
15761 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
15762 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 0,NULL,
15763 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
15764 {
15765 hddLog (VOS_TRACE_LEVEL_ERROR,
15766 "%s: unable to clear WNI_CFG_PROBE_RSP_ADDNIE_FLAG",
15767 __func__);
15768 return -EINVAL;
15769 }
15770#endif
15771
Jeff Johnson295189b2012-06-20 16:38:30 -070015772 /* Issue Disconnect request */
15773 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singh69de3302016-11-11 16:44:32 +053015774 hal_status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
15775 pAdapter->sessionId,
15776 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
15777 if (!HAL_STATUS_SUCCESS(hal_status)) {
15778 hddLog(LOGE,
15779 FL("sme_RoamDisconnect failed hal_status(%d)"),
15780 hal_status);
15781 return -EAGAIN;
15782 }
15783 status = wait_for_completion_timeout(
15784 &pAdapter->disconnect_comp_var,
15785 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
15786 if (!status) {
15787 hddLog(LOGE,
15788 FL("wait on disconnect_comp_var failed"));
15789 return -ETIMEDOUT;
15790 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015791
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015792 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015793 return 0;
15794}
15795
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015796static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
15797 struct net_device *dev
15798 )
15799{
15800 int ret = 0;
15801
15802 vos_ssr_protect(__func__);
15803 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
15804 vos_ssr_unprotect(__func__);
15805
15806 return ret;
15807}
15808
Jeff Johnson295189b2012-06-20 16:38:30 -070015809/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015810 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070015811 * This function is used to set the phy parameters
15812 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
15813 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015814static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015815 u32 changed)
15816{
15817 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15818 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015819 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015820
15821 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015822
15823 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015824 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
15825 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015826
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015827 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015828 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015829 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015830 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015831 }
15832
Jeff Johnson295189b2012-06-20 16:38:30 -070015833 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
15834 {
15835 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
15836 WNI_CFG_RTS_THRESHOLD_STAMAX :
15837 wiphy->rts_threshold;
15838
15839 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015840 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070015841 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015842 hddLog(VOS_TRACE_LEVEL_ERROR,
15843 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015844 __func__, rts_threshold);
15845 return -EINVAL;
15846 }
15847
15848 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
15849 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015850 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015851 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015852 hddLog(VOS_TRACE_LEVEL_ERROR,
15853 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015854 __func__, rts_threshold);
15855 return -EIO;
15856 }
15857
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015858 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015859 rts_threshold);
15860 }
15861
15862 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
15863 {
15864 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
15865 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
15866 wiphy->frag_threshold;
15867
15868 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015869 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015870 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015871 hddLog(VOS_TRACE_LEVEL_ERROR,
15872 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015873 frag_threshold);
15874 return -EINVAL;
15875 }
15876
15877 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
15878 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015879 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015880 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015881 hddLog(VOS_TRACE_LEVEL_ERROR,
15882 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015883 __func__, frag_threshold);
15884 return -EIO;
15885 }
15886
15887 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
15888 frag_threshold);
15889 }
15890
15891 if ((changed & WIPHY_PARAM_RETRY_SHORT)
15892 || (changed & WIPHY_PARAM_RETRY_LONG))
15893 {
15894 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
15895 wiphy->retry_short :
15896 wiphy->retry_long;
15897
15898 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
15899 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
15900 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015901 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015902 __func__, retry_value);
15903 return -EINVAL;
15904 }
15905
15906 if (changed & WIPHY_PARAM_RETRY_SHORT)
15907 {
15908 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
15909 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015910 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015911 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015912 hddLog(VOS_TRACE_LEVEL_ERROR,
15913 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015914 __func__, retry_value);
15915 return -EIO;
15916 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015917 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015918 __func__, retry_value);
15919 }
15920 else if (changed & WIPHY_PARAM_RETRY_SHORT)
15921 {
15922 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
15923 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015924 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015925 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015926 hddLog(VOS_TRACE_LEVEL_ERROR,
15927 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015928 __func__, retry_value);
15929 return -EIO;
15930 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015931 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015932 __func__, retry_value);
15933 }
15934 }
15935
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015936 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015937 return 0;
15938}
15939
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015940static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
15941 u32 changed)
15942{
15943 int ret;
15944
15945 vos_ssr_protect(__func__);
15946 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
15947 vos_ssr_unprotect(__func__);
15948
15949 return ret;
15950}
15951
Jeff Johnson295189b2012-06-20 16:38:30 -070015952/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015953 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015954 * This function is used to set the txpower
15955 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015956static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015957#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15958 struct wireless_dev *wdev,
15959#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015960#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015961 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015962#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015963 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015964#endif
15965 int dbm)
15966{
15967 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015968 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015969 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
15970 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015971 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015972
15973 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015974
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015975 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15976 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
15977 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015978 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015979 if (0 != status)
15980 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015981 return status;
15982 }
15983
15984 hHal = pHddCtx->hHal;
15985
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015986 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
15987 dbm, ccmCfgSetCallback,
15988 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015989 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015990 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015991 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
15992 return -EIO;
15993 }
15994
15995 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
15996 dbm);
15997
15998 switch(type)
15999 {
16000 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
16001 /* Fall through */
16002 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
16003 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
16004 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016005 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
16006 __func__);
16007 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070016008 }
16009 break;
16010 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016011 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070016012 __func__);
16013 return -EOPNOTSUPP;
16014 break;
16015 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016016 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
16017 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070016018 return -EIO;
16019 }
16020
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016021 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016022 return 0;
16023}
16024
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016025static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
16026#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16027 struct wireless_dev *wdev,
16028#endif
16029#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
16030 enum tx_power_setting type,
16031#else
16032 enum nl80211_tx_power_setting type,
16033#endif
16034 int dbm)
16035{
16036 int ret;
16037 vos_ssr_protect(__func__);
16038 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
16039#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16040 wdev,
16041#endif
16042#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
16043 type,
16044#else
16045 type,
16046#endif
16047 dbm);
16048 vos_ssr_unprotect(__func__);
16049
16050 return ret;
16051}
16052
Jeff Johnson295189b2012-06-20 16:38:30 -070016053/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016054 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070016055 * This function is used to read the txpower
16056 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016057static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070016058#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16059 struct wireless_dev *wdev,
16060#endif
16061 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070016062{
16063
16064 hdd_adapter_t *pAdapter;
16065 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016066 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016067
Jeff Johnsone7245742012-09-05 17:12:55 -070016068 ENTER();
16069
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016070 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016071 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016072 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016073 *dbm = 0;
16074 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016075 }
16076
Jeff Johnson295189b2012-06-20 16:38:30 -070016077 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
16078 if (NULL == pAdapter)
16079 {
16080 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
16081 return -ENOENT;
16082 }
16083
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016084 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16085 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
16086 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070016087 wlan_hdd_get_classAstats(pAdapter);
16088 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
16089
Jeff Johnsone7245742012-09-05 17:12:55 -070016090 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016091 return 0;
16092}
16093
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016094static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
16095#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16096 struct wireless_dev *wdev,
16097#endif
16098 int *dbm)
16099{
16100 int ret;
16101
16102 vos_ssr_protect(__func__);
16103 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
16104#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16105 wdev,
16106#endif
16107 dbm);
16108 vos_ssr_unprotect(__func__);
16109
16110 return ret;
16111}
16112
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016113static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016114#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16115 const u8* mac,
16116#else
16117 u8* mac,
16118#endif
16119 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070016120{
16121 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
16122 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16123 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053016124 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070016125
16126 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
16127 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070016128
16129 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
16130 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
16131 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
16132 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
16133 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
16134 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
16135 tANI_U16 maxRate = 0;
16136 tANI_U16 myRate;
16137 tANI_U16 currentRate = 0;
16138 tANI_U8 maxSpeedMCS = 0;
16139 tANI_U8 maxMCSIdx = 0;
16140 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053016141 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070016142 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016143 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016144
Leo Chang6f8870f2013-03-26 18:11:36 -070016145#ifdef WLAN_FEATURE_11AC
16146 tANI_U32 vht_mcs_map;
16147 eDataRate11ACMaxMcs vhtMaxMcs;
16148#endif /* WLAN_FEATURE_11AC */
16149
Jeff Johnsone7245742012-09-05 17:12:55 -070016150 ENTER();
16151
Jeff Johnson295189b2012-06-20 16:38:30 -070016152 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
16153 (0 == ssidlen))
16154 {
16155 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
16156 " Invalid ssidlen, %d", __func__, ssidlen);
16157 /*To keep GUI happy*/
16158 return 0;
16159 }
16160
Mukul Sharma811205f2014-07-09 21:07:30 +053016161 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16162 {
16163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16164 "%s: Roaming in progress, so unable to proceed this request", __func__);
Sachin Ahuja81ab1812016-08-19 21:35:58 +053016165 /* return a cached value */
16166 sinfo->signal = pAdapter->rssi;
Mukul Sharma811205f2014-07-09 21:07:30 +053016167 return 0;
16168 }
16169
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016170 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016171 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016172 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016173 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016174 }
16175
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053016176 wlan_hdd_get_station_stats(pAdapter);
16177 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070016178
Kiet Lam3b17fc82013-09-27 05:24:08 +053016179 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
16180 sinfo->filled |= STATION_INFO_SIGNAL;
16181
c_hpothu09f19542014-05-30 21:53:31 +053016182 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053016183 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
16184 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053016185 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053016186 {
16187 rate_flags = pAdapter->maxRateFlags;
16188 }
c_hpothu44ff4e02014-05-08 00:13:57 +053016189
Jeff Johnson295189b2012-06-20 16:38:30 -070016190 //convert to the UI units of 100kbps
16191 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
16192
16193#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070016194 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 -070016195 sinfo->signal,
16196 pCfg->reportMaxLinkSpeed,
16197 myRate,
16198 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016199 (int) pCfg->linkSpeedRssiMid,
16200 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070016201 (int) rate_flags,
16202 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070016203#endif //LINKSPEED_DEBUG_ENABLED
16204
16205 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
16206 {
16207 // we do not want to necessarily report the current speed
16208 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
16209 {
16210 // report the max possible speed
16211 rssidx = 0;
16212 }
16213 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
16214 {
16215 // report the max possible speed with RSSI scaling
16216 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
16217 {
16218 // report the max possible speed
16219 rssidx = 0;
16220 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016221 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016222 {
16223 // report middle speed
16224 rssidx = 1;
16225 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016226 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
16227 {
16228 // report middle speed
16229 rssidx = 2;
16230 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016231 else
16232 {
16233 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016234 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070016235 }
16236 }
16237 else
16238 {
16239 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
16240 hddLog(VOS_TRACE_LEVEL_ERROR,
16241 "%s: Invalid value for reportMaxLinkSpeed: %u",
16242 __func__, pCfg->reportMaxLinkSpeed);
16243 rssidx = 0;
16244 }
16245
16246 maxRate = 0;
16247
16248 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016249 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
16250 OperationalRates, &ORLeng))
16251 {
16252 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16253 /*To keep GUI happy*/
16254 return 0;
16255 }
16256
Jeff Johnson295189b2012-06-20 16:38:30 -070016257 for (i = 0; i < ORLeng; i++)
16258 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016259 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016260 {
16261 /* Validate Rate Set */
16262 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
16263 {
16264 currentRate = supported_data_rate[j].supported_rate[rssidx];
16265 break;
16266 }
16267 }
16268 /* Update MAX rate */
16269 maxRate = (currentRate > maxRate)?currentRate:maxRate;
16270 }
16271
16272 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016273 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
16274 ExtendedRates, &ERLeng))
16275 {
16276 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16277 /*To keep GUI happy*/
16278 return 0;
16279 }
16280
Jeff Johnson295189b2012-06-20 16:38:30 -070016281 for (i = 0; i < ERLeng; i++)
16282 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016283 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016284 {
16285 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
16286 {
16287 currentRate = supported_data_rate[j].supported_rate[rssidx];
16288 break;
16289 }
16290 }
16291 /* Update MAX rate */
16292 maxRate = (currentRate > maxRate)?currentRate:maxRate;
16293 }
c_hpothu79aab322014-07-14 21:11:01 +053016294
Kiet Lamb69f8dc2013-11-15 15:34:27 +053016295 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053016296 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053016297 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053016298 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070016299 {
c_hpothu79aab322014-07-14 21:11:01 +053016300 if (rate_flags & eHAL_TX_RATE_VHT80)
16301 mode = 2;
16302 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
16303 mode = 1;
16304 else
16305 mode = 0;
16306
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016307 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
16308 MCSRates, &MCSLeng))
16309 {
16310 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16311 /*To keep GUI happy*/
16312 return 0;
16313 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016314 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070016315#ifdef WLAN_FEATURE_11AC
16316 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016317 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070016318 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016319 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016320 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070016321 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070016322 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016323 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070016324 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016325 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070016326 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016327 maxMCSIdx = 7;
16328 }
16329 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
16330 {
16331 maxMCSIdx = 8;
16332 }
16333 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
16334 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016335 //VHT20 is supporting 0~8
16336 if (rate_flags & eHAL_TX_RATE_VHT20)
16337 maxMCSIdx = 8;
16338 else
16339 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070016340 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016341
c_hpothu79aab322014-07-14 21:11:01 +053016342 if (0 != rssidx)/*check for scaled */
16343 {
16344 //get middle rate MCS index if rssi=1/2
16345 for (i=0; i <= maxMCSIdx; i++)
16346 {
16347 if (sinfo->signal <= rssiMcsTbl[mode][i])
16348 {
16349 maxMCSIdx = i;
16350 break;
16351 }
16352 }
16353 }
16354
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016355 if (rate_flags & eHAL_TX_RATE_VHT80)
16356 {
16357 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
16358 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
16359 }
16360 else if (rate_flags & eHAL_TX_RATE_VHT40)
16361 {
16362 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
16363 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
16364 }
16365 else if (rate_flags & eHAL_TX_RATE_VHT20)
16366 {
16367 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
16368 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
16369 }
16370
Leo Chang6f8870f2013-03-26 18:11:36 -070016371 maxSpeedMCS = 1;
16372 if (currentRate > maxRate)
16373 {
16374 maxRate = currentRate;
16375 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016376
Leo Chang6f8870f2013-03-26 18:11:36 -070016377 }
16378 else
16379#endif /* WLAN_FEATURE_11AC */
16380 {
16381 if (rate_flags & eHAL_TX_RATE_HT40)
16382 {
16383 rateFlag |= 1;
16384 }
16385 if (rate_flags & eHAL_TX_RATE_SGI)
16386 {
16387 rateFlag |= 2;
16388 }
16389
Girish Gowli01abcee2014-07-31 20:18:55 +053016390 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053016391 if (rssidx == 1 || rssidx == 2)
16392 {
16393 //get middle rate MCS index if rssi=1/2
16394 for (i=0; i <= 7; i++)
16395 {
16396 if (sinfo->signal <= rssiMcsTbl[mode][i])
16397 {
16398 temp = i+1;
16399 break;
16400 }
16401 }
16402 }
c_hpothu79aab322014-07-14 21:11:01 +053016403
16404 for (i = 0; i < MCSLeng; i++)
16405 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016406 for (j = 0; j < temp; j++)
16407 {
16408 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
16409 {
16410 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053016411 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070016412 break;
16413 }
16414 }
16415 if ((j < temp) && (currentRate > maxRate))
16416 {
16417 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070016418 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016419 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053016420 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070016421 }
16422 }
16423
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016424 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
16425 {
16426 maxRate = myRate;
16427 maxSpeedMCS = 1;
16428 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
16429 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016430 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053016431 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070016432 {
16433 maxRate = myRate;
16434 if (rate_flags & eHAL_TX_RATE_LEGACY)
16435 {
16436 maxSpeedMCS = 0;
16437 }
16438 else
16439 {
16440 maxSpeedMCS = 1;
16441 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
16442 }
16443 }
16444
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016445 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070016446 {
16447 sinfo->txrate.legacy = maxRate;
16448#ifdef LINKSPEED_DEBUG_ENABLED
16449 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
16450#endif //LINKSPEED_DEBUG_ENABLED
16451 }
16452 else
16453 {
16454 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070016455#ifdef WLAN_FEATURE_11AC
16456 sinfo->txrate.nss = 1;
16457 if (rate_flags & eHAL_TX_RATE_VHT80)
16458 {
16459 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016460 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070016461 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016462 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070016463 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016464 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16465 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16466 }
16467 else if (rate_flags & eHAL_TX_RATE_VHT20)
16468 {
16469 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16470 }
16471#endif /* WLAN_FEATURE_11AC */
16472 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
16473 {
16474 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
16475 if (rate_flags & eHAL_TX_RATE_HT40)
16476 {
16477 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16478 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016479 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016480 if (rate_flags & eHAL_TX_RATE_SGI)
16481 {
16482 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
16483 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016484
Jeff Johnson295189b2012-06-20 16:38:30 -070016485#ifdef LINKSPEED_DEBUG_ENABLED
16486 pr_info("Reporting MCS rate %d flags %x\n",
16487 sinfo->txrate.mcs,
16488 sinfo->txrate.flags );
16489#endif //LINKSPEED_DEBUG_ENABLED
16490 }
16491 }
16492 else
16493 {
16494 // report current rate instead of max rate
16495
16496 if (rate_flags & eHAL_TX_RATE_LEGACY)
16497 {
16498 //provide to the UI in units of 100kbps
16499 sinfo->txrate.legacy = myRate;
16500#ifdef LINKSPEED_DEBUG_ENABLED
16501 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
16502#endif //LINKSPEED_DEBUG_ENABLED
16503 }
16504 else
16505 {
16506 //must be MCS
16507 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070016508#ifdef WLAN_FEATURE_11AC
16509 sinfo->txrate.nss = 1;
16510 if (rate_flags & eHAL_TX_RATE_VHT80)
16511 {
16512 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16513 }
16514 else
16515#endif /* WLAN_FEATURE_11AC */
16516 {
16517 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
16518 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016519 if (rate_flags & eHAL_TX_RATE_SGI)
16520 {
16521 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
16522 }
16523 if (rate_flags & eHAL_TX_RATE_HT40)
16524 {
16525 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16526 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016527#ifdef WLAN_FEATURE_11AC
16528 else if (rate_flags & eHAL_TX_RATE_VHT80)
16529 {
16530 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
16531 }
16532#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070016533#ifdef LINKSPEED_DEBUG_ENABLED
16534 pr_info("Reporting actual MCS rate %d flags %x\n",
16535 sinfo->txrate.mcs,
16536 sinfo->txrate.flags );
16537#endif //LINKSPEED_DEBUG_ENABLED
16538 }
16539 }
16540 sinfo->filled |= STATION_INFO_TX_BITRATE;
16541
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070016542 sinfo->tx_packets =
16543 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
16544 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
16545 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
16546 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
16547
16548 sinfo->tx_retries =
16549 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
16550 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
16551 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
16552 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
16553
16554 sinfo->tx_failed =
16555 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
16556 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
16557 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
16558 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
16559
16560 sinfo->filled |=
16561 STATION_INFO_TX_PACKETS |
16562 STATION_INFO_TX_RETRIES |
16563 STATION_INFO_TX_FAILED;
16564
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053016565 sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt;
16566 sinfo->filled |= STATION_INFO_RX_PACKETS;
16567
16568 if (rate_flags & eHAL_TX_RATE_LEGACY)
16569 hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"),
16570 sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets,
16571 sinfo->rx_packets);
16572 else
16573 hddLog(LOG1,
16574 FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"),
16575 sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags,
16576 sinfo->tx_packets, sinfo->rx_packets);
16577
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016578 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16579 TRACE_CODE_HDD_CFG80211_GET_STA,
16580 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070016581 EXIT();
16582 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016583}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016584#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16585static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
16586 const u8* mac, struct station_info *sinfo)
16587#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016588static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
16589 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016590#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016591{
16592 int ret;
16593
16594 vos_ssr_protect(__func__);
16595 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
16596 vos_ssr_unprotect(__func__);
16597
16598 return ret;
16599}
16600
16601static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070016602 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070016603{
16604 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016605 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070016606 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016607 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016608
Jeff Johnsone7245742012-09-05 17:12:55 -070016609 ENTER();
16610
Jeff Johnson295189b2012-06-20 16:38:30 -070016611 if (NULL == pAdapter)
16612 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016613 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016614 return -ENODEV;
16615 }
16616
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016617 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16618 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
16619 pAdapter->sessionId, timeout));
16620
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016621 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016622 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016623 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016624 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016625 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016626 }
16627
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016628 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
16629 (TRUE == pHddCtx->hdd_wlan_suspended) &&
16630 (pHddCtx->cfg_ini->fhostArpOffload) &&
16631 (eConnectionState_Associated ==
16632 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
16633 {
Amar Singhald53568e2013-09-26 11:03:45 -070016634
16635 hddLog(VOS_TRACE_LEVEL_INFO,
16636 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053016637 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016638 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16639 {
16640 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080016641 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016642 __func__, vos_status);
16643 }
16644 }
16645
Jeff Johnson295189b2012-06-20 16:38:30 -070016646 /**The get power cmd from the supplicant gets updated by the nl only
16647 *on successful execution of the function call
16648 *we are oppositely mapped w.r.t mode in the driver
16649 **/
16650 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
16651
16652 if (VOS_STATUS_E_FAILURE == vos_status)
16653 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016654 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16655 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016656 return -EINVAL;
16657 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016658 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016659 return 0;
16660}
16661
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016662static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
16663 struct net_device *dev, bool mode, int timeout)
16664{
16665 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016666
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016667 vos_ssr_protect(__func__);
16668 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
16669 vos_ssr_unprotect(__func__);
16670
16671 return ret;
16672}
Sushant Kaushik084f6592015-09-10 13:11:56 +053016673
Jeff Johnson295189b2012-06-20 16:38:30 -070016674#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016675static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
16676 struct net_device *netdev,
16677 u8 key_index)
16678{
16679 ENTER();
16680 return 0;
16681}
16682
Jeff Johnson295189b2012-06-20 16:38:30 -070016683static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016684 struct net_device *netdev,
16685 u8 key_index)
16686{
16687 int ret;
16688 vos_ssr_protect(__func__);
16689 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
16690 vos_ssr_unprotect(__func__);
16691 return ret;
16692}
16693#endif //LINUX_VERSION_CODE
16694
16695#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16696static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16697 struct net_device *dev,
16698 struct ieee80211_txq_params *params)
16699{
16700 ENTER();
16701 return 0;
16702}
16703#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16704static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16705 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016706{
Jeff Johnsone7245742012-09-05 17:12:55 -070016707 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070016708 return 0;
16709}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016710#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070016711
16712#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16713static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016714 struct net_device *dev,
16715 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016716{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016717 int ret;
16718
16719 vos_ssr_protect(__func__);
16720 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
16721 vos_ssr_unprotect(__func__);
16722 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016723}
16724#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16725static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
16726 struct ieee80211_txq_params *params)
16727{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016728 int ret;
16729
16730 vos_ssr_protect(__func__);
16731 ret = __wlan_hdd_set_txq_params(wiphy, params);
16732 vos_ssr_unprotect(__func__);
16733 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016734}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016735#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016736
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016737static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016738 struct net_device *dev,
16739 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070016740{
16741 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016742 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016743 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016744 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016745 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016746 v_CONTEXT_t pVosContext = NULL;
16747 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016748
Jeff Johnsone7245742012-09-05 17:12:55 -070016749 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016750
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016751 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070016752 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016753 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016754 return -EINVAL;
16755 }
16756
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016757 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16758 TRACE_CODE_HDD_CFG80211_DEL_STA,
16759 pAdapter->sessionId, pAdapter->device_mode));
16760
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016761 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16762 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016763 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016764 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016765 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016766 }
16767
Jeff Johnson295189b2012-06-20 16:38:30 -070016768 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016769 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016770 )
16771 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016772 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
16773 pSapCtx = VOS_GET_SAP_CB(pVosContext);
16774 if(pSapCtx == NULL){
16775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16776 FL("psapCtx is NULL"));
16777 return -ENOENT;
16778 }
Agrawal Ashish306b75f2017-01-11 19:16:25 +053016779 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
16780 {
16781 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
16782 "Change reason code to eSIR_MAC_DISASSOC_LEAVING_BSS_REASON in sap auth offload");
16783 pDelStaParams->reason_code = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
16784 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016785 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070016786 {
16787 v_U16_t i;
16788 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
16789 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016790 if ((pSapCtx->aStaInfo[i].isUsed) &&
16791 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070016792 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016793 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016794 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016795 ETHER_ADDR_LEN);
16796
Jeff Johnson295189b2012-06-20 16:38:30 -070016797 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016798 "%s: Delete STA with MAC::"
16799 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016800 __func__,
16801 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
16802 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070016803 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016804 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016805 }
16806 }
16807 }
16808 else
16809 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016810
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016811 vos_status = hdd_softap_GetStaId(pAdapter,
16812 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016813 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16814 {
16815 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016816 "%s: Skip this DEL STA as this is not used::"
16817 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016818 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016819 return -ENOENT;
16820 }
16821
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016822 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016823 {
16824 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016825 "%s: Skip this DEL STA as deauth is in progress::"
16826 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016827 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016828 return -ENOENT;
16829 }
16830
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016831 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016832
Jeff Johnson295189b2012-06-20 16:38:30 -070016833 hddLog(VOS_TRACE_LEVEL_INFO,
16834 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016835 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016836 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016837 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016838
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016839 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016840 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16841 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016842 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016843 hddLog(VOS_TRACE_LEVEL_INFO,
16844 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016845 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016846 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016847 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016848 return -ENOENT;
16849 }
16850
Jeff Johnson295189b2012-06-20 16:38:30 -070016851 }
16852 }
16853
16854 EXIT();
16855
16856 return 0;
16857}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016858
16859#ifdef CFG80211_DEL_STA_V2
Kapil Gupta137ef892016-12-13 19:38:00 +053016860int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016861 struct net_device *dev,
16862 struct station_del_parameters *param)
16863#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016864#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
Kapil Gupta137ef892016-12-13 19:38:00 +053016865int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016866 struct net_device *dev, const u8 *mac)
16867#else
Kapil Gupta137ef892016-12-13 19:38:00 +053016868int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016869 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016870#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016871#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016872{
16873 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016874 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070016875
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016876 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016877
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016878#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016879 if (NULL == param) {
16880 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016881 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016882 return -EINVAL;
16883 }
16884
16885 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
16886 param->subtype, &delStaParams);
16887
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016888#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053016889 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016890 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016891#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016892 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
16893
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016894 vos_ssr_unprotect(__func__);
16895
16896 return ret;
16897}
16898
16899static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016900 struct net_device *dev,
16901#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16902 const u8 *mac,
16903#else
16904 u8 *mac,
16905#endif
16906 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016907{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016908 hdd_adapter_t *pAdapter;
16909 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016910 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016911#ifdef FEATURE_WLAN_TDLS
16912 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016913
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016914 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016915
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016916 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16917 if (NULL == pAdapter)
16918 {
16919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16920 "%s: Adapter is NULL",__func__);
16921 return -EINVAL;
16922 }
16923 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16924 status = wlan_hdd_validate_context(pHddCtx);
16925 if (0 != status)
16926 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016927 return status;
16928 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016929
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016930 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16931 TRACE_CODE_HDD_CFG80211_ADD_STA,
16932 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016933 mask = params->sta_flags_mask;
16934
16935 set = params->sta_flags_set;
16936
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016937 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016938 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
16939 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016940
16941 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
16942 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080016943 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016944 }
16945 }
16946#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016947 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016948 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016949}
16950
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016951#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16952static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16953 struct net_device *dev, const u8 *mac,
16954 struct station_parameters *params)
16955#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016956static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16957 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016958#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016959{
16960 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016961
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016962 vos_ssr_protect(__func__);
16963 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
16964 vos_ssr_unprotect(__func__);
16965
16966 return ret;
16967}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016968#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070016969
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016970static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070016971 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016972{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016973 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16974 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016975 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016976 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016977 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016978 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070016979
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016980 ENTER();
16981
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016982 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016983 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016984 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016985 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016986 return -EINVAL;
16987 }
16988
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016989 if (!pmksa) {
16990 hddLog(LOGE, FL("pmksa is NULL"));
16991 return -EINVAL;
16992 }
16993
16994 if (!pmksa->bssid || !pmksa->pmkid) {
16995 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
16996 pmksa->bssid, pmksa->pmkid);
16997 return -EINVAL;
16998 }
16999
17000 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
17001 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
17002
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017003 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17004 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017005 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017006 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017007 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017008 }
17009
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017010 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017011 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17012
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017013 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
17014 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017015
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017016 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017017 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017018 &pmk_id, 1, FALSE);
17019
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017020 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17021 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
17022 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017023
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017024 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017025 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017026}
17027
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017028static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
17029 struct cfg80211_pmksa *pmksa)
17030{
17031 int ret;
17032
17033 vos_ssr_protect(__func__);
17034 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
17035 vos_ssr_unprotect(__func__);
17036
17037 return ret;
17038}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017039
Wilson Yang6507c4e2013-10-01 20:11:19 -070017040
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017041static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070017042 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017043{
Wilson Yang6507c4e2013-10-01 20:11:19 -070017044 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17045 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017046 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080017047 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017048
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017049 ENTER();
17050
Wilson Yang6507c4e2013-10-01 20:11:19 -070017051 /* Validate pAdapter */
17052 if (NULL == pAdapter)
17053 {
17054 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
17055 return -EINVAL;
17056 }
17057
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017058 if (!pmksa) {
17059 hddLog(LOGE, FL("pmksa is NULL"));
17060 return -EINVAL;
17061 }
17062
17063 if (!pmksa->bssid) {
17064 hddLog(LOGE, FL("pmksa->bssid is NULL"));
17065 return -EINVAL;
17066 }
17067
Kiet Lam98c46a12014-10-31 15:34:57 -070017068 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
17069 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
17070
Wilson Yang6507c4e2013-10-01 20:11:19 -070017071 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17072 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070017073 if (0 != status)
17074 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070017075 return status;
17076 }
17077
17078 /*Retrieve halHandle*/
17079 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17080
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017081 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17082 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
17083 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017084 /* Delete the PMKID CSR cache */
17085 if (eHAL_STATUS_SUCCESS !=
17086 sme_RoamDelPMKIDfromCache(halHandle,
17087 pAdapter->sessionId, pmksa->bssid, FALSE)) {
17088 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
17089 MAC_ADDR_ARRAY(pmksa->bssid));
17090 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017091 }
17092
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017093 EXIT();
17094 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017095}
17096
Wilson Yang6507c4e2013-10-01 20:11:19 -070017097
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017098static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
17099 struct cfg80211_pmksa *pmksa)
17100{
17101 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017102
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017103 vos_ssr_protect(__func__);
17104 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
17105 vos_ssr_unprotect(__func__);
17106
17107 return ret;
17108
17109}
17110
17111static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017112{
Wilson Yang6507c4e2013-10-01 20:11:19 -070017113 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17114 tHalHandle halHandle;
17115 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080017116 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017117
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017118 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070017119
17120 /* Validate pAdapter */
17121 if (NULL == pAdapter)
17122 {
17123 hddLog(VOS_TRACE_LEVEL_ERROR,
17124 "%s: Invalid Adapter" ,__func__);
17125 return -EINVAL;
17126 }
17127
17128 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17129 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070017130 if (0 != status)
17131 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070017132 return status;
17133 }
17134
17135 /*Retrieve halHandle*/
17136 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17137
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017138 /* Flush the PMKID cache in CSR */
17139 if (eHAL_STATUS_SUCCESS !=
17140 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
17141 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
17142 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017143 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017144 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080017145 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017146}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017147
17148static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
17149{
17150 int ret;
17151
17152 vos_ssr_protect(__func__);
17153 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
17154 vos_ssr_unprotect(__func__);
17155
17156 return ret;
17157}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017158#endif
17159
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017160#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017161static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
17162 struct net_device *dev,
17163 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017164{
17165 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17166 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017167 hdd_context_t *pHddCtx;
17168 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017169
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017170 ENTER();
17171
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017172 if (NULL == pAdapter)
17173 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017174 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017175 return -ENODEV;
17176 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017177 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17178 ret = wlan_hdd_validate_context(pHddCtx);
17179 if (0 != ret)
17180 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017181 return ret;
17182 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017183 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017184 if (NULL == pHddStaCtx)
17185 {
17186 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
17187 return -EINVAL;
17188 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017189
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017190 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17191 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
17192 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017193 // Added for debug on reception of Re-assoc Req.
17194 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
17195 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017196 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017197 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080017198 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017199 }
17200
17201#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080017202 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017203 ftie->ie_len);
17204#endif
17205
17206 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053017207 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
17208 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017209 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017210
17211 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017212 return 0;
17213}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017214
17215static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
17216 struct net_device *dev,
17217 struct cfg80211_update_ft_ies_params *ftie)
17218{
17219 int ret;
17220
17221 vos_ssr_protect(__func__);
17222 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
17223 vos_ssr_unprotect(__func__);
17224
17225 return ret;
17226}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017227#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017228
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017229#ifdef FEATURE_WLAN_SCAN_PNO
17230
17231void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
17232 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
17233{
17234 int ret;
17235 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
17236 hdd_context_t *pHddCtx;
17237
Nirav Shah80830bf2013-12-31 16:35:12 +053017238 ENTER();
17239
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017240 if (NULL == pAdapter)
17241 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053017242 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017243 "%s: HDD adapter is Null", __func__);
17244 return ;
17245 }
17246
17247 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17248 if (NULL == pHddCtx)
17249 {
17250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17251 "%s: HDD context is Null!!!", __func__);
17252 return ;
17253 }
17254
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017255 spin_lock(&pHddCtx->schedScan_lock);
17256 if (TRUE == pHddCtx->isWiphySuspended)
17257 {
17258 pHddCtx->isSchedScanUpdatePending = TRUE;
17259 spin_unlock(&pHddCtx->schedScan_lock);
17260 hddLog(VOS_TRACE_LEVEL_INFO,
17261 "%s: Update cfg80211 scan database after it resume", __func__);
17262 return ;
17263 }
17264 spin_unlock(&pHddCtx->schedScan_lock);
17265
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017266 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
17267
17268 if (0 > ret)
17269 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053017270 else
17271 {
17272 /* Acquire wakelock to handle the case where APP's tries to suspend
17273 * immediatly after the driver gets connect request(i.e after pno)
17274 * from supplicant, this result in app's is suspending and not able
17275 * to process the connect request to AP */
17276 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
17277 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017278 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17280 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017281}
17282
17283/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017284 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017285 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017286 */
17287static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
17288{
17289 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
17290 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017291 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017292 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17293 int status = 0;
Agrawal Ashishcff31692016-12-16 17:17:50 +053017294
17295 if (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
17296 {
17297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17298 "%s: PNO is allowed only in STA interface", __func__);
17299 return eHAL_STATUS_FAILURE;
17300 }
17301
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017302 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
17303
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017304 /* The current firmware design does not allow PNO during any
Agrawal Ashishcff31692016-12-16 17:17:50 +053017305 * active sessions. PNO is allowed only in case when sap session
17306 * is present and sapo auth offload feature enabled in firmare.
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017307 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017308 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
17309 {
17310 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017311 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017312
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017313 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
17314 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
17315 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
17316 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
Agrawal Ashishcff31692016-12-16 17:17:50 +053017317 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode &&
17318 !pHddCtx->cfg_ini->enable_sap_auth_offload)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053017319 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017320 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017321 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017322 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017323 }
17324 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
17325 pAdapterNode = pNext;
17326 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017327 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017328}
17329
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017330void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
17331{
17332 hdd_adapter_t *pAdapter = callbackContext;
17333 hdd_context_t *pHddCtx;
17334
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017335 ENTER();
17336
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017337 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
17338 {
17339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17340 FL("Invalid adapter or adapter has invalid magic"));
17341 return;
17342 }
17343
17344 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17345 if (0 != wlan_hdd_validate_context(pHddCtx))
17346 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017347 return;
17348 }
17349
c_hpothub53c45d2014-08-18 16:53:14 +053017350 if (VOS_STATUS_SUCCESS != status)
17351 {
17352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017353 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053017354 pHddCtx->isPnoEnable = FALSE;
17355 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017356
17357 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
17358 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017359 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017360}
17361
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017362#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) || \
17363 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
17364/**
17365 * hdd_config_sched_scan_plan() - configures the sched scan plans
17366 * from the framework.
17367 * @pno_req: pointer to PNO scan request
17368 * @request: pointer to scan request from framework
17369 *
17370 * Return: None
17371 */
17372static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
17373 struct cfg80211_sched_scan_request *request,
17374 hdd_context_t *hdd_ctx)
17375{
17376 v_U32_t i = 0;
17377
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017378 pno_req->scanTimers.ucScanTimersCount = request->n_scan_plans;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017379 for (i = 0; i < request->n_scan_plans; i++)
17380 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017381 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
17382 request->scan_plans[i].iterations;
17383 pno_req->scanTimers.aTimerValues[i].uTimerValue =
17384 request->scan_plans[i].interval;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017385 }
17386}
17387#else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017388static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017389 struct cfg80211_sched_scan_request *request,
17390 hdd_context_t *hdd_ctx)
17391{
17392 v_U32_t i, temp_int;
17393 /* Driver gets only one time interval which is hardcoded in
17394 * supplicant for 10000ms. Taking power consumption into account 6
17395 * timers will be used, Timervalue is increased exponentially
17396 * i.e 10,20,40, 80,160,320 secs. And number of scan cycle for each
17397 * timer is configurable through INI param gPNOScanTimerRepeatValue.
17398 * If it is set to 0 only one timer will be used and PNO scan cycle
17399 * will be repeated after each interval specified by supplicant
17400 * till PNO is disabled.
17401 */
17402 if (0 == hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue)
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017403 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017404 HDD_PNO_SCAN_TIMERS_SET_ONE;
17405 else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017406 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017407 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
17408
17409 temp_int = (request->interval)/1000;
17410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17411 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
17412 temp_int, hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue);
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017413 for ( i = 0; i < pno_req->scanTimers.ucScanTimersCount; i++)
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017414 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017415 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017416 hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue;
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017417 pno_req->scanTimers.aTimerValues[i].uTimerValue = temp_int;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017418 temp_int *= 2;
17419 }
17420 //Repeat last timer until pno disabled.
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017421 pno_req->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017422}
17423#endif
17424
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017425/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017426 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
17427 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017428 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017429static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017430 struct net_device *dev, struct cfg80211_sched_scan_request *request)
17431{
17432 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017433 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017434 hdd_context_t *pHddCtx;
17435 tHalHandle hHal;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017436 v_U32_t i, indx, num_ch, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053017437 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
17438 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017439 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
17440 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017441 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017442 hdd_config_t *pConfig = NULL;
17443 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017444
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017445 ENTER();
17446
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017447 if (NULL == pAdapter)
17448 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017450 "%s: HDD adapter is Null", __func__);
17451 return -ENODEV;
17452 }
17453
17454 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017455 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017456
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017457 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017458 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017459 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017460 }
17461
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017462 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017463 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17464 if (NULL == hHal)
17465 {
17466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17467 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017468 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017469 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017470 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17471 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
17472 pAdapter->sessionId, pAdapter->device_mode));
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053017473 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053017474 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053017475 {
17476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17477 "%s: aborting the existing scan is unsuccessfull", __func__);
17478 return -EBUSY;
17479 }
17480
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017481 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017482 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017484 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017485 return -EBUSY;
17486 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017487
c_hpothu37f21312014-04-09 21:49:54 +053017488 if (TRUE == pHddCtx->isPnoEnable)
17489 {
17490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
17491 FL("already PNO is enabled"));
17492 return -EBUSY;
17493 }
c_hpothu225aa7c2014-10-22 17:45:13 +053017494
17495 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
17496 {
17497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17498 "%s: abort ROC failed ", __func__);
17499 return -EBUSY;
17500 }
17501
c_hpothu37f21312014-04-09 21:49:54 +053017502 pHddCtx->isPnoEnable = TRUE;
17503
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017504 pnoRequest.enable = 1; /*Enable PNO */
17505 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017506
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017507 if (( !pnoRequest.ucNetworksCount ) ||
17508 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017509 {
17510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017511 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017512 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017513 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017514 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017515 goto error;
17516 }
17517
17518 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
17519 {
17520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017521 "%s: Incorrect number of channels %d",
17522 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017523 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017524 goto error;
17525 }
17526
17527 /* Framework provides one set of channels(all)
17528 * common for all saved profile */
17529 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
17530 channels_allowed, &num_channels_allowed))
17531 {
17532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17533 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017534 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017535 goto error;
17536 }
17537 /* Checking each channel against allowed channel list */
17538 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053017539 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017540 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017541 char chList [(request->n_channels*5)+1];
17542 int len;
17543 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017544 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017545 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017546 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017547 if (request->channels[i]->hw_value == channels_allowed[indx])
17548 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017549 if ((!pConfig->enableDFSPnoChnlScan) &&
17550 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
17551 {
17552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17553 "%s : Dropping DFS channel : %d",
17554 __func__,channels_allowed[indx]);
17555 num_ignore_dfs_ch++;
17556 break;
17557 }
17558
Nirav Shah80830bf2013-12-31 16:35:12 +053017559 valid_ch[num_ch++] = request->channels[i]->hw_value;
17560 len += snprintf(chList+len, 5, "%d ",
17561 request->channels[i]->hw_value);
17562 break ;
17563 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017564 }
17565 }
Nirav Shah80830bf2013-12-31 16:35:12 +053017566 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017567
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017568 /*If all channels are DFS and dropped, then ignore the PNO request*/
17569 if (num_ignore_dfs_ch == request->n_channels)
17570 {
17571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17572 "%s : All requested channels are DFS channels", __func__);
17573 ret = -EINVAL;
17574 goto error;
17575 }
17576 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017577
17578 pnoRequest.aNetworks =
17579 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17580 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017581 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017582 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17583 FL("failed to allocate memory aNetworks %u"),
17584 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17585 goto error;
17586 }
17587 vos_mem_zero(pnoRequest.aNetworks,
17588 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17589
17590 /* Filling per profile params */
17591 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
17592 {
17593 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017594 request->match_sets[i].ssid.ssid_len;
17595
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017596 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
17597 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017598 {
17599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017600 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017601 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017602 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017603 goto error;
17604 }
17605
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017606 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017607 request->match_sets[i].ssid.ssid,
17608 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17610 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017611 i, pnoRequest.aNetworks[i].ssId.ssId);
17612 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
17613 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
17614 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017615
17616 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017617 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
17618 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017619
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017620 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017621 }
17622
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017623 for (i = 0; i < request->n_ssids; i++)
17624 {
17625 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017626 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017627 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017628 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017629 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017630 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017631 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017632 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017633 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017634 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017635 break;
17636 }
17637 j++;
17638 }
17639 }
17640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17641 "Number of hidden networks being Configured = %d",
17642 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080017644 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017645
17646 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
17647 if (pnoRequest.p24GProbeTemplate == NULL)
17648 {
17649 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17650 FL("failed to allocate memory p24GProbeTemplate %u"),
17651 SIR_PNO_MAX_PB_REQ_SIZE);
17652 goto error;
17653 }
17654
17655 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
17656 if (pnoRequest.p5GProbeTemplate == NULL)
17657 {
17658 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17659 FL("failed to allocate memory p5GProbeTemplate %u"),
17660 SIR_PNO_MAX_PB_REQ_SIZE);
17661 goto error;
17662 }
17663
17664 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
17665 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
17666
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053017667 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
17668 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017669 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017670 pnoRequest.us24GProbeTemplateLen = request->ie_len;
17671 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
17672 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017673
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017674 pnoRequest.us5GProbeTemplateLen = request->ie_len;
17675 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
17676 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017677 }
17678
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017679 hdd_config_sched_scan_plan(&pnoRequest, request, pHddCtx);
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017680
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017681 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017682
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017683 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017684 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17685 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017686 pAdapter->pno_req_status = 0;
17687
Nirav Shah80830bf2013-12-31 16:35:12 +053017688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17689 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017690 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
17691 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053017692
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017693 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017694 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017695 hdd_cfg80211_sched_scan_done_callback, pAdapter);
17696 if (eHAL_STATUS_SUCCESS != status)
17697 {
17698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017699 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017700 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017701 goto error;
17702 }
17703
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017704 ret = wait_for_completion_timeout(
17705 &pAdapter->pno_comp_var,
17706 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17707 if (0 >= ret)
17708 {
17709 // Did not receive the response for PNO enable in time.
17710 // Assuming the PNO enable was success.
17711 // Returning error from here, because we timeout, results
17712 // in side effect of Wifi (Wifi Setting) not to work.
17713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17714 FL("Timed out waiting for PNO to be Enabled"));
17715 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017716 }
17717
17718 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053017719 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017720
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017721error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17723 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053017724 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017725 if (pnoRequest.aNetworks)
17726 vos_mem_free(pnoRequest.aNetworks);
17727 if (pnoRequest.p24GProbeTemplate)
17728 vos_mem_free(pnoRequest.p24GProbeTemplate);
17729 if (pnoRequest.p5GProbeTemplate)
17730 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017731
17732 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017733 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017734}
17735
17736/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017737 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
17738 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017739 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017740static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
17741 struct net_device *dev, struct cfg80211_sched_scan_request *request)
17742{
17743 int ret;
17744
17745 vos_ssr_protect(__func__);
17746 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
17747 vos_ssr_unprotect(__func__);
17748
17749 return ret;
17750}
17751
17752/*
17753 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
17754 * Function to disable PNO
17755 */
17756static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017757 struct net_device *dev)
17758{
17759 eHalStatus status = eHAL_STATUS_FAILURE;
17760 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17761 hdd_context_t *pHddCtx;
17762 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017763 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017764 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017765
17766 ENTER();
17767
17768 if (NULL == pAdapter)
17769 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017771 "%s: HDD adapter is Null", __func__);
17772 return -ENODEV;
17773 }
17774
17775 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017776
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017777 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017778 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017780 "%s: HDD context is Null", __func__);
17781 return -ENODEV;
17782 }
17783
17784 /* The return 0 is intentional when isLogpInProgress and
17785 * isLoadUnloadInProgress. We did observe a crash due to a return of
17786 * failure in sched_scan_stop , especially for a case where the unload
17787 * of the happens at the same time. The function __cfg80211_stop_sched_scan
17788 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
17789 * success. If it returns a failure , then its next invocation due to the
17790 * clean up of the second interface will have the dev pointer corresponding
17791 * to the first one leading to a crash.
17792 */
17793 if (pHddCtx->isLogpInProgress)
17794 {
17795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17796 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053017797 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017798 return ret;
17799 }
17800
Mihir Shete18156292014-03-11 15:38:30 +053017801 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017802 {
17803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17804 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17805 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017806 }
17807
17808 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17809 if (NULL == hHal)
17810 {
17811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17812 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017813 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017814 }
17815
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017816 pnoRequest.enable = 0; /* Disable PNO */
17817 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017818
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017819 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17820 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
17821 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017822
17823 INIT_COMPLETION(pAdapter->pno_comp_var);
17824 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17825 pnoRequest.callbackContext = pAdapter;
17826 pAdapter->pno_req_status = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017827 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017828 pAdapter->sessionId,
17829 NULL, pAdapter);
17830 if (eHAL_STATUS_SUCCESS != status)
17831 {
17832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17833 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017834 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017835 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017836 }
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017837 ret = wait_for_completion_timeout(
17838 &pAdapter->pno_comp_var,
17839 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17840 if (0 >= ret)
17841 {
17842 // Did not receive the response for PNO disable in time.
17843 // Assuming the PNO disable was success.
17844 // Returning error from here, because we timeout, results
17845 // in side effect of Wifi (Wifi Setting) not to work.
Anurag Chouhan96b41cb2016-09-28 18:54:47 +053017846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017847 FL("Timed out waiting for PNO to be disabled"));
17848 ret = 0;
17849 }
17850
17851 ret = pAdapter->pno_req_status;
17852 pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017853
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017854error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017856 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017857
17858 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017859 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017860}
17861
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017862/*
17863 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
17864 * NL interface to disable PNO
17865 */
17866static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
17867 struct net_device *dev)
17868{
17869 int ret;
17870
17871 vos_ssr_protect(__func__);
17872 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
17873 vos_ssr_unprotect(__func__);
17874
17875 return ret;
17876}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017877#endif /*FEATURE_WLAN_SCAN_PNO*/
17878
17879
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017880#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017881#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017882static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17883 struct net_device *dev,
17884 u8 *peer, u8 action_code,
17885 u8 dialog_token,
17886 u16 status_code, u32 peer_capability,
17887 const u8 *buf, size_t len)
17888#else /* TDLS_MGMT_VERSION2 */
17889#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17890static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17891 struct net_device *dev,
17892 const u8 *peer, u8 action_code,
17893 u8 dialog_token, u16 status_code,
17894 u32 peer_capability, bool initiator,
17895 const u8 *buf, size_t len)
17896#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17897static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17898 struct net_device *dev,
17899 const u8 *peer, u8 action_code,
17900 u8 dialog_token, u16 status_code,
17901 u32 peer_capability, const u8 *buf,
17902 size_t len)
17903#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17904static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17905 struct net_device *dev,
17906 u8 *peer, u8 action_code,
17907 u8 dialog_token,
17908 u16 status_code, u32 peer_capability,
17909 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017910#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017911static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17912 struct net_device *dev,
17913 u8 *peer, u8 action_code,
17914 u8 dialog_token,
17915 u16 status_code, const u8 *buf,
17916 size_t len)
17917#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017918#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017919{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017920 hdd_adapter_t *pAdapter;
17921 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017922 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070017923 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080017924 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070017925 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017926 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053017927 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017928#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017929 u32 peer_capability = 0;
17930#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017931 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017932 hdd_station_ctx_t *pHddStaCtx = NULL;
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053017933 tdlsCtx_t *pHddTdlsCtx;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017934
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017935 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17936 if (NULL == pAdapter)
17937 {
17938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17939 "%s: Adapter is NULL",__func__);
17940 return -EINVAL;
17941 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017942 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17943 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
17944 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017945
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017946 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017947 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017948 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017949 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017950 "Invalid arguments");
17951 return -EINVAL;
17952 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017953
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017954 if (pHddCtx->isLogpInProgress)
17955 {
17956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17957 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053017958 wlan_hdd_tdls_set_link_status(pAdapter,
17959 peer,
17960 eTDLS_LINK_IDLE,
17961 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017962 return -EBUSY;
17963 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017964
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017965 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
17966 {
17967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17968 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17969 return -EAGAIN;
17970 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017971
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053017972 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
17973 if (!pHddTdlsCtx) {
17974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17975 "%s: pHddTdlsCtx not valid.", __func__);
17976 }
17977
Hoonki Lee27511902013-03-14 18:19:06 -070017978 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017979 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017980 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070017981 "%s: TDLS mode is disabled OR not enabled in FW."
17982 MAC_ADDRESS_STR " action %d declined.",
17983 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017984 return -ENOTSUPP;
17985 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017986
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017987 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17988
17989 if( NULL == pHddStaCtx )
17990 {
17991 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17992 "%s: HDD station context NULL ",__func__);
17993 return -EINVAL;
17994 }
17995
17996 /* STA should be connected and authenticated
17997 * before sending any TDLS frames
17998 */
17999 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
18000 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
18001 {
18002 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18003 "STA is not connected or unauthenticated. "
18004 "connState %u, uIsAuthenticated %u",
18005 pHddStaCtx->conn_info.connState,
18006 pHddStaCtx->conn_info.uIsAuthenticated);
18007 return -EAGAIN;
18008 }
18009
Hoonki Lee27511902013-03-14 18:19:06 -070018010 /* other than teardown frame, other mgmt frames are not sent if disabled */
18011 if (SIR_MAC_TDLS_TEARDOWN != action_code)
18012 {
18013 /* if tdls_mode is disabled to respond to peer's request */
18014 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
18015 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018016 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070018017 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070018018 " TDLS mode is disabled. action %d declined.",
18019 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070018020
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018021 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070018022 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053018023
18024 if (vos_max_concurrent_connections_reached())
18025 {
18026 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
18027 return -EINVAL;
18028 }
Hoonki Lee27511902013-03-14 18:19:06 -070018029 }
18030
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018031 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
18032 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053018033 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018034 {
18035 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018036 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070018037 " TDLS setup is ongoing. action %d declined.",
18038 __func__, MAC_ADDR_ARRAY(peer), action_code);
18039 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018040 }
18041 }
18042
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018043 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
18044 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080018045 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018046 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18047 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080018048 {
18049 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
18050 we return error code at 'add_station()'. Hence we have this
18051 check again in addtion to add_station().
18052 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018053 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080018054 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018055 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18056 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018057 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
18058 __func__, MAC_ADDR_ARRAY(peer), action_code,
18059 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053018060 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080018061 }
18062 else
18063 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018064 /* maximum reached. tweak to send error code to peer and return
18065 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080018066 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018067 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18068 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018069 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
18070 __func__, MAC_ADDR_ARRAY(peer), status_code,
18071 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070018072 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018073 /* fall through to send setup resp with failure status
18074 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080018075 }
18076 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018077 else
18078 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018079 mutex_lock(&pHddCtx->tdls_lock);
18080 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018081 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018082 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018083 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018084 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070018085 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
18086 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018087 return -EPERM;
18088 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018089 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018090 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018091 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018092
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018093 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053018094 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018095 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
18096 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018097
Hoonki Leea34dd892013-02-05 22:56:02 -080018098 /*Except teardown responder will not be used so just make 0*/
18099 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018100 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080018101 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018102
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018103 mutex_lock(&pHddCtx->tdls_lock);
18104 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018105
18106 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
18107 responder = pTdlsPeer->is_responder;
18108 else
Hoonki Leea34dd892013-02-05 22:56:02 -080018109 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018110 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053018111 "%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 -070018112 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
18113 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018114 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018115 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080018116 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018117 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018118 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018119
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053018120 /* Discard TDLS setup if peer is removed by user app */
18121 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
18122 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
18123 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
18124 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
18125
18126 mutex_lock(&pHddCtx->tdls_lock);
18127 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18128 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
18129 mutex_unlock(&pHddCtx->tdls_lock);
18130 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
18131 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
18132 MAC_ADDR_ARRAY(peer), action_code);
18133 return -EINVAL;
18134 }
18135 mutex_unlock(&pHddCtx->tdls_lock);
18136 }
18137
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053018138 /* For explicit trigger of DIS_REQ come out of BMPS for
18139 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070018140 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Deepthi Gowrif78f1f72016-03-21 13:13:28 +053018141 (SIR_MAC_TDLS_SETUP_CNF== action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053018142 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
18143 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070018144 {
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018145 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018146 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018147 "%s: Sending frame action_code %u.Disable BMPS", __func__,
18148 action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018149 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
18150 if (status != VOS_STATUS_SUCCESS) {
18151 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018152 } else {
18153 pHddTdlsCtx->is_tdls_disabled_bmps = true;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018154 }
Hoonki Lee14621352013-04-16 17:51:19 -070018155 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018156 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018157 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018158 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
18159 }
18160 }
Hoonki Lee14621352013-04-16 17:51:19 -070018161 }
18162
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018163 /* make sure doesn't call send_mgmt() while it is pending */
18164 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
18165 {
18166 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080018167 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018168 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018169 ret = -EBUSY;
18170 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018171 }
18172
18173 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018174 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
18175
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018176 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
18177 pAdapter->sessionId, peer, action_code, dialog_token,
18178 status_code, peer_capability, (tANI_U8 *)buf, len,
18179 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018180
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018181 if (VOS_STATUS_SUCCESS != status)
18182 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18184 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018185 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018186 ret = -EINVAL;
18187 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018188 }
18189
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18191 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
18192 WAIT_TIME_TDLS_MGMT);
18193
Hoonki Leed37cbb32013-04-20 00:31:14 -070018194 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
18195 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
18196
18197 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018198 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070018199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070018200 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070018201 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018202 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080018203
18204 if (pHddCtx->isLogpInProgress)
18205 {
18206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18207 "%s: LOGP in Progress. Ignore!!!", __func__);
18208 return -EAGAIN;
18209 }
Abhishek Singh837adf22015-10-01 17:37:37 +053018210 if (rc <= 0)
18211 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
18212 WLAN_LOG_INDICATOR_HOST_DRIVER,
18213 WLAN_LOG_REASON_HDD_TIME_OUT,
18214 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080018215
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018216 ret = -EINVAL;
18217 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018218 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018219 else
18220 {
18221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18222 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
18223 __func__, rc, pAdapter->mgmtTxCompletionStatus);
18224 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018225
Gopichand Nakkala05922802013-03-14 12:23:19 -070018226 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070018227 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018228 ret = max_sta_failed;
18229 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070018230 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018231
Hoonki Leea34dd892013-02-05 22:56:02 -080018232 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
18233 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018234 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018235 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
18236 }
Hoonki Leea34dd892013-02-05 22:56:02 -080018237 }
18238 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
18239 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018240 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018241 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
18242 }
Hoonki Leea34dd892013-02-05 22:56:02 -080018243 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018244
18245 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018246
18247tx_failed:
18248 /* add_station will be called before sending TDLS_SETUP_REQ and
18249 * TDLS_SETUP_RSP and as part of add_station driver will enable
18250 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
18251 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
18252 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
18253 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
18254 */
18255
18256 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
18257 (SIR_MAC_TDLS_SETUP_RSP == action_code))
18258 wlan_hdd_tdls_check_bmps(pAdapter);
18259 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018260}
18261
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018262#if TDLS_MGMT_VERSION2
18263static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
18264 u8 *peer, u8 action_code, u8 dialog_token,
18265 u16 status_code, u32 peer_capability,
18266 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018267#else /* TDLS_MGMT_VERSION2 */
18268#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
18269static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18270 struct net_device *dev,
18271 const u8 *peer, u8 action_code,
18272 u8 dialog_token, u16 status_code,
18273 u32 peer_capability, bool initiator,
18274 const u8 *buf, size_t len)
18275#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
18276static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18277 struct net_device *dev,
18278 const u8 *peer, u8 action_code,
18279 u8 dialog_token, u16 status_code,
18280 u32 peer_capability, const u8 *buf,
18281 size_t len)
18282#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
18283static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18284 struct net_device *dev,
18285 u8 *peer, u8 action_code,
18286 u8 dialog_token,
18287 u16 status_code, u32 peer_capability,
18288 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018289#else
18290static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
18291 u8 *peer, u8 action_code, u8 dialog_token,
18292 u16 status_code, const u8 *buf, size_t len)
18293#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018294#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018295{
18296 int ret;
18297
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018298 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018299#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018300 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18301 dialog_token, status_code,
18302 peer_capability, buf, len);
18303#else /* TDLS_MGMT_VERSION2 */
18304#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
18305 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18306 dialog_token, status_code,
18307 peer_capability, initiator,
18308 buf, len);
18309#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
18310 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18311 dialog_token, status_code,
18312 peer_capability, buf, len);
18313#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
18314 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18315 dialog_token, status_code,
18316 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018317#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018318 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18319 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018320#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018321#endif
18322 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018323
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018324 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018325}
Atul Mittal115287b2014-07-08 13:26:33 +053018326
18327int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018328#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18329 const u8 *peer,
18330#else
Atul Mittal115287b2014-07-08 13:26:33 +053018331 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018332#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018333 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053018334 cfg80211_exttdls_callback callback)
18335{
18336
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018337 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053018338 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018339 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053018340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18341 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
18342 __func__, MAC_ADDR_ARRAY(peer));
18343
18344 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
18345 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
18346
18347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018348 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
18349 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
18350 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053018351 return -ENOTSUPP;
18352 }
18353
18354 /* To cater the requirement of establishing the TDLS link
18355 * irrespective of the data traffic , get an entry of TDLS peer.
18356 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053018357 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018358 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
18359 if (pTdlsPeer == NULL) {
18360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18361 "%s: peer " MAC_ADDRESS_STR " not existing",
18362 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053018363 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018364 return -EINVAL;
18365 }
18366
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053018367 /* check FW TDLS Off Channel capability */
18368 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053018369 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053018370 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018371 {
18372 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
18373 pTdlsPeer->peerParams.global_operating_class =
18374 tdls_peer_params->global_operating_class;
18375 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
18376 pTdlsPeer->peerParams.min_bandwidth_kbps =
18377 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018378 /* check configured channel is valid, non dfs and
18379 * not current operating channel */
18380 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
18381 tdls_peer_params->channel)) &&
18382 (pHddStaCtx) &&
18383 (tdls_peer_params->channel !=
18384 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018385 {
18386 pTdlsPeer->isOffChannelConfigured = TRUE;
18387 }
18388 else
18389 {
18390 pTdlsPeer->isOffChannelConfigured = FALSE;
18391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18392 "%s: Configured Tdls Off Channel is not valid", __func__);
18393
18394 }
18395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018396 "%s: tdls_off_channel %d isOffChannelConfigured %d "
18397 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018398 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018399 pTdlsPeer->isOffChannelConfigured,
18400 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018401 }
18402 else
18403 {
18404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053018405 "%s: TDLS off channel FW capability %d, "
18406 "host capab %d or Invalid TDLS Peer Params", __func__,
18407 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
18408 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018409 }
18410
Atul Mittal115287b2014-07-08 13:26:33 +053018411 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
18412
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018413 mutex_unlock(&pHddCtx->tdls_lock);
18414
Atul Mittal115287b2014-07-08 13:26:33 +053018415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18416 " %s TDLS Add Force Peer Failed",
18417 __func__);
18418 return -EINVAL;
18419 }
18420 /*EXT TDLS*/
18421
18422 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018423 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18425 " %s TDLS set callback Failed",
18426 __func__);
18427 return -EINVAL;
18428 }
18429
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018430 mutex_unlock(&pHddCtx->tdls_lock);
18431
Atul Mittal115287b2014-07-08 13:26:33 +053018432 return(0);
18433
18434}
18435
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018436int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
18437#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18438 const u8 *peer
18439#else
18440 u8 *peer
18441#endif
18442)
Atul Mittal115287b2014-07-08 13:26:33 +053018443{
18444
18445 hddTdlsPeer_t *pTdlsPeer;
18446 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053018447
Atul Mittal115287b2014-07-08 13:26:33 +053018448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18449 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
18450 __func__, MAC_ADDR_ARRAY(peer));
18451
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053018452 if (0 != wlan_hdd_validate_context(pHddCtx)) {
18453 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
18454 return -EINVAL;
18455 }
18456
Atul Mittal115287b2014-07-08 13:26:33 +053018457 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
18458 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
18459
18460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018461 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
18462 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
18463 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053018464 return -ENOTSUPP;
18465 }
18466
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018467 mutex_lock(&pHddCtx->tdls_lock);
18468 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053018469
18470 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018471 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018472 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018473 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053018474 __func__, MAC_ADDR_ARRAY(peer));
18475 return -EINVAL;
18476 }
18477 else {
18478 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
18479 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053018480 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL,
18481 pTdlsPeer->peerMac);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018482 /* if channel switch is configured, reset
18483 the channel for this peer */
18484 if (TRUE == pTdlsPeer->isOffChannelConfigured)
18485 {
18486 pTdlsPeer->peerParams.channel = 0;
18487 pTdlsPeer->isOffChannelConfigured = FALSE;
18488 }
Atul Mittal115287b2014-07-08 13:26:33 +053018489 }
18490
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018491 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018492 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018493 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053018494 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018495 }
Atul Mittal115287b2014-07-08 13:26:33 +053018496
18497 /*EXT TDLS*/
18498
18499 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018500 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18502 " %s TDLS set callback Failed",
18503 __func__);
18504 return -EINVAL;
18505 }
Atul Mittal115287b2014-07-08 13:26:33 +053018506
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018507 mutex_unlock(&pHddCtx->tdls_lock);
18508
18509 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053018510}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018511static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018512#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18513 const u8 *peer,
18514#else
18515 u8 *peer,
18516#endif
18517 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018518{
18519 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18520 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018521 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018522 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018523
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018524 ENTER();
18525
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053018526 if (!pAdapter) {
18527 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
18528 return -EINVAL;
18529 }
18530
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018531 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18532 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
18533 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018534 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018535 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018536 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070018537 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018538 return -EINVAL;
18539 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018540
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018541 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018542 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018543 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018544 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018545 }
18546
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018547
18548 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018549 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018550 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018551 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018552 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
18553 "Cannot process TDLS commands",
18554 pHddCtx->cfg_ini->fEnableTDLSSupport,
18555 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018556 return -ENOTSUPP;
18557 }
18558
18559 switch (oper) {
18560 case NL80211_TDLS_ENABLE_LINK:
18561 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018562 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018563 long ret;
Hanumantha Reddy Pothulada389492016-02-11 17:29:27 +053018564 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams = { {0}, 0,
18565 0, 0, 0, 0, 0, 0, {0}, 0, {0} };
Agarwal Ashish16020c42014-12-29 22:01:11 +053018566 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018567 tANI_U16 numCurrTdlsPeers = 0;
18568 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018569 tANI_U8 suppChannelLen = 0;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018570 tSirMacAddr peerMac;
18571 int channel;
18572 tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018573
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18575 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
18576 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018577
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018578 mutex_lock(&pHddCtx->tdls_lock);
18579 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018580 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053018581 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018582 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018583 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18584 " (oper %d) not exsting. ignored",
18585 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18586 return -EINVAL;
18587 }
18588
18589 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18590 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18591 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18592 "NL80211_TDLS_ENABLE_LINK");
18593
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070018594 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
18595 {
18596 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
18597 MAC_ADDRESS_STR " failed",
18598 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018599 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070018600 return -EINVAL;
18601 }
18602
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018603 /* before starting tdls connection, set tdls
18604 * off channel established status to default value */
18605 pTdlsPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018606
18607 mutex_unlock(&pHddCtx->tdls_lock);
18608
Deepthi Gowri2d85bbf2016-07-25 15:43:31 +053018609 wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018610 /* TDLS Off Channel, Disable tdls channel switch,
18611 when there are more than one tdls link */
18612 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053018613 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018614 {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018615 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018616 /* get connected peer and send disable tdls off chan */
18617 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018618 if ((connPeer) &&
18619 (connPeer->isOffChannelSupported == TRUE) &&
18620 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018621 {
18622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18623 "%s: More then one peer connected, Disable "
18624 "TDLS channel switch", __func__);
18625
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018626 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018627 vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr));
18628 channel = connPeer->peerParams.channel;
18629
18630 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018631
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018632 ret = sme_SendTdlsChanSwitchReq(
18633 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018634 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018635 peerMac,
18636 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018637 TDLS_OFF_CHANNEL_BW_OFFSET,
18638 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018639 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018640 hddLog(VOS_TRACE_LEVEL_ERROR,
18641 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018642 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018643 }
18644 else
18645 {
18646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18647 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018648 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018649 "isOffChannelConfigured %d",
18650 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018651 (connPeer ? (connPeer->isOffChannelSupported)
18652 : -1),
18653 (connPeer ? (connPeer->isOffChannelConfigured)
18654 : -1));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018655 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018656 }
18657 }
18658
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018659 mutex_lock(&pHddCtx->tdls_lock);
18660 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18661 if ( NULL == pTdlsPeer ) {
18662 mutex_unlock(&pHddCtx->tdls_lock);
18663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18664 "%s: " MAC_ADDRESS_STR
18665 " (oper %d) peer got freed in other context. ignored",
18666 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18667 return -EINVAL;
18668 }
18669 peer_status = pTdlsPeer->link_status;
18670 mutex_unlock(&pHddCtx->tdls_lock);
18671
18672 if (eTDLS_LINK_CONNECTED != peer_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018673 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018674 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053018675
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018676 if (0 != wlan_hdd_tdls_get_link_establish_params(
18677 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018678 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018679 return -EINVAL;
18680 }
18681 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018682
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018683 ret = sme_SendTdlsLinkEstablishParams(
18684 WLAN_HDD_GET_HAL_CTX(pAdapter),
18685 pAdapter->sessionId, peer,
18686 &tdlsLinkEstablishParams);
18687 if (ret != VOS_STATUS_SUCCESS) {
18688 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
18689 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018690 /* Send TDLS peer UAPSD capabilities to the firmware and
18691 * register with the TL on after the response for this operation
18692 * is received .
18693 */
18694 ret = wait_for_completion_interruptible_timeout(
18695 &pAdapter->tdls_link_establish_req_comp,
18696 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Masti, Narayanraddie1892a52015-12-15 15:01:01 +053018697
18698 mutex_lock(&pHddCtx->tdls_lock);
18699 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18700 if ( NULL == pTdlsPeer ) {
18701 mutex_unlock(&pHddCtx->tdls_lock);
18702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18703 "%s %d: " MAC_ADDRESS_STR
18704 " (oper %d) peer got freed in other context. ignored",
18705 __func__, __LINE__, MAC_ADDR_ARRAY(peer),
18706 (int)oper);
18707 return -EINVAL;
18708 }
18709 peer_status = pTdlsPeer->link_status;
18710 mutex_unlock(&pHddCtx->tdls_lock);
18711
18712 if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING))
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018713 {
18714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018715 FL("Link Establish Request Failed Status %ld"),
18716 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018717 return -EINVAL;
18718 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018719 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018720
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018721 mutex_lock(&pHddCtx->tdls_lock);
18722 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18723 if ( NULL == pTdlsPeer ) {
18724 mutex_unlock(&pHddCtx->tdls_lock);
18725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18726 "%s: " MAC_ADDRESS_STR
18727 " (oper %d) peer got freed in other context. ignored",
18728 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18729 return -EINVAL;
18730 }
18731
Atul Mittal115287b2014-07-08 13:26:33 +053018732 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18733 eTDLS_LINK_CONNECTED,
18734 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018735 staDesc.ucSTAId = pTdlsPeer->staId;
18736 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053018737
18738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18739 "%s: tdlsLinkEstablishParams of peer "
18740 MAC_ADDRESS_STR "uapsdQueues: %d"
18741 "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d"
18742 "isResponder: %d peerstaId: %d",
18743 __func__,
18744 MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac),
18745 tdlsLinkEstablishParams.uapsdQueues,
18746 tdlsLinkEstablishParams.qos,
18747 tdlsLinkEstablishParams.maxSp,
18748 tdlsLinkEstablishParams.isBufSta,
18749 tdlsLinkEstablishParams.isOffChannelSupported,
18750 tdlsLinkEstablishParams.isResponder,
18751 pTdlsPeer->staId);
18752
18753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18754 "%s: StaDesc ucSTAId: %d ucQosEnabled: %d",
18755 __func__,
18756 staDesc.ucSTAId,
18757 staDesc.ucQosEnabled);
18758
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018759 ret = WLANTL_UpdateTdlsSTAClient(
18760 pHddCtx->pvosContext,
18761 &staDesc);
18762 if (ret != VOS_STATUS_SUCCESS) {
18763 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
18764 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053018765
Gopichand Nakkala471708b2013-06-04 20:03:01 +053018766 /* Mark TDLS client Authenticated .*/
18767 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
18768 pTdlsPeer->staId,
18769 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018770 if (VOS_STATUS_SUCCESS == status)
18771 {
Hoonki Lee14621352013-04-16 17:51:19 -070018772 if (pTdlsPeer->is_responder == 0)
18773 {
18774 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018775 tdlsConnInfo_t *tdlsInfo;
18776
18777 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
18778
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053018779 if (!vos_timer_is_initialized(
18780 &pTdlsPeer->initiatorWaitTimeoutTimer))
18781 {
18782 /* Initialize initiator wait callback */
18783 vos_timer_init(
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018784 &pTdlsPeer->initiatorWaitTimeoutTimer,
18785 VOS_TIMER_TYPE_SW,
18786 wlan_hdd_tdls_initiator_wait_cb,
18787 tdlsInfo);
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053018788 }
Hoonki Lee14621352013-04-16 17:51:19 -070018789 wlan_hdd_tdls_timer_restart(pAdapter,
18790 &pTdlsPeer->initiatorWaitTimeoutTimer,
18791 WAIT_TIME_TDLS_INITIATOR);
18792 /* suspend initiator TX until it receives direct packet from the
18793 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018794 ret = WLANTL_SuspendDataTx(
18795 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18796 &staId, NULL);
18797 if (ret != VOS_STATUS_SUCCESS) {
18798 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
18799 }
Hoonki Lee14621352013-04-16 17:51:19 -070018800 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018801
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018802 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018803 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018804 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018805 suppChannelLen =
18806 tdlsLinkEstablishParams.supportedChannelsLen;
18807
18808 if ((suppChannelLen > 0) &&
18809 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
18810 {
18811 tANI_U8 suppPeerChannel = 0;
18812 int i = 0;
18813 for (i = 0U; i < suppChannelLen; i++)
18814 {
18815 suppPeerChannel =
18816 tdlsLinkEstablishParams.supportedChannels[i];
18817
18818 pTdlsPeer->isOffChannelSupported = FALSE;
18819 if (suppPeerChannel ==
18820 pTdlsPeer->peerParams.channel)
18821 {
18822 pTdlsPeer->isOffChannelSupported = TRUE;
18823 break;
18824 }
18825 }
18826 }
18827 else
18828 {
18829 pTdlsPeer->isOffChannelSupported = FALSE;
18830 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018831 }
18832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18833 "%s: TDLS channel switch request for channel "
18834 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018835 "%d isOffChannelSupported %d", __func__,
18836 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018837 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018838 suppChannelLen,
18839 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018840
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018841 /* TDLS Off Channel, Enable tdls channel switch,
18842 when their is only one tdls link and it supports */
18843 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18844 if ((numCurrTdlsPeers == 1) &&
18845 (TRUE == pTdlsPeer->isOffChannelSupported) &&
18846 (TRUE == pTdlsPeer->isOffChannelConfigured))
18847 {
18848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18849 "%s: Send TDLS channel switch request for channel %d",
18850 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018851
18852 pTdlsPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018853 vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr));
18854 channel = pTdlsPeer->peerParams.channel;
18855
18856 mutex_unlock(&pHddCtx->tdls_lock);
18857
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018858 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
18859 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018860 peerMac,
18861 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018862 TDLS_OFF_CHANNEL_BW_OFFSET,
18863 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018864 if (ret != VOS_STATUS_SUCCESS) {
18865 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
18866 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018867 }
18868 else
18869 {
18870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18871 "%s: TDLS channel switch request not sent"
18872 " numCurrTdlsPeers %d "
18873 "isOffChannelSupported %d "
18874 "isOffChannelConfigured %d",
18875 __func__, numCurrTdlsPeers,
18876 pTdlsPeer->isOffChannelSupported,
18877 pTdlsPeer->isOffChannelConfigured);
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018878 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018879 }
18880
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018881 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018882 else
18883 mutex_unlock(&pHddCtx->tdls_lock);
18884
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018885 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018886
18887 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018888 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
18889 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018890 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018891 int ac;
18892 uint8 ucAc[4] = { WLANTL_AC_VO,
18893 WLANTL_AC_VI,
18894 WLANTL_AC_BK,
18895 WLANTL_AC_BE };
18896 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
18897 for(ac=0; ac < 4; ac++)
18898 {
18899 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18900 pTdlsPeer->staId, ucAc[ac],
18901 tlTid[ac], tlTid[ac], 0, 0,
18902 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018903 if (status != VOS_STATUS_SUCCESS) {
18904 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
18905 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018906 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018907 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018908 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018909
Bhargav Shah66896792015-10-01 18:17:37 +053018910 /* stop TCP delack timer if TDLS is enable */
18911 set_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
18912 hdd_manage_delack_timer(pHddCtx);
Abhishek Singh67fa6bc2016-01-05 15:57:19 +053018913 hdd_wlan_tdls_enable_link_event(peer,
18914 pTdlsPeer->isOffChannelSupported,
18915 pTdlsPeer->isOffChannelConfigured,
18916 pTdlsPeer->isOffChannelEstablished);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018917 }
18918 break;
18919 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080018920 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018921 tANI_U16 numCurrTdlsPeers = 0;
18922 hddTdlsPeer_t *connPeer = NULL;
18923
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18925 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
18926 __func__, MAC_ADDR_ARRAY(peer));
18927
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018928 mutex_lock(&pHddCtx->tdls_lock);
18929 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018930
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018931
Sunil Dutt41de4e22013-11-14 18:09:02 +053018932 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018933 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018934 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18935 " (oper %d) not exsting. ignored",
18936 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18937 return -EINVAL;
18938 }
18939
18940 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18941 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18942 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18943 "NL80211_TDLS_DISABLE_LINK");
18944
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018945 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080018946 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018947 long status;
18948
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018949 /* set tdls off channel status to false for this peer */
18950 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053018951 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18952 eTDLS_LINK_TEARING,
18953 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
18954 eTDLS_LINK_UNSPECIFIED:
18955 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018956 mutex_unlock(&pHddCtx->tdls_lock);
18957
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018958 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
18959
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018960 status = sme_DeleteTdlsPeerSta(
18961 WLAN_HDD_GET_HAL_CTX(pAdapter),
18962 pAdapter->sessionId, peer );
18963 if (status != VOS_STATUS_SUCCESS) {
18964 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
18965 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018966
18967 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
18968 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018969
18970 mutex_lock(&pHddCtx->tdls_lock);
18971 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18972 if ( NULL == pTdlsPeer ) {
18973 mutex_unlock(&pHddCtx->tdls_lock);
18974 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18975 " peer was freed in other context",
18976 __func__, MAC_ADDR_ARRAY(peer));
18977 return -EINVAL;
18978 }
18979
Atul Mittal271a7652014-09-12 13:18:22 +053018980 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053018981 eTDLS_LINK_IDLE,
18982 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018983 mutex_unlock(&pHddCtx->tdls_lock);
18984
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018985 if (status <= 0)
18986 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18988 "%s: Del station failed status %ld",
18989 __func__, status);
18990 return -EPERM;
18991 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018992
18993 /* TDLS Off Channel, Enable tdls channel switch,
18994 when their is only one tdls link and it supports */
18995 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18996 if (numCurrTdlsPeers == 1)
18997 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018998 tSirMacAddr peerMac;
18999 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053019000
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019001 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019002 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053019003
19004 if (connPeer == NULL) {
19005 mutex_unlock(&pHddCtx->tdls_lock);
19006 hddLog(VOS_TRACE_LEVEL_ERROR,
19007 "%s connPeer is NULL", __func__);
19008 return -EINVAL;
19009 }
19010
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019011 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
19012 channel = connPeer->peerParams.channel;
19013
19014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19015 "%s: TDLS channel switch "
19016 "isOffChannelSupported %d "
19017 "isOffChannelConfigured %d "
19018 "isOffChannelEstablished %d",
19019 __func__,
19020 (connPeer ? connPeer->isOffChannelSupported : -1),
19021 (connPeer ? connPeer->isOffChannelConfigured : -1),
19022 (connPeer ? connPeer->isOffChannelEstablished : -1));
19023
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019024 if ((connPeer) &&
19025 (connPeer->isOffChannelSupported == TRUE) &&
19026 (connPeer->isOffChannelConfigured == TRUE))
19027 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053019028 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019029 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019030 status = sme_SendTdlsChanSwitchReq(
19031 WLAN_HDD_GET_HAL_CTX(pAdapter),
19032 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019033 peerMac,
19034 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019035 TDLS_OFF_CHANNEL_BW_OFFSET,
19036 TDLS_CHANNEL_SWITCH_ENABLE);
19037 if (status != VOS_STATUS_SUCCESS) {
19038 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
19039 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019040 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019041 else
19042 mutex_unlock(&pHddCtx->tdls_lock);
19043 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019044 else
19045 {
19046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19047 "%s: TDLS channel switch request not sent "
19048 "numCurrTdlsPeers %d ",
19049 __func__, numCurrTdlsPeers);
19050 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080019051 }
19052 else
19053 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019054 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19056 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080019057 }
Bhargav Shah66896792015-10-01 18:17:37 +053019058 if (numCurrTdlsPeers == 0) {
19059 /* start TCP delack timer if TDLS is disable */
19060 clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
19061 hdd_manage_delack_timer(pHddCtx);
19062 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080019063 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019064 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019065 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053019066 {
Atul Mittal115287b2014-07-08 13:26:33 +053019067 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019068
Atul Mittal115287b2014-07-08 13:26:33 +053019069 if (0 != status)
19070 {
19071 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019072 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053019073 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053019074 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053019075 break;
19076 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019077 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053019078 {
Atul Mittal115287b2014-07-08 13:26:33 +053019079 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
19080 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019081 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053019082 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019083
Atul Mittal115287b2014-07-08 13:26:33 +053019084 if (0 != status)
19085 {
19086 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019087 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053019088 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053019089 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053019090 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053019091 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019092 case NL80211_TDLS_DISCOVERY_REQ:
19093 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019095 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019096 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019097 return -ENOTSUPP;
19098 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19100 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019101 return -ENOTSUPP;
19102 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019103
19104 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019105 return 0;
19106}
Chilam NG571c65a2013-01-19 12:27:36 +053019107
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019108static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019109#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
19110 const u8 *peer,
19111#else
19112 u8 *peer,
19113#endif
19114 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019115{
19116 int ret;
19117
19118 vos_ssr_protect(__func__);
19119 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
19120 vos_ssr_unprotect(__func__);
19121
19122 return ret;
19123}
19124
Chilam NG571c65a2013-01-19 12:27:36 +053019125int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
19126 struct net_device *dev, u8 *peer)
19127{
Arif Hussaina7c8e412013-11-20 11:06:42 -080019128 hddLog(VOS_TRACE_LEVEL_INFO,
19129 "tdls send discover req: "MAC_ADDRESS_STR,
19130 MAC_ADDR_ARRAY(peer));
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053019131#if TDLS_MGMT_VERSION2
19132 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19133 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19134#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019135#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
19136 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19137 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
19138#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
19139 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19140 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19141#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
19142 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19143 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19144#else
Chilam NG571c65a2013-01-19 12:27:36 +053019145 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19146 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053019147#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019148#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053019149}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019150#endif
19151
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019152#ifdef WLAN_FEATURE_GTK_OFFLOAD
19153/*
19154 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
19155 * Callback rountine called upon receiving response for
19156 * get offload info
19157 */
19158void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
19159 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
19160{
19161
19162 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019163 tANI_U8 tempReplayCounter[8];
19164 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019165
19166 ENTER();
19167
19168 if (NULL == pAdapter)
19169 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053019170 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019171 "%s: HDD adapter is Null", __func__);
19172 return ;
19173 }
19174
19175 if (NULL == pGtkOffloadGetInfoRsp)
19176 {
19177 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19178 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
19179 return ;
19180 }
19181
19182 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
19183 {
19184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19185 "%s: wlan Failed to get replay counter value",
19186 __func__);
19187 return ;
19188 }
19189
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019190 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19191 /* Update replay counter */
19192 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
19193 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
19194
19195 {
19196 /* changing from little to big endian since supplicant
19197 * works on big endian format
19198 */
19199 int i;
19200 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
19201
19202 for (i = 0; i < 8; i++)
19203 {
19204 tempReplayCounter[7-i] = (tANI_U8)p[i];
19205 }
19206 }
19207
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019208 /* Update replay counter to NL */
19209 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019210 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019211}
19212
19213/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019214 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019215 * This function is used to offload GTK rekeying job to the firmware.
19216 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019217int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019218 struct cfg80211_gtk_rekey_data *data)
19219{
19220 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19221 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
19222 hdd_station_ctx_t *pHddStaCtx;
19223 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019224 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019225 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019226 eHalStatus status = eHAL_STATUS_FAILURE;
19227
19228 ENTER();
19229
19230 if (NULL == pAdapter)
19231 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019232 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019233 "%s: HDD adapter is Null", __func__);
19234 return -ENODEV;
19235 }
19236
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019237 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19238 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
19239 pAdapter->sessionId, pAdapter->device_mode));
19240
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019241 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019242 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019243 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019244 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019245 }
19246
19247 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19248 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
19249 if (NULL == hHal)
19250 {
19251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19252 "%s: HAL context is Null!!!", __func__);
19253 return -EAGAIN;
19254 }
19255
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019256 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
19257 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
19258 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
19259 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019260 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019261 {
19262 /* changing from big to little endian since driver
19263 * works on little endian format
19264 */
19265 tANI_U8 *p =
19266 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
19267 int i;
19268
19269 for (i = 0; i < 8; i++)
19270 {
19271 p[7-i] = data->replay_ctr[i];
19272 }
19273 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019274
19275 if (TRUE == pHddCtx->hdd_wlan_suspended)
19276 {
19277 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019278 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
19279 sizeof (tSirGtkOffloadParams));
19280 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019281 pAdapter->sessionId);
19282
19283 if (eHAL_STATUS_SUCCESS != status)
19284 {
19285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19286 "%s: sme_SetGTKOffload failed, returned %d",
19287 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053019288
19289 /* Need to clear any trace of key value in the memory.
19290 * Thus zero out the memory even though it is local
19291 * variable.
19292 */
19293 vos_mem_zero(&hddGtkOffloadReqParams,
19294 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019295 return status;
19296 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19298 "%s: sme_SetGTKOffload successfull", __func__);
19299 }
19300 else
19301 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19303 "%s: wlan not suspended GTKOffload request is stored",
19304 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019305 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019306
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053019307 /* Need to clear any trace of key value in the memory.
19308 * Thus zero out the memory even though it is local
19309 * variable.
19310 */
19311 vos_mem_zero(&hddGtkOffloadReqParams,
19312 sizeof(hddGtkOffloadReqParams));
19313
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019314 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019315 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019316}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019317
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019318int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
19319 struct cfg80211_gtk_rekey_data *data)
19320{
19321 int ret;
19322
19323 vos_ssr_protect(__func__);
19324 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
19325 vos_ssr_unprotect(__func__);
19326
19327 return ret;
19328}
19329#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019330/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019331 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019332 * This function is used to set access control policy
19333 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019334static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
19335 struct net_device *dev,
19336 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019337{
19338 int i;
19339 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19340 hdd_hostapd_state_t *pHostapdState;
19341 tsap_Config_t *pConfig;
19342 v_CONTEXT_t pVosContext = NULL;
19343 hdd_context_t *pHddCtx;
19344 int status;
19345
19346 ENTER();
19347
19348 if (NULL == pAdapter)
19349 {
19350 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19351 "%s: HDD adapter is Null", __func__);
19352 return -ENODEV;
19353 }
19354
19355 if (NULL == params)
19356 {
19357 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19358 "%s: params is Null", __func__);
19359 return -EINVAL;
19360 }
19361
19362 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19363 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019364 if (0 != status)
19365 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019366 return status;
19367 }
19368
19369 pVosContext = pHddCtx->pvosContext;
19370 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
19371
19372 if (NULL == pHostapdState)
19373 {
19374 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19375 "%s: pHostapdState is Null", __func__);
19376 return -EINVAL;
19377 }
19378
19379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
19380 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019381 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19382 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
19383 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019384
19385 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
19386 {
19387 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
19388
19389 /* default value */
19390 pConfig->num_accept_mac = 0;
19391 pConfig->num_deny_mac = 0;
19392
19393 /**
19394 * access control policy
19395 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
19396 * listed in hostapd.deny file.
19397 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
19398 * listed in hostapd.accept file.
19399 */
19400 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
19401 {
19402 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
19403 }
19404 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
19405 {
19406 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
19407 }
19408 else
19409 {
19410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19411 "%s:Acl Policy : %d is not supported",
19412 __func__, params->acl_policy);
19413 return -ENOTSUPP;
19414 }
19415
19416 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
19417 {
19418 pConfig->num_accept_mac = params->n_acl_entries;
19419 for (i = 0; i < params->n_acl_entries; i++)
19420 {
19421 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19422 "** Add ACL MAC entry %i in WhiletList :"
19423 MAC_ADDRESS_STR, i,
19424 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
19425
19426 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
19427 sizeof(qcmacaddr));
19428 }
19429 }
19430 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
19431 {
19432 pConfig->num_deny_mac = params->n_acl_entries;
19433 for (i = 0; i < params->n_acl_entries; i++)
19434 {
19435 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19436 "** Add ACL MAC entry %i in BlackList :"
19437 MAC_ADDRESS_STR, i,
19438 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
19439
19440 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
19441 sizeof(qcmacaddr));
19442 }
19443 }
19444
19445 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
19446 {
19447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19448 "%s: SAP Set Mac Acl fail", __func__);
19449 return -EINVAL;
19450 }
19451 }
19452 else
19453 {
19454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053019455 "%s: Invalid device_mode = %s (%d)",
19456 __func__, hdd_device_modetoString(pAdapter->device_mode),
19457 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019458 return -EINVAL;
19459 }
19460
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019461 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019462 return 0;
19463}
19464
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019465static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
19466 struct net_device *dev,
19467 const struct cfg80211_acl_data *params)
19468{
19469 int ret;
19470 vos_ssr_protect(__func__);
19471 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
19472 vos_ssr_unprotect(__func__);
19473
19474 return ret;
19475}
19476
Leo Chang9056f462013-08-01 19:21:11 -070019477#ifdef WLAN_NL80211_TESTMODE
19478#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070019479void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070019480(
19481 void *pAdapter,
19482 void *indCont
19483)
19484{
Leo Changd9df8aa2013-09-26 13:32:26 -070019485 tSirLPHBInd *lphbInd;
19486 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053019487 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070019488
19489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070019490 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070019491
c_hpothu73f35e62014-04-18 13:40:08 +053019492 if (pAdapter == NULL)
19493 {
19494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19495 "%s: pAdapter is NULL\n",__func__);
19496 return;
19497 }
19498
Leo Chang9056f462013-08-01 19:21:11 -070019499 if (NULL == indCont)
19500 {
19501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070019502 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070019503 return;
19504 }
19505
c_hpothu73f35e62014-04-18 13:40:08 +053019506 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070019507 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070019508 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053019509 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070019510 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070019511 GFP_ATOMIC);
19512 if (!skb)
19513 {
19514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19515 "LPHB timeout, NL buffer alloc fail");
19516 return;
19517 }
19518
Leo Changac3ba772013-10-07 09:47:04 -070019519 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070019520 {
19521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19522 "WLAN_HDD_TM_ATTR_CMD put fail");
19523 goto nla_put_failure;
19524 }
Leo Changac3ba772013-10-07 09:47:04 -070019525 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070019526 {
19527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19528 "WLAN_HDD_TM_ATTR_TYPE put fail");
19529 goto nla_put_failure;
19530 }
Leo Changac3ba772013-10-07 09:47:04 -070019531 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070019532 sizeof(tSirLPHBInd), lphbInd))
19533 {
19534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19535 "WLAN_HDD_TM_ATTR_DATA put fail");
19536 goto nla_put_failure;
19537 }
Leo Chang9056f462013-08-01 19:21:11 -070019538 cfg80211_testmode_event(skb, GFP_ATOMIC);
19539 return;
19540
19541nla_put_failure:
19542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19543 "NLA Put fail");
19544 kfree_skb(skb);
19545
19546 return;
19547}
19548#endif /* FEATURE_WLAN_LPHB */
19549
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019550static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070019551{
19552 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
19553 int err = 0;
19554#ifdef FEATURE_WLAN_LPHB
19555 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070019556 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019557
19558 ENTER();
19559
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019560 err = wlan_hdd_validate_context(pHddCtx);
19561 if (0 != err)
19562 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019563 return err;
19564 }
Leo Chang9056f462013-08-01 19:21:11 -070019565#endif /* FEATURE_WLAN_LPHB */
19566
19567 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
19568 if (err)
19569 {
19570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19571 "%s Testmode INV ATTR", __func__);
19572 return err;
19573 }
19574
19575 if (!tb[WLAN_HDD_TM_ATTR_CMD])
19576 {
19577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19578 "%s Testmode INV CMD", __func__);
19579 return -EINVAL;
19580 }
19581
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019582 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19583 TRACE_CODE_HDD_CFG80211_TESTMODE,
19584 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070019585 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
19586 {
19587#ifdef FEATURE_WLAN_LPHB
19588 /* Low Power Heartbeat configuration request */
19589 case WLAN_HDD_TM_CMD_WLAN_HB:
19590 {
19591 int buf_len;
19592 void *buf;
19593 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080019594 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070019595
19596 if (!tb[WLAN_HDD_TM_ATTR_DATA])
19597 {
19598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19599 "%s Testmode INV DATA", __func__);
19600 return -EINVAL;
19601 }
19602
19603 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
19604 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080019605
Manjeet Singh3c577442017-02-10 19:03:38 +053019606 if (buf_len > sizeof(*hb_params)) {
19607 hddLog(LOGE, FL("buf_len=%d exceeded hb_params size limit"),
19608 buf_len);
19609 return -ERANGE;
19610 }
19611
Amar Singhal05852702014-02-04 14:40:00 -080019612 hb_params_temp =(tSirLPHBReq *)buf;
19613 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
19614 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
19615 return -EINVAL;
19616
Leo Chang9056f462013-08-01 19:21:11 -070019617 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
19618 if (NULL == hb_params)
19619 {
19620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19621 "%s Request Buffer Alloc Fail", __func__);
19622 return -EINVAL;
19623 }
19624
19625 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070019626 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
19627 hb_params,
19628 wlan_hdd_cfg80211_lphb_ind_handler);
19629 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070019630 {
Leo Changd9df8aa2013-09-26 13:32:26 -070019631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19632 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070019633 vos_mem_free(hb_params);
19634 }
Leo Chang9056f462013-08-01 19:21:11 -070019635 return 0;
19636 }
19637#endif /* FEATURE_WLAN_LPHB */
19638 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19640 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070019641 return -EOPNOTSUPP;
19642 }
19643
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019644 EXIT();
19645 return err;
Leo Chang9056f462013-08-01 19:21:11 -070019646}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019647
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053019648static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
19649#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
19650 struct wireless_dev *wdev,
19651#endif
19652 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019653{
19654 int ret;
19655
19656 vos_ssr_protect(__func__);
19657 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
19658 vos_ssr_unprotect(__func__);
19659
19660 return ret;
19661}
Leo Chang9056f462013-08-01 19:21:11 -070019662#endif /* CONFIG_NL80211_TESTMODE */
19663
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019664extern void hdd_set_wlan_suspend_mode(bool suspend);
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019665static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019666 struct net_device *dev,
19667 int idx, struct survey_info *survey)
19668{
19669 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19670 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053019671 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019672 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053019673 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019674 v_S7_t snr,rssi;
19675 int status, i, j, filled = 0;
19676
19677 ENTER();
19678
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019679 if (NULL == pAdapter)
19680 {
19681 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19682 "%s: HDD adapter is Null", __func__);
19683 return -ENODEV;
19684 }
19685
19686 if (NULL == wiphy)
19687 {
19688 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19689 "%s: wiphy is Null", __func__);
19690 return -ENODEV;
19691 }
19692
19693 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19694 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019695 if (0 != status)
19696 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019697 return status;
19698 }
19699
Mihir Sheted9072e02013-08-21 17:02:29 +053019700 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19701
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019702 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053019703 0 != pAdapter->survey_idx ||
19704 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019705 {
19706 /* The survey dump ops when implemented completely is expected to
19707 * return a survey of all channels and the ops is called by the
19708 * kernel with incremental values of the argument 'idx' till it
19709 * returns -ENONET. But we can only support the survey for the
19710 * operating channel for now. survey_idx is used to track
19711 * that the ops is called only once and then return -ENONET for
19712 * the next iteration
19713 */
19714 pAdapter->survey_idx = 0;
19715 return -ENONET;
19716 }
19717
Mukul Sharma9d5233b2015-06-11 20:28:20 +053019718 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
19719 {
19720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19721 "%s: Roaming in progress, hence return ", __func__);
19722 return -ENONET;
19723 }
19724
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019725 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19726
19727 wlan_hdd_get_snr(pAdapter, &snr);
19728 wlan_hdd_get_rssi(pAdapter, &rssi);
19729
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019730 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19731 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
19732 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019733 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
19734 hdd_wlan_get_freq(channel, &freq);
19735
19736
19737 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
19738 {
19739 if (NULL == wiphy->bands[i])
19740 {
19741 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
19742 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
19743 continue;
19744 }
19745
19746 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
19747 {
19748 struct ieee80211_supported_band *band = wiphy->bands[i];
19749
19750 if (band->channels[j].center_freq == (v_U16_t)freq)
19751 {
19752 survey->channel = &band->channels[j];
19753 /* The Rx BDs contain SNR values in dB for the received frames
19754 * while the supplicant expects noise. So we calculate and
19755 * return the value of noise (dBm)
19756 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
19757 */
19758 survey->noise = rssi - snr;
19759 survey->filled = SURVEY_INFO_NOISE_DBM;
19760 filled = 1;
19761 }
19762 }
19763 }
19764
19765 if (filled)
19766 pAdapter->survey_idx = 1;
19767 else
19768 {
19769 pAdapter->survey_idx = 0;
19770 return -ENONET;
19771 }
19772
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019773 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019774 return 0;
19775}
19776
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019777static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
19778 struct net_device *dev,
19779 int idx, struct survey_info *survey)
19780{
19781 int ret;
19782
19783 vos_ssr_protect(__func__);
19784 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
19785 vos_ssr_unprotect(__func__);
19786
19787 return ret;
19788}
19789
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019790/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019791 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019792 * this is called when cfg80211 driver resume
19793 * driver updates latest sched_scan scan result(if any) to cfg80211 database
19794 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019795int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019796{
19797 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
19798 hdd_adapter_t *pAdapter;
19799 hdd_adapter_list_node_t *pAdapterNode, *pNext;
19800 VOS_STATUS status = VOS_STATUS_SUCCESS;
19801
19802 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019803
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019804 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019805 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019806 return 0;
19807 }
19808
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019809 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
19810 NO_SESSION, pHddCtx->isWiphySuspended));
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019811
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053019812 if (pHddCtx->is_ap_mode_wow_supported)
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019813 {
19814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19815 "%s: Resume SoftAP", __func__);
19816 hdd_set_wlan_suspend_mode(false);
19817 }
19818
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019819 spin_lock(&pHddCtx->schedScan_lock);
19820 pHddCtx->isWiphySuspended = FALSE;
19821 if (TRUE != pHddCtx->isSchedScanUpdatePending)
19822 {
19823 spin_unlock(&pHddCtx->schedScan_lock);
19824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19825 "%s: Return resume is not due to PNO indication", __func__);
19826 return 0;
19827 }
19828 // Reset flag to avoid updatating cfg80211 data old results again
19829 pHddCtx->isSchedScanUpdatePending = FALSE;
19830 spin_unlock(&pHddCtx->schedScan_lock);
19831
19832 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
19833
19834 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
19835 {
19836 pAdapter = pAdapterNode->pAdapter;
19837 if ( (NULL != pAdapter) &&
19838 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
19839 {
19840 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019841 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
19843 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019844 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019845 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019846 {
19847 /* Acquire wakelock to handle the case where APP's tries to
19848 * suspend immediately after updating the scan results. Whis
19849 * results in app's is in suspended state and not able to
19850 * process the connect request to AP
19851 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053019852 hdd_prevent_suspend_timeout(2000,
19853 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019854 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019855 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019856
19857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19858 "%s : cfg80211 scan result database updated", __func__);
19859
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019860 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019861 return 0;
19862
19863 }
19864 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
19865 pAdapterNode = pNext;
19866 }
19867
19868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19869 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019870 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019871 return 0;
19872}
19873
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019874int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
19875{
19876 int ret;
19877
19878 vos_ssr_protect(__func__);
19879 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
19880 vos_ssr_unprotect(__func__);
19881
19882 return ret;
19883}
19884
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019885/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019886 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019887 * this is called when cfg80211 driver suspends
19888 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019889int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019890 struct cfg80211_wowlan *wow)
19891{
19892 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019893 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019894
19895 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019896
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019897 ret = wlan_hdd_validate_context(pHddCtx);
19898 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019899 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019900 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019901 }
19902
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053019903 if (pHddCtx->is_ap_mode_wow_supported) {
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19905 "%s: Suspend SoftAP", __func__);
19906 hdd_set_wlan_suspend_mode(true);
19907 }
19908
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019909
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019910 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19911 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
19912 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019913 pHddCtx->isWiphySuspended = TRUE;
19914
19915 EXIT();
19916
19917 return 0;
19918}
19919
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019920int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
19921 struct cfg80211_wowlan *wow)
19922{
19923 int ret;
19924
19925 vos_ssr_protect(__func__);
19926 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
19927 vos_ssr_unprotect(__func__);
19928
19929 return ret;
19930}
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019931
19932#ifdef FEATURE_OEM_DATA_SUPPORT
19933static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019934 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019935{
19936 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19937
19938 ENTER();
19939
19940 if (wlan_hdd_validate_context(pHddCtx)) {
19941 return;
19942 }
19943 if (!pMsg)
19944 {
19945 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
19946 return;
19947 }
19948
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019949 send_oem_data_rsp_msg(evLen, pMsg);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019950
19951 EXIT();
19952 return;
19953
19954}
19955
19956void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019957 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019958{
19959 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19960
19961 ENTER();
19962
19963 if (wlan_hdd_validate_context(pHddCtx)) {
19964 return;
19965 }
19966
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019967 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d) evLen %d"), evType, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019968
19969 switch(evType) {
19970 case SIR_HAL_START_OEM_DATA_RSP_IND_NEW:
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019971 wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019972 break;
19973 default:
19974 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
19975 break;
19976 }
19977 EXIT();
19978}
19979#endif
19980
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019981#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
19982 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019983/**
19984 * __wlan_hdd_cfg80211_abort_scan() - cfg80211 abort scan api
19985 * @wiphy: Pointer to wiphy
19986 * @wdev: Pointer to wireless device structure
19987 *
19988 * This function is used to abort an ongoing scan
19989 *
19990 * Return: None
19991 */
19992static void __wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
19993 struct wireless_dev *wdev)
19994{
19995 struct net_device *dev = wdev->netdev;
19996 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
19997 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
19998 int ret;
19999
20000 ENTER();
20001
20002 if (NULL == adapter) {
20003 hddLog(VOS_TRACE_LEVEL_FATAL, FL("HDD adapter is NULL"));
20004 return;
20005 }
20006
20007 ret = wlan_hdd_validate_context(hdd_ctx);
20008 if (0 != ret)
20009 return;
20010
20011 wlan_hdd_scan_abort(adapter);
20012
20013 return;
20014}
20015
20016/**
20017 * wlan_hdd_cfg80211_abort_scan - cfg80211 abort scan api
20018 * @wiphy: Pointer to wiphy
20019 * @wdev: Pointer to wireless device structure
20020 *
20021 * Return: None
20022 */
20023void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
20024 struct wireless_dev *wdev)
20025{
20026 vos_ssr_protect(__func__);
20027 __wlan_hdd_cfg80211_abort_scan(wiphy, wdev);
20028 vos_ssr_unprotect(__func__);
20029
20030 return;
20031}
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020032#endif
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053020033
Jeff Johnson295189b2012-06-20 16:38:30 -070020034/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053020035static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070020036{
20037 .add_virtual_intf = wlan_hdd_add_virtual_intf,
20038 .del_virtual_intf = wlan_hdd_del_virtual_intf,
20039 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
20040 .change_station = wlan_hdd_change_station,
20041#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
20042 .add_beacon = wlan_hdd_cfg80211_add_beacon,
20043 .del_beacon = wlan_hdd_cfg80211_del_beacon,
20044 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070020045#else
20046 .start_ap = wlan_hdd_cfg80211_start_ap,
20047 .change_beacon = wlan_hdd_cfg80211_change_beacon,
20048 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070020049#endif
20050 .change_bss = wlan_hdd_cfg80211_change_bss,
20051 .add_key = wlan_hdd_cfg80211_add_key,
20052 .get_key = wlan_hdd_cfg80211_get_key,
20053 .del_key = wlan_hdd_cfg80211_del_key,
20054 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080020055#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070020056 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080020057#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070020058 .scan = wlan_hdd_cfg80211_scan,
20059 .connect = wlan_hdd_cfg80211_connect,
20060 .disconnect = wlan_hdd_cfg80211_disconnect,
20061 .join_ibss = wlan_hdd_cfg80211_join_ibss,
20062 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
20063 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
20064 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
20065 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070020066 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
20067 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053020068 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070020069#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
20070 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
20071 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
20072 .set_txq_params = wlan_hdd_set_txq_params,
20073#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070020074 .get_station = wlan_hdd_cfg80211_get_station,
20075 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
20076 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070020077 .add_station = wlan_hdd_cfg80211_add_station,
20078#ifdef FEATURE_WLAN_LFR
20079 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
20080 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
20081 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
20082#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070020083#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
20084 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
20085#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020086#ifdef FEATURE_WLAN_TDLS
20087 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
20088 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
20089#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053020090#ifdef WLAN_FEATURE_GTK_OFFLOAD
20091 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
20092#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020093#ifdef FEATURE_WLAN_SCAN_PNO
20094 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
20095 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
20096#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020097 .resume = wlan_hdd_cfg80211_resume_wlan,
20098 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020099 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070020100#ifdef WLAN_NL80211_TESTMODE
20101 .testmode_cmd = wlan_hdd_cfg80211_testmode,
20102#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020103 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020104#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
20105 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053020106 .abort_scan = wlan_hdd_cfg80211_abort_scan,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020107#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070020108};
20109