blob: e8c0449d76b8729255dccc06107c47fd0e9f6981 [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
Anurag Chouhanfcd20172017-07-19 17:25:19 +0530783/*
784 * define short names for the global vendor params
785 * used by __wlan_hdd_cfg80211_get_station_cmd()
786 */
787#define STATION_INVALID \
788 QCA_WLAN_VENDOR_ATTR_GET_STATION_INVALID
789#define STATION_INFO \
790 QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO
791#define STATION_ASSOC_FAIL_REASON \
792 QCA_WLAN_VENDOR_ATTR_GET_STATION_ASSOC_FAIL_REASON
793#define STATION_MAX \
794 QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX
795
796static const struct nla_policy
797hdd_get_station_policy[STATION_MAX + 1] = {
798 [STATION_INFO] = {.type = NLA_FLAG},
799 [STATION_ASSOC_FAIL_REASON] = {.type = NLA_FLAG},
800};
801
802/**
803 * hdd_get_station_assoc_fail() - Handle get station assoc fail
804 * @hdd_ctx: HDD context within host driver
805 * @wdev: wireless device
806 *
807 * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION_ASSOC_FAIL.
808 * Validate cmd attributes and send the station info to upper layers.
809 *
810 * Return: Success(0) or reason code for failure
811 */
812static int hdd_get_station_assoc_fail(hdd_context_t *hdd_ctx,
813 hdd_adapter_t *adapter)
814{
815 struct sk_buff *skb = NULL;
816 uint32_t nl_buf_len;
817 hdd_station_ctx_t *hdd_sta_ctx;
818
819 nl_buf_len = NLMSG_HDRLEN;
820 nl_buf_len += sizeof(uint32_t);
821 skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len);
822
823 if (!skb) {
824 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"cfg80211_vendor_cmd_alloc_reply_skb failed");
825 return -ENOMEM;
826 }
827
828 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
829
830 if (nla_put_u32(skb, INFO_ASSOC_FAIL_REASON,
831 hdd_sta_ctx->conn_info.assoc_status_code)) {
832 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
833 goto fail;
834 }
835 return cfg80211_vendor_cmd_reply(skb);
836fail:
837 if (skb)
838 kfree_skb(skb);
839 return -EINVAL;
840}
841
842/**
843 * hdd_map_auth_type() - transform auth type specific to
844 * vendor command
845 * @auth_type: csr auth type
846 *
847 * Return: Success(0) or reason code for failure
848 */
849static int hdd_convert_auth_type(uint32_t auth_type)
850{
851 uint32_t ret_val;
852
853 switch (auth_type) {
854 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
855 ret_val = QCA_WLAN_AUTH_TYPE_OPEN;
856 break;
857 case eCSR_AUTH_TYPE_SHARED_KEY:
858 ret_val = QCA_WLAN_AUTH_TYPE_SHARED;
859 break;
860 case eCSR_AUTH_TYPE_WPA:
861 ret_val = QCA_WLAN_AUTH_TYPE_WPA;
862 break;
863 case eCSR_AUTH_TYPE_WPA_PSK:
864 ret_val = QCA_WLAN_AUTH_TYPE_WPA_PSK;
865 break;
866 case eCSR_AUTH_TYPE_AUTOSWITCH:
867 ret_val = QCA_WLAN_AUTH_TYPE_AUTOSWITCH;
868 break;
869 case eCSR_AUTH_TYPE_WPA_NONE:
870 ret_val = QCA_WLAN_AUTH_TYPE_WPA_NONE;
871 break;
872 case eCSR_AUTH_TYPE_RSN:
873 ret_val = QCA_WLAN_AUTH_TYPE_RSN;
874 break;
875 case eCSR_AUTH_TYPE_RSN_PSK:
876 ret_val = QCA_WLAN_AUTH_TYPE_RSN_PSK;
877 break;
878 case eCSR_AUTH_TYPE_FT_RSN:
879 ret_val = QCA_WLAN_AUTH_TYPE_FT;
880 break;
881 case eCSR_AUTH_TYPE_FT_RSN_PSK:
882 ret_val = QCA_WLAN_AUTH_TYPE_FT_PSK;
883 break;
884 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
885 ret_val = QCA_WLAN_AUTH_TYPE_WAI;
886 break;
887 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
888 ret_val = QCA_WLAN_AUTH_TYPE_WAI_PSK;
889 break;
890#ifdef FEATURE_WLAN_ESE
891 case eCSR_AUTH_TYPE_CCKM_WPA:
892 ret_val = QCA_WLAN_AUTH_TYPE_CCKM_WPA;
893 break;
894 case eCSR_AUTH_TYPE_CCKM_RSN:
895 ret_val = QCA_WLAN_AUTH_TYPE_CCKM_RSN;
896 break;
897#endif
898 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
899 ret_val = QCA_WLAN_AUTH_TYPE_SHA256_PSK;
900 break;
901 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
902 ret_val = QCA_WLAN_AUTH_TYPE_SHA256;
903 break;
904 case eCSR_NUM_OF_SUPPORT_AUTH_TYPE:
905 case eCSR_AUTH_TYPE_FAILED:
906 case eCSR_AUTH_TYPE_NONE:
907 default:
908 ret_val = QCA_WLAN_AUTH_TYPE_INVALID;
909 break;
910 }
911 return ret_val;
912}
913
914/**
915 * hdd_map_dot_11_mode() - transform dot11mode type specific to
916 * vendor command
917 * @dot11mode: dot11mode
918 *
919 * Return: Success(0) or reason code for failure
920 */
921static int hdd_convert_dot11mode(uint32_t dot11mode)
922{
923 uint32_t ret_val;
924
925 switch (dot11mode) {
926 case eCSR_CFG_DOT11_MODE_11A:
927 ret_val = QCA_WLAN_802_11_MODE_11A;
928 break;
929 case eCSR_CFG_DOT11_MODE_11B:
930 ret_val = QCA_WLAN_802_11_MODE_11B;
931 break;
932 case eCSR_CFG_DOT11_MODE_11G:
933 ret_val = QCA_WLAN_802_11_MODE_11G;
934 break;
935 case eCSR_CFG_DOT11_MODE_11N:
936 ret_val = QCA_WLAN_802_11_MODE_11N;
937 break;
938 case eCSR_CFG_DOT11_MODE_11AC:
939 ret_val = QCA_WLAN_802_11_MODE_11AC;
940 break;
941 case eCSR_CFG_DOT11_MODE_AUTO:
942 case eCSR_CFG_DOT11_MODE_ABG:
943 default:
944 ret_val = QCA_WLAN_802_11_MODE_INVALID;
945 }
946 return ret_val;
947}
948
949/**
950 * hdd_add_tx_bitrate() - add tx bitrate attribute
951 * @skb: pointer to sk buff
952 * @hdd_sta_ctx: pointer to hdd station context
953 * @idx: attribute index
954 *
955 * Return: Success(0) or reason code for failure
956 */
957static int32_t hdd_add_tx_bitrate(struct sk_buff *skb,
958 hdd_station_ctx_t *hdd_sta_ctx,
959 int idx)
960{
961 struct nlattr *nla_attr;
962 uint32_t bitrate, bitrate_compat;
963
964 nla_attr = nla_nest_start(skb, idx);
965 if (!nla_attr)
966 goto fail;
967 /* cfg80211_calculate_bitrate will return 0 for mcs >= 32 */
968 bitrate = cfg80211_calculate_bitrate(&hdd_sta_ctx->conn_info.txrate);
969
970 /* report 16-bit bitrate only if we can */
971 bitrate_compat = bitrate < (1UL << 16) ? bitrate : 0;
972 if (bitrate > 0 &&
973 nla_put_u32(skb, NL80211_RATE_INFO_BITRATE32, bitrate)) {
974 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
975 goto fail;
976 }
977 if (bitrate_compat > 0 &&
978 nla_put_u16(skb, NL80211_RATE_INFO_BITRATE, bitrate_compat)) {
979 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
980 goto fail;
981 }
982 if (nla_put_u8(skb, NL80211_RATE_INFO_VHT_NSS,
983 hdd_sta_ctx->conn_info.txrate.nss)) {
984 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
985 goto fail;
986 }
987 nla_nest_end(skb, nla_attr);
988 return 0;
989fail:
990 return -EINVAL;
991}
992
993/**
994 * hdd_add_sta_info() - add station info attribute
995 * @skb: pointer to sk buff
996 * @hdd_sta_ctx: pointer to hdd station context
997 * @idx: attribute index
998 *
999 * Return: Success(0) or reason code for failure
1000 */
1001static int32_t hdd_add_sta_info(struct sk_buff *skb,
1002 hdd_station_ctx_t *hdd_sta_ctx, int idx)
1003{
1004 struct nlattr *nla_attr;
1005
1006 nla_attr = nla_nest_start(skb, idx);
1007 if (!nla_attr)
1008 goto fail;
1009 if (nla_put_u8(skb, NL80211_STA_INFO_SIGNAL,
1010 (hdd_sta_ctx->conn_info.signal + 100))) {
1011 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1012 goto fail;
1013 }
1014 if (hdd_add_tx_bitrate(skb, hdd_sta_ctx, NL80211_STA_INFO_TX_BITRATE))
1015 goto fail;
1016 nla_nest_end(skb, nla_attr);
1017 return 0;
1018fail:
1019 return -EINVAL;
1020}
1021
1022/**
1023 * hdd_add_survey_info() - add survey info attribute
1024 * @skb: pointer to sk buff
1025 * @hdd_sta_ctx: pointer to hdd station context
1026 * @idx: attribute index
1027 *
1028 * Return: Success(0) or reason code for failure
1029 */
1030static int32_t hdd_add_survey_info(struct sk_buff *skb,
1031 hdd_station_ctx_t *hdd_sta_ctx,
1032 int idx)
1033{
1034 struct nlattr *nla_attr;
1035
1036 nla_attr = nla_nest_start(skb, idx);
1037 if (!nla_attr)
1038 goto fail;
1039 if (nla_put_u32(skb, NL80211_SURVEY_INFO_FREQUENCY,
1040 hdd_sta_ctx->conn_info.freq) ||
1041 nla_put_u8(skb, NL80211_SURVEY_INFO_NOISE,
1042 (hdd_sta_ctx->conn_info.noise + 100))) {
1043 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1044 goto fail;
1045 }
1046 nla_nest_end(skb, nla_attr);
1047 return 0;
1048fail:
1049 return -EINVAL;
1050}
1051
1052/**
1053 * hdd_add_link_standard_info() - add link info attribute
1054 * @skb: pointer to sk buff
1055 * @hdd_sta_ctx: pointer to hdd station context
1056 * @idx: attribute index
1057 *
1058 * Return: Success(0) or reason code for failure
1059 */
1060static int32_t
1061hdd_add_link_standard_info(struct sk_buff *skb,
1062 hdd_station_ctx_t *hdd_sta_ctx, int idx)
1063{
1064 struct nlattr *nla_attr;
1065
1066 nla_attr = nla_nest_start(skb, idx);
1067 if (!nla_attr)
1068 goto fail;
1069 if (nla_put(skb,
1070 NL80211_ATTR_SSID,
1071 hdd_sta_ctx->conn_info.SSID.SSID.length,
1072 hdd_sta_ctx->conn_info.SSID.SSID.ssId)) {
1073 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1074 goto fail;
1075 }
1076 if (hdd_add_survey_info(skb, hdd_sta_ctx, NL80211_ATTR_SURVEY_INFO))
1077 goto fail;
1078 if (hdd_add_sta_info(skb, hdd_sta_ctx, NL80211_ATTR_STA_INFO))
1079 goto fail;
1080 nla_nest_end(skb, nla_attr);
1081 return 0;
1082fail:
1083 return -EINVAL;
1084}
1085
1086/**
1087 * hdd_add_ap_standard_info() - add ap info attribute
1088 * @skb: pointer to sk buff
1089 * @hdd_sta_ctx: pointer to hdd station context
1090 * @idx: attribute index
1091 *
1092 * Return: Success(0) or reason code for failure
1093 */
1094static int32_t
1095hdd_add_ap_standard_info(struct sk_buff *skb,
1096 hdd_station_ctx_t *hdd_sta_ctx, int idx)
1097{
1098 struct nlattr *nla_attr;
1099
1100 nla_attr = nla_nest_start(skb, idx);
1101 if (!nla_attr)
1102 goto fail;
1103 if (hdd_sta_ctx->conn_info.conn_flag.vht_present)
1104 if (nla_put(skb, NL80211_ATTR_VHT_CAPABILITY,
1105 sizeof(hdd_sta_ctx->conn_info.vht_caps),
1106 &hdd_sta_ctx->conn_info.vht_caps)) {
1107 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1108 goto fail;
1109 }
1110 if (hdd_sta_ctx->conn_info.conn_flag.ht_present)
1111 if (nla_put(skb, NL80211_ATTR_HT_CAPABILITY,
1112 sizeof(hdd_sta_ctx->conn_info.ht_caps),
1113 &hdd_sta_ctx->conn_info.ht_caps)) {
1114 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1115 goto fail;
1116 }
1117 nla_nest_end(skb, nla_attr);
1118 return 0;
1119fail:
1120 return -EINVAL;
1121}
1122
1123/**
1124 * hdd_get_station_info() - send BSS information to supplicant
1125 * @hdd_ctx: pointer to hdd context
1126 * @adapter: pointer to adapter
1127 *
1128 * Return: 0 if success else error status
1129 */
1130static int hdd_get_station_info(hdd_context_t *hdd_ctx,
1131 hdd_adapter_t *adapter)
1132{
1133 struct sk_buff *skb = NULL;
1134 uint8_t *tmp_hs20 = NULL;
1135 uint32_t nl_buf_len;
1136 hdd_station_ctx_t *hdd_sta_ctx;
1137
1138 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1139
1140 nl_buf_len = NLMSG_HDRLEN;
1141 nl_buf_len += sizeof(hdd_sta_ctx->conn_info.SSID.SSID.length) +
1142 sizeof(hdd_sta_ctx->conn_info.freq) +
1143 sizeof(hdd_sta_ctx->conn_info.noise) +
1144 sizeof(hdd_sta_ctx->conn_info.signal) +
1145 (sizeof(uint32_t) * 2) +
1146 sizeof(hdd_sta_ctx->conn_info.txrate.nss) +
1147 sizeof(hdd_sta_ctx->conn_info.roam_count) +
1148 sizeof(hdd_sta_ctx->conn_info.authType) +
1149 sizeof(hdd_sta_ctx->conn_info.dot11Mode);
1150 if (hdd_sta_ctx->conn_info.conn_flag.vht_present)
1151 nl_buf_len += sizeof(hdd_sta_ctx->conn_info.vht_caps);
1152 if (hdd_sta_ctx->conn_info.conn_flag.ht_present)
1153 nl_buf_len += sizeof(hdd_sta_ctx->conn_info.ht_caps);
1154 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present) {
1155 tmp_hs20 = (uint8_t *)&(hdd_sta_ctx->conn_info.hs20vendor_ie);
1156 nl_buf_len += (sizeof(hdd_sta_ctx->conn_info.hs20vendor_ie) -
1157 1);
1158 }
1159 if (hdd_sta_ctx->conn_info.conn_flag.ht_op_present)
1160 nl_buf_len += sizeof(hdd_sta_ctx->conn_info.ht_operation);
1161 if (hdd_sta_ctx->conn_info.conn_flag.vht_op_present)
1162 nl_buf_len += sizeof(hdd_sta_ctx->conn_info.vht_operation);
1163
1164
1165 skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len);
1166 if (!skb) {
1167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: %d cfg80211_vendor_cmd_alloc_reply_skb failed",
1168 __func__, __LINE__);
1169 return -ENOMEM;
1170 }
1171
1172 if (hdd_add_link_standard_info(skb, hdd_sta_ctx,
1173 LINK_INFO_STANDARD_NL80211_ATTR)) {
1174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1175 goto fail;
1176 }
1177 if (hdd_add_ap_standard_info(skb, hdd_sta_ctx,
1178 AP_INFO_STANDARD_NL80211_ATTR)) {
1179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1180 goto fail;
1181 }
1182 if (nla_put_u32(skb, INFO_ROAM_COUNT,
1183 hdd_sta_ctx->conn_info.roam_count) ||
1184 nla_put_u32(skb, INFO_AKM,
1185 hdd_convert_auth_type(
1186 hdd_sta_ctx->conn_info.authType)) ||
1187 nla_put_u32(skb, WLAN802_11_MODE,
1188 hdd_convert_dot11mode(
1189 hdd_sta_ctx->conn_info.dot11Mode))) {
1190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1191 goto fail;
1192 }
1193 if (hdd_sta_ctx->conn_info.conn_flag.ht_op_present)
1194 if (nla_put(skb, HT_OPERATION,
1195 (sizeof(hdd_sta_ctx->conn_info.ht_operation)),
1196 &hdd_sta_ctx->conn_info.ht_operation)) {
1197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1198 goto fail;
1199 }
1200 if (hdd_sta_ctx->conn_info.conn_flag.vht_op_present)
1201 if (nla_put(skb, VHT_OPERATION,
1202 (sizeof(hdd_sta_ctx->conn_info.vht_operation)),
1203 &hdd_sta_ctx->conn_info.vht_operation)) {
1204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1205 goto fail;
1206 }
1207 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1208 if (nla_put(skb, AP_INFO_HS20_INDICATION,
1209 (sizeof(hdd_sta_ctx->conn_info.hs20vendor_ie) - 1),
1210 tmp_hs20 + 1)) {
1211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1212 goto fail;
1213 }
1214
1215 return cfg80211_vendor_cmd_reply(skb);
1216fail:
1217 if (skb)
1218 kfree_skb(skb);
1219 return -EINVAL;
1220}
1221
1222/**
1223 * __hdd_cfg80211_get_station_cmd() - Handle get station vendor cmd
1224 * @wiphy: corestack handler
1225 * @wdev: wireless device
1226 * @data: data
1227 * @data_len: data length
1228 *
1229 * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION.
1230 * Validate cmd attributes and send the station info to upper layers.
1231 *
1232 * Return: Success(0) or reason code for failure
1233 */
1234static int32_t
1235__hdd_cfg80211_get_station_cmd(struct wiphy *wiphy,
1236 struct wireless_dev *wdev,
1237 const void *data,
1238 int data_len)
1239{
1240 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
1241 struct net_device *dev = wdev->netdev;
1242 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1243 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX + 1];
1244 int32_t status;
1245
1246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"Enter");
1247 if (VOS_FTM_MODE == hdd_get_conparam()) {
1248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"Command not allowed in FTM mode");
1249 status = -EPERM;
1250 goto out;
1251 }
1252
1253 status = wlan_hdd_validate_context(hdd_ctx);
1254 if (0 != status)
1255 goto out;
1256
1257
1258 status = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX,
1259 data, data_len, NULL);
1260 if (status) {
1261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"Invalid ATTR");
1262 goto out;
1263 }
1264
1265 /* Parse and fetch Command Type*/
1266 if (tb[STATION_INFO]) {
1267 status = hdd_get_station_info(hdd_ctx, adapter);
1268 } else if (tb[STATION_ASSOC_FAIL_REASON]) {
1269 status = hdd_get_station_assoc_fail(hdd_ctx, adapter);
1270 } else {
1271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"get station info cmd type failed");
1272 status = -EINVAL;
1273 goto out;
1274 }
1275 EXIT();
1276out:
1277 return status;
1278}
1279
1280/**
1281 * wlan_hdd_cfg80211_get_station_cmd() - Handle get station vendor cmd
1282 * @wiphy: corestack handler
1283 * @wdev: wireless device
1284 * @data: data
1285 * @data_len: data length
1286 *
1287 * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION.
1288 * Validate cmd attributes and send the station info to upper layers.
1289 *
1290 * Return: Success(0) or reason code for failure
1291 */
1292static int32_t
1293hdd_cfg80211_get_station_cmd(struct wiphy *wiphy,
1294 struct wireless_dev *wdev,
1295 const void *data,
1296 int data_len)
1297{
1298 int ret;
1299
1300 vos_ssr_protect(__func__);
1301 ret = __hdd_cfg80211_get_station_cmd(wiphy, wdev, data, data_len);
1302 vos_ssr_unprotect(__func__);
1303
1304 return ret;
1305}
1306
1307/*
1308 * undef short names defined for get station command
1309 * used by __wlan_hdd_cfg80211_get_station_cmd()
1310 */
1311#undef STATION_INVALID
1312#undef STATION_INFO
1313#undef STATION_ASSOC_FAIL_REASON
1314#undef STATION_MAX
Srinivas Dasari030bad32015-02-18 23:23:54 +05301315
Sunil Duttc69bccb2014-05-26 21:30:20 +05301316#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1317
1318static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
1319 struct sk_buff *vendor_event)
1320{
1321 if (nla_put_u8(vendor_event,
1322 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
1323 stats->rate.preamble) ||
1324 nla_put_u8(vendor_event,
1325 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
1326 stats->rate.nss) ||
1327 nla_put_u8(vendor_event,
1328 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
1329 stats->rate.bw) ||
1330 nla_put_u8(vendor_event,
1331 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
1332 stats->rate.rateMcsIdx) ||
1333 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
1334 stats->rate.bitrate ) ||
1335 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
1336 stats->txMpdu ) ||
1337 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
1338 stats->rxMpdu ) ||
1339 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
1340 stats->mpduLost ) ||
1341 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
1342 stats->retries) ||
1343 nla_put_u32(vendor_event,
1344 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
1345 stats->retriesShort ) ||
1346 nla_put_u32(vendor_event,
1347 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
1348 stats->retriesLong))
1349 {
1350 hddLog(VOS_TRACE_LEVEL_ERROR,
1351 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1352 return FALSE;
1353 }
1354 return TRUE;
1355}
1356
1357static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
1358 struct sk_buff *vendor_event)
1359{
1360 u32 i = 0;
1361 struct nlattr *rateInfo;
1362 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
1363 stats->type) ||
1364 nla_put(vendor_event,
1365 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
1366 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
1367 nla_put_u32(vendor_event,
1368 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
1369 stats->capabilities) ||
1370 nla_put_u32(vendor_event,
1371 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
1372 stats->numRate))
1373 {
1374 hddLog(VOS_TRACE_LEVEL_ERROR,
1375 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1376 goto error;
1377 }
1378
1379 rateInfo = nla_nest_start(vendor_event,
1380 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301381 if(!rateInfo)
1382 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301383 for (i = 0; i < stats->numRate; i++)
1384 {
1385 struct nlattr *rates;
1386 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
1387 stats->rateStats +
1388 (i * sizeof(tSirWifiRateStat)));
1389 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301390 if(!rates)
1391 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301392
1393 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
1394 {
1395 hddLog(VOS_TRACE_LEVEL_ERROR,
1396 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1397 return FALSE;
1398 }
1399 nla_nest_end(vendor_event, rates);
1400 }
1401 nla_nest_end(vendor_event, rateInfo);
1402
1403 return TRUE;
1404error:
1405 return FALSE;
1406}
1407
1408static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
1409 struct sk_buff *vendor_event)
1410{
1411 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
1412 stats->ac ) ||
1413 nla_put_u32(vendor_event,
1414 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
1415 stats->txMpdu ) ||
1416 nla_put_u32(vendor_event,
1417 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
1418 stats->rxMpdu ) ||
1419 nla_put_u32(vendor_event,
1420 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
1421 stats->txMcast ) ||
1422 nla_put_u32(vendor_event,
1423 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
1424 stats->rxMcast ) ||
1425 nla_put_u32(vendor_event,
1426 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
1427 stats->rxAmpdu ) ||
1428 nla_put_u32(vendor_event,
1429 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
1430 stats->txAmpdu ) ||
1431 nla_put_u32(vendor_event,
1432 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
1433 stats->mpduLost )||
1434 nla_put_u32(vendor_event,
1435 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
1436 stats->retries ) ||
1437 nla_put_u32(vendor_event,
1438 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
1439 stats->retriesShort ) ||
1440 nla_put_u32(vendor_event,
1441 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
1442 stats->retriesLong ) ||
1443 nla_put_u32(vendor_event,
1444 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
1445 stats->contentionTimeMin ) ||
1446 nla_put_u32(vendor_event,
1447 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
1448 stats->contentionTimeMax ) ||
1449 nla_put_u32(vendor_event,
1450 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
1451 stats->contentionTimeAvg ) ||
1452 nla_put_u32(vendor_event,
1453 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
1454 stats->contentionNumSamples ))
1455 {
1456 hddLog(VOS_TRACE_LEVEL_ERROR,
1457 FL("QCA_WLAN_VENDOR_ATTR put fail") );
1458 return FALSE;
1459 }
1460 return TRUE;
1461}
1462
1463static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
1464 struct sk_buff *vendor_event)
1465{
Dino Myclec8f3f332014-07-21 16:48:27 +05301466 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301467 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
1468 nla_put(vendor_event,
1469 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
1470 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
1471 nla_put_u32(vendor_event,
1472 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
1473 stats->state ) ||
1474 nla_put_u32(vendor_event,
1475 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
1476 stats->roaming ) ||
1477 nla_put_u32(vendor_event,
1478 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
1479 stats->capabilities ) ||
1480 nla_put(vendor_event,
1481 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
1482 strlen(stats->ssid), stats->ssid) ||
1483 nla_put(vendor_event,
1484 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
1485 WNI_CFG_BSSID_LEN, stats->bssid) ||
1486 nla_put(vendor_event,
1487 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
1488 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
1489 nla_put(vendor_event,
1490 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
1491 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
1492 )
1493 {
1494 hddLog(VOS_TRACE_LEVEL_ERROR,
1495 FL("QCA_WLAN_VENDOR_ATTR put fail") );
1496 return FALSE;
1497 }
1498 return TRUE;
1499}
1500
Dino Mycle3b9536d2014-07-09 22:05:24 +05301501static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
1502 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301503 struct sk_buff *vendor_event)
1504{
1505 int i = 0;
1506 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301507 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1508 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05301509 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301510
Sunil Duttc69bccb2014-05-26 21:30:20 +05301511 if (FALSE == put_wifi_interface_info(
1512 &pWifiIfaceStat->info,
1513 vendor_event))
1514 {
1515 hddLog(VOS_TRACE_LEVEL_ERROR,
1516 FL("QCA_WLAN_VENDOR_ATTR put fail") );
1517 return FALSE;
1518
1519 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05301520 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
1521 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
1522 if (NULL == pWifiIfaceStatTL)
1523 {
1524 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
1525 return FALSE;
1526 }
1527
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05301528 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
1529 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1530 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1531 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1532
1533 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1534 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1535 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1536 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301537
1538 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1539 {
1540 if (VOS_STATUS_SUCCESS ==
1541 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1542 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1543 {
1544 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1545 * obtained from TL structure
1546 */
1547
1548 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1549 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301550 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1551
Srinivas Dasari98947432014-11-07 19:41:24 +05301552 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1553 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1554 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1555 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1556 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1557 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1558 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1559 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301560
Srinivas Dasari98947432014-11-07 19:41:24 +05301561 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1562 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1563 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1564 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1565 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1566 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1567 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1568 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301569
Srinivas Dasari98947432014-11-07 19:41:24 +05301570 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1571 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1572 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1573 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1574 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1575 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1576 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1577 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301578 }
1579 else
1580 {
1581 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1582 }
1583
Dino Mycle3b9536d2014-07-09 22:05:24 +05301584 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1585 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1586 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1587 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1588 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1589 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1590 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1591 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1592 }
1593 else
1594 {
1595 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1596 }
1597
1598
Sunil Duttc69bccb2014-05-26 21:30:20 +05301599
1600 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301601 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1602 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
1603 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301604 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1605 pWifiIfaceStat->beaconRx) ||
1606 nla_put_u32(vendor_event,
1607 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1608 pWifiIfaceStat->mgmtRx) ||
1609 nla_put_u32(vendor_event,
1610 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1611 pWifiIfaceStat->mgmtActionRx) ||
1612 nla_put_u32(vendor_event,
1613 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1614 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301615 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301616 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1617 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301618 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301619 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1620 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301621 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301622 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1623 pWifiIfaceStat->rssiAck))
1624 {
1625 hddLog(VOS_TRACE_LEVEL_ERROR,
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05301626 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1627 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301628 return FALSE;
1629 }
1630
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05301631#ifdef FEATURE_EXT_LL_STAT
1632 /*
1633 * Ensure when EXT_LL_STAT is supported by both host and fwr,
1634 * then host should send Leaky AP stats to upper layer,
1635 * otherwise no need to send these stats.
1636 */
1637 if(sme_IsFeatureSupportedByFW(EXT_LL_STAT) &&
1638 sme_IsFeatureSupportedByDriver(EXT_LL_STAT)
1639 )
1640 {
1641 hddLog(VOS_TRACE_LEVEL_INFO,
1642 FL("EXT_LL_STAT is supported by fwr and host %u %u %u %llu"),
1643 pWifiIfaceStat->leakyApStat.is_leaky_ap,
1644 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked,
1645 pWifiIfaceStat->leakyApStat.rx_leak_window,
1646 pWifiIfaceStat->leakyApStat.avg_bcn_spread);
1647 if (nla_put_u32(vendor_event,
1648 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_DETECTED,
1649 pWifiIfaceStat->leakyApStat.is_leaky_ap) ||
1650 nla_put_u32(vendor_event,
1651 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_AVG_NUM_FRAMES_LEAKED,
1652 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked) ||
1653 nla_put_u32(vendor_event,
1654 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_GUARD_TIME,
1655 pWifiIfaceStat->leakyApStat.rx_leak_window) ||
1656 nla_put_u64(vendor_event,
1657 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_AVERAGE_TSF_OFFSET,
1658 pWifiIfaceStat->leakyApStat.avg_bcn_spread))
1659 {
1660 hddLog(VOS_TRACE_LEVEL_ERROR,
1661 FL("EXT_LL_STAT put fail"));
1662 vos_mem_free(pWifiIfaceStatTL);
1663 return FALSE;
1664 }
1665 }
1666#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +05301667 wmmInfo = nla_nest_start(vendor_event,
1668 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301669 if(!wmmInfo)
1670 {
1671 vos_mem_free(pWifiIfaceStatTL);
1672 return FALSE;
1673 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301674 for (i = 0; i < WIFI_AC_MAX; i++)
1675 {
1676 struct nlattr *wmmStats;
1677 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301678 if(!wmmStats)
1679 {
1680 vos_mem_free(pWifiIfaceStatTL);
1681 return FALSE;
1682 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301683 if (FALSE == put_wifi_wmm_ac_stat(
1684 &pWifiIfaceStat->AccessclassStats[i],
1685 vendor_event))
1686 {
1687 hddLog(VOS_TRACE_LEVEL_ERROR,
1688 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301689 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301690 return FALSE;
1691 }
1692
1693 nla_nest_end(vendor_event, wmmStats);
1694 }
1695 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301696 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301697 return TRUE;
1698}
1699
1700static tSirWifiInterfaceMode
1701 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1702{
1703 switch (deviceMode)
1704 {
1705 case WLAN_HDD_INFRA_STATION:
1706 return WIFI_INTERFACE_STA;
1707 case WLAN_HDD_SOFTAP:
1708 return WIFI_INTERFACE_SOFTAP;
1709 case WLAN_HDD_P2P_CLIENT:
1710 return WIFI_INTERFACE_P2P_CLIENT;
1711 case WLAN_HDD_P2P_GO:
1712 return WIFI_INTERFACE_P2P_GO;
1713 case WLAN_HDD_IBSS:
1714 return WIFI_INTERFACE_IBSS;
1715 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301716 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301717 }
1718}
1719
1720static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1721 tpSirWifiInterfaceInfo pInfo)
1722{
1723 v_U8_t *staMac = NULL;
1724 hdd_station_ctx_t *pHddStaCtx;
1725 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1726 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1727
1728 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1729
1730 vos_mem_copy(pInfo->macAddr,
1731 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1732
1733 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1734 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1735 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1736 {
1737 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1738 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1739 {
1740 pInfo->state = WIFI_DISCONNECTED;
1741 }
1742 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1743 {
1744 hddLog(VOS_TRACE_LEVEL_ERROR,
1745 "%s: Session ID %d, Connection is in progress", __func__,
1746 pAdapter->sessionId);
1747 pInfo->state = WIFI_ASSOCIATING;
1748 }
1749 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1750 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1751 {
1752 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1753 hddLog(VOS_TRACE_LEVEL_ERROR,
1754 "%s: client " MAC_ADDRESS_STR
1755 " is in the middle of WPS/EAPOL exchange.", __func__,
1756 MAC_ADDR_ARRAY(staMac));
1757 pInfo->state = WIFI_AUTHENTICATING;
1758 }
1759 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1760 {
1761 pInfo->state = WIFI_ASSOCIATED;
1762 vos_mem_copy(pInfo->bssid,
1763 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1764 vos_mem_copy(pInfo->ssid,
1765 pHddStaCtx->conn_info.SSID.SSID.ssId,
1766 pHddStaCtx->conn_info.SSID.SSID.length);
1767 //NULL Terminate the string.
1768 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1769 }
1770 }
1771 vos_mem_copy(pInfo->countryStr,
1772 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1773
1774 vos_mem_copy(pInfo->apCountryStr,
1775 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1776
1777 return TRUE;
1778}
1779
1780/*
1781 * hdd_link_layer_process_peer_stats () - This function is called after
1782 * receiving Link Layer Peer statistics from FW.This function converts
1783 * the firmware data to the NL data and sends the same to the kernel/upper
1784 * layers.
1785 */
1786static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1787 v_VOID_t *pData)
1788{
1789 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301790 tpSirWifiPeerStat pWifiPeerStat;
1791 tpSirWifiPeerInfo pWifiPeerInfo;
1792 struct nlattr *peerInfo;
1793 struct sk_buff *vendor_event;
1794 int status, i;
1795
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301796 ENTER();
1797
Sunil Duttc69bccb2014-05-26 21:30:20 +05301798 status = wlan_hdd_validate_context(pHddCtx);
1799 if (0 != status)
1800 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301801 return;
1802 }
1803
1804 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1805
1806 hddLog(VOS_TRACE_LEVEL_INFO,
1807 "LL_STATS_PEER_ALL : numPeers %u",
1808 pWifiPeerStat->numPeers);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301809 /*
1810 * Allocate a size of 4096 for the peer stats comprising
1811 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1812 * sizeof (tSirWifiRateStat).Each field is put with an
1813 * NL attribute.The size of 4096 is considered assuming
1814 * that number of rates shall not exceed beyond 50 with
1815 * the sizeof (tSirWifiRateStat) being 32.
1816 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301817 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1818 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301819 if (!vendor_event)
1820 {
1821 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301822 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301823 __func__);
1824 return;
1825 }
1826 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301827 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1828 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
1829 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301830 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1831 pWifiPeerStat->numPeers))
1832 {
1833 hddLog(VOS_TRACE_LEVEL_ERROR,
1834 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1835 kfree_skb(vendor_event);
1836 return;
1837 }
1838
1839 peerInfo = nla_nest_start(vendor_event,
1840 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301841 if(!peerInfo)
1842 {
1843 hddLog(VOS_TRACE_LEVEL_ERROR,
1844 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1845 __func__);
1846 kfree_skb(vendor_event);
1847 return;
1848 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301849
1850 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1851 pWifiPeerStat->peerInfo);
1852
1853 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1854 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301855 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301856 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301857
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301858 if(!peers)
1859 {
1860 hddLog(VOS_TRACE_LEVEL_ERROR,
1861 "%s: peer stats put fail",
1862 __func__);
1863 kfree_skb(vendor_event);
1864 return;
1865 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301866 if (FALSE == put_wifi_peer_info(
1867 pWifiPeerInfo, vendor_event))
1868 {
1869 hddLog(VOS_TRACE_LEVEL_ERROR,
1870 "%s: put_wifi_peer_info put fail", __func__);
1871 kfree_skb(vendor_event);
1872 return;
1873 }
1874
1875 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1876 pWifiPeerStat->peerInfo +
1877 (i * sizeof(tSirWifiPeerInfo)) +
1878 (numRate * sizeof (tSirWifiRateStat)));
1879 nla_nest_end(vendor_event, peers);
1880 }
1881 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301882 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301883 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301884}
1885
1886/*
1887 * hdd_link_layer_process_iface_stats () - This function is called after
1888 * receiving Link Layer Interface statistics from FW.This function converts
1889 * the firmware data to the NL data and sends the same to the kernel/upper
1890 * layers.
1891 */
1892static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1893 v_VOID_t *pData)
1894{
1895 tpSirWifiIfaceStat pWifiIfaceStat;
1896 struct sk_buff *vendor_event;
1897 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1898 int status;
1899
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301900 ENTER();
1901
Sunil Duttc69bccb2014-05-26 21:30:20 +05301902 status = wlan_hdd_validate_context(pHddCtx);
1903 if (0 != status)
1904 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301905 return;
1906 }
1907 /*
1908 * Allocate a size of 4096 for the interface stats comprising
1909 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1910 * assuming that all these fit with in the limit.Please take
1911 * a call on the limit based on the data requirements on
1912 * interface statistics.
1913 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301914 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1915 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301916 if (!vendor_event)
1917 {
1918 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301919 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301920 return;
1921 }
1922
1923 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1924
Dino Mycle3b9536d2014-07-09 22:05:24 +05301925
1926 if (FALSE == hdd_get_interface_info( pAdapter,
1927 &pWifiIfaceStat->info))
1928 {
1929 hddLog(VOS_TRACE_LEVEL_ERROR,
1930 FL("hdd_get_interface_info get fail") );
1931 kfree_skb(vendor_event);
1932 return;
1933 }
1934
1935 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1936 vendor_event))
1937 {
1938 hddLog(VOS_TRACE_LEVEL_ERROR,
1939 FL("put_wifi_iface_stats fail") );
1940 kfree_skb(vendor_event);
1941 return;
1942 }
1943
Sunil Duttc69bccb2014-05-26 21:30:20 +05301944 hddLog(VOS_TRACE_LEVEL_INFO,
1945 "WMI_LINK_STATS_IFACE Data");
1946
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301947 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301948
1949 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301950}
1951
1952/*
1953 * hdd_link_layer_process_radio_stats () - This function is called after
1954 * receiving Link Layer Radio statistics from FW.This function converts
1955 * the firmware data to the NL data and sends the same to the kernel/upper
1956 * layers.
1957 */
1958static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1959 v_VOID_t *pData)
1960{
1961 int status, i;
1962 tpSirWifiRadioStat pWifiRadioStat;
1963 tpSirWifiChannelStats pWifiChannelStats;
1964 struct sk_buff *vendor_event;
1965 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1966 struct nlattr *chList;
1967
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301968 ENTER();
1969
Sunil Duttc69bccb2014-05-26 21:30:20 +05301970 status = wlan_hdd_validate_context(pHddCtx);
1971 if (0 != status)
1972 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301973 return;
1974 }
1975 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1976
1977 hddLog(VOS_TRACE_LEVEL_INFO,
1978 "LL_STATS_RADIO"
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05301979 " number of radios = %u"
Sunil Duttc69bccb2014-05-26 21:30:20 +05301980 " radio is %d onTime is %u "
1981 " txTime is %u rxTime is %u "
1982 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301983 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301984 " onTimePnoScan is %u onTimeHs20 is %u "
1985 " numChannels is %u",
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05301986 NUM_RADIOS,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301987 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1988 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1989 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301990 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301991 pWifiRadioStat->onTimeRoamScan,
1992 pWifiRadioStat->onTimePnoScan,
1993 pWifiRadioStat->onTimeHs20,
1994 pWifiRadioStat->numChannels);
1995 /*
1996 * Allocate a size of 4096 for the Radio stats comprising
1997 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1998 * (tSirWifiChannelStats).Each channel data is put with an
1999 * NL attribute.The size of 4096 is considered assuming that
2000 * number of channels shall not exceed beyond 60 with the
2001 * sizeof (tSirWifiChannelStats) being 24 bytes.
2002 */
2003
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302004 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
2005 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302006 if (!vendor_event)
2007 {
2008 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302009 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05302010 return;
2011 }
2012
2013 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302014 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
2015 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
2016 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302017 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
2018 pWifiRadioStat->radio) ||
2019 nla_put_u32(vendor_event,
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05302020 QCA_WLAN_VENDOR_ATTR_LL_STATS_NUM_RADIOS,
2021 NUM_RADIOS) ||
2022 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302023 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
2024 pWifiRadioStat->onTime) ||
2025 nla_put_u32(vendor_event,
2026 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
2027 pWifiRadioStat->txTime) ||
2028 nla_put_u32(vendor_event,
2029 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
2030 pWifiRadioStat->rxTime) ||
2031 nla_put_u32(vendor_event,
2032 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
2033 pWifiRadioStat->onTimeScan) ||
2034 nla_put_u32(vendor_event,
2035 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
2036 pWifiRadioStat->onTimeNbd) ||
2037 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302038 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
2039 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05302040 nla_put_u32(vendor_event,
2041 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
2042 pWifiRadioStat->onTimeRoamScan) ||
2043 nla_put_u32(vendor_event,
2044 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
2045 pWifiRadioStat->onTimePnoScan) ||
2046 nla_put_u32(vendor_event,
2047 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
2048 pWifiRadioStat->onTimeHs20) ||
2049 nla_put_u32(vendor_event,
2050 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
2051 pWifiRadioStat->numChannels))
2052 {
2053 hddLog(VOS_TRACE_LEVEL_ERROR,
2054 FL("QCA_WLAN_VENDOR_ATTR put fail"));
2055 kfree_skb(vendor_event);
2056 return ;
2057 }
2058
2059 chList = nla_nest_start(vendor_event,
2060 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302061 if(!chList)
2062 {
2063 hddLog(VOS_TRACE_LEVEL_ERROR,
2064 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
2065 __func__);
2066 kfree_skb(vendor_event);
2067 return;
2068 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302069 for (i = 0; i < pWifiRadioStat->numChannels; i++)
2070 {
2071 struct nlattr *chInfo;
2072
2073 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
2074 pWifiRadioStat->channels +
2075 (i * sizeof(tSirWifiChannelStats)));
2076
Sunil Duttc69bccb2014-05-26 21:30:20 +05302077 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302078 if(!chInfo)
2079 {
2080 hddLog(VOS_TRACE_LEVEL_ERROR,
2081 "%s: failed to put chInfo",
2082 __func__);
2083 kfree_skb(vendor_event);
2084 return;
2085 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302086
2087 if (nla_put_u32(vendor_event,
2088 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
2089 pWifiChannelStats->channel.width) ||
2090 nla_put_u32(vendor_event,
2091 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
2092 pWifiChannelStats->channel.centerFreq) ||
2093 nla_put_u32(vendor_event,
2094 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
2095 pWifiChannelStats->channel.centerFreq0) ||
2096 nla_put_u32(vendor_event,
2097 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
2098 pWifiChannelStats->channel.centerFreq1) ||
2099 nla_put_u32(vendor_event,
2100 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
2101 pWifiChannelStats->onTime) ||
2102 nla_put_u32(vendor_event,
2103 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
2104 pWifiChannelStats->ccaBusyTime))
2105 {
2106 hddLog(VOS_TRACE_LEVEL_ERROR,
2107 FL("cfg80211_vendor_event_alloc failed") );
2108 kfree_skb(vendor_event);
2109 return ;
2110 }
2111 nla_nest_end(vendor_event, chInfo);
2112 }
2113 nla_nest_end(vendor_event, chList);
2114
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302115 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302116
2117 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302118 return;
2119}
2120
2121/*
2122 * hdd_link_layer_stats_ind_callback () - This function is called after
2123 * receiving Link Layer indications from FW.This callback converts the firmware
2124 * data to the NL data and send the same to the kernel/upper layers.
2125 */
2126static void hdd_link_layer_stats_ind_callback ( void *pCtx,
2127 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05302128 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302129{
Dino Mycled3d50022014-07-07 12:58:25 +05302130 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
2131 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302132 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05302133 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302134 int status;
2135
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302136 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302137
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302138 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302139 if (0 != status)
2140 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302141 return;
2142 }
2143
Dino Mycled3d50022014-07-07 12:58:25 +05302144 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
2145 if (NULL == pAdapter)
2146 {
2147 hddLog(VOS_TRACE_LEVEL_ERROR,
2148 FL(" MAC address %pM does not exist with host"),
2149 macAddr);
2150 return;
2151 }
2152
Sunil Duttc69bccb2014-05-26 21:30:20 +05302153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302154 "%s: Interface: %s LLStats indType: %d", __func__,
2155 pAdapter->dev->name, indType);
2156
Sunil Duttc69bccb2014-05-26 21:30:20 +05302157 switch (indType)
2158 {
2159 case SIR_HAL_LL_STATS_RESULTS_RSP:
2160 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302161 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302162 "LL_STATS RESP paramID = 0x%x, ifaceId = %u MAC: %pM "
2163 "respId = %u, moreResultToFollow = %u",
2164 linkLayerStatsResults->paramId, linkLayerStatsResults->ifaceId,
2165 macAddr, linkLayerStatsResults->respId,
2166 linkLayerStatsResults->moreResultToFollow);
2167
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302168 spin_lock(&hdd_context_lock);
2169 context = &pHddCtx->ll_stats_context;
2170 /* validate response received from target */
2171 if ((context->request_id != linkLayerStatsResults->respId) ||
2172 !(context->request_bitmap & linkLayerStatsResults->paramId))
2173 {
2174 spin_unlock(&hdd_context_lock);
2175 hddLog(LOGE,
2176 FL("Error : Request id %d response id %d request bitmap 0x%x"
2177 "response bitmap 0x%x"),
2178 context->request_id, linkLayerStatsResults->respId,
2179 context->request_bitmap, linkLayerStatsResults->paramId);
2180 return;
2181 }
2182 spin_unlock(&hdd_context_lock);
2183
Sunil Duttc69bccb2014-05-26 21:30:20 +05302184 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
2185 {
2186 hdd_link_layer_process_radio_stats(pAdapter,
2187 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302188 spin_lock(&hdd_context_lock);
2189 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
2190 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302191 }
2192 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
2193 {
2194 hdd_link_layer_process_iface_stats(pAdapter,
2195 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302196 spin_lock(&hdd_context_lock);
2197 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
2198 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302199 }
2200 else if ( linkLayerStatsResults->paramId &
2201 WMI_LINK_STATS_ALL_PEER )
2202 {
2203 hdd_link_layer_process_peer_stats(pAdapter,
2204 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302205 spin_lock(&hdd_context_lock);
2206 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
2207 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302208 } /* WMI_LINK_STATS_ALL_PEER */
2209 else
2210 {
2211 hddLog(VOS_TRACE_LEVEL_ERROR,
2212 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
2213 }
2214
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302215 spin_lock(&hdd_context_lock);
2216 /* complete response event if all requests are completed */
2217 if (0 == context->request_bitmap)
2218 complete(&context->response_event);
2219 spin_unlock(&hdd_context_lock);
2220
Sunil Duttc69bccb2014-05-26 21:30:20 +05302221 break;
2222 }
2223 default:
2224 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
2225 break;
2226 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302227
2228 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302229 return;
2230}
2231
2232const struct
2233nla_policy
2234qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
2235{
2236 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
2237 { .type = NLA_U32 },
2238 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
2239 { .type = NLA_U32 },
2240};
2241
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302242static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
2243 struct wireless_dev *wdev,
2244 const void *data,
2245 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302246{
2247 int status;
2248 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302249 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302250 struct net_device *dev = wdev->netdev;
2251 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2252 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2253
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302254 ENTER();
2255
Sunil Duttc69bccb2014-05-26 21:30:20 +05302256 status = wlan_hdd_validate_context(pHddCtx);
2257 if (0 != status)
2258 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302259 return -EINVAL;
2260 }
2261
2262 if (NULL == pAdapter)
2263 {
2264 hddLog(VOS_TRACE_LEVEL_ERROR,
2265 FL("HDD adapter is Null"));
2266 return -ENODEV;
2267 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302268 /* check the LLStats Capability */
2269 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2270 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2271 {
Anurag Chouhan65ea6dc2016-10-25 19:59:14 +05302272 hddLog(VOS_TRACE_LEVEL_WARN,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302273 FL("Link Layer Statistics not supported by Firmware"));
2274 return -EINVAL;
2275 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302276
2277 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
2278 (struct nlattr *)data,
2279 data_len, qca_wlan_vendor_ll_set_policy))
2280 {
2281 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2282 return -EINVAL;
2283 }
2284 if (!tb_vendor
2285 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
2286 {
2287 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
2288 return -EINVAL;
2289 }
2290 if (!tb_vendor[
2291 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
2292 {
2293 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
2294 return -EINVAL;
2295 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302296 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302297 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302298
Dino Mycledf0a5d92014-07-04 09:41:55 +05302299 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302300 nla_get_u32(
2301 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
2302
Dino Mycledf0a5d92014-07-04 09:41:55 +05302303 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302304 nla_get_u32(
2305 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
2306
Dino Mycled3d50022014-07-07 12:58:25 +05302307 vos_mem_copy(linkLayerStatsSetReq.macAddr,
2308 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302309
2310
2311 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302312 "LL_STATS_SET reqId = %d, MAC = %pM, mpduSizeThreshold = %d "
2313 "Statistics Gathering = %d ",
2314 linkLayerStatsSetReq.reqId, linkLayerStatsSetReq.macAddr,
2315 linkLayerStatsSetReq.mpduSizeThreshold,
2316 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302317
2318 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
2319 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05302320 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302321 {
2322 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2323 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302324 return -EINVAL;
2325
2326 }
Srinivas Dasari98947432014-11-07 19:41:24 +05302327
Sunil Duttc69bccb2014-05-26 21:30:20 +05302328 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302329 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302330 {
2331 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2332 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302333 return -EINVAL;
2334 }
2335
2336 pAdapter->isLinkLayerStatsSet = 1;
2337
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302338 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302339 return 0;
2340}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302341static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
2342 struct wireless_dev *wdev,
2343 const void *data,
2344 int data_len)
2345{
2346 int ret = 0;
2347
2348 vos_ssr_protect(__func__);
2349 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
2350 vos_ssr_unprotect(__func__);
2351
2352 return ret;
2353}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302354
2355const struct
2356nla_policy
2357qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
2358{
2359 /* Unsigned 32bit value provided by the caller issuing the GET stats
2360 * command. When reporting
2361 * the stats results, the driver uses the same value to indicate
2362 * which GET request the results
2363 * correspond to.
2364 */
2365 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
2366
2367 /* Unsigned 32bit value . bit mask to identify what statistics are
2368 requested for retrieval */
2369 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
2370};
2371
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302372static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2373 struct wireless_dev *wdev,
2374 const void *data,
2375 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302376{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302377 unsigned long rc;
2378 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302379 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2380 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302381 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302382 struct net_device *dev = wdev->netdev;
2383 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05302384 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302385 int status;
2386
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302387 ENTER();
2388
Sunil Duttc69bccb2014-05-26 21:30:20 +05302389 status = wlan_hdd_validate_context(pHddCtx);
2390 if (0 != status)
2391 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302392 return -EINVAL ;
2393 }
2394
2395 if (NULL == pAdapter)
2396 {
2397 hddLog(VOS_TRACE_LEVEL_FATAL,
2398 "%s: HDD adapter is Null", __func__);
2399 return -ENODEV;
2400 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05302401
2402 if (pHddStaCtx == NULL)
2403 {
2404 hddLog(VOS_TRACE_LEVEL_FATAL,
2405 "%s: HddStaCtx is Null", __func__);
2406 return -ENODEV;
2407 }
2408
Dino Mycledf0a5d92014-07-04 09:41:55 +05302409 /* check the LLStats Capability */
2410 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2411 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2412 {
2413 hddLog(VOS_TRACE_LEVEL_ERROR,
2414 FL("Link Layer Statistics not supported by Firmware"));
2415 return -EINVAL;
2416 }
2417
Sunil Duttc69bccb2014-05-26 21:30:20 +05302418
2419 if (!pAdapter->isLinkLayerStatsSet)
2420 {
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05302421 hddLog(VOS_TRACE_LEVEL_ERROR,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302422 "%s: isLinkLayerStatsSet : %d",
2423 __func__, pAdapter->isLinkLayerStatsSet);
2424 return -EINVAL;
2425 }
2426
Mukul Sharma10313ba2015-07-29 19:14:39 +05302427 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
2428 {
2429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2430 "%s: Roaming in progress, so unable to proceed this request", __func__);
2431 return -EBUSY;
2432 }
2433
Sunil Duttc69bccb2014-05-26 21:30:20 +05302434 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2435 (struct nlattr *)data,
2436 data_len, qca_wlan_vendor_ll_get_policy))
2437 {
2438 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2439 return -EINVAL;
2440 }
2441
2442 if (!tb_vendor
2443 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2444 {
2445 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2446 return -EINVAL;
2447 }
2448
2449 if (!tb_vendor
2450 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2451 {
2452 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2453 return -EINVAL;
2454 }
2455
Sunil Duttc69bccb2014-05-26 21:30:20 +05302456
Dino Mycledf0a5d92014-07-04 09:41:55 +05302457 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302458 nla_get_u32( tb_vendor[
2459 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302460 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302461 nla_get_u32( tb_vendor[
2462 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2463
Dino Mycled3d50022014-07-07 12:58:25 +05302464 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2465 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302466
2467 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302468 "LL_STATS_GET reqId = %d, MAC = %pM, paramIdMask = %d",
2469 linkLayerStatsGetReq.reqId, linkLayerStatsGetReq.macAddr,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302470 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302471
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302472 spin_lock(&hdd_context_lock);
2473 context = &pHddCtx->ll_stats_context;
2474 context->request_id = linkLayerStatsGetReq.reqId;
2475 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
2476 INIT_COMPLETION(context->response_event);
2477 spin_unlock(&hdd_context_lock);
2478
Sunil Duttc69bccb2014-05-26 21:30:20 +05302479 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302480 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302481 {
2482 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2483 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302484 return -EINVAL;
2485 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302486
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302487 rc = wait_for_completion_timeout(&context->response_event,
2488 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
2489 if (!rc)
2490 {
2491 hddLog(LOGE,
2492 FL("Target response timed out request id %d request bitmap 0x%x"),
2493 context->request_id, context->request_bitmap);
2494 return -ETIMEDOUT;
2495 }
2496
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302497 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302498 return 0;
2499}
2500
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302501static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2502 struct wireless_dev *wdev,
2503 const void *data,
2504 int data_len)
2505{
2506 int ret = 0;
2507
2508 vos_ssr_protect(__func__);
2509 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2510 vos_ssr_unprotect(__func__);
2511
2512 return ret;
2513}
2514
Sunil Duttc69bccb2014-05-26 21:30:20 +05302515const struct
2516nla_policy
2517qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2518{
2519 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2520 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2521 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2522 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2523};
2524
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302525static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2526 struct wireless_dev *wdev,
2527 const void *data,
2528 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302529{
2530 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2531 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302532 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302533 struct net_device *dev = wdev->netdev;
2534 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2535 u32 statsClearReqMask;
2536 u8 stopReq;
2537 int status;
2538
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302539 ENTER();
2540
Sunil Duttc69bccb2014-05-26 21:30:20 +05302541 status = wlan_hdd_validate_context(pHddCtx);
2542 if (0 != status)
2543 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302544 return -EINVAL;
2545 }
2546
2547 if (NULL == pAdapter)
2548 {
2549 hddLog(VOS_TRACE_LEVEL_FATAL,
2550 "%s: HDD adapter is Null", __func__);
2551 return -ENODEV;
2552 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302553 /* check the LLStats Capability */
2554 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2555 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2556 {
2557 hddLog(VOS_TRACE_LEVEL_ERROR,
2558 FL("Enable LLStats Capability"));
2559 return -EINVAL;
2560 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302561
2562 if (!pAdapter->isLinkLayerStatsSet)
2563 {
2564 hddLog(VOS_TRACE_LEVEL_FATAL,
2565 "%s: isLinkLayerStatsSet : %d",
2566 __func__, pAdapter->isLinkLayerStatsSet);
2567 return -EINVAL;
2568 }
2569
2570 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2571 (struct nlattr *)data,
2572 data_len, qca_wlan_vendor_ll_clr_policy))
2573 {
2574 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2575 return -EINVAL;
2576 }
2577
2578 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2579
2580 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2581 {
2582 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2583 return -EINVAL;
2584
2585 }
2586
Sunil Duttc69bccb2014-05-26 21:30:20 +05302587
Dino Mycledf0a5d92014-07-04 09:41:55 +05302588 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302589 nla_get_u32(
2590 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2591
Dino Mycledf0a5d92014-07-04 09:41:55 +05302592 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302593 nla_get_u8(
2594 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2595
2596 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302597 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302598
Dino Mycled3d50022014-07-07 12:58:25 +05302599 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2600 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302601
2602 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302603 "LL_STATS_CLEAR reqId = %d, MAC = %pM,"
2604 "statsClearReqMask = 0x%X, stopReq = %d",
2605 linkLayerStatsClearReq.reqId,
2606 linkLayerStatsClearReq.macAddr,
2607 linkLayerStatsClearReq.statsClearReqMask,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302608 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302609
2610 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302611 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302612 {
2613 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302614 hdd_station_ctx_t *pHddStaCtx;
2615
2616 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2617 if (VOS_STATUS_SUCCESS !=
2618 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2619 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2620 {
2621 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2622 "WLANTL_ClearInterfaceStats Failed", __func__);
2623 return -EINVAL;
2624 }
2625 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2626 (statsClearReqMask & WIFI_STATS_IFACE)) {
2627 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2628 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2629 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2630 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2631 }
2632
Sunil Duttc69bccb2014-05-26 21:30:20 +05302633 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2634 2 * sizeof(u32) +
2635 NLMSG_HDRLEN);
2636
2637 if (temp_skbuff != NULL)
2638 {
2639
2640 if (nla_put_u32(temp_skbuff,
2641 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2642 statsClearReqMask) ||
2643 nla_put_u32(temp_skbuff,
2644 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2645 stopReq))
2646 {
2647 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2648 kfree_skb(temp_skbuff);
2649 return -EINVAL;
2650 }
2651 /* If the ask is to stop the stats collection as part of clear
2652 * (stopReq = 1) , ensure that no further requests of get
2653 * go to the firmware by having isLinkLayerStatsSet set to 0.
2654 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302655 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302656 * case the firmware is just asked to clear the statistics.
2657 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302658 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302659 pAdapter->isLinkLayerStatsSet = 0;
2660 return cfg80211_vendor_cmd_reply(temp_skbuff);
2661 }
2662 return -ENOMEM;
2663 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302664
2665 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302666 return -EINVAL;
2667}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302668static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2669 struct wireless_dev *wdev,
2670 const void *data,
2671 int data_len)
2672{
2673 int ret = 0;
2674
2675 vos_ssr_protect(__func__);
2676 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2677 vos_ssr_unprotect(__func__);
2678
2679 return ret;
2680
2681
2682}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302683#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2684
Dino Mycle6fb96c12014-06-10 11:52:40 +05302685#ifdef WLAN_FEATURE_EXTSCAN
2686static const struct nla_policy
2687wlan_hdd_extscan_config_policy
2688 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2689{
2690 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2691 { .type = NLA_U32 },
2692 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2693 { .type = NLA_U32 },
2694 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2695 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2696 { .type = NLA_U32 },
2697 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2698 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2699
2700 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2701 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2702 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2703 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2704 { .type = NLA_U8 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302705 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD] =
2706 { .type = NLA_U32 },
2707 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT] =
2708 { .type = NLA_U32 },
2709 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT] =
2710 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302711 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2712 { .type = NLA_U32 },
2713 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2714 { .type = NLA_U32 },
2715 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2716 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302717 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT] =
2718 { .type = NLA_U8 },
2719 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302720 { .type = NLA_U8 },
2721 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2722 { .type = NLA_U8 },
2723 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2724 { .type = NLA_U8 },
2725
2726 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2727 { .type = NLA_U32 },
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05302728 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] = {
2729 .type = NLA_UNSPEC,
2730 .len = HDD_MAC_ADDR_LEN},
Dino Mycle6fb96c12014-06-10 11:52:40 +05302731 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2732 { .type = NLA_S32 },
2733 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2734 { .type = NLA_S32 },
2735 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2736 { .type = NLA_U32 },
2737 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2738 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302739 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE] =
2740 { .type = NLA_U32 },
2741 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID] =
2742 { .type = NLA_BINARY,
2743 .len = IEEE80211_MAX_SSID_LEN + 1 },
2744 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302745 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302746 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID] =
2747 { .type = NLA_U32 },
2748 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND] =
2749 { .type = NLA_U8 },
2750 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW] =
2751 { .type = NLA_S32 },
2752 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH] =
2753 { .type = NLA_S32 },
2754 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS] =
2755 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302756};
2757
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302758/**
2759 * wlan_hdd_cfg80211_extscan_get_capabilities_rsp() - response from target
2760 * @ctx: hdd global context
2761 * @data: capabilities data
2762 *
2763 * Return: none
2764 */
2765static void
2766wlan_hdd_cfg80211_extscan_get_capabilities_rsp(void *ctx, void *pMsg)
Dino Mycle6fb96c12014-06-10 11:52:40 +05302767{
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302768 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302769 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302770 tSirEXTScanCapabilitiesEvent *data =
2771 (tSirEXTScanCapabilitiesEvent *) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302772
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302773 ENTER();
2774
2775 if (wlan_hdd_validate_context(pHddCtx))
2776 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302777 return;
2778 }
2779
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302780 if (!pMsg)
2781 {
2782 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2783 return;
2784 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302785
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302786 vos_spin_lock_acquire(&hdd_context_lock);
2787
2788 context = &pHddCtx->ext_scan_context;
2789 /* validate response received from target*/
2790 if (context->request_id != data->requestId)
2791 {
2792 vos_spin_lock_release(&hdd_context_lock);
2793 hddLog(LOGE,
2794 FL("Target response id did not match: request_id %d resposne_id %d"),
2795 context->request_id, data->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302796 return;
2797 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302798 else
2799 {
2800 context->capability_response = *data;
2801 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302802 }
2803
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302804 vos_spin_lock_release(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302805
Dino Mycle6fb96c12014-06-10 11:52:40 +05302806 return;
2807}
2808
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302809/*
2810 * define short names for the global vendor params
2811 * used by wlan_hdd_send_ext_scan_capability()
2812 */
2813#define PARAM_REQUEST_ID \
2814 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
2815#define PARAM_STATUS \
2816 QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS
2817#define MAX_SCAN_CACHE_SIZE \
2818 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE
2819#define MAX_SCAN_BUCKETS \
2820 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS
2821#define MAX_AP_CACHE_PER_SCAN \
2822 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN
2823#define MAX_RSSI_SAMPLE_SIZE \
2824 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE
2825#define MAX_SCAN_RPT_THRHOLD \
2826 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD
2827#define MAX_HOTLIST_BSSIDS \
2828 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS
2829#define MAX_BSSID_HISTORY_ENTRIES \
2830 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES
2831#define MAX_HOTLIST_SSIDS \
2832 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302833#define MAX_SIGNIFICANT_WIFI_CHANGE_APS \
2834 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302835
2836static int wlan_hdd_send_ext_scan_capability(void *ctx)
2837{
2838 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2839 struct sk_buff *skb = NULL;
2840 int ret;
2841 tSirEXTScanCapabilitiesEvent *data;
2842 tANI_U32 nl_buf_len;
2843
2844 ret = wlan_hdd_validate_context(pHddCtx);
2845 if (0 != ret)
2846 {
2847 return ret;
2848 }
2849
2850 data = &(pHddCtx->ext_scan_context.capability_response);
2851
2852 nl_buf_len = NLMSG_HDRLEN;
2853 nl_buf_len += (sizeof(data->requestId) + NLA_HDRLEN) +
2854 (sizeof(data->status) + NLA_HDRLEN) +
2855 (sizeof(data->scanCacheSize) + NLA_HDRLEN) +
2856 (sizeof(data->scanBuckets) + NLA_HDRLEN) +
2857 (sizeof(data->maxApPerScan) + NLA_HDRLEN) +
2858 (sizeof(data->maxRssiSampleSize) + NLA_HDRLEN) +
2859 (sizeof(data->maxScanReportingThreshold) + NLA_HDRLEN) +
2860 (sizeof(data->maxHotlistAPs) + NLA_HDRLEN) +
2861 (sizeof(data->maxBsidHistoryEntries) + NLA_HDRLEN) +
2862 (sizeof(data->maxHotlistSSIDs) + NLA_HDRLEN);
2863
2864 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, nl_buf_len);
2865
2866 if (!skb)
2867 {
2868 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
2869 return -ENOMEM;
2870 }
2871
2872 hddLog(LOG1, "Req Id (%u) Status (%u)", data->requestId, data->status);
2873 hddLog(LOG1, "Scan cache size (%u) Scan buckets (%u) Max AP per scan (%u)",
2874 data->scanCacheSize, data->scanBuckets, data->maxApPerScan);
2875 hddLog(LOG1, "max_rssi_sample_size (%u) max_scan_reporting_threshold (%u)",
2876 data->maxRssiSampleSize, data->maxScanReportingThreshold);
2877 hddLog(LOG1, "max_hotlist_bssids (%u) max_bssid_history_entries (%u)"
2878 "max_hotlist_ssids (%u)", data->maxHotlistAPs,
2879 data->maxBsidHistoryEntries, data->maxHotlistSSIDs);
2880
2881 if (nla_put_u32(skb, PARAM_REQUEST_ID, data->requestId) ||
2882 nla_put_u32(skb, PARAM_STATUS, data->status) ||
2883 nla_put_u32(skb, MAX_SCAN_CACHE_SIZE, data->scanCacheSize) ||
2884 nla_put_u32(skb, MAX_SCAN_BUCKETS, data->scanBuckets) ||
2885 nla_put_u32(skb, MAX_AP_CACHE_PER_SCAN,
2886 data->maxApPerScan) ||
2887 nla_put_u32(skb, MAX_RSSI_SAMPLE_SIZE,
2888 data->maxRssiSampleSize) ||
2889 nla_put_u32(skb, MAX_SCAN_RPT_THRHOLD,
2890 data->maxScanReportingThreshold) ||
2891 nla_put_u32(skb, MAX_HOTLIST_BSSIDS, data->maxHotlistAPs) ||
2892 nla_put_u32(skb, MAX_BSSID_HISTORY_ENTRIES,
2893 data->maxBsidHistoryEntries) ||
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302894 nla_put_u32(skb, MAX_HOTLIST_SSIDS, data->maxHotlistSSIDs) ||
2895 nla_put_u32(skb, MAX_SIGNIFICANT_WIFI_CHANGE_APS, 0))
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302896 {
2897 hddLog(LOGE, FL("nla put fail"));
2898 goto nla_put_failure;
2899 }
2900
2901 cfg80211_vendor_cmd_reply(skb);
2902 return 0;
2903
2904nla_put_failure:
2905 kfree_skb(skb);
2906 return -EINVAL;;
2907}
2908
2909/*
2910 * done with short names for the global vendor params
2911 * used by wlan_hdd_send_ext_scan_capability()
2912 */
2913#undef PARAM_REQUEST_ID
2914#undef PARAM_STATUS
2915#undef MAX_SCAN_CACHE_SIZE
2916#undef MAX_SCAN_BUCKETS
2917#undef MAX_AP_CACHE_PER_SCAN
2918#undef MAX_RSSI_SAMPLE_SIZE
2919#undef MAX_SCAN_RPT_THRHOLD
2920#undef MAX_HOTLIST_BSSIDS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302921#undef MAX_BSSID_HISTORY_ENTRIES
2922#undef MAX_HOTLIST_SSIDS
Dino Mycle6fb96c12014-06-10 11:52:40 +05302923
2924static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2925{
2926 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2927 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302928 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302929 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302930
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302931 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302932
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302933 if (wlan_hdd_validate_context(pHddCtx))
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302934 return;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302935
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302936 if (!pMsg)
2937 {
2938 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302939 return;
2940 }
2941
Dino Mycle6fb96c12014-06-10 11:52:40 +05302942 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2943 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2944
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302945 context = &pHddCtx->ext_scan_context;
2946 spin_lock(&hdd_context_lock);
2947 if (context->request_id == pData->requestId) {
2948 context->response_status = pData->status ? -EINVAL : 0;
2949 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302950 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302951 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302952
2953 /*
2954 * Store the Request ID for comparing with the requestID obtained
2955 * in other requests.HDD shall return a failure is the extscan_stop
2956 * request is issued with a different requestId as that of the
2957 * extscan_start request. Also, This requestId shall be used while
2958 * indicating the full scan results to the upper layers.
2959 * The requestId is stored with the assumption that the firmware
2960 * shall return the ext scan start request's requestId in ext scan
2961 * start response.
2962 */
2963 if (pData->status == 0)
2964 pMac->sme.extScanStartReqId = pData->requestId;
2965
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302966 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302967 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302968}
2969
2970
2971static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2972{
2973 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2974 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302975 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302976
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302977 ENTER();
2978
2979 if (wlan_hdd_validate_context(pHddCtx)){
2980 return;
2981 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302982
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302983 if (!pMsg)
2984 {
2985 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302986 return;
2987 }
2988
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302989 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2990 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302991
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302992 context = &pHddCtx->ext_scan_context;
2993 spin_lock(&hdd_context_lock);
2994 if (context->request_id == pData->requestId) {
2995 context->response_status = pData->status ? -EINVAL : 0;
2996 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302997 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302998 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302999
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303000 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303001 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303002}
3003
Dino Mycle6fb96c12014-06-10 11:52:40 +05303004static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
3005 void *pMsg)
3006{
3007 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303008 tpSirEXTScanSetBssidHotListRspParams pData =
3009 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303010 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303011
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303012 ENTER();
3013
3014 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05303015 return;
3016 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303017
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303018 if (!pMsg)
3019 {
3020 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3021 return;
3022 }
3023
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303024 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
3025 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303026
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303027 context = &pHddCtx->ext_scan_context;
3028 spin_lock(&hdd_context_lock);
3029 if (context->request_id == pData->requestId) {
3030 context->response_status = pData->status ? -EINVAL : 0;
3031 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303032 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303033 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303034
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303035 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303036 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303037}
3038
3039static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
3040 void *pMsg)
3041{
3042 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303043 tpSirEXTScanResetBssidHotlistRspParams pData =
3044 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05303045 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303046
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303047 ENTER();
3048
3049 if (wlan_hdd_validate_context(pHddCtx)) {
3050 return;
3051 }
3052 if (!pMsg)
3053 {
3054 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303055 return;
3056 }
3057
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05303058 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
3059 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303060
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05303061 context = &pHddCtx->ext_scan_context;
3062 spin_lock(&hdd_context_lock);
3063 if (context->request_id == pData->requestId) {
3064 context->response_status = pData->status ? -EINVAL : 0;
3065 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303066 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05303067 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303068
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303069 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303070 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303071}
3072
Dino Mycle6fb96c12014-06-10 11:52:40 +05303073static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
3074 void *pMsg)
3075{
3076 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3077 struct sk_buff *skb = NULL;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303078 tANI_U32 i = 0, j, resultsPerEvent, scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303079 tANI_S32 totalResults;
3080 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303081 tpSirWifiScanResult pSirWifiScanResult, head_ptr;
3082 struct hdd_ext_scan_context *context;
3083 bool ignore_cached_results = false;
3084 tExtscanCachedScanResult *result;
3085 struct nlattr *nla_results;
3086 tANI_U16 ieLength= 0;
3087 tANI_U8 *ie = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303088
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303089 ENTER();
3090
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303091 if (wlan_hdd_validate_context(pHddCtx))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303092 return;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303093
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303094 if (!pMsg)
3095 {
3096 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3097 return;
3098 }
3099
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303100 spin_lock(&hdd_context_lock);
3101 context = &pHddCtx->ext_scan_context;
3102 ignore_cached_results = context->ignore_cached_results;
3103 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303104
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303105 if (ignore_cached_results) {
3106 hddLog(LOGE,
3107 FL("Ignore the cached results received after timeout"));
3108 return;
3109 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303110
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303111 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u More Data %u No of scan ids %u",
3112 pData->requestId, pData->moreData, pData->scanResultSize);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303113
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303114 result = (tExtscanCachedScanResult *)&(pData->result);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303115
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303116 for (scan_id_index = 0; scan_id_index < pData->scanResultSize;
3117 scan_id_index++) {
3118 result+= scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303119
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303120 totalResults = result->num_results;
3121 hddLog(VOS_TRACE_LEVEL_INFO, "scan_id %u flags %u Num results %u",
3122 result->scan_id, result->flags, totalResults);
3123 i = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303124
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303125 do{
3126 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
3127 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
3128 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303129
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303130 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
3131 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN);
3132
3133 if (!skb) {
3134 hddLog(VOS_TRACE_LEVEL_ERROR,
3135 FL("cfg80211_vendor_event_alloc failed"));
3136 return;
3137 }
3138
3139 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
3140
3141 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3142 pData->requestId) ||
3143 nla_put_u32(skb,
3144 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3145 resultsPerEvent)) {
3146 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3147 goto fail;
3148 }
3149 if (nla_put_u8(skb,
3150 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3151 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303152 {
3153 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3154 goto fail;
3155 }
3156
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303157 if (nla_put_u32(skb,
3158 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
3159 result->scan_id)) {
3160 hddLog(LOGE, FL("put fail"));
3161 goto fail;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303162 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303163
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303164 nla_results = nla_nest_start(skb,
3165 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST);
3166 if (!nla_results)
3167 goto fail;
3168
3169 if (resultsPerEvent) {
3170 struct nlattr *aps;
3171 struct nlattr *nla_result;
3172
3173 nla_result = nla_nest_start(skb, scan_id_index);
3174 if(!nla_result)
3175 goto fail;
3176
3177 if (nla_put_u32(skb,
3178 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
3179 result->scan_id) ||
3180 nla_put_u32(skb,
3181 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_FLAGS,
3182 result->flags) ||
3183 nla_put_u32(skb,
3184 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3185 totalResults)) {
3186 hddLog(LOGE, FL("put fail"));
3187 goto fail;
3188 }
3189
3190 aps = nla_nest_start(skb,
3191 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3192 if (!aps)
3193 {
3194 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3195 goto fail;
3196 }
3197
3198 head_ptr = (tpSirWifiScanResult) &(result->ap);
3199
3200 for (j = 0; j < resultsPerEvent; j++, i++) {
3201 struct nlattr *ap;
3202 pSirWifiScanResult = head_ptr + i;
3203
3204 /*
Srinivas Dasari91727c12016-03-23 17:59:06 +05303205 * Firmware returns timestamp from extscan_start till
3206 * BSSID was cached (in micro seconds). Add this with
3207 * time gap between system boot up to extscan_start
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303208 * to derive the time since boot when the
3209 * BSSID was cached.
3210 */
Srinivas Dasari91727c12016-03-23 17:59:06 +05303211 pSirWifiScanResult->ts +=
3212 pHddCtx->extscan_start_time_since_boot;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303213 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
3214 "Ssid (%s)"
3215 "Bssid: %pM "
3216 "Channel (%u)"
3217 "Rssi (%d)"
3218 "RTT (%u)"
3219 "RTT_SD (%u)"
3220 "Beacon Period %u"
3221 "Capability 0x%x "
3222 "Ie length %d",
3223 i,
3224 pSirWifiScanResult->ts,
3225 pSirWifiScanResult->ssid,
3226 pSirWifiScanResult->bssid,
3227 pSirWifiScanResult->channel,
3228 pSirWifiScanResult->rssi,
3229 pSirWifiScanResult->rtt,
3230 pSirWifiScanResult->rtt_sd,
3231 pSirWifiScanResult->beaconPeriod,
3232 pSirWifiScanResult->capability,
3233 ieLength);
3234
3235 ap = nla_nest_start(skb, j + 1);
3236 if (!ap)
3237 {
3238 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3239 goto fail;
3240 }
3241
3242 if (nla_put_u64(skb,
3243 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3244 pSirWifiScanResult->ts) )
3245 {
3246 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3247 goto fail;
3248 }
3249 if (nla_put(skb,
3250 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3251 sizeof(pSirWifiScanResult->ssid),
3252 pSirWifiScanResult->ssid) )
3253 {
3254 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3255 goto fail;
3256 }
3257 if (nla_put(skb,
3258 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3259 sizeof(pSirWifiScanResult->bssid),
3260 pSirWifiScanResult->bssid) )
3261 {
3262 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3263 goto fail;
3264 }
3265 if (nla_put_u32(skb,
3266 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3267 pSirWifiScanResult->channel) )
3268 {
3269 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3270 goto fail;
3271 }
3272 if (nla_put_s32(skb,
3273 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3274 pSirWifiScanResult->rssi) )
3275 {
3276 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3277 goto fail;
3278 }
3279 if (nla_put_u32(skb,
3280 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3281 pSirWifiScanResult->rtt) )
3282 {
3283 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3284 goto fail;
3285 }
3286 if (nla_put_u32(skb,
3287 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3288 pSirWifiScanResult->rtt_sd))
3289 {
3290 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3291 goto fail;
3292 }
3293 if (nla_put_u32(skb,
3294 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3295 pSirWifiScanResult->beaconPeriod))
3296 {
3297 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3298 goto fail;
3299 }
3300 if (nla_put_u32(skb,
3301 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3302 pSirWifiScanResult->capability))
3303 {
3304 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3305 goto fail;
3306 }
3307 if (nla_put_u32(skb,
3308 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3309 ieLength))
3310 {
3311 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3312 goto fail;
3313 }
3314
3315 if (ieLength)
3316 if (nla_put(skb,
3317 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3318 ieLength, ie)) {
3319 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3320 goto fail;
3321 }
3322
3323 nla_nest_end(skb, ap);
3324 }
3325 nla_nest_end(skb, aps);
3326 nla_nest_end(skb, nla_result);
3327 }
3328
3329 nla_nest_end(skb, nla_results);
3330
3331 cfg80211_vendor_cmd_reply(skb);
3332
3333 } while (totalResults > 0);
3334 }
3335
3336 if (!pData->moreData) {
3337 spin_lock(&hdd_context_lock);
3338 context->response_status = 0;
3339 complete(&context->response_event);
3340 spin_unlock(&hdd_context_lock);
3341 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303342
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303343 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303344 return;
3345fail:
3346 kfree_skb(skb);
3347 return;
3348}
3349
3350static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
3351 void *pMsg)
3352{
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303353 tpSirEXTScanHotlistMatch pData = (tpSirEXTScanHotlistMatch) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303354 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3355 struct sk_buff *skb = NULL;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303356 tANI_U32 i, index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303357
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303358 ENTER();
3359
3360 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303361 hddLog(LOGE,
3362 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303363 return;
3364 }
3365 if (!pMsg)
3366 {
3367 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303368 return;
3369 }
3370
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303371 if (pData->bss_found)
3372 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX;
3373 else
3374 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX;
3375
Dino Mycle6fb96c12014-06-10 11:52:40 +05303376 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303377#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3378 NULL,
3379#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303380 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303381 index, GFP_KERNEL);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303382
3383 if (!skb) {
3384 hddLog(VOS_TRACE_LEVEL_ERROR,
3385 FL("cfg80211_vendor_event_alloc failed"));
3386 return;
3387 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303388
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303389 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3390 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numHotlistBss);
3391 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
3392 hddLog(VOS_TRACE_LEVEL_INFO, "ap_found %u", pData->bss_found);
3393
3394 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303395 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
3396 "Ssid (%s) "
3397 "Bssid (" MAC_ADDRESS_STR ") "
3398 "Channel (%u) "
3399 "Rssi (%d) "
3400 "RTT (%u) "
3401 "RTT_SD (%u) ",
3402 i,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303403 pData->bssHotlist[i].ts,
3404 pData->bssHotlist[i].ssid,
3405 MAC_ADDR_ARRAY(pData->bssHotlist[i].bssid),
3406 pData->bssHotlist[i].channel,
3407 pData->bssHotlist[i].rssi,
3408 pData->bssHotlist[i].rtt,
3409 pData->bssHotlist[i].rtt_sd);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303410 }
3411
3412 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3413 pData->requestId) ||
3414 nla_put_u32(skb,
3415 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303416 pData->numHotlistBss)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303417 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3418 goto fail;
3419 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303420 if (pData->numHotlistBss) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303421 struct nlattr *aps;
3422
3423 aps = nla_nest_start(skb,
3424 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3425 if (!aps)
3426 goto fail;
3427
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303428 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303429 struct nlattr *ap;
3430
3431 ap = nla_nest_start(skb, i + 1);
3432 if (!ap)
3433 goto fail;
3434
3435 if (nla_put_u64(skb,
3436 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303437 pData->bssHotlist[i].ts) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303438 nla_put(skb,
3439 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303440 sizeof(pData->bssHotlist[i].ssid),
3441 pData->bssHotlist[i].ssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303442 nla_put(skb,
3443 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303444 sizeof(pData->bssHotlist[i].bssid),
3445 pData->bssHotlist[i].bssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303446 nla_put_u32(skb,
3447 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303448 pData->bssHotlist[i].channel) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303449 nla_put_s32(skb,
3450 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303451 pData->bssHotlist[i].rssi) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303452 nla_put_u32(skb,
3453 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303454 pData->bssHotlist[i].rtt) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303455 nla_put_u32(skb,
3456 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303457 pData->bssHotlist[i].rtt_sd))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303458 goto fail;
3459
3460 nla_nest_end(skb, ap);
3461 }
3462 nla_nest_end(skb, aps);
3463
3464 if (nla_put_u8(skb,
3465 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3466 pData->moreData))
3467 goto fail;
3468 }
3469
3470 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303471 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303472 return;
3473
3474fail:
3475 kfree_skb(skb);
3476 return;
3477
3478}
Dino Mycle6fb96c12014-06-10 11:52:40 +05303479
3480static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3481 void *pMsg)
3482{
3483 struct sk_buff *skb;
3484 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3485 tpSirWifiFullScanResultEvent pData =
3486 (tpSirWifiFullScanResultEvent) (pMsg);
3487
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303488 ENTER();
3489
3490 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303491 hddLog(LOGE,
3492 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303493 return;
3494 }
3495 if (!pMsg)
3496 {
3497 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303498 return;
3499 }
3500
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303501 /*
3502 * If the full scan result including IE data exceeds NL 4K size
3503 * limitation, drop that beacon/probe rsp frame.
3504 */
3505 if ((sizeof(*pData) + pData->ieLength) >= EXTSCAN_EVENT_BUF_SIZE) {
3506 hddLog(LOGE, FL("Frame exceeded NL size limilation, drop it!"));
3507 return;
3508 }
3509
Dino Mycle6fb96c12014-06-10 11:52:40 +05303510 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303511#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3512 NULL,
3513#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303514 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3515 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3516 GFP_KERNEL);
3517
3518 if (!skb) {
3519 hddLog(VOS_TRACE_LEVEL_ERROR,
3520 FL("cfg80211_vendor_event_alloc failed"));
3521 return;
3522 }
3523
Dino Mycle6fb96c12014-06-10 11:52:40 +05303524 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3525 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3526 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3527 "Ssid (%s)"
3528 "Bssid (" MAC_ADDRESS_STR ")"
3529 "Channel (%u)"
3530 "Rssi (%d)"
3531 "RTT (%u)"
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303532 "RTT_SD (%u)"
3533 "Bcn Period %d"
3534 "Capability 0x%X "),
Dino Mycle6fb96c12014-06-10 11:52:40 +05303535 pData->ap.ts,
3536 pData->ap.ssid,
3537 MAC_ADDR_ARRAY(pData->ap.bssid),
3538 pData->ap.channel,
3539 pData->ap.rssi,
3540 pData->ap.rtt,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303541 pData->ap.rtt_sd,
3542 pData->ap.beaconPeriod,
3543 pData->ap.capability);
3544
Dino Mycle6fb96c12014-06-10 11:52:40 +05303545 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3546 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3547 pData->requestId) ||
3548 nla_put_u64(skb,
3549 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3550 pData->ap.ts) ||
3551 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3552 sizeof(pData->ap.ssid),
3553 pData->ap.ssid) ||
3554 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3555 WNI_CFG_BSSID_LEN,
3556 pData->ap.bssid) ||
3557 nla_put_u32(skb,
3558 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3559 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303560 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303561 pData->ap.rssi) ||
3562 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3563 pData->ap.rtt) ||
3564 nla_put_u32(skb,
3565 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3566 pData->ap.rtt_sd) ||
3567 nla_put_u16(skb,
3568 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3569 pData->ap.beaconPeriod) ||
3570 nla_put_u16(skb,
3571 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3572 pData->ap.capability) ||
3573 nla_put_u32(skb,
3574 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303575 pData->ieLength) ||
3576 nla_put_u8(skb,
3577 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3578 pData->moreData))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303579 {
3580 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3581 goto nla_put_failure;
3582 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303583
3584 if (pData->ieLength) {
3585 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3586 pData->ieLength,
3587 pData->ie))
3588 {
3589 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3590 goto nla_put_failure;
3591 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303592 }
3593
3594 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303595 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303596 return;
3597
3598nla_put_failure:
3599 kfree_skb(skb);
3600 return;
3601}
3602
3603static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3604 void *pMsg)
3605{
3606 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3607 struct sk_buff *skb = NULL;
3608 tpSirEXTScanResultsAvailableIndParams pData =
3609 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3610
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303611 ENTER();
3612
3613 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303614 hddLog(LOGE,
3615 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303616 return;
3617 }
3618 if (!pMsg)
3619 {
3620 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303621 return;
3622 }
3623
3624 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303625#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3626 NULL,
3627#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303628 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3629 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3630 GFP_KERNEL);
3631
3632 if (!skb) {
3633 hddLog(VOS_TRACE_LEVEL_ERROR,
3634 FL("cfg80211_vendor_event_alloc failed"));
3635 return;
3636 }
3637
Dino Mycle6fb96c12014-06-10 11:52:40 +05303638 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3639 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3640 pData->numResultsAvailable);
3641 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3642 pData->requestId) ||
3643 nla_put_u32(skb,
3644 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3645 pData->numResultsAvailable)) {
3646 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3647 goto nla_put_failure;
3648 }
3649
3650 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303651 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303652 return;
3653
3654nla_put_failure:
3655 kfree_skb(skb);
3656 return;
3657}
3658
3659static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3660{
3661 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3662 struct sk_buff *skb = NULL;
3663 tpSirEXTScanProgressIndParams pData =
3664 (tpSirEXTScanProgressIndParams) pMsg;
3665
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303666 ENTER();
3667
3668 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303669 hddLog(LOGE,
3670 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303671 return;
3672 }
3673 if (!pMsg)
3674 {
3675 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303676 return;
3677 }
3678
3679 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303680#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3681 NULL,
3682#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303683 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3684 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3685 GFP_KERNEL);
3686
3687 if (!skb) {
3688 hddLog(VOS_TRACE_LEVEL_ERROR,
3689 FL("cfg80211_vendor_event_alloc failed"));
3690 return;
3691 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303692 hddLog(VOS_TRACE_LEVEL_INFO, FL("Request Id (%u) "), pData->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303693 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3694 pData->extScanEventType);
3695 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3696 pData->status);
3697
3698 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3699 pData->extScanEventType) ||
3700 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303701 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3702 pData->requestId) ||
3703 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303704 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3705 pData->status)) {
3706 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3707 goto nla_put_failure;
3708 }
3709
3710 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303711 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303712 return;
3713
3714nla_put_failure:
3715 kfree_skb(skb);
3716 return;
3717}
3718
3719void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3720 void *pMsg)
3721{
3722 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3723
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303724 ENTER();
3725
Dino Mycle6fb96c12014-06-10 11:52:40 +05303726 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303727 return;
3728 }
3729
3730 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3731
3732
3733 switch(evType) {
3734 case SIR_HAL_EXTSCAN_START_RSP:
3735 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3736 break;
3737
3738 case SIR_HAL_EXTSCAN_STOP_RSP:
3739 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3740 break;
3741 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3742 /* There is no need to send this response to upper layer
3743 Just log the message */
3744 hddLog(VOS_TRACE_LEVEL_INFO,
3745 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3746 break;
3747 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3748 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3749 break;
3750
3751 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3752 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3753 break;
3754
Dino Mycle6fb96c12014-06-10 11:52:40 +05303755 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303756 wlan_hdd_cfg80211_extscan_get_capabilities_rsp(ctx, pMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303757 break;
3758 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3759 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3760 break;
3761 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3762 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3763 break;
3764 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3765 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3766 break;
3767 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3768 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3769 break;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303770 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3771 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3772 break;
3773 default:
3774 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3775 break;
3776 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303777 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303778}
3779
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303780static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3781 struct wireless_dev *wdev,
3782 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303783{
Dino Myclee8843b32014-07-04 14:21:45 +05303784 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303785 struct net_device *dev = wdev->netdev;
3786 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3787 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3788 struct nlattr
3789 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3790 eHalStatus status;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303791 struct hdd_ext_scan_context *context;
3792 unsigned long rc;
3793 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303794
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303795 ENTER();
3796
Dino Mycle6fb96c12014-06-10 11:52:40 +05303797 status = wlan_hdd_validate_context(pHddCtx);
3798 if (0 != status)
3799 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303800 return -EINVAL;
3801 }
Dino Myclee8843b32014-07-04 14:21:45 +05303802 /* check the EXTScan Capability */
3803 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303804 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3805 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303806 {
3807 hddLog(VOS_TRACE_LEVEL_ERROR,
3808 FL("EXTScan not enabled/supported by Firmware"));
3809 return -EINVAL;
3810 }
3811
Dino Mycle6fb96c12014-06-10 11:52:40 +05303812 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3813 data, dataLen,
3814 wlan_hdd_extscan_config_policy)) {
3815 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3816 return -EINVAL;
3817 }
3818
3819 /* Parse and fetch request Id */
3820 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3821 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3822 return -EINVAL;
3823 }
3824
Dino Myclee8843b32014-07-04 14:21:45 +05303825 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303826 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303827 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303828
Dino Myclee8843b32014-07-04 14:21:45 +05303829 reqMsg.sessionId = pAdapter->sessionId;
3830 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303831
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303832 vos_spin_lock_acquire(&hdd_context_lock);
3833 context = &pHddCtx->ext_scan_context;
3834 context->request_id = reqMsg.requestId;
3835 INIT_COMPLETION(context->response_event);
3836 vos_spin_lock_release(&hdd_context_lock);
3837
Dino Myclee8843b32014-07-04 14:21:45 +05303838 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303839 if (!HAL_STATUS_SUCCESS(status)) {
3840 hddLog(VOS_TRACE_LEVEL_ERROR,
3841 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303842 return -EINVAL;
3843 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303844
3845 rc = wait_for_completion_timeout(&context->response_event,
3846 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3847 if (!rc) {
3848 hddLog(LOGE, FL("Target response timed out"));
3849 return -ETIMEDOUT;
3850 }
3851
3852 ret = wlan_hdd_send_ext_scan_capability(pHddCtx);
3853 if (ret)
3854 hddLog(LOGE, FL("Failed to send ext scan capability to user space"));
3855
3856 return ret;
3857
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303858 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303859 return 0;
3860}
3861
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303862static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3863 struct wireless_dev *wdev,
3864 const void *data, int dataLen)
3865{
3866 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303867
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303868 vos_ssr_protect(__func__);
3869 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3870 vos_ssr_unprotect(__func__);
3871
3872 return ret;
3873}
3874
3875static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3876 struct wireless_dev *wdev,
3877 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303878{
Dino Myclee8843b32014-07-04 14:21:45 +05303879 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303880 struct net_device *dev = wdev->netdev;
3881 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3882 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3883 struct nlattr
3884 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3885 eHalStatus status;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303886 struct hdd_ext_scan_context *context;
3887 unsigned long rc;
3888 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303889
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303890 ENTER();
3891
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303892 if (VOS_FTM_MODE == hdd_get_conparam()) {
3893 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3894 return -EINVAL;
3895 }
3896
Dino Mycle6fb96c12014-06-10 11:52:40 +05303897 status = wlan_hdd_validate_context(pHddCtx);
3898 if (0 != status)
3899 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303900 return -EINVAL;
3901 }
Dino Myclee8843b32014-07-04 14:21:45 +05303902 /* check the EXTScan Capability */
3903 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303904 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3905 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303906 {
3907 hddLog(VOS_TRACE_LEVEL_ERROR,
3908 FL("EXTScan not enabled/supported by Firmware"));
3909 return -EINVAL;
3910 }
3911
Dino Mycle6fb96c12014-06-10 11:52:40 +05303912 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3913 data, dataLen,
3914 wlan_hdd_extscan_config_policy)) {
3915 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3916 return -EINVAL;
3917 }
3918 /* Parse and fetch request Id */
3919 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3920 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3921 return -EINVAL;
3922 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303923
Dino Myclee8843b32014-07-04 14:21:45 +05303924 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303925 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3926
Dino Myclee8843b32014-07-04 14:21:45 +05303927 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303928
Dino Myclee8843b32014-07-04 14:21:45 +05303929 reqMsg.sessionId = pAdapter->sessionId;
3930 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303931
3932 /* Parse and fetch flush parameter */
3933 if (!tb
3934 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3935 {
3936 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3937 goto failed;
3938 }
Dino Myclee8843b32014-07-04 14:21:45 +05303939 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303940 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3941
Dino Myclee8843b32014-07-04 14:21:45 +05303942 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303943
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303944 spin_lock(&hdd_context_lock);
3945 context = &pHddCtx->ext_scan_context;
3946 context->request_id = reqMsg.requestId;
3947 context->ignore_cached_results = false;
3948 INIT_COMPLETION(context->response_event);
3949 spin_unlock(&hdd_context_lock);
3950
Dino Myclee8843b32014-07-04 14:21:45 +05303951 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303952 if (!HAL_STATUS_SUCCESS(status)) {
3953 hddLog(VOS_TRACE_LEVEL_ERROR,
3954 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303955 return -EINVAL;
3956 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303957
3958 rc = wait_for_completion_timeout(&context->response_event,
3959 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3960 if (!rc) {
3961 hddLog(LOGE, FL("Target response timed out"));
3962 retval = -ETIMEDOUT;
3963 spin_lock(&hdd_context_lock);
3964 context->ignore_cached_results = true;
3965 spin_unlock(&hdd_context_lock);
3966 } else {
3967 spin_lock(&hdd_context_lock);
3968 retval = context->response_status;
3969 spin_unlock(&hdd_context_lock);
3970 }
3971
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303972 EXIT();
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303973 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303974
3975failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303976 return -EINVAL;
3977}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303978static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3979 struct wireless_dev *wdev,
3980 const void *data, int dataLen)
3981{
3982 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303983
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303984 vos_ssr_protect(__func__);
3985 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3986 vos_ssr_unprotect(__func__);
3987
3988 return ret;
3989}
3990
3991static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303992 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303993 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303994{
3995 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3996 struct net_device *dev = wdev->netdev;
3997 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3998 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3999 struct nlattr
4000 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4001 struct nlattr
4002 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4003 struct nlattr *apTh;
4004 eHalStatus status;
4005 tANI_U8 i = 0;
4006 int rem;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304007 struct hdd_ext_scan_context *context;
4008 tANI_U32 request_id;
4009 unsigned long rc;
4010 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304011
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304012 ENTER();
4013
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304014 if (VOS_FTM_MODE == hdd_get_conparam()) {
4015 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4016 return -EINVAL;
4017 }
4018
Dino Mycle6fb96c12014-06-10 11:52:40 +05304019 status = wlan_hdd_validate_context(pHddCtx);
4020 if (0 != status)
4021 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304022 return -EINVAL;
4023 }
Dino Myclee8843b32014-07-04 14:21:45 +05304024 /* check the EXTScan Capability */
4025 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304026 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4027 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304028 {
4029 hddLog(VOS_TRACE_LEVEL_ERROR,
4030 FL("EXTScan not enabled/supported by Firmware"));
4031 return -EINVAL;
4032 }
4033
Dino Mycle6fb96c12014-06-10 11:52:40 +05304034 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4035 data, dataLen,
4036 wlan_hdd_extscan_config_policy)) {
4037 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4038 return -EINVAL;
4039 }
4040
4041 /* Parse and fetch request Id */
4042 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4043 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4044 return -EINVAL;
4045 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05304046 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
4047 vos_mem_malloc(sizeof(*pReqMsg));
4048 if (!pReqMsg) {
4049 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4050 return -ENOMEM;
4051 }
4052
Dino Myclee8843b32014-07-04 14:21:45 +05304053
Dino Mycle6fb96c12014-06-10 11:52:40 +05304054 pReqMsg->requestId = nla_get_u32(
4055 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4056 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4057
4058 /* Parse and fetch number of APs */
4059 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
4060 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
4061 goto fail;
4062 }
4063
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304064 /* Parse and fetch lost ap sample size */
4065 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]) {
4066 hddLog(LOGE, FL("attr lost ap sample size failed"));
4067 goto fail;
4068 }
4069
4070 pReqMsg->lostBssidSampleSize = nla_get_u32(
4071 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]);
4072 hddLog(LOG1, FL("Lost ap sample size %d"), pReqMsg->lostBssidSampleSize);
4073
Dino Mycle6fb96c12014-06-10 11:52:40 +05304074 pReqMsg->sessionId = pAdapter->sessionId;
4075 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4076
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304077 pReqMsg->numBssid = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304078 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05304079 if (pReqMsg->numBssid > WLAN_EXTSCAN_MAX_HOTLIST_APS) {
4080 hddLog(LOGE, FL("Number of AP: %u exceeds max: %u"),
4081 pReqMsg->numBssid, WLAN_EXTSCAN_MAX_HOTLIST_APS);
4082 goto fail;
4083 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304084 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304085
4086 nla_for_each_nested(apTh,
4087 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05304088 if (i == pReqMsg->numBssid) {
4089 hddLog(LOGW, FL("Ignoring excess AP"));
4090 break;
4091 }
4092
Dino Mycle6fb96c12014-06-10 11:52:40 +05304093 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4094 nla_data(apTh), nla_len(apTh),
4095 NULL)) {
4096 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4097 goto fail;
4098 }
4099
4100 /* Parse and fetch MAC address */
4101 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
4102 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
4103 goto fail;
4104 }
4105 memcpy(pReqMsg->ap[i].bssid, nla_data(
4106 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
4107 sizeof(tSirMacAddr));
4108 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
4109
4110 /* Parse and fetch low RSSI */
4111 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
4112 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
4113 goto fail;
4114 }
4115 pReqMsg->ap[i].low = nla_get_s32(
4116 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
4117 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
4118
4119 /* Parse and fetch high RSSI */
4120 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
4121 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
4122 goto fail;
4123 }
4124 pReqMsg->ap[i].high = nla_get_s32(
4125 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
4126 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
4127 pReqMsg->ap[i].high);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304128 i++;
4129 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304130
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05304131 if (i < pReqMsg->numBssid) {
4132 hddLog(LOGW, FL("Number of AP %u less than expected %u"),
4133 i, pReqMsg->numBssid);
4134 pReqMsg->numBssid = i;
4135 }
4136
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304137 context = &pHddCtx->ext_scan_context;
4138 spin_lock(&hdd_context_lock);
4139 INIT_COMPLETION(context->response_event);
4140 context->request_id = request_id = pReqMsg->requestId;
4141 spin_unlock(&hdd_context_lock);
4142
Dino Mycle6fb96c12014-06-10 11:52:40 +05304143 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
4144 if (!HAL_STATUS_SUCCESS(status)) {
4145 hddLog(VOS_TRACE_LEVEL_ERROR,
4146 FL("sme_SetBssHotlist failed(err=%d)"), status);
4147 vos_mem_free(pReqMsg);
4148 return -EINVAL;
4149 }
4150
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304151 /* request was sent -- wait for the response */
4152 rc = wait_for_completion_timeout(&context->response_event,
4153 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4154
4155 if (!rc) {
4156 hddLog(LOGE, FL("sme_SetBssHotlist timed out"));
4157 retval = -ETIMEDOUT;
4158 } else {
4159 spin_lock(&hdd_context_lock);
4160 if (context->request_id == request_id)
4161 retval = context->response_status;
4162 else
4163 retval = -EINVAL;
4164 spin_unlock(&hdd_context_lock);
4165 }
4166
Dino Myclee8843b32014-07-04 14:21:45 +05304167 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304168 EXIT();
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304169 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304170
4171fail:
4172 vos_mem_free(pReqMsg);
4173 return -EINVAL;
4174}
4175
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304176static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
4177 struct wireless_dev *wdev,
4178 const void *data, int dataLen)
4179{
4180 int ret = 0;
4181
4182 vos_ssr_protect(__func__);
4183 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
4184 dataLen);
4185 vos_ssr_unprotect(__func__);
4186
4187 return ret;
4188}
4189
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304190static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304191 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304192 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304193{
Agrawal Ashish16abf782016-08-18 22:42:59 +05304194 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4195 struct net_device *dev = wdev->netdev;
4196 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4197 uint32_t chan_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4198 uint8_t num_channels = 0;
4199 uint8_t num_chan_new = 0;
4200 uint8_t buf[256] = {0};
Dino Mycle6fb96c12014-06-10 11:52:40 +05304201 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304202 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304203 tWifiBand wifiBand;
4204 eHalStatus status;
4205 struct sk_buff *replySkb;
Agrawal Ashish16abf782016-08-18 22:42:59 +05304206 tANI_U8 i,j,k;
4207 int ret,len = 0;;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304208
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304209 ENTER();
4210
Dino Mycle6fb96c12014-06-10 11:52:40 +05304211 status = wlan_hdd_validate_context(pHddCtx);
4212 if (0 != status)
4213 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304214 return -EINVAL;
4215 }
Dino Myclee8843b32014-07-04 14:21:45 +05304216
Dino Mycle6fb96c12014-06-10 11:52:40 +05304217 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4218 data, dataLen,
4219 wlan_hdd_extscan_config_policy)) {
4220 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4221 return -EINVAL;
4222 }
4223
4224 /* Parse and fetch request Id */
4225 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4226 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4227 return -EINVAL;
4228 }
4229 requestId = nla_get_u32(
4230 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4231 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
4232
4233 /* Parse and fetch wifi band */
4234 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
4235 {
4236 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4237 return -EINVAL;
4238 }
4239 wifiBand = nla_get_u32(
4240 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
4241 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
4242
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304243 /* Parse and fetch max channels */
4244 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
4245 {
4246 hddLog(LOGE, FL("attr max channels failed"));
4247 return -EINVAL;
4248 }
4249 maxChannels = nla_get_u32(
4250 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
4251 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
4252
Dino Mycle6fb96c12014-06-10 11:52:40 +05304253 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
Agrawal Ashish16abf782016-08-18 22:42:59 +05304254 wifiBand, chan_list,
4255 &num_channels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304256 if (eHAL_STATUS_SUCCESS != status) {
4257 hddLog(VOS_TRACE_LEVEL_ERROR,
4258 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4259 return -EINVAL;
4260 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304261
Agrawal Ashish16abf782016-08-18 22:42:59 +05304262 num_channels = VOS_MIN(num_channels, maxChannels);
4263 num_chan_new = num_channels;
4264 /* remove the indoor only channels if iface is SAP */
4265 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
4266 {
4267 num_chan_new = 0;
4268 for (i = 0; i < num_channels; i++)
4269 for (j = 0; j < IEEE80211_NUM_BANDS; j++) {
4270 if (wiphy->bands[j] == NULL)
4271 continue;
4272 for (k = 0; k < wiphy->bands[j]->n_channels; k++) {
4273 if ((chan_list[i] ==
4274 wiphy->bands[j]->channels[k].center_freq) &&
4275 (!(wiphy->bands[j]->channels[k].flags &
4276 IEEE80211_CHAN_INDOOR_ONLY))) {
4277 chan_list[num_chan_new] = chan_list[i];
4278 num_chan_new++;
4279 }
4280 }
4281 }
4282 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304283
Agrawal Ashish16abf782016-08-18 22:42:59 +05304284 hddLog(LOG1, FL("Number of channels: %d"), num_chan_new);
4285 for (i = 0; i < num_chan_new; i++)
4286 len += scnprintf(buf + len, sizeof(buf) - len, "%u ", chan_list[i]);
4287 hddLog(LOG1, "Channels: %s", buf);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304288
4289 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
Agrawal Ashish16abf782016-08-18 22:42:59 +05304290 sizeof(u32) * num_chan_new +
Dino Mycle6fb96c12014-06-10 11:52:40 +05304291 NLMSG_HDRLEN);
4292
4293 if (!replySkb) {
4294 hddLog(VOS_TRACE_LEVEL_ERROR,
4295 FL("valid channels: buffer alloc fail"));
4296 return -EINVAL;
4297 }
4298 if (nla_put_u32(replySkb,
4299 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05304300 num_chan_new) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05304301 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05304302 sizeof(u32) * num_chan_new, chan_list)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304303
4304 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4305 kfree_skb(replySkb);
4306 return -EINVAL;
4307 }
4308
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304309 ret = cfg80211_vendor_cmd_reply(replySkb);
4310
4311 EXIT();
4312 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304313}
4314
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304315static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4316 struct wireless_dev *wdev,
4317 const void *data, int dataLen)
4318{
4319 int ret = 0;
4320
4321 vos_ssr_protect(__func__);
4322 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4323 dataLen);
4324 vos_ssr_unprotect(__func__);
4325
4326 return ret;
4327}
4328
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304329static int hdd_extscan_start_fill_bucket_channel_spec(
4330 hdd_context_t *pHddCtx,
4331 tpSirEXTScanStartReqParams pReqMsg,
4332 struct nlattr **tb)
4333{
4334 struct nlattr *bucket[
4335 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4336 struct nlattr *channel[
4337 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4338 struct nlattr *buckets;
4339 struct nlattr *channels;
4340 int rem1, rem2;
4341 eHalStatus status;
4342 tANI_U8 bktIndex, j, numChannels;
Ashish Kumar Dhanotiyacb407902017-08-14 19:57:32 +05304343 uint32_t expected_buckets;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304344 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4345 tANI_U32 passive_max_chn_time, active_max_chn_time;
4346
Ashish Kumar Dhanotiyacb407902017-08-14 19:57:32 +05304347 expected_buckets = pReqMsg->numBuckets;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304348 bktIndex = 0;
4349
4350 nla_for_each_nested(buckets,
4351 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
Ashish Kumar Dhanotiyacb407902017-08-14 19:57:32 +05304352 if (bktIndex >= expected_buckets) {
4353 hddLog(LOGW, FL("ignoring excess buckets"));
4354 break;
4355 }
4356
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304357 if (nla_parse(bucket,
Ashish Kumar Dhanotiya9c93f562017-06-20 12:13:33 +05304358 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4359 nla_data(buckets), nla_len(buckets),
4360 wlan_hdd_extscan_config_policy)) {
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304361 hddLog(LOGE, FL("nla_parse failed"));
4362 return -EINVAL;
4363 }
4364
4365 /* Parse and fetch bucket spec */
4366 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4367 hddLog(LOGE, FL("attr bucket index failed"));
4368 return -EINVAL;
4369 }
4370 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
4371 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4372 hddLog(LOG1, FL("Bucket spec Index %d"),
4373 pReqMsg->buckets[bktIndex].bucket);
4374
4375 /* Parse and fetch wifi band */
4376 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4377 hddLog(LOGE, FL("attr wifi band failed"));
4378 return -EINVAL;
4379 }
4380 pReqMsg->buckets[bktIndex].band = nla_get_u8(
4381 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4382 hddLog(LOG1, FL("Wifi band %d"),
4383 pReqMsg->buckets[bktIndex].band);
4384
4385 /* Parse and fetch period */
4386 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4387 hddLog(LOGE, FL("attr period failed"));
4388 return -EINVAL;
4389 }
4390 pReqMsg->buckets[bktIndex].period = nla_get_u32(
4391 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4392 hddLog(LOG1, FL("period %d"),
4393 pReqMsg->buckets[bktIndex].period);
4394
4395 /* Parse and fetch report events */
4396 if (!bucket[
4397 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4398 hddLog(LOGE, FL("attr report events failed"));
4399 return -EINVAL;
4400 }
4401 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
4402 bucket[
4403 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4404 hddLog(LOG1, FL("report events %d"),
4405 pReqMsg->buckets[bktIndex].reportEvents);
4406
4407 /* Parse and fetch max period */
4408 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
4409 hddLog(LOGE, FL("attr max period failed"));
4410 return -EINVAL;
4411 }
4412 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
4413 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
4414 hddLog(LOG1, FL("max period %u"),
4415 pReqMsg->buckets[bktIndex].max_period);
4416
4417 /* Parse and fetch exponent */
4418 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
4419 hddLog(LOGE, FL("attr exponent failed"));
4420 return -EINVAL;
4421 }
4422 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
4423 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
4424 hddLog(LOG1, FL("exponent %u"),
4425 pReqMsg->buckets[bktIndex].exponent);
4426
4427 /* Parse and fetch step count */
4428 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
4429 hddLog(LOGE, FL("attr step count failed"));
4430 return -EINVAL;
4431 }
4432 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
4433 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
4434 hddLog(LOG1, FL("Step count %u"),
4435 pReqMsg->buckets[bktIndex].step_count);
4436
4437 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
4438 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
4439
4440 /* Framework shall pass the channel list if the input WiFi band is
4441 * WIFI_BAND_UNSPECIFIED.
4442 * If the input WiFi band is specified (any value other than
4443 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
4444 */
4445 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
4446 numChannels = 0;
4447 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
4448 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
4449 pReqMsg->buckets[bktIndex].band,
4450 chanList, &numChannels);
4451 if (!HAL_STATUS_SUCCESS(status)) {
4452 hddLog(LOGE,
4453 FL("sme_GetValidChannelsByBand failed (err=%d)"),
4454 status);
4455 return -EINVAL;
4456 }
4457
4458 pReqMsg->buckets[bktIndex].numChannels =
4459 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
4460 hddLog(LOG1, FL("Num channels %d"),
4461 pReqMsg->buckets[bktIndex].numChannels);
4462
4463 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
4464 j++) {
4465 pReqMsg->buckets[bktIndex].channels[j].channel =
4466 chanList[j];
4467 pReqMsg->buckets[bktIndex].channels[j].
4468 chnlClass = 0;
4469 if (CSR_IS_CHANNEL_DFS(
4470 vos_freq_to_chan(chanList[j]))) {
4471 pReqMsg->buckets[bktIndex].channels[j].
4472 passive = 1;
4473 pReqMsg->buckets[bktIndex].channels[j].
4474 dwellTimeMs = passive_max_chn_time;
4475 } else {
4476 pReqMsg->buckets[bktIndex].channels[j].
4477 passive = 0;
4478 pReqMsg->buckets[bktIndex].channels[j].
4479 dwellTimeMs = active_max_chn_time;
4480 }
4481
4482 hddLog(LOG1,
4483 "Channel %u Passive %u Dwell time %u ms",
4484 pReqMsg->buckets[bktIndex].channels[j].channel,
4485 pReqMsg->buckets[bktIndex].channels[j].passive,
4486 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4487 }
4488
4489 bktIndex++;
4490 continue;
4491 }
4492
4493 /* Parse and fetch number of channels */
4494 if (!bucket[
4495 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
4496 hddLog(LOGE, FL("attr num channels failed"));
4497 return -EINVAL;
4498 }
4499
4500 pReqMsg->buckets[bktIndex].numChannels =
4501 nla_get_u32(bucket[
4502 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4503 hddLog(LOG1, FL("num channels %d"),
4504 pReqMsg->buckets[bktIndex].numChannels);
4505
4506 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4507 hddLog(LOGE, FL("attr channel spec failed"));
4508 return -EINVAL;
4509 }
4510
4511 j = 0;
4512 nla_for_each_nested(channels,
4513 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4514 if (nla_parse(channel,
4515 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4516 nla_data(channels), nla_len(channels),
4517 wlan_hdd_extscan_config_policy)) {
4518 hddLog(LOGE, FL("nla_parse failed"));
4519 return -EINVAL;
4520 }
4521
4522 /* Parse and fetch channel */
4523 if (!channel[
4524 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4525 hddLog(LOGE, FL("attr channel failed"));
4526 return -EINVAL;
4527 }
4528 pReqMsg->buckets[bktIndex].channels[j].channel =
4529 nla_get_u32(channel[
4530 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4531 hddLog(LOG1, FL("channel %u"),
4532 pReqMsg->buckets[bktIndex].channels[j].channel);
4533
4534 /* Parse and fetch dwell time */
4535 if (!channel[
4536 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4537 hddLog(LOGE, FL("attr dwelltime failed"));
4538 return -EINVAL;
4539 }
4540 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
4541 nla_get_u32(channel[
4542 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4543
4544 hddLog(LOG1, FL("Dwell time (%u ms)"),
4545 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4546
4547
4548 /* Parse and fetch channel spec passive */
4549 if (!channel[
4550 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4551 hddLog(LOGE,
4552 FL("attr channel spec passive failed"));
4553 return -EINVAL;
4554 }
4555 pReqMsg->buckets[bktIndex].channels[j].passive =
4556 nla_get_u8(channel[
4557 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4558 hddLog(LOG1, FL("Chnl spec passive %u"),
4559 pReqMsg->buckets[bktIndex].channels[j].passive);
4560
4561 j++;
4562 }
4563
4564 bktIndex++;
4565 }
4566
4567 return 0;
4568}
4569
4570
4571/*
4572 * define short names for the global vendor params
4573 * used by wlan_hdd_cfg80211_extscan_start()
4574 */
4575#define PARAM_MAX \
4576QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
4577#define PARAM_REQUEST_ID \
4578QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
4579#define PARAM_BASE_PERIOD \
4580QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
4581#define PARAM_MAX_AP_PER_SCAN \
4582QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
4583#define PARAM_RPT_THRHLD_PERCENT \
4584QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
4585#define PARAM_RPT_THRHLD_NUM_SCANS \
4586QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
4587#define PARAM_NUM_BUCKETS \
4588QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
4589
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304590static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304591 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304592 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304593{
Dino Myclee8843b32014-07-04 14:21:45 +05304594 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304595 struct net_device *dev = wdev->netdev;
4596 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4597 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4598 struct nlattr *tb[PARAM_MAX + 1];
4599 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304600 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304601 tANI_U32 request_id;
4602 struct hdd_ext_scan_context *context;
4603 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304604
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304605 ENTER();
4606
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304607 if (VOS_FTM_MODE == hdd_get_conparam()) {
4608 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4609 return -EINVAL;
4610 }
4611
Dino Mycle6fb96c12014-06-10 11:52:40 +05304612 status = wlan_hdd_validate_context(pHddCtx);
4613 if (0 != status)
4614 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304615 return -EINVAL;
4616 }
Dino Myclee8843b32014-07-04 14:21:45 +05304617 /* check the EXTScan Capability */
4618 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304619 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4620 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304621 {
4622 hddLog(VOS_TRACE_LEVEL_ERROR,
4623 FL("EXTScan not enabled/supported by Firmware"));
4624 return -EINVAL;
4625 }
4626
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304627 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304628 data, dataLen,
4629 wlan_hdd_extscan_config_policy)) {
4630 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4631 return -EINVAL;
4632 }
4633
4634 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304635 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304636 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4637 return -EINVAL;
4638 }
4639
Dino Myclee8843b32014-07-04 14:21:45 +05304640 pReqMsg = (tpSirEXTScanStartReqParams)
4641 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304642 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304643 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4644 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304645 }
4646
4647 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304648 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304649 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4650
4651 pReqMsg->sessionId = pAdapter->sessionId;
4652 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4653
4654 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304655 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304656 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4657 goto fail;
4658 }
4659 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304660 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304661 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4662 pReqMsg->basePeriod);
4663
4664 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304665 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304666 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4667 goto fail;
4668 }
4669 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304670 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304671 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4672 pReqMsg->maxAPperScan);
4673
4674 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304675 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304676 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4677 goto fail;
4678 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304679 pReqMsg->reportThresholdPercent = nla_get_u8(
4680 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304681 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304682 pReqMsg->reportThresholdPercent);
4683
4684 /* Parse and fetch report threshold num scans */
4685 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
4686 hddLog(LOGE, FL("attr report_threshold num scans failed"));
4687 goto fail;
4688 }
4689 pReqMsg->reportThresholdNumScans = nla_get_u8(
4690 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
4691 hddLog(LOG1, FL("Report Threshold num scans %d"),
4692 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304693
4694 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304695 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304696 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4697 goto fail;
4698 }
4699 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304700 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304701 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4702 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4703 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4704 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4705 }
4706 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4707 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304708
Dino Mycle6fb96c12014-06-10 11:52:40 +05304709 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4710 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4711 goto fail;
4712 }
4713
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304714 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304715
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304716 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
4717 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304718
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304719 context = &pHddCtx->ext_scan_context;
4720 spin_lock(&hdd_context_lock);
4721 INIT_COMPLETION(context->response_event);
4722 context->request_id = request_id = pReqMsg->requestId;
4723 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304724
Dino Mycle6fb96c12014-06-10 11:52:40 +05304725 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4726 if (!HAL_STATUS_SUCCESS(status)) {
4727 hddLog(VOS_TRACE_LEVEL_ERROR,
4728 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304729 goto fail;
4730 }
4731
Srinivas Dasari91727c12016-03-23 17:59:06 +05304732 pHddCtx->extscan_start_time_since_boot = vos_get_monotonic_boottime();
4733
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304734 /* request was sent -- wait for the response */
4735 rc = wait_for_completion_timeout(&context->response_event,
4736 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4737
4738 if (!rc) {
4739 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
4740 retval = -ETIMEDOUT;
4741 } else {
4742 spin_lock(&hdd_context_lock);
4743 if (context->request_id == request_id)
4744 retval = context->response_status;
4745 else
4746 retval = -EINVAL;
4747 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304748 }
4749
Dino Myclee8843b32014-07-04 14:21:45 +05304750 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304751 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304752 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304753
4754fail:
4755 vos_mem_free(pReqMsg);
4756 return -EINVAL;
4757}
4758
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304759/*
4760 * done with short names for the global vendor params
4761 * used by wlan_hdd_cfg80211_extscan_start()
4762 */
4763#undef PARAM_MAX
4764#undef PARAM_REQUEST_ID
4765#undef PARAM_BASE_PERIOD
4766#undef PARAMS_MAX_AP_PER_SCAN
4767#undef PARAMS_RPT_THRHLD_PERCENT
4768#undef PARAMS_RPT_THRHLD_NUM_SCANS
4769#undef PARAMS_NUM_BUCKETS
4770
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304771static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4772 struct wireless_dev *wdev,
4773 const void *data, int dataLen)
4774{
4775 int ret = 0;
4776
4777 vos_ssr_protect(__func__);
4778 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4779 vos_ssr_unprotect(__func__);
4780
4781 return ret;
4782}
4783
4784static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304785 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304786 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304787{
Dino Myclee8843b32014-07-04 14:21:45 +05304788 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304789 struct net_device *dev = wdev->netdev;
4790 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4791 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4792 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4793 eHalStatus status;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304794 int retval;
4795 unsigned long rc;
4796 struct hdd_ext_scan_context *context;
4797 tANI_U32 request_id;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304798
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304799 ENTER();
4800
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304801 if (VOS_FTM_MODE == hdd_get_conparam()) {
4802 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4803 return -EINVAL;
4804 }
4805
Dino Mycle6fb96c12014-06-10 11:52:40 +05304806 status = wlan_hdd_validate_context(pHddCtx);
4807 if (0 != status)
4808 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304809 return -EINVAL;
4810 }
Dino Myclee8843b32014-07-04 14:21:45 +05304811 /* check the EXTScan Capability */
4812 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304813 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4814 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304815 {
4816 hddLog(VOS_TRACE_LEVEL_ERROR,
4817 FL("EXTScan not enabled/supported by Firmware"));
4818 return -EINVAL;
4819 }
4820
Dino Mycle6fb96c12014-06-10 11:52:40 +05304821 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4822 data, dataLen,
4823 wlan_hdd_extscan_config_policy)) {
4824 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4825 return -EINVAL;
4826 }
4827
4828 /* Parse and fetch request Id */
4829 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4830 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4831 return -EINVAL;
4832 }
4833
Dino Myclee8843b32014-07-04 14:21:45 +05304834 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304835 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304836 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304837
Dino Myclee8843b32014-07-04 14:21:45 +05304838 reqMsg.sessionId = pAdapter->sessionId;
4839 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304840
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304841 context = &pHddCtx->ext_scan_context;
4842 spin_lock(&hdd_context_lock);
4843 INIT_COMPLETION(context->response_event);
Sravanti Palakonda7539fb92016-02-26 17:49:21 +05304844 context->request_id = request_id = reqMsg.requestId;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304845 spin_unlock(&hdd_context_lock);
4846
Dino Myclee8843b32014-07-04 14:21:45 +05304847 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304848 if (!HAL_STATUS_SUCCESS(status)) {
4849 hddLog(VOS_TRACE_LEVEL_ERROR,
4850 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304851 return -EINVAL;
4852 }
4853
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304854 /* request was sent -- wait for the response */
4855 rc = wait_for_completion_timeout(&context->response_event,
4856 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4857
4858 if (!rc) {
4859 hddLog(LOGE, FL("sme_ExtScanStop timed out"));
4860 retval = -ETIMEDOUT;
4861 } else {
4862 spin_lock(&hdd_context_lock);
4863 if (context->request_id == request_id)
4864 retval = context->response_status;
4865 else
4866 retval = -EINVAL;
4867 spin_unlock(&hdd_context_lock);
4868 }
4869
4870 return retval;
4871
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304872 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304873 return 0;
4874}
4875
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304876static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4877 struct wireless_dev *wdev,
4878 const void *data, int dataLen)
4879{
4880 int ret = 0;
4881
4882 vos_ssr_protect(__func__);
4883 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4884 vos_ssr_unprotect(__func__);
4885
4886 return ret;
4887}
4888
4889static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304890 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304891 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304892{
Dino Myclee8843b32014-07-04 14:21:45 +05304893 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304894 struct net_device *dev = wdev->netdev;
4895 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4896 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4897 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4898 eHalStatus status;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304899 struct hdd_ext_scan_context *context;
4900 tANI_U32 request_id;
4901 unsigned long rc;
4902 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304903
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304904 ENTER();
4905
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304906 if (VOS_FTM_MODE == hdd_get_conparam()) {
4907 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4908 return -EINVAL;
4909 }
4910
Dino Mycle6fb96c12014-06-10 11:52:40 +05304911 status = wlan_hdd_validate_context(pHddCtx);
4912 if (0 != status)
4913 {
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304914 hddLog(LOGE, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304915 return -EINVAL;
4916 }
Dino Myclee8843b32014-07-04 14:21:45 +05304917 /* check the EXTScan Capability */
4918 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304919 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4920 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304921 {
4922 hddLog(VOS_TRACE_LEVEL_ERROR,
4923 FL("EXTScan not enabled/supported by Firmware"));
4924 return -EINVAL;
4925 }
4926
Dino Mycle6fb96c12014-06-10 11:52:40 +05304927 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4928 data, dataLen,
4929 wlan_hdd_extscan_config_policy)) {
4930 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4931 return -EINVAL;
4932 }
4933
4934 /* Parse and fetch request Id */
4935 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4936 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4937 return -EINVAL;
4938 }
4939
Dino Myclee8843b32014-07-04 14:21:45 +05304940 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304941 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304942 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304943
Dino Myclee8843b32014-07-04 14:21:45 +05304944 reqMsg.sessionId = pAdapter->sessionId;
4945 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304946
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304947 context = &pHddCtx->ext_scan_context;
4948 spin_lock(&hdd_context_lock);
4949 INIT_COMPLETION(context->response_event);
4950 context->request_id = request_id = reqMsg.requestId;
4951 spin_unlock(&hdd_context_lock);
4952
Dino Myclee8843b32014-07-04 14:21:45 +05304953 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304954 if (!HAL_STATUS_SUCCESS(status)) {
4955 hddLog(VOS_TRACE_LEVEL_ERROR,
4956 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304957 return -EINVAL;
4958 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304959
4960 /* request was sent -- wait for the response */
4961 rc = wait_for_completion_timeout(&context->response_event,
4962 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4963 if (!rc) {
4964 hddLog(LOGE, FL("sme_ResetBssHotlist timed out"));
4965 retval = -ETIMEDOUT;
4966 } else {
4967 spin_lock(&hdd_context_lock);
4968 if (context->request_id == request_id)
4969 retval = context->response_status;
4970 else
4971 retval = -EINVAL;
4972 spin_unlock(&hdd_context_lock);
4973 }
4974
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304975 EXIT();
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304976 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304977}
4978
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304979static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4980 struct wireless_dev *wdev,
4981 const void *data, int dataLen)
4982{
4983 int ret = 0;
4984
4985 vos_ssr_protect(__func__);
4986 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4987 vos_ssr_unprotect(__func__);
4988
4989 return ret;
4990}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304991#endif /* WLAN_FEATURE_EXTSCAN */
4992
Atul Mittal115287b2014-07-08 13:26:33 +05304993/*EXT TDLS*/
4994static const struct nla_policy
4995wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4996{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05304997 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {
4998 .type = NLA_UNSPEC,
4999 .len = HDD_MAC_ADDR_LEN},
Atul Mittal115287b2014-07-08 13:26:33 +05305000 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
5001 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
5002 {.type = NLA_S32 },
5003 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
5004 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
5005
5006};
5007
5008static const struct nla_policy
5009wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
5010{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305011 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {
5012 .type = NLA_UNSPEC,
5013 .len = HDD_MAC_ADDR_LEN},
Atul Mittal115287b2014-07-08 13:26:33 +05305014
5015};
5016
5017static const struct nla_policy
5018wlan_hdd_tdls_config_state_change_policy[
5019 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
5020{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305021 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {
5022 .type = NLA_UNSPEC,
5023 .len = HDD_MAC_ADDR_LEN},
Atul Mittal115287b2014-07-08 13:26:33 +05305024 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
5025 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305026 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
5027 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
5028 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305029
5030};
5031
5032static const struct nla_policy
5033wlan_hdd_tdls_config_get_status_policy[
5034 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
5035{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305036 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {
5037 .type = NLA_UNSPEC,
5038 .len = HDD_MAC_ADDR_LEN},
Atul Mittal115287b2014-07-08 13:26:33 +05305039 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
5040 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305041 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
5042 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
5043 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305044
5045};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305046
5047static const struct nla_policy
5048wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
5049{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305050 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {
5051 .type = NLA_UNSPEC,
5052 .len = VOS_MAC_ADDR_FIRST_3_BYTES},
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305053};
5054
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305055static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305056 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305057 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305058 int data_len)
5059{
5060
5061 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5062 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
5063
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305064 ENTER();
5065
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305066 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305067 return -EINVAL;
5068 }
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +05305069 if (0 == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05305070 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305071 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05305072 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305073 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05305074 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305075 return -ENOTSUPP;
5076 }
5077
5078 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
5079 data, data_len, wlan_hdd_mac_config)) {
5080 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5081 return -EINVAL;
5082 }
5083
5084 /* Parse and fetch mac address */
5085 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
5086 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5087 return -EINVAL;
5088 }
5089
5090 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
5091 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5092 VOS_MAC_ADDR_LAST_3_BYTES);
5093
Siddharth Bhal76972212014-10-15 16:22:51 +05305094 pHddCtx->spoofMacAddr.isEnabled = TRUE;
5095
5096 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305097 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5098 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05305099 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
5100 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
5101 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
5102 {
5103 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
5104 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
5105 VOS_MAC_ADDRESS_LEN);
5106 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305107 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305108
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +05305109 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
5110 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305111
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305112 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305113 return 0;
5114}
5115
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305116static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
5117 struct wireless_dev *wdev,
5118 const void *data,
5119 int data_len)
5120{
5121 int ret = 0;
5122
5123 vos_ssr_protect(__func__);
5124 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
5125 vos_ssr_unprotect(__func__);
5126
5127 return ret;
5128}
5129
5130static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305131 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305132 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305133 int data_len)
5134{
5135 u8 peer[6] = {0};
5136 struct net_device *dev = wdev->netdev;
5137 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5138 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5139 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
5140 eHalStatus ret;
5141 tANI_S32 state;
5142 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305143 tANI_S32 global_operating_class = 0;
5144 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05305145 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305146 int retVal;
5147
5148 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305149
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305150 if (!pAdapter) {
5151 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5152 return -EINVAL;
5153 }
5154
Atul Mittal115287b2014-07-08 13:26:33 +05305155 ret = wlan_hdd_validate_context(pHddCtx);
5156 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305157 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305158 return -EINVAL;
5159 }
5160 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305161 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305162 return -ENOTSUPP;
5163 }
5164 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
5165 data, data_len,
5166 wlan_hdd_tdls_config_get_status_policy)) {
5167 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5168 return -EINVAL;
5169 }
5170
5171 /* Parse and fetch mac address */
5172 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
5173 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5174 return -EINVAL;
5175 }
5176
5177 memcpy(peer, nla_data(
5178 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
5179 sizeof(peer));
5180 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5181
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05305182 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05305183
Atul Mittal115287b2014-07-08 13:26:33 +05305184 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305185 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05305186 NLMSG_HDRLEN);
5187
5188 if (!skb) {
5189 hddLog(VOS_TRACE_LEVEL_ERROR,
5190 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5191 return -EINVAL;
5192 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305193 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 +05305194 reason,
5195 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305196 global_operating_class,
5197 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05305198 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305199 if (nla_put_s32(skb,
5200 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
5201 state) ||
5202 nla_put_s32(skb,
5203 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
5204 reason) ||
5205 nla_put_s32(skb,
5206 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
5207 global_operating_class) ||
5208 nla_put_s32(skb,
5209 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
5210 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05305211
5212 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5213 goto nla_put_failure;
5214 }
5215
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305216 retVal = cfg80211_vendor_cmd_reply(skb);
5217 EXIT();
5218 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05305219
5220nla_put_failure:
5221 kfree_skb(skb);
5222 return -EINVAL;
5223}
5224
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305225static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
5226 struct wireless_dev *wdev,
5227 const void *data,
5228 int data_len)
5229{
5230 int ret = 0;
5231
5232 vos_ssr_protect(__func__);
5233 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
5234 vos_ssr_unprotect(__func__);
5235
5236 return ret;
5237}
5238
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05305239static int wlan_hdd_cfg80211_exttdls_callback(
5240#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
5241 const tANI_U8* mac,
5242#else
5243 tANI_U8* mac,
5244#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305245 tANI_S32 state,
5246 tANI_S32 reason,
5247 void *ctx)
5248{
5249 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05305250 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305251 tANI_S32 global_operating_class = 0;
5252 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305253 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05305254
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305255 ENTER();
5256
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305257 if (!pAdapter) {
5258 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5259 return -EINVAL;
5260 }
5261
5262 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05305263 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305264 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305265 return -EINVAL;
5266 }
5267
5268 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305269 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305270 return -ENOTSUPP;
5271 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05305272 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
5273#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
5274 NULL,
5275#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305276 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
5277 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
5278 GFP_KERNEL);
5279
5280 if (!skb) {
5281 hddLog(VOS_TRACE_LEVEL_ERROR,
5282 FL("cfg80211_vendor_event_alloc failed"));
5283 return -EINVAL;
5284 }
5285 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305286 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
5287 reason,
5288 state,
5289 global_operating_class,
5290 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05305291 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
5292 MAC_ADDR_ARRAY(mac));
5293
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305294 if (nla_put(skb,
5295 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
5296 VOS_MAC_ADDR_SIZE, mac) ||
5297 nla_put_s32(skb,
5298 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
5299 state) ||
5300 nla_put_s32(skb,
5301 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
5302 reason) ||
5303 nla_put_s32(skb,
5304 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
5305 channel) ||
5306 nla_put_s32(skb,
5307 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
5308 global_operating_class)
5309 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05305310 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5311 goto nla_put_failure;
5312 }
5313
5314 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305315 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05305316 return (0);
5317
5318nla_put_failure:
5319 kfree_skb(skb);
5320 return -EINVAL;
5321}
5322
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305323static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305324 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305325 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305326 int data_len)
5327{
5328 u8 peer[6] = {0};
5329 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305330 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5331 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
5332 eHalStatus status;
5333 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305334 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305335 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305336
5337 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305338
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305339 if (!dev) {
5340 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5341 return -EINVAL;
5342 }
5343
5344 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5345 if (!pAdapter) {
5346 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5347 return -EINVAL;
5348 }
5349
Atul Mittal115287b2014-07-08 13:26:33 +05305350 status = wlan_hdd_validate_context(pHddCtx);
5351 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305352 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305353 return -EINVAL;
5354 }
5355 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305356 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305357 return -ENOTSUPP;
5358 }
5359 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
5360 data, data_len,
5361 wlan_hdd_tdls_config_enable_policy)) {
5362 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5363 return -EINVAL;
5364 }
5365
5366 /* Parse and fetch mac address */
5367 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
5368 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5369 return -EINVAL;
5370 }
5371
5372 memcpy(peer, nla_data(
5373 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
5374 sizeof(peer));
5375 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5376
5377 /* Parse and fetch channel */
5378 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
5379 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
5380 return -EINVAL;
5381 }
5382 pReqMsg.channel = nla_get_s32(
5383 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
5384 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
5385
5386 /* Parse and fetch global operating class */
5387 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
5388 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
5389 return -EINVAL;
5390 }
5391 pReqMsg.global_operating_class = nla_get_s32(
5392 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
5393 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
5394 pReqMsg.global_operating_class);
5395
5396 /* Parse and fetch latency ms */
5397 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
5398 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
5399 return -EINVAL;
5400 }
5401 pReqMsg.max_latency_ms = nla_get_s32(
5402 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
5403 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
5404 pReqMsg.max_latency_ms);
5405
5406 /* Parse and fetch required bandwidth kbps */
5407 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
5408 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
5409 return -EINVAL;
5410 }
5411
5412 pReqMsg.min_bandwidth_kbps = nla_get_s32(
5413 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
5414 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
5415 pReqMsg.min_bandwidth_kbps);
5416
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305417 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05305418 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05305419 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305420 wlan_hdd_cfg80211_exttdls_callback);
5421
5422 EXIT();
5423 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305424}
5425
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305426static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
5427 struct wireless_dev *wdev,
5428 const void *data,
5429 int data_len)
5430{
5431 int ret = 0;
5432
5433 vos_ssr_protect(__func__);
5434 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
5435 vos_ssr_unprotect(__func__);
5436
5437 return ret;
5438}
5439
5440static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305441 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305442 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305443 int data_len)
5444{
5445 u8 peer[6] = {0};
5446 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305447 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5448 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
5449 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305450 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305451 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305452
5453 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305454
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305455 if (!dev) {
5456 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5457 return -EINVAL;
5458 }
5459
5460 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5461 if (!pAdapter) {
5462 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
5463 return -EINVAL;
5464 }
5465
Atul Mittal115287b2014-07-08 13:26:33 +05305466 status = wlan_hdd_validate_context(pHddCtx);
5467 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305468 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305469 return -EINVAL;
5470 }
5471 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305472 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305473 return -ENOTSUPP;
5474 }
5475 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
5476 data, data_len,
5477 wlan_hdd_tdls_config_disable_policy)) {
5478 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5479 return -EINVAL;
5480 }
5481 /* Parse and fetch mac address */
5482 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5483 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5484 return -EINVAL;
5485 }
5486
5487 memcpy(peer, nla_data(
5488 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5489 sizeof(peer));
5490 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5491
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305492 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5493
5494 EXIT();
5495 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305496}
5497
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305498static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5499 struct wireless_dev *wdev,
5500 const void *data,
5501 int data_len)
5502{
5503 int ret = 0;
5504
5505 vos_ssr_protect(__func__);
5506 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5507 vos_ssr_unprotect(__func__);
5508
5509 return ret;
5510}
5511
Dasari Srinivas7875a302014-09-26 17:50:57 +05305512static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305513__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305514 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305515 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305516{
5517 struct net_device *dev = wdev->netdev;
5518 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5519 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5520 struct sk_buff *skb = NULL;
5521 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305522 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305523
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305524 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305525
5526 ret = wlan_hdd_validate_context(pHddCtx);
5527 if (0 != ret)
5528 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305529 return ret;
5530 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305531 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5532 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5533 fset |= WIFI_FEATURE_INFRA;
5534 }
5535
5536 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5537 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5538 fset |= WIFI_FEATURE_INFRA_5G;
5539 }
5540
5541#ifdef WLAN_FEATURE_P2P
5542 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5543 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5544 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5545 fset |= WIFI_FEATURE_P2P;
5546 }
5547#endif
5548
5549 /* Soft-AP is supported currently by default */
5550 fset |= WIFI_FEATURE_SOFT_AP;
5551
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305552 /* HOTSPOT is a supplicant feature, enable it by default */
5553 fset |= WIFI_FEATURE_HOTSPOT;
5554
Dasari Srinivas7875a302014-09-26 17:50:57 +05305555#ifdef WLAN_FEATURE_EXTSCAN
5556 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05305557 sme_IsFeatureSupportedByFW(EXTENDED_SCAN) &&
5558 sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)) {
5559 hddLog(LOG1, FL("Enhanced EXTScan is supported by firmware"));
Dasari Srinivas7875a302014-09-26 17:50:57 +05305560 fset |= WIFI_FEATURE_EXTSCAN;
5561 }
5562#endif
5563
Dasari Srinivas7875a302014-09-26 17:50:57 +05305564 if (sme_IsFeatureSupportedByFW(NAN)) {
5565 hddLog(LOG1, FL("NAN is supported by firmware"));
5566 fset |= WIFI_FEATURE_NAN;
5567 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305568
5569 /* D2D RTT is not supported currently by default */
5570 if (sme_IsFeatureSupportedByFW(RTT)) {
5571 hddLog(LOG1, FL("RTT is supported by firmware"));
5572 fset |= WIFI_FEATURE_D2AP_RTT;
5573 }
5574
Padma, Santhosh Kumaraac4c4d2015-12-08 16:07:47 +05305575 if (sme_IsFeatureSupportedByFW(RTT3)) {
5576 hddLog(LOG1, FL("RTT3 is supported by firmware"));
5577 fset |= WIFI_FEATURE_RTT3;
5578 }
5579
Dasari Srinivas7875a302014-09-26 17:50:57 +05305580#ifdef FEATURE_WLAN_BATCH_SCAN
5581 if (fset & WIFI_FEATURE_EXTSCAN) {
5582 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5583 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5584 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5585 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5586 fset |= WIFI_FEATURE_BATCH_SCAN;
5587 }
5588#endif
5589
5590#ifdef FEATURE_WLAN_SCAN_PNO
5591 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5592 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5593 hddLog(LOG1, FL("PNO is supported by firmware"));
5594 fset |= WIFI_FEATURE_PNO;
5595 }
5596#endif
5597
5598 /* STA+STA is supported currently by default */
5599 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5600
5601#ifdef FEATURE_WLAN_TDLS
5602 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5603 sme_IsFeatureSupportedByFW(TDLS)) {
5604 hddLog(LOG1, FL("TDLS is supported by firmware"));
5605 fset |= WIFI_FEATURE_TDLS;
5606 }
5607
5608 /* TDLS_OFFCHANNEL is not supported currently by default */
5609#endif
5610
5611#ifdef WLAN_AP_STA_CONCURRENCY
5612 /* AP+STA concurrency is supported currently by default */
5613 fset |= WIFI_FEATURE_AP_STA;
5614#endif
5615
Mukul Sharma5add0532015-08-17 15:57:47 +05305616#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5617 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5618 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5619#endif
5620
Dasari Srinivas7875a302014-09-26 17:50:57 +05305621 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5622 NLMSG_HDRLEN);
5623
5624 if (!skb) {
5625 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5626 return -EINVAL;
5627 }
5628 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5629
5630 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5631 hddLog(LOGE, FL("nla put fail"));
5632 goto nla_put_failure;
5633 }
5634
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305635 ret = cfg80211_vendor_cmd_reply(skb);
5636 EXIT();
5637 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305638
5639nla_put_failure:
5640 kfree_skb(skb);
5641 return -EINVAL;
5642}
5643
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305644static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305645wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5646 struct wireless_dev *wdev,
5647 const void *data, int data_len)
5648{
5649 int ret = 0;
5650
5651 vos_ssr_protect(__func__);
5652 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5653 vos_ssr_unprotect(__func__);
5654
5655 return ret;
5656}
5657
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305658
5659static const struct
5660nla_policy
5661qca_wlan_vendor_wifi_logger_get_ring_data_policy
5662[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = {
5663 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]
5664 = {.type = NLA_U32 },
5665};
5666
5667static int
5668 __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5669 struct wireless_dev *wdev,
5670 const void *data,
5671 int data_len)
5672{
5673 int ret;
5674 VOS_STATUS status;
5675 uint32_t ring_id;
5676 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5677 struct nlattr *tb
5678 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1];
5679
5680 ENTER();
5681
5682 ret = wlan_hdd_validate_context(hdd_ctx);
5683 if (0 != ret) {
5684 return ret;
5685 }
5686
5687 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX,
5688 data, data_len,
5689 qca_wlan_vendor_wifi_logger_get_ring_data_policy)) {
5690 hddLog(LOGE, FL("Invalid attribute"));
5691 return -EINVAL;
5692 }
5693
5694 /* Parse and fetch ring id */
5695 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) {
5696 hddLog(LOGE, FL("attr ATTR failed"));
5697 return -EINVAL;
5698 }
5699
5700 ring_id = nla_get_u32(
5701 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]);
5702
5703 hddLog(LOG1, FL("Bug report triggered by framework"));
5704
5705 status = vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
5706 WLAN_LOG_INDICATOR_FRAMEWORK,
5707 WLAN_LOG_REASON_CODE_FRAMEWORK,
Abhishek Singh837adf22015-10-01 17:37:37 +05305708 TRUE, TRUE
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305709 );
5710 if (VOS_STATUS_SUCCESS != status) {
5711 hddLog(LOGE, FL("Failed to trigger bug report"));
5712
5713 return -EINVAL;
5714 }
5715
5716 return 0;
5717
5718
5719}
5720
5721
5722static int
5723 wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5724 struct wireless_dev *wdev,
5725 const void *data,
5726 int data_len)
5727{
5728 int ret = 0;
5729
5730 vos_ssr_protect(__func__);
5731 ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy,
5732 wdev, data, data_len);
5733 vos_ssr_unprotect(__func__);
5734
5735 return ret;
5736
5737}
5738
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05305739#define MAX_CONCURRENT_MATRIX \
5740 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX
5741#define MATRIX_CONFIG_PARAM_SET_SIZE_MAX \
5742 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX
5743static const struct nla_policy
5744wlan_hdd_get_concurrency_matrix_policy[MAX_CONCURRENT_MATRIX + 1] = {
5745 [MATRIX_CONFIG_PARAM_SET_SIZE_MAX] = {.type = NLA_U32},
5746};
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305747
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305748static int
5749__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305750 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305751 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305752{
5753 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5754 uint8_t i, feature_sets, max_feature_sets;
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05305755 struct nlattr *tb[MAX_CONCURRENT_MATRIX + 1];
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305756 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305757 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5758 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305759
5760 ENTER();
5761
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305762 ret = wlan_hdd_validate_context(pHddCtx);
5763 if (0 != ret)
5764 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305765 return ret;
5766 }
5767
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05305768 if (nla_parse(tb, MAX_CONCURRENT_MATRIX, data, data_len,
5769 wlan_hdd_get_concurrency_matrix_policy)) {
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305770 hddLog(LOGE, FL("Invalid ATTR"));
5771 return -EINVAL;
5772 }
5773
5774 /* Parse and fetch max feature set */
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05305775 if (!tb[MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305776 hddLog(LOGE, FL("Attr max feature set size failed"));
5777 return -EINVAL;
5778 }
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05305779 max_feature_sets = nla_get_u32(tb[MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305780 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5781
5782 /* Fill feature combination matrix */
5783 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305784 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5785 WIFI_FEATURE_P2P;
5786
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305787 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5788 WIFI_FEATURE_SOFT_AP;
5789
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305790 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5791 WIFI_FEATURE_SOFT_AP;
5792
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305793 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5794 WIFI_FEATURE_SOFT_AP |
5795 WIFI_FEATURE_P2P;
5796
5797 /* Add more feature combinations here */
5798
5799 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5800 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5801 hddLog(LOG1, "Feature set matrix");
5802 for (i = 0; i < feature_sets; i++)
5803 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5804
5805 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5806 sizeof(u32) * feature_sets +
5807 NLMSG_HDRLEN);
5808
5809 if (reply_skb) {
5810 if (nla_put_u32(reply_skb,
5811 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5812 feature_sets) ||
5813 nla_put(reply_skb,
5814 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5815 sizeof(u32) * feature_sets, feature_set_matrix)) {
5816 hddLog(LOGE, FL("nla put fail"));
5817 kfree_skb(reply_skb);
5818 return -EINVAL;
5819 }
5820
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305821 ret = cfg80211_vendor_cmd_reply(reply_skb);
5822 EXIT();
5823 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305824 }
5825 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5826 return -ENOMEM;
5827
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305828}
5829
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05305830#undef MAX_CONCURRENT_MATRIX
5831#undef MATRIX_CONFIG_PARAM_SET_SIZE_MAX
5832
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305833static int
5834wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5835 struct wireless_dev *wdev,
5836 const void *data, int data_len)
5837{
5838 int ret = 0;
5839
5840 vos_ssr_protect(__func__);
5841 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5842 data_len);
5843 vos_ssr_unprotect(__func__);
5844
5845 return ret;
5846}
5847
c_manjeecfd1efb2015-09-25 19:32:34 +05305848
5849static int
5850__wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5851 struct wireless_dev *wdev,
5852 const void *data, int data_len)
5853{
5854 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5855 int ret;
5856 ENTER();
5857
5858 ret = wlan_hdd_validate_context(pHddCtx);
5859 if (0 != ret)
5860 {
5861 return ret;
5862 }
5863
5864 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
5865 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
5866 {
5867 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
5868 return -EINVAL;
5869 }
5870 /*call common API for FW mem dump req*/
5871 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
5872
Abhishek Singhc783fa72015-12-09 18:07:34 +05305873 if (!ret)
c_manjee04b4c5c2015-10-13 18:35:01 +05305874 {
5875 /*indicate to userspace the status of fw mem dump */
5876 wlan_indicate_mem_dump_complete(true);
5877 }
5878 else
5879 {
5880 /*else send failure to userspace */
5881 wlan_indicate_mem_dump_complete(false);
5882 }
c_manjeecfd1efb2015-09-25 19:32:34 +05305883 EXIT();
5884 return ret;
5885}
5886
5887/**
5888 * wlan_hdd_cfg80211_get_fw_mem_dump() - Get FW memory dump
5889 * @wiphy: pointer to wireless wiphy structure.
5890 * @wdev: pointer to wireless_dev structure.
5891 * @data: Pointer to the NL data.
5892 * @data_len:Length of @data
5893 *
5894 * This is called when wlan driver needs to get the firmware memory dump
5895 * via vendor specific command.
5896 *
5897 * Return: 0 on success, error number otherwise.
5898 */
5899
5900static int
5901wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5902 struct wireless_dev *wdev,
5903 const void *data, int data_len)
Sushant Kaushik8e644982015-09-23 12:18:54 +05305904{
5905 int ret = 0;
5906 vos_ssr_protect(__func__);
5907 ret = __wlan_hdd_cfg80211_get_fw_mem_dump(wiphy, wdev, data,
5908 data_len);
5909 vos_ssr_unprotect(__func__);
5910 return ret;
5911}
c_manjeecfd1efb2015-09-25 19:32:34 +05305912
Sushant Kaushik8e644982015-09-23 12:18:54 +05305913static const struct
5914nla_policy
5915qca_wlan_vendor_wifi_logger_start_policy
5916[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = {
5917 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]
5918 = {.type = NLA_U32 },
5919 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]
5920 = {.type = NLA_U32 },
5921 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]
5922 = {.type = NLA_U32 },
5923};
5924
5925/**
5926 * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable
5927 * or disable the collection of packet statistics from the firmware
5928 * @wiphy: WIPHY structure pointer
5929 * @wdev: Wireless device structure pointer
5930 * @data: Pointer to the data received
5931 * @data_len: Length of the data received
5932 *
5933 * This function is used to enable or disable the collection of packet
5934 * statistics from the firmware
5935 *
5936 * Return: 0 on success and errno on failure
5937 */
5938static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5939 struct wireless_dev *wdev,
5940 const void *data,
5941 int data_len)
5942{
5943 eHalStatus status;
5944 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5945 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1];
5946 tAniWifiStartLog start_log;
5947
5948 status = wlan_hdd_validate_context(hdd_ctx);
5949 if (0 != status) {
5950 return -EINVAL;
5951 }
5952
5953 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX,
5954 data, data_len,
5955 qca_wlan_vendor_wifi_logger_start_policy)) {
5956 hddLog(LOGE, FL("Invalid attribute"));
5957 return -EINVAL;
5958 }
5959
5960 /* Parse and fetch ring id */
5961 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) {
5962 hddLog(LOGE, FL("attr ATTR failed"));
5963 return -EINVAL;
5964 }
5965 start_log.ringId = nla_get_u32(
5966 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]);
5967 hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId);
5968
5969 /* Parse and fetch verbose level */
5970 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) {
5971 hddLog(LOGE, FL("attr verbose_level failed"));
5972 return -EINVAL;
5973 }
5974 start_log.verboseLevel = nla_get_u32(
5975 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]);
5976 hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel);
5977
5978 /* Parse and fetch flag */
5979 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) {
5980 hddLog(LOGE, FL("attr flag failed"));
5981 return -EINVAL;
5982 }
5983 start_log.flag = nla_get_u32(
5984 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]);
5985 hddLog(LOG1, FL("flag=%d"), start_log.flag);
5986
5987 if ((RING_ID_PER_PACKET_STATS == start_log.ringId) &&
Sushant Kaushik33200572015-08-05 16:46:20 +05305988 (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable ||
5989 !vos_isPktStatsEnabled()))
5990
Sushant Kaushik8e644982015-09-23 12:18:54 +05305991 {
5992 hddLog(LOGE, FL("per pkt stats not enabled"));
5993 return -EINVAL;
5994 }
Sushant Kaushik8e644982015-09-23 12:18:54 +05305995
Sushant Kaushik33200572015-08-05 16:46:20 +05305996 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
Sushant Kaushik8e644982015-09-23 12:18:54 +05305997 return 0;
5998}
5999
6000/**
6001 * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable
6002 * or disable the collection of packet statistics from the firmware
6003 * @wiphy: WIPHY structure pointer
6004 * @wdev: Wireless device structure pointer
6005 * @data: Pointer to the data received
6006 * @data_len: Length of the data received
6007 *
6008 * This function is used to enable or disable the collection of packet
6009 * statistics from the firmware
6010 *
6011 * Return: 0 on success and errno on failure
6012 */
6013static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
6014 struct wireless_dev *wdev,
6015 const void *data,
6016 int data_len)
c_manjeecfd1efb2015-09-25 19:32:34 +05306017{
6018 int ret = 0;
6019
6020 vos_ssr_protect(__func__);
Sushant Kaushik8e644982015-09-23 12:18:54 +05306021
6022 ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy,
6023 wdev, data, data_len);
c_manjeecfd1efb2015-09-25 19:32:34 +05306024 vos_ssr_unprotect(__func__);
6025
6026 return ret;
c_manjeecfd1efb2015-09-25 19:32:34 +05306027}
6028
6029
Agarwal Ashish738843c2014-09-25 12:27:56 +05306030static const struct nla_policy
6031wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
6032 +1] =
6033{
6034 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
6035};
6036
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306037static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306038 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306039 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306040 int data_len)
6041{
6042 struct net_device *dev = wdev->netdev;
6043 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6044 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6045 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6046 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
6047 eHalStatus status;
6048 u32 dfsFlag = 0;
6049
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306050 ENTER();
6051
Agarwal Ashish738843c2014-09-25 12:27:56 +05306052 status = wlan_hdd_validate_context(pHddCtx);
6053 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05306054 return -EINVAL;
6055 }
6056 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
6057 data, data_len,
6058 wlan_hdd_set_no_dfs_flag_config_policy)) {
6059 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6060 return -EINVAL;
6061 }
6062
6063 /* Parse and fetch required bandwidth kbps */
6064 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
6065 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
6066 return -EINVAL;
6067 }
6068
6069 dfsFlag = nla_get_u32(
6070 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
6071 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
6072 dfsFlag);
6073
6074 pHddCtx->disable_dfs_flag = dfsFlag;
6075
6076 sme_disable_dfs_channel(hHal, dfsFlag);
6077 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306078
6079 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05306080 return 0;
6081}
Atul Mittal115287b2014-07-08 13:26:33 +05306082
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306083static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
6084 struct wireless_dev *wdev,
6085 const void *data,
6086 int data_len)
6087{
6088 int ret = 0;
6089
6090 vos_ssr_protect(__func__);
6091 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
6092 vos_ssr_unprotect(__func__);
6093
6094 return ret;
6095
6096}
6097
Mukul Sharma2a271632014-10-13 14:59:01 +05306098const struct
6099nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
6100{
6101 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05306102 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = {
6103 .type = NLA_UNSPEC,
6104 .len = HDD_MAC_ADDR_LEN},
Mukul Sharma2a271632014-10-13 14:59:01 +05306105};
6106
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306107static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05306108 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05306109{
6110
6111 u8 bssid[6] = {0};
6112 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6113 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6114 eHalStatus status = eHAL_STATUS_SUCCESS;
6115 v_U32_t isFwrRoamEnabled = FALSE;
6116 int ret;
6117
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306118 ENTER();
6119
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306120 ret = wlan_hdd_validate_context(pHddCtx);
6121 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306122 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05306123 }
6124
6125 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
6126 data, data_len,
6127 qca_wlan_vendor_attr);
6128 if (ret){
6129 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6130 return -EINVAL;
6131 }
6132
6133 /* Parse and fetch Enable flag */
6134 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
6135 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
6136 return -EINVAL;
6137 }
6138
6139 isFwrRoamEnabled = nla_get_u32(
6140 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
6141
6142 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
6143
6144 /* Parse and fetch bssid */
6145 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6146 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
6147 return -EINVAL;
6148 }
6149
6150 memcpy(bssid, nla_data(
6151 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6152 sizeof(bssid));
6153 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
6154
6155 //Update roaming
6156 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306157 if (!HAL_STATUS_SUCCESS(status)) {
6158 hddLog(LOGE,
6159 FL("sme_ConfigFwrRoaming failed (err=%d)"), status);
6160 return -EINVAL;
6161 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306162 EXIT();
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306163 return 0;
Mukul Sharma2a271632014-10-13 14:59:01 +05306164}
6165
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306166static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
6167 struct wireless_dev *wdev, const void *data, int data_len)
6168{
6169 int ret = 0;
6170
6171 vos_ssr_protect(__func__);
6172 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
6173 vos_ssr_unprotect(__func__);
6174
6175 return ret;
6176}
6177
Sushant Kaushik847890c2015-09-28 16:05:17 +05306178static const struct
6179nla_policy
6180qca_wlan_vendor_get_wifi_info_policy[
6181 QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = {
6182 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
6183 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
6184};
6185
6186
6187/**
6188 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6189 * @wiphy: pointer to wireless wiphy structure.
6190 * @wdev: pointer to wireless_dev structure.
6191 * @data: Pointer to the data to be passed via vendor interface
6192 * @data_len:Length of the data to be passed
6193 *
6194 * This is called when wlan driver needs to send wifi driver related info
6195 * (driver/fw version) to the user space application upon request.
6196 *
6197 * Return: Return the Success or Failure code.
6198 */
6199static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6200 struct wireless_dev *wdev,
6201 const void *data, int data_len)
6202{
6203 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6204 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
6205 tSirVersionString version;
6206 uint32 version_len;
6207 uint8 attr;
6208 int status;
6209 struct sk_buff *reply_skb = NULL;
6210
6211 if (VOS_FTM_MODE == hdd_get_conparam()) {
6212 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6213 return -EINVAL;
6214 }
6215
6216 status = wlan_hdd_validate_context(hdd_ctx);
6217 if (0 != status) {
6218 hddLog(LOGE, FL("HDD context is not valid"));
6219 return -EINVAL;
6220 }
6221
6222 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
6223 data_len, qca_wlan_vendor_get_wifi_info_policy)) {
6224 hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
6225 return -EINVAL;
6226 }
6227
6228 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
6229 hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"),
6230 QWLAN_VERSIONSTR);
6231 strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
6232 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
6233 } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
6234 hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"),
6235 hdd_ctx->fw_Version);
6236 strlcpy(version, hdd_ctx->fw_Version, sizeof(version));
6237 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
6238 } else {
6239 hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
6240 return -EINVAL;
6241 }
6242
6243 version_len = strlen(version);
6244 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6245 version_len + NLA_HDRLEN + NLMSG_HDRLEN);
6246 if (!reply_skb) {
6247 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6248 return -ENOMEM;
6249 }
6250
6251 if (nla_put(reply_skb, attr, version_len, version)) {
6252 hddLog(LOGE, FL("nla put fail"));
6253 kfree_skb(reply_skb);
6254 return -EINVAL;
6255 }
6256
6257 return cfg80211_vendor_cmd_reply(reply_skb);
6258}
6259
6260/**
6261 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6262 * @wiphy: pointer to wireless wiphy structure.
6263 * @wdev: pointer to wireless_dev structure.
6264 * @data: Pointer to the data to be passed via vendor interface
6265 * @data_len:Length of the data to be passed
6266 * @data_len: Length of the data received
6267 *
6268 * This function is used to enable or disable the collection of packet
6269 * statistics from the firmware
6270 *
6271 * Return: 0 on success and errno on failure
6272 */
6273
6274static int
6275wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6276 struct wireless_dev *wdev,
6277 const void *data, int data_len)
6278
6279
6280{
6281 int ret = 0;
6282
6283 vos_ssr_protect(__func__);
6284 ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy,
6285 wdev, data, data_len);
6286 vos_ssr_unprotect(__func__);
6287
6288 return ret;
6289}
6290
6291
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306292/*
6293 * define short names for the global vendor params
6294 * used by __wlan_hdd_cfg80211_monitor_rssi()
6295 */
6296#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX
6297#define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID
6298#define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL
6299#define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI
6300#define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI
6301
6302/**---------------------------------------------------------------------------
6303
6304 \brief hdd_rssi_monitor_start_done - callback to be executed when rssi
6305 monitor start is completed successfully.
6306
6307 \return - None
6308
6309 --------------------------------------------------------------------------*/
6310void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6311{
6312 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6313
6314 if (NULL == pHddCtx)
6315 {
6316 hddLog(VOS_TRACE_LEVEL_ERROR,
6317 "%s: HDD context is NULL",__func__);
6318 return;
6319 }
6320
6321 if (VOS_STATUS_SUCCESS == status)
6322 {
6323 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful"));
6324 }
6325 else
6326 {
6327 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful"));
6328 }
6329
6330 return;
6331}
6332
6333/**---------------------------------------------------------------------------
6334
6335 \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor
6336 stop is completed successfully.
6337
6338 \return - None
6339
6340 --------------------------------------------------------------------------*/
6341void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6342{
6343 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6344
6345 if (NULL == pHddCtx)
6346 {
6347 hddLog(VOS_TRACE_LEVEL_ERROR,
6348 "%s: HDD context is NULL",__func__);
6349 return;
6350 }
6351
6352 if (VOS_STATUS_SUCCESS == status)
6353 {
6354 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful"));
6355 }
6356 else
6357 {
6358 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful"));
6359 }
6360
6361 return;
6362}
6363
6364/**
6365 * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi
6366 * @wiphy: Pointer to wireless phy
6367 * @wdev: Pointer to wireless device
6368 * @data: Pointer to data
6369 * @data_len: Data length
6370 *
6371 * Return: 0 on success, negative errno on failure
6372 */
6373
6374static int
6375__wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy,
6376 struct wireless_dev *wdev,
6377 const void *data,
6378 int data_len)
6379{
6380 struct net_device *dev = wdev->netdev;
6381 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6382 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6383 hdd_station_ctx_t *pHddStaCtx;
6384 struct nlattr *tb[PARAM_MAX + 1];
6385 tpSirRssiMonitorReq pReq;
6386 eHalStatus status;
6387 int ret;
6388 uint32_t control;
6389 static const struct nla_policy policy[PARAM_MAX + 1] = {
6390 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6391 [PARAM_CONTROL] = { .type = NLA_U32 },
6392 [PARAM_MIN_RSSI] = { .type = NLA_S8 },
6393 [PARAM_MAX_RSSI] = { .type = NLA_S8 },
6394 };
6395
6396 ENTER();
6397
6398 ret = wlan_hdd_validate_context(hdd_ctx);
6399 if (0 != ret) {
6400 return -EINVAL;
6401 }
6402
6403 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6404 hddLog(LOGE, FL("Not in Connected state!"));
6405 return -ENOTSUPP;
6406 }
6407
6408 if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) {
6409 hddLog(LOGE, FL("Invalid ATTR"));
6410 return -EINVAL;
6411 }
6412
6413 if (!tb[PARAM_REQUEST_ID]) {
6414 hddLog(LOGE, FL("attr request id failed"));
6415 return -EINVAL;
6416 }
6417
6418 if (!tb[PARAM_CONTROL]) {
6419 hddLog(LOGE, FL("attr control failed"));
6420 return -EINVAL;
6421 }
6422
6423 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6424
6425 pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq));
6426 if(NULL == pReq)
6427 {
6428 hddLog(LOGE,
6429 FL("vos_mem_alloc failed "));
6430 return eHAL_STATUS_FAILED_ALLOC;
6431 }
6432 vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0);
6433
6434 pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
6435 pReq->sessionId = pAdapter->sessionId;
6436 pReq->rssiMonitorCbContext = hdd_ctx;
6437 control = nla_get_u32(tb[PARAM_CONTROL]);
6438 vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6439
6440 hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"),
6441 pReq->requestId, pReq->sessionId, control);
6442
6443 if (control == QCA_WLAN_RSSI_MONITORING_START) {
6444 if (!tb[PARAM_MIN_RSSI]) {
6445 hddLog(LOGE, FL("attr min rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306446 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306447 }
6448
6449 if (!tb[PARAM_MAX_RSSI]) {
6450 hddLog(LOGE, FL("attr max rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306451 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306452 }
6453
6454 pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]);
6455 pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]);
6456 pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done;
6457
6458 if (!(pReq->minRssi < pReq->maxRssi)) {
6459 hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"),
6460 pReq->minRssi, pReq->maxRssi);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306461 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306462 }
6463 hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"),
6464 pReq->minRssi, pReq->maxRssi);
6465 status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq);
6466
6467 }
6468 else if (control == QCA_WLAN_RSSI_MONITORING_STOP) {
6469 pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done;
6470 status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq);
6471 }
6472 else {
6473 hddLog(LOGE, FL("Invalid control cmd: %d"), control);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306474 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306475 }
6476
6477 if (!HAL_STATUS_SUCCESS(status)) {
6478 hddLog(LOGE,
6479 FL("sme_set_rssi_monitoring failed(err=%d)"), status);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306480 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306481 }
6482
6483 return 0;
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306484fail:
6485 vos_mem_free(pReq);
6486 return -EINVAL;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306487}
6488
6489/*
6490 * done with short names for the global vendor params
6491 * used by __wlan_hdd_cfg80211_monitor_rssi()
6492 */
6493#undef PARAM_MAX
6494#undef PARAM_CONTROL
6495#undef PARAM_REQUEST_ID
6496#undef PARAM_MAX_RSSI
6497#undef PARAM_MIN_RSSI
6498
6499/**
6500 * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
6501 * @wiphy: wiphy structure pointer
6502 * @wdev: Wireless device structure pointer
6503 * @data: Pointer to the data received
6504 * @data_len: Length of @data
6505 *
6506 * Return: 0 on success; errno on failure
6507 */
6508static int
6509wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
6510 const void *data, int data_len)
6511{
6512 int ret;
6513
6514 vos_ssr_protect(__func__);
6515 ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len);
6516 vos_ssr_unprotect(__func__);
6517
6518 return ret;
6519}
6520
6521/**
6522 * hdd_rssi_threshold_breached_cb() - rssi breached NL event
6523 * @hddctx: HDD context
6524 * @data: rssi breached event data
6525 *
6526 * This function reads the rssi breached event %data and fill in the skb with
6527 * NL attributes and send up the NL event.
6528 * This callback execute in atomic context and must not invoke any
6529 * blocking calls.
6530 *
6531 * Return: none
6532 */
6533void hdd_rssi_threshold_breached_cb(void *hddctx,
6534 struct rssi_breach_event *data)
6535{
6536 hdd_context_t *pHddCtx = (hdd_context_t *)hddctx;
6537 int status;
6538 struct sk_buff *skb;
6539
6540 ENTER();
6541 status = wlan_hdd_validate_context(pHddCtx);
6542
6543 if (0 != status) {
6544 return;
6545 }
6546
6547 if (!data) {
6548 hddLog(LOGE, FL("data is null"));
6549 return;
6550 }
6551
6552 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
6553#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6554 NULL,
6555#endif
6556 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
6557 QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
6558 GFP_KERNEL);
6559
6560 if (!skb) {
6561 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
6562 return;
6563 }
6564
6565 hddLog(LOG1, "Req Id: %u Current rssi: %d",
6566 data->request_id, data->curr_rssi);
6567 hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR,
6568 MAC_ADDR_ARRAY(data->curr_bssid.bytes));
6569
6570 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID,
6571 data->request_id) ||
6572 nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID,
6573 sizeof(data->curr_bssid), data->curr_bssid.bytes) ||
6574 nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI,
6575 data->curr_rssi)) {
6576 hddLog(LOGE, FL("nla put fail"));
6577 goto fail;
6578 }
6579
6580 cfg80211_vendor_event(skb, GFP_KERNEL);
6581 return;
6582
6583fail:
6584 kfree_skb(skb);
6585 return;
6586}
6587
6588
6589
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306590/**
6591 * __wlan_hdd_cfg80211_setband() - set band
6592 * @wiphy: Pointer to wireless phy
6593 * @wdev: Pointer to wireless device
6594 * @data: Pointer to data
6595 * @data_len: Data length
6596 *
6597 * Return: 0 on success, negative errno on failure
6598 */
6599static int
6600__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6601 struct wireless_dev *wdev,
6602 const void *data,
6603 int data_len)
6604{
6605 struct net_device *dev = wdev->netdev;
6606 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6607 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6608 int ret;
6609 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
6610 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
6611
6612 ENTER();
6613
6614 ret = wlan_hdd_validate_context(hdd_ctx);
6615 if (0 != ret) {
6616 hddLog(LOGE, FL("HDD context is not valid"));
6617 return ret;
6618 }
6619
6620 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
6621 policy)) {
6622 hddLog(LOGE, FL("Invalid ATTR"));
6623 return -EINVAL;
6624 }
6625
6626 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
6627 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
6628 return -EINVAL;
6629 }
6630
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306631 hdd_ctx->isSetBandByNL = TRUE;
6632 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306633 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306634 hdd_ctx->isSetBandByNL = FALSE;
6635
6636 EXIT();
6637 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306638}
6639
6640/**
6641 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
6642 * @wiphy: wiphy structure pointer
6643 * @wdev: Wireless device structure pointer
6644 * @data: Pointer to the data received
6645 * @data_len: Length of @data
6646 *
6647 * Return: 0 on success; errno on failure
6648 */
6649static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6650 struct wireless_dev *wdev,
6651 const void *data,
6652 int data_len)
6653{
6654 int ret = 0;
6655
6656 vos_ssr_protect(__func__);
6657 ret = __wlan_hdd_cfg80211_setband(wiphy,
6658 wdev, data, data_len);
6659 vos_ssr_unprotect(__func__);
6660
6661 return ret;
6662}
6663
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306664#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
6665/**
6666 * hdd_map_req_id_to_pattern_id() - map request id to pattern id
6667 * @hdd_ctx: HDD context
6668 * @request_id: [input] request id
6669 * @pattern_id: [output] pattern id
6670 *
6671 * This function loops through request id to pattern id array
6672 * if the slot is available, store the request id and return pattern id
6673 * if entry exists, return the pattern id
6674 *
6675 * Return: 0 on success and errno on failure
6676 */
6677static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6678 uint32_t request_id,
6679 uint8_t *pattern_id)
6680{
6681 uint32_t i;
6682
6683 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6684 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6685 {
6686 if (hdd_ctx->op_ctx.op_table[i].request_id == 0)
6687 {
6688 hdd_ctx->op_ctx.op_table[i].request_id = request_id;
6689 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6690 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6691 return 0;
6692 } else if (hdd_ctx->op_ctx.op_table[i].request_id ==
6693 request_id) {
6694 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6695 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6696 return 0;
6697 }
6698 }
6699 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6700 return -EINVAL;
6701}
6702
6703/**
6704 * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id
6705 * @hdd_ctx: HDD context
6706 * @request_id: [input] request id
6707 * @pattern_id: [output] pattern id
6708 *
6709 * This function loops through request id to pattern id array
6710 * reset request id to 0 (slot available again) and
6711 * return pattern id
6712 *
6713 * Return: 0 on success and errno on failure
6714 */
6715static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6716 uint32_t request_id,
6717 uint8_t *pattern_id)
6718{
6719 uint32_t i;
6720
6721 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6722 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6723 {
6724 if (hdd_ctx->op_ctx.op_table[i].request_id == request_id)
6725 {
6726 hdd_ctx->op_ctx.op_table[i].request_id = 0;
6727 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6728 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6729 return 0;
6730 }
6731 }
6732 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6733 return -EINVAL;
6734}
6735
6736
6737/*
6738 * define short names for the global vendor params
6739 * used by __wlan_hdd_cfg80211_offloaded_packets()
6740 */
6741#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX
6742#define PARAM_REQUEST_ID \
6743 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID
6744#define PARAM_CONTROL \
6745 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL
6746#define PARAM_IP_PACKET \
6747 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA
6748#define PARAM_SRC_MAC_ADDR \
6749 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR
6750#define PARAM_DST_MAC_ADDR \
6751 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR
6752#define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD
6753
6754/**
6755 * wlan_hdd_add_tx_ptrn() - add tx pattern
6756 * @adapter: adapter pointer
6757 * @hdd_ctx: hdd context
6758 * @tb: nl attributes
6759 *
6760 * This function reads the NL attributes and forms a AddTxPtrn message
6761 * posts it to SME.
6762 *
6763 */
6764static int
6765wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6766 struct nlattr **tb)
6767{
6768 struct sSirAddPeriodicTxPtrn *add_req;
6769 eHalStatus status;
6770 uint32_t request_id, ret, len;
6771 uint8_t pattern_id = 0;
6772 v_MACADDR_t dst_addr;
6773 uint16_t eth_type = htons(ETH_P_IP);
6774
6775 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
6776 {
6777 hddLog(LOGE, FL("Not in Connected state!"));
6778 return -ENOTSUPP;
6779 }
6780
6781 add_req = vos_mem_malloc(sizeof(*add_req));
6782 if (!add_req)
6783 {
6784 hddLog(LOGE, FL("memory allocation failed"));
6785 return -ENOMEM;
6786 }
6787
6788 /* Parse and fetch request Id */
6789 if (!tb[PARAM_REQUEST_ID])
6790 {
6791 hddLog(LOGE, FL("attr request id failed"));
6792 goto fail;
6793 }
6794
6795 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6796 hddLog(LOG1, FL("Request Id: %u"), request_id);
6797 if (request_id == 0)
6798 {
6799 hddLog(LOGE, FL("request_id cannot be zero"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306800 goto fail;
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306801 }
6802
6803 if (!tb[PARAM_PERIOD])
6804 {
6805 hddLog(LOGE, FL("attr period failed"));
6806 goto fail;
6807 }
6808 add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]);
6809 hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs);
6810 if (add_req->usPtrnIntervalMs == 0)
6811 {
6812 hddLog(LOGE, FL("Invalid interval zero, return failure"));
6813 goto fail;
6814 }
6815
6816 if (!tb[PARAM_SRC_MAC_ADDR])
6817 {
6818 hddLog(LOGE, FL("attr source mac address failed"));
6819 goto fail;
6820 }
6821 nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR],
6822 VOS_MAC_ADDR_SIZE);
6823 hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR,
6824 MAC_ADDR_ARRAY(add_req->macAddress));
6825
6826 if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes,
6827 VOS_MAC_ADDR_SIZE))
6828 {
6829 hddLog(LOGE,
6830 FL("input src mac address and connected ap bssid are different"));
6831 goto fail;
6832 }
6833
6834 if (!tb[PARAM_DST_MAC_ADDR])
6835 {
6836 hddLog(LOGE, FL("attr dst mac address failed"));
6837 goto fail;
6838 }
6839 nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE);
6840 hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR,
6841 MAC_ADDR_ARRAY(dst_addr.bytes));
6842
6843 if (!tb[PARAM_IP_PACKET])
6844 {
6845 hddLog(LOGE, FL("attr ip packet failed"));
6846 goto fail;
6847 }
6848 add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]);
6849 hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize);
6850
6851 if (add_req->ucPtrnSize < 0 ||
6852 add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE -
6853 HDD_ETH_HEADER_LEN))
6854 {
6855 hddLog(LOGE, FL("Invalid IP packet len: %d"),
6856 add_req->ucPtrnSize);
6857 goto fail;
6858 }
6859
6860 len = 0;
6861 vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE);
6862 len += VOS_MAC_ADDR_SIZE;
6863 vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress,
6864 VOS_MAC_ADDR_SIZE);
6865 len += VOS_MAC_ADDR_SIZE;
6866 vos_mem_copy(&add_req->ucPattern[len], &eth_type, 2);
6867 len += 2;
6868
6869 /*
6870 * This is the IP packet, add 14 bytes Ethernet (802.3) header
6871 * ------------------------------------------------------------
6872 * | 14 bytes Ethernet (802.3) header | IP header and payload |
6873 * ------------------------------------------------------------
6874 */
6875 vos_mem_copy(&add_req->ucPattern[len],
6876 nla_data(tb[PARAM_IP_PACKET]),
6877 add_req->ucPtrnSize);
6878 add_req->ucPtrnSize += len;
6879
6880 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6881 add_req->ucPattern, add_req->ucPtrnSize);
6882
6883 ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6884 if (ret)
6885 {
6886 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6887 goto fail;
6888 }
6889 add_req->ucPtrnId = pattern_id;
6890 hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId);
6891
6892 status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req);
6893 if (!HAL_STATUS_SUCCESS(status))
6894 {
6895 hddLog(LOGE,
6896 FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status);
6897 goto fail;
6898 }
6899
6900 EXIT();
6901 vos_mem_free(add_req);
6902 return 0;
6903
6904fail:
6905 vos_mem_free(add_req);
6906 return -EINVAL;
6907}
6908
6909/**
6910 * wlan_hdd_del_tx_ptrn() - delete tx pattern
6911 * @adapter: adapter pointer
6912 * @hdd_ctx: hdd context
6913 * @tb: nl attributes
6914 *
6915 * This function reads the NL attributes and forms a DelTxPtrn message
6916 * posts it to SME.
6917 *
6918 */
6919static int
6920wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6921 struct nlattr **tb)
6922{
6923 struct sSirDelPeriodicTxPtrn *del_req;
6924 eHalStatus status;
6925 uint32_t request_id, ret;
6926 uint8_t pattern_id = 0;
6927
6928 /* Parse and fetch request Id */
6929 if (!tb[PARAM_REQUEST_ID])
6930 {
6931 hddLog(LOGE, FL("attr request id failed"));
6932 return -EINVAL;
6933 }
6934 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6935 if (request_id == 0)
6936 {
6937 hddLog(LOGE, FL("request_id cannot be zero"));
6938 return -EINVAL;
6939 }
6940
6941 ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6942 if (ret)
6943 {
6944 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6945 return -EINVAL;
6946 }
6947
6948 del_req = vos_mem_malloc(sizeof(*del_req));
6949 if (!del_req)
6950 {
6951 hddLog(LOGE, FL("memory allocation failed"));
6952 return -ENOMEM;
6953 }
6954
6955 vos_mem_set(del_req, sizeof(*del_req), 0);
6956 vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes,
6957 VOS_MAC_ADDR_SIZE);
6958 hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress));
6959 del_req->ucPatternIdBitmap |= (0x1 << pattern_id);
6960 hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"),
6961 request_id, pattern_id, del_req->ucPatternIdBitmap);
6962
6963 status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req);
6964 if (!HAL_STATUS_SUCCESS(status))
6965 {
6966 hddLog(LOGE,
6967 FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status);
6968 goto fail;
6969 }
6970
6971 EXIT();
6972 vos_mem_free(del_req);
6973 return 0;
6974
6975fail:
6976 vos_mem_free(del_req);
6977 return -EINVAL;
6978}
6979
6980
6981/**
6982 * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets
6983 * @wiphy: Pointer to wireless phy
6984 * @wdev: Pointer to wireless device
6985 * @data: Pointer to data
6986 * @data_len: Data length
6987 *
6988 * Return: 0 on success, negative errno on failure
6989 */
6990static int
6991__wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
6992 struct wireless_dev *wdev,
6993 const void *data,
6994 int data_len)
6995{
6996 struct net_device *dev = wdev->netdev;
6997 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6998 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6999 struct nlattr *tb[PARAM_MAX + 1];
7000 uint8_t control;
7001 int ret;
7002 static const struct nla_policy policy[PARAM_MAX + 1] =
7003 {
7004 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
7005 [PARAM_CONTROL] = { .type = NLA_U32 },
7006 [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY,
7007 .len = VOS_MAC_ADDR_SIZE },
7008 [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY,
7009 .len = VOS_MAC_ADDR_SIZE },
7010 [PARAM_PERIOD] = { .type = NLA_U32 },
7011 };
7012
7013 ENTER();
7014
7015 ret = wlan_hdd_validate_context(hdd_ctx);
7016 if (0 != ret)
7017 {
7018 hddLog(LOGE, FL("HDD context is not valid"));
7019 return ret;
7020 }
7021
7022 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
7023 {
7024 hddLog(LOGE,
7025 FL("Periodic Tx Pattern Offload feature is not supported in FW!"));
7026 return -ENOTSUPP;
7027 }
7028
7029 if (nla_parse(tb, PARAM_MAX, data, data_len, policy))
7030 {
7031 hddLog(LOGE, FL("Invalid ATTR"));
7032 return -EINVAL;
7033 }
7034
7035 if (!tb[PARAM_CONTROL])
7036 {
7037 hddLog(LOGE, FL("attr control failed"));
7038 return -EINVAL;
7039 }
7040 control = nla_get_u32(tb[PARAM_CONTROL]);
7041 hddLog(LOG1, FL("Control: %d"), control);
7042
7043 if (control == WLAN_START_OFFLOADED_PACKETS)
7044 return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb);
7045 else if (control == WLAN_STOP_OFFLOADED_PACKETS)
7046 return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb);
7047 else
7048 {
7049 hddLog(LOGE, FL("Invalid control: %d"), control);
7050 return -EINVAL;
7051 }
7052}
7053
7054/*
7055 * done with short names for the global vendor params
7056 * used by __wlan_hdd_cfg80211_offloaded_packets()
7057 */
7058#undef PARAM_MAX
7059#undef PARAM_REQUEST_ID
7060#undef PARAM_CONTROL
7061#undef PARAM_IP_PACKET
7062#undef PARAM_SRC_MAC_ADDR
7063#undef PARAM_DST_MAC_ADDR
7064#undef PARAM_PERIOD
7065
7066/**
7067 * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets
7068 * @wiphy: wiphy structure pointer
7069 * @wdev: Wireless device structure pointer
7070 * @data: Pointer to the data received
7071 * @data_len: Length of @data
7072 *
7073 * Return: 0 on success; errno on failure
7074 */
7075static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7076 struct wireless_dev *wdev,
7077 const void *data,
7078 int data_len)
7079{
7080 int ret = 0;
7081
7082 vos_ssr_protect(__func__);
7083 ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy,
7084 wdev, data, data_len);
7085 vos_ssr_unprotect(__func__);
7086
7087 return ret;
7088}
7089#endif
7090
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307091static const struct
7092nla_policy
7093qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = {
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05307094 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = {
7095 .type = NLA_BINARY,
7096 .len = HDD_MAC_ADDR_LEN},
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307097};
7098
7099/**
7100 * wlan_hdd_cfg80211_get_link_properties() - This function is used to
7101 * get link properties like nss, rate flags and operating frequency for
7102 * the connection with the given peer.
7103 * @wiphy: WIPHY structure pointer
7104 * @wdev: Wireless device structure pointer
7105 * @data: Pointer to the data received
7106 * @data_len: Length of the data received
7107 *
7108 * This function return the above link properties on success.
7109 *
7110 * Return: 0 on success and errno on failure
7111 */
7112static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
7113 struct wireless_dev *wdev,
7114 const void *data,
7115 int data_len)
7116{
7117 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7118 struct net_device *dev = wdev->netdev;
7119 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7120 hdd_station_ctx_t *hdd_sta_ctx;
7121 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1];
7122 uint8_t peer_mac[VOS_MAC_ADDR_SIZE];
7123 uint32_t sta_id;
7124 struct sk_buff *reply_skb;
7125 uint32_t rate_flags = 0;
7126 uint8_t nss;
7127 uint8_t final_rate_flags = 0;
7128 uint32_t freq;
7129 v_CONTEXT_t pVosContext = NULL;
7130 ptSapContext pSapCtx = NULL;
7131
7132 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
7133 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
7134 return -EINVAL;
7135 }
7136
7137 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7138 qca_wlan_vendor_attr_policy)) {
7139 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute"));
7140 return -EINVAL;
7141 }
7142
7143 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
7144 hddLog(VOS_TRACE_LEVEL_ERROR,
7145 FL("Attribute peerMac not provided for mode=%d"),
7146 adapter->device_mode);
7147 return -EINVAL;
7148 }
7149
Ashish Kumar Dhanotiyaddaf0482017-06-23 15:22:42 +05307150 if (nla_len(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) < sizeof(peer_mac)) {
7151 hddLog(VOS_TRACE_LEVEL_ERROR,
7152 FL("Attribute peerMac is invalid=%d"),
7153 adapter->device_mode);
7154 return -EINVAL;
7155 }
7156
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307157 memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
7158 sizeof(peer_mac));
7159 hddLog(VOS_TRACE_LEVEL_INFO,
7160 FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"),
7161 MAC_ADDR_ARRAY(peer_mac), adapter->device_mode);
7162
7163 if (adapter->device_mode == WLAN_HDD_INFRA_STATION ||
7164 adapter->device_mode == WLAN_HDD_P2P_CLIENT) {
7165 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
7166 if ((hdd_sta_ctx->conn_info.connState !=
7167 eConnectionState_Associated) ||
7168 !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac,
7169 VOS_MAC_ADDRESS_LEN)) {
7170 hddLog(VOS_TRACE_LEVEL_ERROR,
7171 FL("Not Associated to mac "MAC_ADDRESS_STR),
7172 MAC_ADDR_ARRAY(peer_mac));
7173 return -EINVAL;
7174 }
7175
7176 nss = 1; //pronto supports only one spatial stream
7177 freq = vos_chan_to_freq(
7178 hdd_sta_ctx->conn_info.operationChannel);
7179 rate_flags = hdd_sta_ctx->conn_info.rate_flags;
7180
7181 } else if (adapter->device_mode == WLAN_HDD_P2P_GO ||
7182 adapter->device_mode == WLAN_HDD_SOFTAP) {
7183
7184 pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext;
7185 pSapCtx = VOS_GET_SAP_CB(pVosContext);
7186 if(pSapCtx == NULL){
7187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7188 FL("psapCtx is NULL"));
7189 return -ENOENT;
7190 }
7191
7192
7193 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
7194 if (pSapCtx->aStaInfo[sta_id].isUsed &&
7195 !vos_is_macaddr_broadcast(
7196 &pSapCtx->aStaInfo[sta_id].macAddrSTA) &&
7197 vos_mem_compare(
7198 &pSapCtx->aStaInfo[sta_id].macAddrSTA,
7199 peer_mac, VOS_MAC_ADDRESS_LEN))
7200 break;
7201 }
7202
7203 if (WLAN_MAX_STA_COUNT == sta_id) {
7204 hddLog(VOS_TRACE_LEVEL_ERROR,
7205 FL("No active peer with mac="MAC_ADDRESS_STR),
7206 MAC_ADDR_ARRAY(peer_mac));
7207 return -EINVAL;
7208 }
7209
7210 nss = 1; //pronto supports only one spatial stream
7211 freq = vos_chan_to_freq(
7212 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel);
7213 rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags;
7214 } else {
7215 hddLog(VOS_TRACE_LEVEL_ERROR,
7216 FL("Not Associated! with mac"MAC_ADDRESS_STR),
7217 MAC_ADDR_ARRAY(peer_mac));
7218 return -EINVAL;
7219 }
7220
7221 if (!(rate_flags & eHAL_TX_RATE_LEGACY)) {
7222 if (rate_flags & eHAL_TX_RATE_VHT80) {
7223 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7224 final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7225 } else if (rate_flags & eHAL_TX_RATE_VHT40) {
7226 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7227 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7228 } else if (rate_flags & eHAL_TX_RATE_VHT20) {
7229 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7230 } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) {
7231 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7232 if (rate_flags & eHAL_TX_RATE_HT40)
7233 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7234 }
7235
7236 if (rate_flags & eHAL_TX_RATE_SGI) {
7237 if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS))
7238 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7239 final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI;
7240 }
7241 }
7242
7243 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7244 sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN);
7245
7246 if (NULL == reply_skb) {
7247 hddLog(VOS_TRACE_LEVEL_ERROR,
7248 FL("getLinkProperties: skb alloc failed"));
7249 return -EINVAL;
7250 }
7251
7252 if (nla_put_u8(reply_skb,
7253 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS,
7254 nss) ||
7255 nla_put_u8(reply_skb,
7256 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS,
7257 final_rate_flags) ||
7258 nla_put_u32(reply_skb,
7259 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ,
7260 freq)) {
7261 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed"));
7262 kfree_skb(reply_skb);
7263 return -EINVAL;
7264 }
7265
7266 return cfg80211_vendor_cmd_reply(reply_skb);
7267}
7268
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307269#define BEACON_MISS_THRESH_2_4 \
7270 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24
7271#define BEACON_MISS_THRESH_5_0 \
7272 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307273#define PARAM_WIFICONFIG_MAX QCA_WLAN_VENDOR_ATTR_CONFIG_MAX
7274#define PARAM_MODULATED_DTIM QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM
7275#define PARAM_STATS_AVG_FACTOR QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR
7276#define PARAM_GUARD_TIME QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307277#define PARAM_BCNMISS_PENALTY_PARAM_COUNT \
7278 QCA_WLAN_VENDOR_ATTR_CONFIG_PENALIZE_AFTER_NCONS_BEACON_MISS
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307279
7280/**
7281 * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7282 * vendor command
7283 *
7284 * @wiphy: wiphy device pointer
7285 * @wdev: wireless device pointer
7286 * @data: Vendor command data buffer
7287 * @data_len: Buffer length
7288 *
7289 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7290 *
7291 * Return: EOK or other error codes.
7292 */
7293
7294static int __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7295 struct wireless_dev *wdev,
7296 const void *data,
7297 int data_len)
7298{
7299 struct net_device *dev = wdev->netdev;
7300 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7301 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7302 hdd_station_ctx_t *pHddStaCtx;
7303 struct nlattr *tb[PARAM_WIFICONFIG_MAX + 1];
7304 tpSetWifiConfigParams pReq;
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307305 tModifyRoamParamsReqParams modifyRoamParamsReq;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307306 eHalStatus status;
7307 int ret_val;
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307308 uint8_t hb_thresh_val;
7309
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307310 static const struct nla_policy policy[PARAM_WIFICONFIG_MAX + 1] = {
7311 [PARAM_STATS_AVG_FACTOR] = { .type = NLA_U16 },
7312 [PARAM_MODULATED_DTIM] = { .type = NLA_U32 },
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307313 [PARAM_GUARD_TIME] = { .type = NLA_U32},
7314 [PARAM_BCNMISS_PENALTY_PARAM_COUNT] =
7315 { .type = NLA_U32},
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307316 [BEACON_MISS_THRESH_2_4] = { .type = NLA_U8 },
7317 [BEACON_MISS_THRESH_5_0] = { .type = NLA_U8 },
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307318 };
7319
7320 ENTER();
7321
7322 if (VOS_FTM_MODE == hdd_get_conparam()) {
7323 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7324 return -EINVAL;
7325 }
7326
7327 ret_val = wlan_hdd_validate_context(pHddCtx);
7328 if (ret_val) {
7329 return ret_val;
7330 }
7331
7332 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7333
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307334 if (nla_parse(tb, PARAM_WIFICONFIG_MAX, data, data_len, policy)) {
7335 hddLog(LOGE, FL("Invalid ATTR"));
7336 return -EINVAL;
7337 }
7338
7339 /* check the Wifi Capability */
7340 if ( (TRUE != pHddCtx->cfg_ini->fEnableWifiConfig) &&
7341 (TRUE != sme_IsFeatureSupportedByFW(WIFI_CONFIG)))
7342 {
7343 hddLog(VOS_TRACE_LEVEL_ERROR,
7344 FL("WIFICONFIG not supported by Firmware"));
7345 return -EINVAL;
7346 }
7347
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307348 if (tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]) {
7349 modifyRoamParamsReq.param = WIFI_CONFIG_SET_BCNMISS_PENALTY_COUNT;
7350 modifyRoamParamsReq.value =
7351 nla_get_u32(tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]);
7352
7353 if (eHAL_STATUS_SUCCESS !=
7354 sme_setBcnMissPenaltyCount(pHddCtx->hHal,&modifyRoamParamsReq))
7355 {
7356 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed", __func__);
7357 ret_val = -EINVAL;
7358 }
7359 return ret_val;
7360 }
7361
7362 /* Moved this down in order to provide provision to set beacon
7363 * miss penalty count irrespective of connection state.
7364 */
7365 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
7366 hddLog(LOGE, FL("Not in Connected state!"));
7367 return -ENOTSUPP;
7368 }
7369
7370 pReq = vos_mem_malloc(sizeof(tSetWifiConfigParams));
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307371
7372 if (!pReq) {
7373 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7374 "%s: Not able to allocate memory for tSetWifiConfigParams",
7375 __func__);
7376 return eHAL_STATUS_E_MALLOC_FAILED;
7377 }
7378
7379 vos_mem_set(pReq, sizeof(tSetWifiConfigParams), 0);
7380
7381 pReq->sessionId = pAdapter->sessionId;
7382 vos_mem_copy( &pReq->bssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
7383
7384 if (tb[PARAM_MODULATED_DTIM]) {
7385 pReq->paramValue = nla_get_u32(
7386 tb[PARAM_MODULATED_DTIM]);
7387 hddLog(LOG1, FL("Modulated DTIM: pReq->paramValue:%d "),
7388 pReq->paramValue);
Arun Khandavalli876886f2015-11-23 11:42:27 +05307389 pHddCtx->cfg_ini->enableDynamicDTIM = pReq->paramValue;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307390 hdd_set_pwrparams(pHddCtx);
7391 if (BMPS == pmcGetPmcState(pHddCtx->hHal)) {
7392 hddLog( LOG1, FL("WifiConfig: Requesting FullPower!"));
7393
7394 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
7395 iw_full_power_cbfn, pAdapter,
7396 eSME_FULL_PWR_NEEDED_BY_HDD);
7397 }
7398 else
7399 {
7400 hddLog( LOG1, FL("WifiConfig Not in BMPS state"));
7401 }
7402 }
7403
7404 if (tb[PARAM_STATS_AVG_FACTOR]) {
7405 pReq->paramType = WIFI_CONFIG_SET_AVG_STATS_FACTOR;
7406 pReq->paramValue = nla_get_u16(
7407 tb[PARAM_STATS_AVG_FACTOR]);
7408 hddLog(LOG1, FL("AVG_STATS_FACTOR pReq->paramType:%d,pReq->paramValue:%d "),
7409 pReq->paramType, pReq->paramValue);
7410 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7411
7412 if (eHAL_STATUS_SUCCESS != status)
7413 {
7414 vos_mem_free(pReq);
7415 pReq = NULL;
7416 ret_val = -EPERM;
7417 return ret_val;
7418 }
7419 }
7420
7421
7422 if (tb[PARAM_GUARD_TIME]) {
7423 pReq->paramType = WIFI_CONFIG_SET_GUARD_TIME;
7424 pReq->paramValue = nla_get_u32(
7425 tb[PARAM_GUARD_TIME]);
7426 hddLog(LOG1, FL("GUARD_TIME pReq->paramType:%d,pReq->paramValue:%d "),
7427 pReq->paramType, pReq->paramValue);
7428 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7429
7430 if (eHAL_STATUS_SUCCESS != status)
7431 {
7432 vos_mem_free(pReq);
7433 pReq = NULL;
7434 ret_val = -EPERM;
7435 return ret_val;
7436 }
7437
7438 }
7439
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307440 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]) {
7441 hb_thresh_val = nla_get_u8(
7442 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]);
7443
7444 hddLog(LOG1, "WLAN set heartbeat threshold for 2.4Ghz %d",
7445 hb_thresh_val);
7446 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7447 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
7448 NULL, eANI_BOOLEAN_FALSE);
7449
7450 status = sme_update_hb_threshold(
7451 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
7452 WNI_CFG_HEART_BEAT_THRESHOLD,
7453 hb_thresh_val, eCSR_BAND_24);
7454 if (eHAL_STATUS_SUCCESS != status) {
7455 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
7456 vos_mem_free(pReq);
7457 pReq = NULL;
7458 return -EPERM;
7459 }
7460 }
7461
7462 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]) {
7463 hb_thresh_val = nla_get_u8(
7464 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]);
7465
7466 hddLog(LOG1, "WLAN set heartbeat threshold for 5Ghz %d",
7467 hb_thresh_val);
7468 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7469 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
7470 NULL, eANI_BOOLEAN_FALSE);
7471
7472 status = sme_update_hb_threshold(
7473 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
7474 WNI_CFG_HEART_BEAT_THRESHOLD,
7475 hb_thresh_val, eCSR_BAND_5G);
7476 if (eHAL_STATUS_SUCCESS != status) {
7477 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
7478 vos_mem_free(pReq);
7479 pReq = NULL;
7480 return -EPERM;
7481 }
7482 }
7483
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307484 EXIT();
7485 return ret_val;
7486}
7487
7488/**
7489 * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7490 * vendor command
7491 *
7492 * @wiphy: wiphy device pointer
7493 * @wdev: wireless device pointer
7494 * @data: Vendor command data buffer
7495 * @data_len: Buffer length
7496 *
7497 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7498 *
7499 * Return: EOK or other error codes.
7500 */
7501static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7502 struct wireless_dev *wdev,
7503 const void *data,
7504 int data_len)
7505{
7506 int ret;
7507
7508 vos_ssr_protect(__func__);
7509 ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev,
7510 data, data_len);
7511 vos_ssr_unprotect(__func__);
7512
7513 return ret;
7514}
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307515
7516/*
7517 * define short names for the global vendor params
7518 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
7519 */
7520#define STATS_SET_INVALID \
7521 QCA_ATTR_NUD_STATS_SET_INVALID
7522#define STATS_SET_START \
7523 QCA_ATTR_NUD_STATS_SET_START
7524#define STATS_GW_IPV4 \
7525 QCA_ATTR_NUD_STATS_GW_IPV4
7526#define STATS_SET_MAX \
7527 QCA_ATTR_NUD_STATS_SET_MAX
7528
7529const struct nla_policy
7530qca_wlan_vendor_set_nud_stats[STATS_SET_MAX +1] =
7531{
7532 [STATS_SET_START] = {.type = NLA_FLAG },
7533 [STATS_GW_IPV4] = {.type = NLA_U32 },
7534};
7535
7536/**
7537 * hdd_set_nud_stats_cb() - hdd callback api to get status
7538 * @data: pointer to adapter
7539 * @rsp: status
7540 *
7541 * Return: None
7542 */
7543static void hdd_set_nud_stats_cb(void *data, VOS_STATUS rsp)
7544{
7545
7546 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
7547
7548 if (NULL == adapter)
7549 return;
7550
7551 if (VOS_STATUS_SUCCESS == rsp) {
7552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7553 "%s success received STATS_SET_START", __func__);
7554 } else {
7555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7556 "%s STATS_SET_START Failed!!", __func__);
7557 }
7558 return;
7559}
7560
7561/**
7562 * __wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
7563 * @wiphy: pointer to wireless wiphy structure.
7564 * @wdev: pointer to wireless_dev structure.
7565 * @data: pointer to apfind configuration data.
7566 * @data_len: the length in byte of apfind data.
7567 *
7568 * This is called when wlan driver needs to send arp stats to
7569 * firmware.
7570 *
7571 * Return: An error code or 0 on success.
7572 */
7573static int __wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
7574 struct wireless_dev *wdev,
7575 const void *data, int data_len)
7576{
7577 struct nlattr *tb[STATS_SET_MAX + 1];
7578 struct net_device *dev = wdev->netdev;
7579 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7580 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05307581 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307582 setArpStatsParams arp_stats_params;
7583 int err = 0;
7584
7585 ENTER();
7586
7587 err = wlan_hdd_validate_context(hdd_ctx);
7588 if (0 != err)
7589 return err;
7590
7591 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
7592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7593 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
7594 return -EINVAL;
7595 }
7596
7597 err = nla_parse(tb, STATS_SET_MAX, data, data_len,
7598 qca_wlan_vendor_set_nud_stats);
7599 if (err)
7600 {
7601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7602 "%s STATS_SET_START ATTR", __func__);
7603 return err;
7604 }
7605
7606 if (tb[STATS_SET_START])
7607 {
7608 if (!tb[STATS_GW_IPV4]) {
7609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7610 "%s STATS_SET_START CMD", __func__);
7611 return -EINVAL;
7612 }
7613 arp_stats_params.flag = true;
7614 arp_stats_params.ip_addr = nla_get_u32(tb[STATS_GW_IPV4]);
7615 } else {
7616 arp_stats_params.flag = false;
7617 }
Anurag Chouhan630c5562017-03-23 14:51:47 +05307618 if (arp_stats_params.flag)
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7620 "%s STATS_SET_START Cleared!!", __func__);
Anurag Chouhan630c5562017-03-23 14:51:47 +05307621 vos_mem_zero(&adapter->hdd_stats.hddArpStats,
7622 sizeof(adapter->hdd_stats.hddArpStats));
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307623
7624 arp_stats_params.pkt_type = 1; // ARP packet type
7625
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05307626 if (arp_stats_params.flag) {
7627 hdd_ctx->track_arp_ip = arp_stats_params.ip_addr;
7628 WLANTL_SetARPFWDatapath(pVosContext, true);
7629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7630 "%s Set FW in data path for ARP with tgt IP :%d",
7631 __func__, hdd_ctx->track_arp_ip);
7632 }
7633 else {
7634 WLANTL_SetARPFWDatapath(pVosContext, false);
7635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7636 "%s Remove FW from data path", __func__);
7637 }
7638
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307639 arp_stats_params.rsp_cb_fn = hdd_set_nud_stats_cb;
7640 arp_stats_params.data_ctx = adapter;
7641
7642 if (eHAL_STATUS_SUCCESS !=
7643 sme_set_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
7644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7645 "%s STATS_SET_START CMD Failed!!", __func__);
7646 return -EINVAL;
7647 }
7648
7649 EXIT();
7650
7651 return err;
7652}
7653
7654/**
7655 * wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
7656 * @wiphy: pointer to wireless wiphy structure.
7657 * @wdev: pointer to wireless_dev structure.
7658 * @data: pointer to apfind configuration data.
7659 * @data_len: the length in byte of apfind data.
7660 *
7661 * This is called when wlan driver needs to send arp stats to
7662 * firmware.
7663 *
7664 * Return: An error code or 0 on success.
7665 */
7666static int wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
7667 struct wireless_dev *wdev,
7668 const void *data, int data_len)
7669{
7670 int ret;
7671
7672 vos_ssr_protect(__func__);
7673 ret = __wlan_hdd_cfg80211_set_nud_stats(wiphy, wdev, data, data_len);
7674 vos_ssr_unprotect(__func__);
7675
7676 return ret;
7677}
7678#undef STATS_SET_INVALID
7679#undef STATS_SET_START
7680#undef STATS_GW_IPV4
7681#undef STATS_SET_MAX
7682
7683/*
7684 * define short names for the global vendor params
7685 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
7686 */
7687#define STATS_GET_INVALID \
7688 QCA_ATTR_NUD_STATS_SET_INVALID
7689#define COUNT_FROM_NETDEV \
7690 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
7691#define COUNT_TO_LOWER_MAC \
7692 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
7693#define RX_COUNT_BY_LOWER_MAC \
7694 QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
7695#define COUNT_TX_SUCCESS \
7696 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
7697#define RSP_RX_COUNT_BY_LOWER_MAC \
7698 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
7699#define RSP_RX_COUNT_BY_UPPER_MAC \
7700 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
7701#define RSP_COUNT_TO_NETDEV \
7702 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
7703#define RSP_COUNT_OUT_OF_ORDER_DROP \
7704 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
7705#define AP_LINK_ACTIVE \
7706 QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
7707#define AP_LINK_DAD \
7708 QCA_ATTR_NUD_STATS_AP_LINK_DAD
7709#define STATS_GET_MAX \
7710 QCA_ATTR_NUD_STATS_GET_MAX
7711
7712const struct nla_policy
7713qca_wlan_vendor_get_nud_stats[STATS_GET_MAX +1] =
7714{
7715 [COUNT_FROM_NETDEV] = {.type = NLA_U16 },
7716 [COUNT_TO_LOWER_MAC] = {.type = NLA_U16 },
7717 [RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
7718 [COUNT_TX_SUCCESS] = {.type = NLA_U16 },
7719 [RSP_RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
7720 [RSP_RX_COUNT_BY_UPPER_MAC] = {.type = NLA_U16 },
7721 [RSP_COUNT_TO_NETDEV] = {.type = NLA_U16 },
7722 [RSP_COUNT_OUT_OF_ORDER_DROP] = {.type = NLA_U16 },
7723 [AP_LINK_ACTIVE] = {.type = NLA_FLAG },
7724 [AP_LINK_DAD] = {.type = NLA_FLAG },
7725};
7726
7727static void hdd_get_nud_stats_cb(void *data, rsp_stats *rsp)
7728{
7729
7730 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
7731 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
7732 struct hdd_nud_stats_context *context;
7733 int status;
7734
7735 ENTER();
7736
7737 if (NULL == adapter)
7738 return;
7739
7740 status = wlan_hdd_validate_context(hdd_ctx);
7741 if (0 != status) {
7742 return;
7743 }
7744
7745 if (!rsp) {
7746 hddLog(LOGE, FL("data is null"));
7747 return;
7748 }
7749
7750 adapter->hdd_stats.hddArpStats.tx_fw_cnt = rsp->tx_fw_cnt;
7751 adapter->hdd_stats.hddArpStats.rx_fw_cnt = rsp->rx_fw_cnt;
7752 adapter->hdd_stats.hddArpStats.tx_ack_cnt = rsp->tx_ack_cnt;
7753 adapter->dad |= rsp->dad;
7754
7755 spin_lock(&hdd_context_lock);
7756 context = &hdd_ctx->nud_stats_context;
7757 complete(&context->response_event);
7758 spin_unlock(&hdd_context_lock);
7759
7760 return;
7761}
7762static int __wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
7763 struct wireless_dev *wdev,
7764 const void *data, int data_len)
7765{
7766 int err = 0;
7767 unsigned long rc;
7768 struct hdd_nud_stats_context *context;
7769 struct net_device *dev = wdev->netdev;
7770 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7771 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7772 getArpStatsParams arp_stats_params;
7773 struct sk_buff *skb;
7774
7775 ENTER();
7776
7777 err = wlan_hdd_validate_context(hdd_ctx);
7778 if (0 != err)
7779 return err;
7780
7781 arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE;
7782 arp_stats_params.get_rsp_cb_fn = hdd_get_nud_stats_cb;
7783 arp_stats_params.data_ctx = adapter;
7784
7785 spin_lock(&hdd_context_lock);
7786 context = &hdd_ctx->nud_stats_context;
7787 INIT_COMPLETION(context->response_event);
7788 spin_unlock(&hdd_context_lock);
7789
7790 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
7791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7792 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
7793 return -EINVAL;
7794 }
7795
7796 if (eHAL_STATUS_SUCCESS !=
7797 sme_get_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
7798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7799 "%s STATS_SET_START CMD Failed!!", __func__);
7800 return -EINVAL;
7801 }
7802
7803 rc = wait_for_completion_timeout(&context->response_event,
7804 msecs_to_jiffies(WLAN_WAIT_TIME_NUD_STATS));
7805 if (!rc)
7806 {
7807 hddLog(LOGE,
7808 FL("Target response timed out request "));
7809 return -ETIMEDOUT;
7810 }
7811
7812 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7813 WLAN_NUD_STATS_LEN);
7814 if (!skb)
7815 {
7816 hddLog(VOS_TRACE_LEVEL_ERROR,
7817 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
7818 __func__);
7819 return -ENOMEM;
7820 }
7821
7822 if (nla_put_u16(skb, COUNT_FROM_NETDEV,
7823 adapter->hdd_stats.hddArpStats.txCount) ||
7824 nla_put_u16(skb, COUNT_TO_LOWER_MAC,
7825 adapter->hdd_stats.hddArpStats.tx_host_fw_sent) ||
7826 nla_put_u16(skb, RX_COUNT_BY_LOWER_MAC,
7827 adapter->hdd_stats.hddArpStats.tx_fw_cnt) ||
7828 nla_put_u16(skb, COUNT_TX_SUCCESS,
7829 adapter->hdd_stats.hddArpStats.tx_ack_cnt) ||
7830 nla_put_u16(skb, RSP_RX_COUNT_BY_LOWER_MAC,
7831 adapter->hdd_stats.hddArpStats.rx_fw_cnt) ||
7832 nla_put_u16(skb, RSP_RX_COUNT_BY_UPPER_MAC,
7833 adapter->hdd_stats.hddArpStats.rxCount) ||
7834 nla_put_u16(skb, RSP_COUNT_TO_NETDEV,
7835 adapter->hdd_stats.hddArpStats.rxDelivered) ||
7836 nla_put_u16(skb, RSP_COUNT_OUT_OF_ORDER_DROP,
7837 adapter->hdd_stats.hddArpStats.rx_host_drop_reorder)) {
7838 hddLog(LOGE, FL("nla put fail"));
7839 kfree_skb(skb);
7840 return -EINVAL;
7841 }
7842 if (adapter->con_status)
7843 nla_put_flag(skb, AP_LINK_ACTIVE);
7844 if (adapter->dad)
7845 nla_put_flag(skb, AP_LINK_DAD);
7846
7847 cfg80211_vendor_cmd_reply(skb);
7848 return err;
7849}
7850
7851static int wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
7852 struct wireless_dev *wdev,
7853 const void *data, int data_len)
7854{
7855 int ret;
7856
7857 vos_ssr_protect(__func__);
7858 ret = __wlan_hdd_cfg80211_get_nud_stats(wiphy, wdev, data, data_len);
7859 vos_ssr_unprotect(__func__);
7860
7861 return ret;
7862}
7863
7864#undef QCA_ATTR_NUD_STATS_SET_INVALID
7865#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
7866#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
7867#undef QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
7868#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
7869#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
7870#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
7871#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
7872#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
7873#undef QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
7874#undef QCA_ATTR_NUD_STATS_GET_MAX
7875
7876
7877
Kapil Guptaee33bf12016-12-20 18:27:37 +05307878#ifdef WLAN_FEATURE_APFIND
7879/**
7880 * __wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
7881 * @wiphy: pointer to wireless wiphy structure.
7882 * @wdev: pointer to wireless_dev structure.
7883 * @data: pointer to apfind configuration data.
7884 * @data_len: the length in byte of apfind data.
7885 *
7886 * This is called when wlan driver needs to send APFIND configurations to
7887 * firmware.
7888 *
7889 * Return: An error code or 0 on success.
7890 */
7891static int __wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
7892 struct wireless_dev *wdev,
7893 const void *data, int data_len)
7894{
7895 struct sme_ap_find_request_req apfind_req;
7896 VOS_STATUS status;
7897 int ret_val;
7898 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7899
7900 ENTER();
7901
7902 ret_val = wlan_hdd_validate_context(hdd_ctx);
7903 if (ret_val)
7904 return ret_val;
7905
7906 if (VOS_FTM_MODE == hdd_get_conparam()) {
7907 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7908 return -EPERM;
7909 }
7910
7911 apfind_req.request_data_len = data_len;
7912 apfind_req.request_data = data;
7913
7914 status = sme_apfind_set_cmd(&apfind_req);
7915 if (VOS_STATUS_SUCCESS != status) {
7916 ret_val = -EIO;
7917 }
7918 return ret_val;
7919}
7920
7921/**
7922 * wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
7923 * @wiphy: pointer to wireless wiphy structure.
7924 * @wdev: pointer to wireless_dev structure.
7925 * @data: pointer to apfind configuration data.
7926 * @data_len: the length in byte of apfind data.
7927 *
7928 * This is called when wlan driver needs to send APFIND configurations to
7929 * firmware.
7930 *
7931 * Return: An error code or 0 on success.
7932 */
7933static int wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
7934 struct wireless_dev *wdev,
7935 const void *data, int data_len)
7936{
7937 int ret;
7938
7939 vos_ssr_protect(__func__);
7940 ret = __wlan_hdd_cfg80211_apfind_cmd(wiphy, wdev, data, data_len);
7941 vos_ssr_unprotect(__func__);
7942
7943 return ret;
7944}
7945#endif /* WLAN_FEATURE_APFIND */
Sunil Duttc69bccb2014-05-26 21:30:20 +05307946const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
7947{
Mukul Sharma2a271632014-10-13 14:59:01 +05307948 {
7949 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7950 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
7951 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7952 WIPHY_VENDOR_CMD_NEED_NETDEV |
7953 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307954 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05307955 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05307956
7957 {
7958 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7959 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
7960 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7961 WIPHY_VENDOR_CMD_NEED_NETDEV |
7962 WIPHY_VENDOR_CMD_NEED_RUNNING,
7963 .doit = wlan_hdd_cfg80211_nan_request
7964 },
7965
Sunil Duttc69bccb2014-05-26 21:30:20 +05307966#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7967 {
7968 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7969 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
7970 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7971 WIPHY_VENDOR_CMD_NEED_NETDEV |
7972 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307973 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05307974 },
7975
7976 {
7977 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7978 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
7979 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7980 WIPHY_VENDOR_CMD_NEED_NETDEV |
7981 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307982 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05307983 },
7984
7985 {
7986 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7987 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
7988 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7989 WIPHY_VENDOR_CMD_NEED_NETDEV |
7990 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307991 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05307992 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307993#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307994#ifdef WLAN_FEATURE_EXTSCAN
7995 {
7996 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7997 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
7998 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7999 WIPHY_VENDOR_CMD_NEED_NETDEV |
8000 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308001 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05308002 },
8003 {
8004 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8005 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
8006 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8007 WIPHY_VENDOR_CMD_NEED_NETDEV |
8008 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308009 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05308010 },
8011 {
8012 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8013 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
8014 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8015 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308016 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05308017 },
8018 {
8019 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8020 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
8021 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8022 WIPHY_VENDOR_CMD_NEED_NETDEV |
8023 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308024 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05308025 },
8026 {
8027 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8028 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
8029 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8030 WIPHY_VENDOR_CMD_NEED_NETDEV |
8031 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308032 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05308033 },
8034 {
8035 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8036 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
8037 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8038 WIPHY_VENDOR_CMD_NEED_NETDEV |
8039 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308040 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05308041 },
8042 {
8043 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8044 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
8045 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8046 WIPHY_VENDOR_CMD_NEED_NETDEV |
8047 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308048 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05308049 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05308050#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05308051/*EXT TDLS*/
8052 {
8053 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8054 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
8055 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8056 WIPHY_VENDOR_CMD_NEED_NETDEV |
8057 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308058 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05308059 },
8060 {
8061 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8062 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
8063 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8064 WIPHY_VENDOR_CMD_NEED_NETDEV |
8065 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308066 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05308067 },
8068 {
8069 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8070 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
8071 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8072 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308073 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05308074 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05308075 {
8076 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8077 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
8078 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8079 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308080 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05308081 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05308082 {
8083 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8084 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
8085 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8086 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308087 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05308088 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05308089 {
8090 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8091 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
8092 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8093 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308094 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05308095 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05308096 {
8097 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8098 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
8099 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8100 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308101 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05308102 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05308103 {
8104 .info.vendor_id = QCA_NL80211_VENDOR_ID,
c_manjeecfd1efb2015-09-25 19:32:34 +05308105 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP,
8106 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8107 WIPHY_VENDOR_CMD_NEED_NETDEV |
8108 WIPHY_VENDOR_CMD_NEED_RUNNING,
8109 .doit = wlan_hdd_cfg80211_get_fw_mem_dump
8110 },
8111 {
8112 .info.vendor_id = QCA_NL80211_VENDOR_ID,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05308113 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
8114 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8115 WIPHY_VENDOR_CMD_NEED_NETDEV |
8116 WIPHY_VENDOR_CMD_NEED_RUNNING,
8117 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05308118 },
8119 {
8120 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8121 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
8122 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8123 WIPHY_VENDOR_CMD_NEED_NETDEV,
8124 .doit = wlan_hdd_cfg80211_wifi_logger_start
8125 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05308126 {
8127 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8128 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
8129 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8130 WIPHY_VENDOR_CMD_NEED_NETDEV|
8131 WIPHY_VENDOR_CMD_NEED_RUNNING,
8132 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05308133 },
8134 {
8135 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8136 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
8137 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8138 WIPHY_VENDOR_CMD_NEED_NETDEV |
8139 WIPHY_VENDOR_CMD_NEED_RUNNING,
8140 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05308141 },
8142 {
8143 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8144 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
8145 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8146 WIPHY_VENDOR_CMD_NEED_NETDEV |
8147 WIPHY_VENDOR_CMD_NEED_RUNNING,
8148 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05308149 },
8150#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
8151 {
8152 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8153 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
8154 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8155 WIPHY_VENDOR_CMD_NEED_NETDEV |
8156 WIPHY_VENDOR_CMD_NEED_RUNNING,
8157 .doit = wlan_hdd_cfg80211_offloaded_packets
Deepthi Gowriae6a1662015-10-12 12:59:37 +05308158 },
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05308159#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05308160 {
8161 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8162 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
8163 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8164 WIPHY_VENDOR_CMD_NEED_NETDEV |
8165 WIPHY_VENDOR_CMD_NEED_RUNNING,
8166 .doit = wlan_hdd_cfg80211_get_link_properties
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05308167 },
8168 {
8169 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8170 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION,
8171 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8172 WIPHY_VENDOR_CMD_NEED_NETDEV |
8173 WIPHY_VENDOR_CMD_NEED_RUNNING,
8174 .doit = wlan_hdd_cfg80211_wifi_configuration_set
Kapil Guptaee33bf12016-12-20 18:27:37 +05308175 },
8176#ifdef WLAN_FEATURE_APFIND
8177 {
8178 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8179 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_APFIND,
8180 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8181 WIPHY_VENDOR_CMD_NEED_NETDEV,
8182 .doit = wlan_hdd_cfg80211_apfind_cmd
8183 },
8184#endif /* WLAN_FEATURE_APFIND */
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308185 {
8186 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8187 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_SET,
8188 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8189 WIPHY_VENDOR_CMD_NEED_NETDEV |
8190 WIPHY_VENDOR_CMD_NEED_RUNNING,
8191 .doit = wlan_hdd_cfg80211_set_nud_stats
8192 },
8193 {
8194 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8195 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
8196 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8197 WIPHY_VENDOR_CMD_NEED_NETDEV |
8198 WIPHY_VENDOR_CMD_NEED_RUNNING,
8199 .doit = wlan_hdd_cfg80211_get_nud_stats
8200 },
Anurag Chouhanfcd20172017-07-19 17:25:19 +05308201 {
8202 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8203 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_STATION,
8204 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8205 WIPHY_VENDOR_CMD_NEED_NETDEV |
8206 WIPHY_VENDOR_CMD_NEED_RUNNING,
8207 .doit = hdd_cfg80211_get_station_cmd
8208 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308209};
8210
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008211/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05308212static const
8213struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008214{
8215#ifdef FEATURE_WLAN_CH_AVOID
8216 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05308217 .vendor_id = QCA_NL80211_VENDOR_ID,
8218 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008219 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308220#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
8221#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8222 {
8223 /* Index = 1*/
8224 .vendor_id = QCA_NL80211_VENDOR_ID,
8225 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
8226 },
8227 {
8228 /* Index = 2*/
8229 .vendor_id = QCA_NL80211_VENDOR_ID,
8230 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
8231 },
8232 {
8233 /* Index = 3*/
8234 .vendor_id = QCA_NL80211_VENDOR_ID,
8235 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
8236 },
8237 {
8238 /* Index = 4*/
8239 .vendor_id = QCA_NL80211_VENDOR_ID,
8240 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
8241 },
8242 {
8243 /* Index = 5*/
8244 .vendor_id = QCA_NL80211_VENDOR_ID,
8245 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
8246 },
8247 {
8248 /* Index = 6*/
8249 .vendor_id = QCA_NL80211_VENDOR_ID,
8250 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
8251 },
8252#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05308253#ifdef WLAN_FEATURE_EXTSCAN
8254 {
8255 .vendor_id = QCA_NL80211_VENDOR_ID,
8256 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
8257 },
8258 {
8259 .vendor_id = QCA_NL80211_VENDOR_ID,
8260 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
8261 },
8262 {
8263 .vendor_id = QCA_NL80211_VENDOR_ID,
8264 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
8265 },
8266 {
8267 .vendor_id = QCA_NL80211_VENDOR_ID,
8268 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
8269 },
8270 {
8271 .vendor_id = QCA_NL80211_VENDOR_ID,
8272 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
8273 },
8274 {
8275 .vendor_id = QCA_NL80211_VENDOR_ID,
8276 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
8277 },
8278 {
8279 .vendor_id = QCA_NL80211_VENDOR_ID,
8280 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
8281 },
8282 {
8283 .vendor_id = QCA_NL80211_VENDOR_ID,
8284 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
8285 },
8286 {
8287 .vendor_id = QCA_NL80211_VENDOR_ID,
8288 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
8289 },
8290 {
8291 .vendor_id = QCA_NL80211_VENDOR_ID,
8292 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
8293 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05308294#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05308295/*EXT TDLS*/
8296 {
8297 .vendor_id = QCA_NL80211_VENDOR_ID,
8298 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
8299 },
c_manjeecfd1efb2015-09-25 19:32:34 +05308300 [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = {
8301 .vendor_id = QCA_NL80211_VENDOR_ID,
8302 .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP
8303 },
8304
Srinivas Dasari030bad32015-02-18 23:23:54 +05308305
Srinivas Dasaribd1cf642017-01-23 14:54:41 +05308306 [QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX] = {
Srinivas Dasari030bad32015-02-18 23:23:54 +05308307 .vendor_id = QCA_NL80211_VENDOR_ID,
8308 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
8309 },
8310
Sushant Kaushik084f6592015-09-10 13:11:56 +05308311 {
8312 .vendor_id = QCA_NL80211_VENDOR_ID,
8313 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05308314 },
8315 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
8316 .vendor_id = QCA_NL80211_VENDOR_ID,
8317 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
8318 },
Padma, Santhosh Kumar7bbc7d92015-12-08 20:23:19 +05308319 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = {
8320 .vendor_id = QCA_NL80211_VENDOR_ID,
8321 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST
8322 },
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308323 [QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET_INDEX] = {
8324 .vendor_id = QCA_NL80211_VENDOR_ID,
8325 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
8326 },
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008327};
8328
Jeff Johnson295189b2012-06-20 16:38:30 -07008329/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308330 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308331 * This function is called by hdd_wlan_startup()
8332 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308333 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308335struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07008336{
8337 struct wiphy *wiphy;
8338 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308339 /*
8340 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07008341 */
8342 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
8343
8344 if (!wiphy)
8345 {
8346 /* Print error and jump into err label and free the memory */
8347 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
8348 return NULL;
8349 }
8350
Sunil Duttc69bccb2014-05-26 21:30:20 +05308351
Jeff Johnson295189b2012-06-20 16:38:30 -07008352 return wiphy;
8353}
8354
Anurag Chouhan343af7e2016-12-16 13:11:19 +05308355#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,4,0)) || \
8356 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
8357/**
8358 * hdd_config_sched_scan_plans_to_wiphy() - configure sched scan plans to wiphy
8359 * @wiphy: pointer to wiphy
8360 * @config: pointer to config
8361 *
8362 * Return: None
8363 */
8364static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
8365 hdd_config_t *config)
8366{
8367 wiphy->max_sched_scan_plans = MAX_SCHED_SCAN_PLANS;
8368 if (config->max_sched_scan_plan_interval)
8369 wiphy->max_sched_scan_plan_interval =
8370 config->max_sched_scan_plan_interval;
8371 if (config->max_sched_scan_plan_iterations)
8372 wiphy->max_sched_scan_plan_iterations =
8373 config->max_sched_scan_plan_iterations;
8374}
8375#else
8376static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
8377 hdd_config_t *config)
8378{
8379}
8380#endif
8381
Jeff Johnson295189b2012-06-20 16:38:30 -07008382/*
8383 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308384 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 * private ioctl to change the band value
8386 */
8387int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
8388{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308389 int i, j;
8390 eNVChannelEnabledType channelEnabledState;
8391
Jeff Johnsone7245742012-09-05 17:12:55 -07008392 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308393
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308394 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008395 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308396
8397 if (NULL == wiphy->bands[i])
8398 {
8399 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
8400 __func__, i);
8401 continue;
8402 }
8403
8404 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8405 {
8406 struct ieee80211_supported_band *band = wiphy->bands[i];
8407
8408 channelEnabledState = vos_nv_getChannelEnabledState(
8409 band->channels[j].hw_value);
8410
8411 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
8412 {
Abhishek Singh678227a2014-11-04 10:52:38 +05308413 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308414 continue;
8415 }
8416 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
8417 {
8418 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8419 continue;
8420 }
8421
8422 if (NV_CHANNEL_DISABLE == channelEnabledState ||
8423 NV_CHANNEL_INVALID == channelEnabledState)
8424 {
8425 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8426 }
8427 else if (NV_CHANNEL_DFS == channelEnabledState)
8428 {
8429 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
8430 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
8431 }
8432 else
8433 {
8434 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
8435 |IEEE80211_CHAN_RADAR);
8436 }
8437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 }
8439 return 0;
8440}
8441/*
8442 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308443 * This function is called by hdd_wlan_startup()
8444 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07008445 * This function is used to initialize and register wiphy structure.
8446 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308447int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07008448 struct wiphy *wiphy,
8449 hdd_config_t *pCfg
8450 )
8451{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308452 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05308453 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8454
Jeff Johnsone7245742012-09-05 17:12:55 -07008455 ENTER();
8456
Jeff Johnson295189b2012-06-20 16:38:30 -07008457 /* Now bind the underlying wlan device with wiphy */
8458 set_wiphy_dev(wiphy, dev);
8459
8460 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07008461
Kiet Lam6c583332013-10-14 05:37:09 +05308462#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07008463 /* the flag for the other case would be initialzed in
8464 vos_init_wiphy_from_nv_bin */
Manjeet Singh9e19de62016-08-18 18:26:41 +05308465#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
8466 wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
8467#else
Amar Singhal0a402232013-10-11 20:57:16 -07008468 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05308469#endif
Manjeet Singh9e19de62016-08-18 18:26:41 +05308470#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07008471
Amar Singhalfddc28c2013-09-05 13:03:40 -07008472 /* This will disable updating of NL channels from passive to
8473 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05308474#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
8475 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
8476#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07008477 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05308478#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07008479
Amar Singhala49cbc52013-10-08 18:37:44 -07008480
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008481#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07008482 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
8483 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
8484 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07008485 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05308486#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Rajeev Kumar Sirasanagandla0d6dd752016-08-17 15:01:39 +05308487 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05308488#else
8489 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
8490#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008491#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07008492
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008493#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07008494 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08008495#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07008496 || pCfg->isFastRoamIniFeatureEnabled
8497#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008498#ifdef FEATURE_WLAN_ESE
8499 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07008500#endif
8501 )
8502 {
8503 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
8504 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08008505#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008506#ifdef FEATURE_WLAN_TDLS
8507 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
8508 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
8509#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308510#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05308511 if (pCfg->configPNOScanSupport)
8512 {
8513 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
8514 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
8515 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
8516 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
8517 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308518#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008519
Abhishek Singh10d85972015-04-17 10:27:23 +05308520#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
8521 wiphy->features |= NL80211_FEATURE_HT_IBSS;
8522#endif
8523
Amar Singhalfddc28c2013-09-05 13:03:40 -07008524#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07008525 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
8526 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07008527 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07008528 driver need to determine what to do with both
8529 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07008530
8531 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07008532#else
8533 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07008534#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008535
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308536 wiphy->max_scan_ssids = MAX_SCAN_SSID;
8537
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05308538 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07008539
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308540 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
8541
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05308543 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
8544 | BIT(NL80211_IFTYPE_ADHOC)
8545 | BIT(NL80211_IFTYPE_P2P_CLIENT)
8546 | BIT(NL80211_IFTYPE_P2P_GO)
8547 | BIT(NL80211_IFTYPE_AP);
8548
8549 if (VOS_MONITOR_MODE == hdd_get_conparam())
8550 {
8551 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
8552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008553
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308554 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008555 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308556#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
8557 if( pCfg->enableMCC )
8558 {
8559 /* Currently, supports up to two channels */
8560 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008561
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308562 if( !pCfg->allowMCCGODiffBI )
8563 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008564
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308565 }
8566 wiphy->iface_combinations = &wlan_hdd_iface_combination;
8567 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008568#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308569 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008570
Jeff Johnson295189b2012-06-20 16:38:30 -07008571 /* Before registering we need to update the ht capabilitied based
8572 * on ini values*/
8573 if( !pCfg->ShortGI20MhzEnable )
8574 {
8575 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
8576 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 }
8578
8579 if( !pCfg->ShortGI40MhzEnable )
8580 {
8581 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
8582 }
8583
8584 if( !pCfg->nChannelBondingMode5GHz )
8585 {
8586 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
8587 }
Agrawal Ashish97dec502015-11-26 20:20:58 +05308588 /*
8589 * In case of static linked driver at the time of driver unload,
8590 * module exit doesn't happens. Module cleanup helps in cleaning
8591 * of static memory.
8592 * If driver load happens statically, at the time of driver unload,
8593 * wiphy flags don't get reset because of static memory.
8594 * It's better not to store channel in static memory.
8595 */
8596 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
8597 wiphy->bands[IEEE80211_BAND_2GHZ]->channels =
8598 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_2_4_GHZ));
8599 if (wiphy->bands[IEEE80211_BAND_2GHZ]->channels == NULL)
8600 {
8601 hddLog(VOS_TRACE_LEVEL_ERROR,
8602 FL("Not enough memory to allocate channels"));
8603 return -ENOMEM;
8604 }
8605 vos_mem_copy(wiphy->bands[IEEE80211_BAND_2GHZ]->channels,
8606 &hdd_channels_2_4_GHZ[0],
8607 sizeof(hdd_channels_2_4_GHZ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008608
Agrawal Ashish97dec502015-11-26 20:20:58 +05308609 if (true == hdd_is_5g_supported(pHddCtx))
8610 {
8611 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
8612 wiphy->bands[IEEE80211_BAND_5GHZ]->channels =
8613 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_5_GHZ));
8614 if (wiphy->bands[IEEE80211_BAND_5GHZ]->channels == NULL)
8615 {
8616 hddLog(VOS_TRACE_LEVEL_ERROR,
8617 FL("Not enough memory to allocate channels"));
8618 vos_mem_free(wiphy->bands[IEEE80211_BAND_2GHZ]->channels);
8619 wiphy->bands[IEEE80211_BAND_2GHZ]->channels = NULL;
8620 return -ENOMEM;
8621 }
8622 vos_mem_copy(wiphy->bands[IEEE80211_BAND_5GHZ]->channels,
8623 &hdd_channels_5_GHZ[0],
8624 sizeof(hdd_channels_5_GHZ));
8625 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308626
8627 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8628 {
8629
8630 if (NULL == wiphy->bands[i])
8631 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05308632 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308633 __func__, i);
8634 continue;
8635 }
8636
8637 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8638 {
8639 struct ieee80211_supported_band *band = wiphy->bands[i];
8640
8641 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
8642 {
8643 // Enable social channels for P2P
8644 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
8645 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
8646 else
8647 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8648 continue;
8649 }
8650 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
8651 {
8652 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8653 continue;
8654 }
8655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008656 }
8657 /*Initialise the supported cipher suite details*/
8658 wiphy->cipher_suites = hdd_cipher_suites;
8659 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
8660
8661 /*signal strength in mBm (100*dBm) */
8662 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
8663
8664#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05308665 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07008666#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008667
Sunil Duttc69bccb2014-05-26 21:30:20 +05308668 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
8669 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008670 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
8671 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
8672
Anurag Chouhan343af7e2016-12-16 13:11:19 +05308673 hdd_config_sched_scan_plans_to_wiphy(wiphy, pCfg);
8674
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308675 EXIT();
8676 return 0;
8677}
8678
8679/* In this function we are registering wiphy. */
8680int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
8681{
8682 ENTER();
8683 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008684 if (0 > wiphy_register(wiphy))
8685 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308686 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
8688 return -EIO;
8689 }
8690
8691 EXIT();
8692 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308693}
Jeff Johnson295189b2012-06-20 16:38:30 -07008694
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308695/* In this function we are updating channel list when,
8696 regulatory domain is FCC and country code is US.
8697 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
8698 As per FCC smart phone is not a indoor device.
8699 GO should not opeate on indoor channels */
8700void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
8701{
8702 int j;
8703 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8704 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
8705 //Default counrtycode from NV at the time of wiphy initialization.
8706 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
8707 &defaultCountryCode[0]))
8708 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008709 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308710 }
8711 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
8712 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308713 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
8714 {
8715 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
8716 return;
8717 }
8718 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
8719 {
8720 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
8721 // Mark UNII -1 band channel as passive
8722 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
8723 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
8724 }
8725 }
8726}
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308727/* This function registers for all frame which supplicant is interested in */
8728void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008729{
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8731 /* Register for all P2P action, public action etc frames */
8732 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
Jeff Johnsone7245742012-09-05 17:12:55 -07008733 ENTER();
Abhishek Singh16e05762015-11-30 14:29:27 +05308734 /* Register frame indication call back */
8735 sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame);
Jeff Johnson295189b2012-06-20 16:38:30 -07008736 /* Right now we are registering these frame when driver is getting
8737 initialized. Once we will move to 2.6.37 kernel, in which we have
8738 frame register ops, we will move this code as a part of that */
8739 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308740 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8742
8743 /* GAS Initial Response */
8744 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8745 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308746
Jeff Johnson295189b2012-06-20 16:38:30 -07008747 /* GAS Comeback Request */
8748 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8749 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8750
8751 /* GAS Comeback Response */
8752 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8753 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8754
8755 /* P2P Public Action */
8756 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308757 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 P2P_PUBLIC_ACTION_FRAME_SIZE );
8759
8760 /* P2P Action */
8761 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8762 (v_U8_t*)P2P_ACTION_FRAME,
8763 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07008764
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05308765 /* WNM BSS Transition Request frame */
8766 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8767 (v_U8_t*)WNM_BSS_ACTION_FRAME,
8768 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008769
8770 /* WNM-Notification */
8771 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8772 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8773 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008774}
8775
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308776void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008777{
Jeff Johnson295189b2012-06-20 16:38:30 -07008778 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8779 /* Register for all P2P action, public action etc frames */
8780 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
8781
Jeff Johnsone7245742012-09-05 17:12:55 -07008782 ENTER();
8783
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 /* Right now we are registering these frame when driver is getting
8785 initialized. Once we will move to 2.6.37 kernel, in which we have
8786 frame register ops, we will move this code as a part of that */
8787 /* GAS Initial Request */
8788
8789 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8790 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8791
8792 /* GAS Initial Response */
8793 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8794 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308795
Jeff Johnson295189b2012-06-20 16:38:30 -07008796 /* GAS Comeback Request */
8797 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8798 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8799
8800 /* GAS Comeback Response */
8801 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8802 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8803
8804 /* P2P Public Action */
8805 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308806 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008807 P2P_PUBLIC_ACTION_FRAME_SIZE );
8808
8809 /* P2P Action */
8810 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8811 (v_U8_t*)P2P_ACTION_FRAME,
8812 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008813 /* WNM-Notification */
8814 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8815 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8816 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008817}
8818
8819#ifdef FEATURE_WLAN_WAPI
8820void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05308821 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07008822{
8823 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8824 tCsrRoamSetKey setKey;
8825 v_BOOL_t isConnected = TRUE;
8826 int status = 0;
8827 v_U32_t roamId= 0xFF;
8828 tANI_U8 *pKeyPtr = NULL;
8829 int n = 0;
8830
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308831 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
8832 __func__, hdd_device_modetoString(pAdapter->device_mode),
8833 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008834
Gopichand Nakkalae7480202013-02-11 15:24:22 +05308835 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008836 setKey.keyId = key_index; // Store Key ID
8837 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
8838 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
8839 setKey.paeRole = 0 ; // the PAE role
8840 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
8841 {
8842 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
8843 }
8844 else
8845 {
8846 isConnected = hdd_connIsConnected(pHddStaCtx);
8847 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
8848 }
8849 setKey.keyLength = key_Len;
8850 pKeyPtr = setKey.Key;
8851 memcpy( pKeyPtr, key, key_Len);
8852
Arif Hussain6d2a3322013-11-17 19:50:10 -08008853 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07008854 __func__, key_Len);
8855 for (n = 0 ; n < key_Len; n++)
8856 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
8857 __func__,n,setKey.Key[n]);
8858
8859 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8860 if ( isConnected )
8861 {
8862 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8863 pAdapter->sessionId, &setKey, &roamId );
8864 }
8865 if ( status != 0 )
8866 {
8867 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8868 "[%4d] sme_RoamSetKey returned ERROR status= %d",
8869 __LINE__, status );
8870 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8871 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308872 /* Need to clear any trace of key value in the memory.
8873 * Thus zero out the memory even though it is local
8874 * variable.
8875 */
8876 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008877}
8878#endif /* FEATURE_WLAN_WAPI*/
8879
8880#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308881int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008882 beacon_data_t **ppBeacon,
8883 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008884#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308885int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008886 beacon_data_t **ppBeacon,
8887 struct cfg80211_beacon_data *params,
8888 int dtim_period)
8889#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308890{
Jeff Johnson295189b2012-06-20 16:38:30 -07008891 int size;
8892 beacon_data_t *beacon = NULL;
8893 beacon_data_t *old = NULL;
Kapil Gupta137ef892016-12-13 19:38:00 +05308894 int head_len, tail_len, proberesp_ies_len, assocresp_ies_len;
8895 const u8 *head, *tail, *proberesp_ies, *assocresp_ies;
Jeff Johnson295189b2012-06-20 16:38:30 -07008896
Jeff Johnsone7245742012-09-05 17:12:55 -07008897 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008898 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308899 {
8900 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8901 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008904
8905 old = pAdapter->sessionCtx.ap.beacon;
8906
8907 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308908 {
8909 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8910 FL("session(%d) old and new heads points to NULL"),
8911 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008912 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308913 }
8914
8915 if (params->tail && !params->tail_len)
8916 {
8917 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8918 FL("tail_len is zero but tail is not NULL"));
8919 return -EINVAL;
8920 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008921
Jeff Johnson295189b2012-06-20 16:38:30 -07008922#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
8923 /* Kernel 3.0 is not updating dtim_period for set beacon */
8924 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308925 {
8926 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8927 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008930#endif
8931
Kapil Gupta137ef892016-12-13 19:38:00 +05308932 if (params->head)
8933 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008934 head_len = params->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308935 head = params->head;
8936 } else
8937 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008938 head_len = old->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308939 head = old->head;
8940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008941
Kapil Gupta137ef892016-12-13 19:38:00 +05308942 if (params->tail || !old)
8943 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 tail_len = params->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308945 tail = params->tail;
8946 } else
8947 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008948 tail_len = old->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308949 tail = old->tail;
8950 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008951
Kapil Gupta137ef892016-12-13 19:38:00 +05308952 if (params->proberesp_ies || !old)
8953 {
8954 proberesp_ies_len = params->proberesp_ies_len;
8955 proberesp_ies = params->proberesp_ies;
8956 } else
8957 {
8958 proberesp_ies_len = old->proberesp_ies_len;
8959 proberesp_ies = old->proberesp_ies;
8960 }
8961
8962 if (params->assocresp_ies || !old)
8963 {
8964 assocresp_ies_len = params->assocresp_ies_len;
8965 assocresp_ies = params->assocresp_ies;
8966 } else
8967 {
8968 assocresp_ies_len = old->assocresp_ies_len;
8969 assocresp_ies = old->assocresp_ies;
8970 }
8971
8972 size = sizeof(beacon_data_t) + head_len + tail_len +
8973 proberesp_ies_len + assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07008974
8975 beacon = kzalloc(size, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07008976 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308977 {
8978 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8979 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008980 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008982
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008983#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Kapil Gupta137ef892016-12-13 19:38:00 +05308984 if (params->dtim_period)
Jeff Johnson295189b2012-06-20 16:38:30 -07008985 beacon->dtim_period = params->dtim_period;
8986 else
8987 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008988#else
Kapil Gupta137ef892016-12-13 19:38:00 +05308989 if (dtim_period)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008990 beacon->dtim_period = dtim_period;
8991 else
8992 beacon->dtim_period = old->dtim_period;
8993#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308994
Jeff Johnson295189b2012-06-20 16:38:30 -07008995 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
8996 beacon->tail = beacon->head + head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308997 beacon->proberesp_ies = beacon->tail + tail_len;
8998 beacon->assocresp_ies = beacon->proberesp_ies + proberesp_ies_len;
8999
Jeff Johnson295189b2012-06-20 16:38:30 -07009000 beacon->head_len = head_len;
9001 beacon->tail_len = tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309002 beacon->proberesp_ies_len = proberesp_ies_len;
9003 beacon->assocresp_ies_len= assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07009004
c_manjee527ecac2017-01-25 12:25:27 +05309005 if (head && head_len)
9006 memcpy(beacon->head, head, head_len);
9007 if (tail && tail_len)
9008 memcpy(beacon->tail, tail, tail_len);
9009 if (proberesp_ies && proberesp_ies_len)
9010 memcpy(beacon->proberesp_ies, proberesp_ies, proberesp_ies_len);
9011 if (assocresp_ies && assocresp_ies_len)
9012 memcpy(beacon->assocresp_ies, assocresp_ies, assocresp_ies_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009013
9014 *ppBeacon = beacon;
9015
9016 kfree(old);
9017
9018 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009019}
Jeff Johnson295189b2012-06-20 16:38:30 -07009020
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309021v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
9022#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
9023 const v_U8_t *pIes,
9024#else
9025 v_U8_t *pIes,
9026#endif
9027 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009028{
9029 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309030 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07009031 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309032
Jeff Johnson295189b2012-06-20 16:38:30 -07009033 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309034 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009035 elem_id = ptr[0];
9036 elem_len = ptr[1];
9037 left -= 2;
9038 if(elem_len > left)
9039 {
9040 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009041 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 eid,elem_len,left);
9043 return NULL;
9044 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309045 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009046 {
9047 return ptr;
9048 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309049
Jeff Johnson295189b2012-06-20 16:38:30 -07009050 left -= elem_len;
9051 ptr += (elem_len + 2);
9052 }
9053 return NULL;
9054}
9055
Jeff Johnson295189b2012-06-20 16:38:30 -07009056/* Check if rate is 11g rate or not */
9057static int wlan_hdd_rate_is_11g(u8 rate)
9058{
Sanjay Devnani28322e22013-06-21 16:13:40 -07009059 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009060 u8 i;
9061 for (i = 0; i < 8; i++)
9062 {
9063 if(rate == gRateArray[i])
9064 return TRUE;
9065 }
9066 return FALSE;
9067}
9068
9069/* Check for 11g rate and set proper 11g only mode */
9070static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
9071 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
9072{
9073 u8 i, num_rates = pIe[0];
9074
9075 pIe += 1;
9076 for ( i = 0; i < num_rates; i++)
9077 {
9078 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
9079 {
9080 /* If rate set have 11g rate than change the mode to 11G */
9081 *pSapHw_mode = eSAP_DOT11_MODE_11g;
9082 if (pIe[i] & BASIC_RATE_MASK)
9083 {
9084 /* If we have 11g rate as basic rate, it means mode
9085 is 11g only mode.
9086 */
9087 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
9088 *pCheckRatesfor11g = FALSE;
9089 }
9090 }
9091 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
9092 {
9093 *require_ht = TRUE;
9094 }
9095 }
9096 return;
9097}
9098
9099static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
9100{
9101 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9102 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9103 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9104 u8 checkRatesfor11g = TRUE;
9105 u8 require_ht = FALSE;
9106 u8 *pIe=NULL;
9107
9108 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
9109
9110 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
9111 pBeacon->head_len, WLAN_EID_SUPP_RATES);
9112 if (pIe != NULL)
9113 {
9114 pIe += 1;
9115 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
9116 &pConfig->SapHw_mode);
9117 }
9118
9119 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
9120 WLAN_EID_EXT_SUPP_RATES);
9121 if (pIe != NULL)
9122 {
9123
9124 pIe += 1;
9125 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
9126 &pConfig->SapHw_mode);
9127 }
9128
9129 if( pConfig->channel > 14 )
9130 {
9131 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
9132 }
9133
9134 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
9135 WLAN_EID_HT_CAPABILITY);
9136
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309137 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009138 {
9139 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
9140 if(require_ht)
9141 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
9142 }
9143}
9144
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309145static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
9146 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
9147{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009148 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309149 v_U8_t *pIe = NULL;
9150 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9151
9152 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
9153 pBeacon->tail, pBeacon->tail_len);
9154
9155 if (pIe)
9156 {
9157 ielen = pIe[1] + 2;
9158 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
9159 {
9160 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
9161 }
9162 else
9163 {
9164 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
9165 return -EINVAL;
9166 }
9167 *total_ielen += ielen;
9168 }
9169 return 0;
9170}
9171
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009172static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
9173 v_U8_t *genie, v_U8_t *total_ielen)
9174{
9175 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9176 int left = pBeacon->tail_len;
9177 v_U8_t *ptr = pBeacon->tail;
9178 v_U8_t elem_id, elem_len;
9179 v_U16_t ielen = 0;
9180
9181 if ( NULL == ptr || 0 == left )
9182 return;
9183
9184 while (left >= 2)
9185 {
9186 elem_id = ptr[0];
9187 elem_len = ptr[1];
9188 left -= 2;
9189 if (elem_len > left)
9190 {
9191 hddLog( VOS_TRACE_LEVEL_ERROR,
9192 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
9193 elem_id, elem_len, left);
9194 return;
9195 }
9196 if (IE_EID_VENDOR == elem_id)
9197 {
9198 /* skipping the VSIE's which we don't want to include or
9199 * it will be included by existing code
9200 */
9201 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
9202#ifdef WLAN_FEATURE_WFD
9203 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
9204#endif
9205 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9206 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9207 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
9208 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9209 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
9210 {
9211 ielen = ptr[1] + 2;
9212 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
9213 {
9214 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
9215 *total_ielen += ielen;
9216 }
9217 else
9218 {
9219 hddLog( VOS_TRACE_LEVEL_ERROR,
9220 "IE Length is too big "
9221 "IEs eid=%d elem_len=%d total_ie_lent=%d",
9222 elem_id, elem_len, *total_ielen);
9223 }
9224 }
9225 }
9226
9227 left -= elem_len;
9228 ptr += (elem_len + 2);
9229 }
9230 return;
9231}
9232
Kapil Gupta137ef892016-12-13 19:38:00 +05309233int wlan_hdd_cfg80211_update_apies(hdd_adapter_t *pHostapdAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009234{
9235 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309236 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009237 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07009238 int ret = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +05309239 beacon_data_t *pBeacon = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009240
9241 genie = vos_mem_malloc(MAX_GENIE_LEN);
9242
9243 if(genie == NULL) {
9244
9245 return -ENOMEM;
9246 }
9247
Kapil Gupta137ef892016-12-13 19:38:00 +05309248 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309249 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9250 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07009251 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309252 hddLog(LOGE,
9253 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309254 ret = -EINVAL;
9255 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009256 }
9257
9258#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309259 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9260 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
9261 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309262 hddLog(LOGE,
9263 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309264 ret = -EINVAL;
9265 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009266 }
9267#endif
9268
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309269 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9270 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07009271 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309272 hddLog(LOGE,
9273 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309274 ret = -EINVAL;
9275 goto done;
9276 }
9277
9278 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
9279 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009280 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009281 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009282
9283 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9284 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
9285 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
9286 {
9287 hddLog(LOGE,
9288 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009289 ret = -EINVAL;
9290 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009291 }
9292
9293 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9294 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
9295 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
9296 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
9297 ==eHAL_STATUS_FAILURE)
9298 {
9299 hddLog(LOGE,
9300 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009301 ret = -EINVAL;
9302 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009303 }
9304
9305 // Added for ProResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +05309306 if ((pBeacon->proberesp_ies != NULL) && (pBeacon->proberesp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009307 {
Kapil Gupta137ef892016-12-13 19:38:00 +05309308 u16 rem_probe_resp_ie_len = pBeacon->proberesp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 u8 probe_rsp_ie_len[3] = {0};
9310 u8 counter = 0;
9311 /* Check Probe Resp Length if it is greater then 255 then Store
9312 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
9313 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
9314 Store More then 255 bytes into One Variable.
9315 */
9316 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
9317 {
9318 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
9319 {
9320 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
9321 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
9322 }
9323 else
9324 {
9325 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
9326 rem_probe_resp_ie_len = 0;
9327 }
9328 }
9329
9330 rem_probe_resp_ie_len = 0;
9331
9332 if (probe_rsp_ie_len[0] > 0)
9333 {
9334 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9335 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
Kapil Gupta137ef892016-12-13 19:38:00 +05309336 (tANI_U8*)&pBeacon->
9337 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 probe_rsp_ie_len[0], NULL,
9339 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
9340 {
9341 hddLog(LOGE,
9342 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009343 ret = -EINVAL;
9344 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 }
9346 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
9347 }
9348
9349 if (probe_rsp_ie_len[1] > 0)
9350 {
9351 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9352 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
Kapil Gupta137ef892016-12-13 19:38:00 +05309353 (tANI_U8*)&pBeacon->
9354 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -07009355 probe_rsp_ie_len[1], NULL,
9356 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
9357 {
9358 hddLog(LOGE,
9359 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009360 ret = -EINVAL;
9361 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009362 }
9363 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
9364 }
9365
9366 if (probe_rsp_ie_len[2] > 0)
9367 {
9368 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9369 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
Kapil Gupta137ef892016-12-13 19:38:00 +05309370 (tANI_U8*)&pBeacon->
9371 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -07009372 probe_rsp_ie_len[2], NULL,
9373 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
9374 {
9375 hddLog(LOGE,
9376 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009377 ret = -EINVAL;
9378 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009379 }
9380 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
9381 }
9382
9383 if (probe_rsp_ie_len[1] == 0 )
9384 {
9385 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9386 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
9387 eANI_BOOLEAN_FALSE) )
9388 {
9389 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009390 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009391 }
9392 }
9393
9394 if (probe_rsp_ie_len[2] == 0 )
9395 {
9396 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9397 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
9398 eANI_BOOLEAN_FALSE) )
9399 {
9400 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009401 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 }
9403 }
9404
9405 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9406 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
9407 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
9408 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
9409 == eHAL_STATUS_FAILURE)
9410 {
9411 hddLog(LOGE,
9412 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009413 ret = -EINVAL;
9414 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 }
9416 }
9417 else
9418 {
9419 // Reset WNI_CFG_PROBE_RSP Flags
9420 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
9421
9422 hddLog(VOS_TRACE_LEVEL_INFO,
9423 "%s: No Probe Response IE received in set beacon",
9424 __func__);
9425 }
9426
9427 // Added for AssocResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +05309428 if ((pBeacon->assocresp_ies != NULL) && (pBeacon->assocresp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009429 {
9430 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
Kapil Gupta137ef892016-12-13 19:38:00 +05309431 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)pBeacon->assocresp_ies,
9432 pBeacon->assocresp_ies_len, NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
9434 {
9435 hddLog(LOGE,
9436 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009437 ret = -EINVAL;
9438 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009439 }
9440
9441 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9442 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
9443 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
9444 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
9445 == eHAL_STATUS_FAILURE)
9446 {
9447 hddLog(LOGE,
9448 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009449 ret = -EINVAL;
9450 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009451 }
9452 }
9453 else
9454 {
9455 hddLog(VOS_TRACE_LEVEL_INFO,
9456 "%s: No Assoc Response IE received in set beacon",
9457 __func__);
9458
9459 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9460 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
9461 eANI_BOOLEAN_FALSE) )
9462 {
9463 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009464 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 }
9466 }
9467
Jeff Johnsone7245742012-09-05 17:12:55 -07009468done:
Jeff Johnson295189b2012-06-20 16:38:30 -07009469 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309470 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009471}
Jeff Johnson295189b2012-06-20 16:38:30 -07009472
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309473/*
Jeff Johnson295189b2012-06-20 16:38:30 -07009474 * FUNCTION: wlan_hdd_validate_operation_channel
9475 * called by wlan_hdd_cfg80211_start_bss() and
9476 * wlan_hdd_cfg80211_set_channel()
9477 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309478 * channel list.
9479 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07009480VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07009481{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309482
Jeff Johnson295189b2012-06-20 16:38:30 -07009483 v_U32_t num_ch = 0;
9484 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
9485 u32 indx = 0;
9486 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05309487 v_U8_t fValidChannel = FALSE, count = 0;
9488 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309489
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
9491
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05309492 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07009493 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05309494 /* Validate the channel */
9495 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07009496 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05309497 if ( channel == rfChannels[count].channelNum )
9498 {
9499 fValidChannel = TRUE;
9500 break;
9501 }
9502 }
9503 if (fValidChannel != TRUE)
9504 {
9505 hddLog(VOS_TRACE_LEVEL_ERROR,
9506 "%s: Invalid Channel [%d]", __func__, channel);
9507 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009508 }
9509 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05309510 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009511 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05309512 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
9513 valid_ch, &num_ch))
9514 {
9515 hddLog(VOS_TRACE_LEVEL_ERROR,
9516 "%s: failed to get valid channel list", __func__);
9517 return VOS_STATUS_E_FAILURE;
9518 }
9519 for (indx = 0; indx < num_ch; indx++)
9520 {
9521 if (channel == valid_ch[indx])
9522 {
9523 break;
9524 }
9525 }
9526
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05309527 if (indx >= num_ch)
9528 {
9529 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
9530 {
9531 eCsrBand band;
9532 unsigned int freq;
9533
9534 sme_GetFreqBand(hHal, &band);
9535
9536 if (eCSR_BAND_5G == band)
9537 {
9538#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9539 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9540 {
9541 freq = ieee80211_channel_to_frequency(channel,
9542 IEEE80211_BAND_2GHZ);
9543 }
9544 else
9545 {
9546 freq = ieee80211_channel_to_frequency(channel,
9547 IEEE80211_BAND_5GHZ);
9548 }
9549#else
9550 freq = ieee80211_channel_to_frequency(channel);
9551#endif
9552 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
9553 return VOS_STATUS_SUCCESS;
9554 }
9555 }
9556
9557 hddLog(VOS_TRACE_LEVEL_ERROR,
9558 "%s: Invalid Channel [%d]", __func__, channel);
9559 return VOS_STATUS_E_FAILURE;
9560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05309562
Jeff Johnson295189b2012-06-20 16:38:30 -07009563 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309564
Jeff Johnson295189b2012-06-20 16:38:30 -07009565}
9566
Viral Modi3a32cc52013-02-08 11:14:52 -08009567/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309568 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08009569 * This function is used to set the channel number
9570 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309571static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08009572 struct ieee80211_channel *chan,
9573 enum nl80211_channel_type channel_type
9574 )
9575{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309576 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08009577 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07009578 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08009579 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309580 hdd_context_t *pHddCtx;
9581 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009582
9583 ENTER();
9584
9585 if( NULL == dev )
9586 {
9587 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009588 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009589 return -ENODEV;
9590 }
9591 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309592
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309593 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9594 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
9595 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08009596 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309597 "%s: device_mode = %s (%d) freq = %d", __func__,
9598 hdd_device_modetoString(pAdapter->device_mode),
9599 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309600
9601 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9602 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309603 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08009604 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309605 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009606 }
9607
9608 /*
9609 * Do freq to chan conversion
9610 * TODO: for 11a
9611 */
9612
9613 channel = ieee80211_frequency_to_channel(freq);
9614
9615 /* Check freq range */
9616 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
9617 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
9618 {
9619 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009620 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08009621 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
9622 WNI_CFG_CURRENT_CHANNEL_STAMAX);
9623 return -EINVAL;
9624 }
9625
9626 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
9627
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05309628 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
9629 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08009630 {
9631 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
9632 {
9633 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009634 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08009635 return -EINVAL;
9636 }
9637 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9638 "%s: set channel to [%d] for device mode =%d",
9639 __func__, channel,pAdapter->device_mode);
9640 }
9641 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08009642 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08009643 )
9644 {
9645 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9646 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
9647 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9648
9649 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
9650 {
9651 /* Link is up then return cant set channel*/
9652 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009653 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009654 return -EINVAL;
9655 }
9656
9657 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
9658 pHddStaCtx->conn_info.operationChannel = channel;
9659 pRoamProfile->ChannelInfo.ChannelList =
9660 &pHddStaCtx->conn_info.operationChannel;
9661 }
9662 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08009663 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08009664 )
9665 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309666 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
9667 {
9668 if(VOS_STATUS_SUCCESS !=
9669 wlan_hdd_validate_operation_channel(pAdapter,channel))
9670 {
9671 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009672 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309673 return -EINVAL;
9674 }
9675 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9676 }
9677 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08009678 {
9679 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
9680
9681 /* If auto channel selection is configured as enable/ 1 then ignore
9682 channel set by supplicant
9683 */
9684 if ( cfg_param->apAutoChannelSelection )
9685 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309686 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
9687 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08009688 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309689 "%s: set channel to auto channel (0) for device mode =%s (%d)",
9690 __func__, hdd_device_modetoString(pAdapter->device_mode),
9691 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08009692 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309693 else
9694 {
9695 if(VOS_STATUS_SUCCESS !=
9696 wlan_hdd_validate_operation_channel(pAdapter,channel))
9697 {
9698 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009699 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309700 return -EINVAL;
9701 }
9702 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9703 }
Viral Modi3a32cc52013-02-08 11:14:52 -08009704 }
9705 }
9706 else
9707 {
9708 hddLog(VOS_TRACE_LEVEL_FATAL,
9709 "%s: Invalid device mode failed to set valid channel", __func__);
9710 return -EINVAL;
9711 }
9712 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309713 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009714}
9715
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309716static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
9717 struct net_device *dev,
9718 struct ieee80211_channel *chan,
9719 enum nl80211_channel_type channel_type
9720 )
9721{
9722 int ret;
9723
9724 vos_ssr_protect(__func__);
9725 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
9726 vos_ssr_unprotect(__func__);
9727
9728 return ret;
9729}
9730
Anurag Chouhan83026002016-12-13 22:46:21 +05309731#ifdef DHCP_SERVER_OFFLOAD
9732void hdd_dhcp_server_offload_done(void *fw_dhcp_srv_offload_cb_context,
9733 VOS_STATUS status)
9734{
9735 hdd_adapter_t* adapter = (hdd_adapter_t*)fw_dhcp_srv_offload_cb_context;
9736
9737 ENTER();
9738
9739 if (NULL == adapter)
9740 {
9741 hddLog(VOS_TRACE_LEVEL_ERROR,
9742 "%s: adapter is NULL",__func__);
9743 return;
9744 }
9745
9746 adapter->dhcp_status.dhcp_offload_status = status;
9747 vos_event_set(&adapter->dhcp_status.vos_event);
9748 return;
9749}
9750
9751/**
9752 * wlan_hdd_set_dhcp_server_offload() - set dhcp server offload
9753 * @hostapd_adapter: pointer to hostapd adapter.
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309754 * @re_init: flag set if api called post ssr
Anurag Chouhan83026002016-12-13 22:46:21 +05309755 *
9756 * Return: None
9757 */
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309758VOS_STATUS wlan_hdd_set_dhcp_server_offload(hdd_adapter_t *hostapd_adapter,
9759 bool re_init)
Anurag Chouhan83026002016-12-13 22:46:21 +05309760{
9761 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(hostapd_adapter);
9762 sir_dhcp_srv_offload_info dhcp_srv_info;
9763 tANI_U8 num_entries = 0;
9764 tANI_U8 srv_ip[IPADDR_NUM_ENTRIES];
9765 tANI_U8 num;
9766 tANI_U32 temp;
9767 VOS_STATUS ret;
9768
9769 ENTER();
9770
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309771 if (!re_init) {
9772 ret = wlan_hdd_validate_context(hdd_ctx);
9773 if (0 != ret)
9774 return VOS_STATUS_E_INVAL;
9775 }
Anurag Chouhan83026002016-12-13 22:46:21 +05309776
9777 /* Prepare the request to send to SME */
9778 dhcp_srv_info = vos_mem_malloc(sizeof(*dhcp_srv_info));
9779 if (NULL == dhcp_srv_info) {
9780 hddLog(VOS_TRACE_LEVEL_ERROR,
9781 "%s: could not allocate tDhcpSrvOffloadInfo!", __func__);
9782 return VOS_STATUS_E_NOMEM;
9783 }
9784
9785 vos_mem_zero(dhcp_srv_info, sizeof(*dhcp_srv_info));
9786
9787 dhcp_srv_info->bssidx = hostapd_adapter->sessionId;
9788 dhcp_srv_info->dhcp_srv_offload_enabled = TRUE;
9789 dhcp_srv_info->dhcp_client_num = hdd_ctx->cfg_ini->dhcp_max_num_clients;
9790 dhcp_srv_info->start_lsb = hdd_ctx->cfg_ini->dhcp_start_lsb;
9791 dhcp_srv_info->dhcp_offload_callback = hdd_dhcp_server_offload_done;
9792 dhcp_srv_info->dhcp_server_offload_cb_context = hostapd_adapter;
9793
9794 hdd_string_to_u8_array(hdd_ctx->cfg_ini->dhcp_srv_ip,
9795 srv_ip,
9796 &num_entries,
Anurag Chouhanac145c22016-11-22 16:51:47 +05309797 IPADDR_NUM_ENTRIES, ".");
Anurag Chouhan83026002016-12-13 22:46:21 +05309798 if (num_entries != IPADDR_NUM_ENTRIES) {
9799 hddLog(VOS_TRACE_LEVEL_ERROR,
9800 "%s: incorrect IP address (%s) assigned for DHCP server!",
9801 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9802 vos_mem_free(dhcp_srv_info);
9803 return VOS_STATUS_E_FAILURE;
9804 }
9805
9806 if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) {
9807 hddLog(VOS_TRACE_LEVEL_ERROR,
9808 "%s: invalid IP address (%s)! It could NOT be multicast IP address!",
9809 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9810 vos_mem_free(dhcp_srv_info);
9811 return VOS_STATUS_E_FAILURE;
9812 }
9813
9814 if (srv_ip[IPADDR_NUM_ENTRIES-1] >= DHCP_START_POOL_ADDRESS) {
9815 hddLog(VOS_TRACE_LEVEL_ERROR,
9816 "%s: invalid IP address (%s)! The last field must be less than 100!",
9817 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9818 vos_mem_free(dhcp_srv_info);
9819 return VOS_STATUS_E_FAILURE;
9820 }
9821
9822 for (num = 0; num < num_entries; num++) {
9823 temp = srv_ip[num];
9824 dhcp_srv_info->dhcp_srv_ip |= (temp << (8 * num));
9825 }
9826
9827 if (eHAL_STATUS_SUCCESS !=
9828 sme_set_dhcp_srv_offload(hdd_ctx->hHal, dhcp_srv_info)) {
9829 hddLog(VOS_TRACE_LEVEL_ERROR,
9830 "%s: sme_set_dhcp_srv_offload fail!", __func__);
9831 vos_mem_free(dhcp_srv_info);
9832 return VOS_STATUS_E_FAILURE;
9833 }
9834
9835 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9836 "%s: enable DHCP Server offload successfully!", __func__);
9837
9838 vos_mem_free(dhcp_srv_info);
9839 return 0;
9840}
9841#endif /* DHCP_SERVER_OFFLOAD */
9842
Jeff Johnson295189b2012-06-20 16:38:30 -07009843#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9844static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9845 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009846#else
9847static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9848 struct cfg80211_beacon_data *params,
9849 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309850 enum nl80211_hidden_ssid hidden_ssid,
9851 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009852#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009853{
9854 tsap_Config_t *pConfig;
9855 beacon_data_t *pBeacon = NULL;
9856 struct ieee80211_mgmt *pMgmt_frame;
9857 v_U8_t *pIe=NULL;
9858 v_U16_t capab_info;
9859 eCsrAuthType RSNAuthType;
9860 eCsrEncryptionType RSNEncryptType;
9861 eCsrEncryptionType mcRSNEncryptType;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309862 int status = VOS_STATUS_SUCCESS, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 tpWLAN_SAPEventCB pSapEventCallback;
9864 hdd_hostapd_state_t *pHostapdState;
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309866 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009867 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309868 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07009869 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08009870 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05309871 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07009872 v_BOOL_t MFPCapable = VOS_FALSE;
9873 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309874 v_BOOL_t sapEnable11AC =
9875 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Kapil Gupta137ef892016-12-13 19:38:00 +05309876 u_int16_t prev_rsn_length = 0;
9877
Jeff Johnson295189b2012-06-20 16:38:30 -07009878 ENTER();
9879
Nitesh Shah9b066282017-06-06 18:05:52 +05309880 wlan_hdd_tdls_disable_offchan_and_teardown_links(pHddCtx);
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309881 iniConfig = pHddCtx->cfg_ini;
9882
Jeff Johnson295189b2012-06-20 16:38:30 -07009883 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
9884
9885 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9886
9887 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9888
9889 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9890
9891 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
9892
9893 //channel is already set in the set_channel Call back
9894 //pConfig->channel = pCommitConfig->channel;
9895
9896 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309897 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07009898 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
9899
9900 pConfig->dtim_period = pBeacon->dtim_period;
9901
Arif Hussain6d2a3322013-11-17 19:50:10 -08009902 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07009903 pConfig->dtim_period);
9904
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08009905 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07009906 {
9907 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009908 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05309909 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
9910 {
9911 tANI_BOOLEAN restartNeeded;
9912 pConfig->ieee80211d = 1;
9913 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
9914 sme_setRegInfo(hHal, pConfig->countryCode);
9915 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
9916 }
9917 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07009919 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07009920 pConfig->ieee80211d = 1;
9921 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
9922 sme_setRegInfo(hHal, pConfig->countryCode);
9923 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07009924 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009925 else
9926 {
9927 pConfig->ieee80211d = 0;
9928 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309929 /*
9930 * If auto channel is configured i.e. channel is 0,
9931 * so skip channel validation.
9932 */
9933 if( AUTO_CHANNEL_SELECT != pConfig->channel )
9934 {
9935 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
9936 {
9937 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009938 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309939 return -EINVAL;
9940 }
9941 }
9942 else
9943 {
9944 if(1 != pHddCtx->is_dynamic_channel_range_set)
9945 {
9946 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
9947 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
9948 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
9949 }
9950 pHddCtx->is_dynamic_channel_range_set = 0;
9951 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009952 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009953 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 {
9955 pConfig->ieee80211d = 0;
9956 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309957
9958#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9959 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9960 pConfig->authType = eSAP_OPEN_SYSTEM;
9961 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9962 pConfig->authType = eSAP_SHARED_KEY;
9963 else
9964 pConfig->authType = eSAP_AUTO_SWITCH;
9965#else
9966 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9967 pConfig->authType = eSAP_OPEN_SYSTEM;
9968 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9969 pConfig->authType = eSAP_SHARED_KEY;
9970 else
9971 pConfig->authType = eSAP_AUTO_SWITCH;
9972#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009973
9974 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309975
9976 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07009977 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05309978#ifdef SAP_AUTH_OFFLOAD
9979 /* In case of sap offload, hostapd.conf is configuted with open mode and
9980 * security is configured from ini file. Due to open mode in hostapd.conf
9981 * privacy bit is set to false which will result in not sending,
9982 * data packets as encrypted.
9983 * If enable_sap_auth_offload is enabled in ini and
9984 * sap_auth_offload_sec_type is type of WPA2-PSK,
9985 * driver will set privacy bit to 1.
9986 */
9987 if (pHddCtx->cfg_ini->enable_sap_auth_offload &&
9988 pHddCtx->cfg_ini->sap_auth_offload_sec_type)
9989 pConfig->privacy = VOS_TRUE;
9990#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009991
9992 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
9993
9994 /*Set wps station to configured*/
9995 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
9996
9997 if(pIe)
9998 {
9999 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
10000 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010001 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 return -EINVAL;
10003 }
10004 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
10005 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070010006 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 /* Check 15 bit of WPS IE as it contain information for wps state
10008 * WPS state
10009 */
10010 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
10011 {
10012 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
10013 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
10014 {
10015 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
10016 }
10017 }
10018 }
10019 else
10020 {
10021 pConfig->wps_state = SAP_WPS_DISABLED;
10022 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010023 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -070010024
c_hpothufe599e92014-06-16 11:38:55 +053010025 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
10026 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
10027 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
10028 eCSR_ENCRYPT_TYPE_NONE;
10029
Jeff Johnson295189b2012-06-20 16:38:30 -070010030 pConfig->RSNWPAReqIELength = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +053010031 memset(&pConfig->RSNWPAReqIE[0], 0, sizeof(pConfig->RSNWPAReqIE));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010032 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 WLAN_EID_RSN);
10034 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010035 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010036 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053010037 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
10038 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
10039 pConfig->RSNWPAReqIELength);
10040 else
10041 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
10042 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010043 /* The actual processing may eventually be more extensive than
10044 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -070010045 * by the app.
10046 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010047 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -070010048 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
10049 &RSNEncryptType,
10050 &mcRSNEncryptType,
10051 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -080010052 &MFPCapable,
10053 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +053010054 pConfig->RSNWPAReqIE[1]+2,
10055 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010056
10057 if( VOS_STATUS_SUCCESS == status )
10058 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010059 /* Now copy over all the security attributes you have
10060 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 * */
10062 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
10063 pConfig->mcRSNEncryptType = mcRSNEncryptType;
10064 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
10065 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010066 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010067 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
10069 }
10070 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010071
Jeff Johnson295189b2012-06-20 16:38:30 -070010072 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
10073 pBeacon->tail, pBeacon->tail_len);
10074
10075 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
10076 {
Kapil Gupta137ef892016-12-13 19:38:00 +053010077 if (pConfig->RSNWPAReqIE[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010078 {
10079 /*Mixed mode WPA/WPA2*/
Kapil Gupta137ef892016-12-13 19:38:00 +053010080 prev_rsn_length = pConfig->RSNWPAReqIELength;
Jeff Johnson295189b2012-06-20 16:38:30 -070010081 pConfig->RSNWPAReqIELength += pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053010082 if (pConfig->RSNWPAReqIELength <=
10083 (sizeof(pConfig->RSNWPAReqIE) - prev_rsn_length))
10084 memcpy(&pConfig->RSNWPAReqIE[0] + prev_rsn_length, pIe,
10085 pIe[1] + 2);
10086 else
10087 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
10088 pConfig->RSNWPAReqIELength);
10089
Jeff Johnson295189b2012-06-20 16:38:30 -070010090 }
10091 else
10092 {
10093 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053010094 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
10095 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
10096 pConfig->RSNWPAReqIELength);
10097 else
10098 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
10099 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010100 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -070010101 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
10102 &RSNEncryptType,
10103 &mcRSNEncryptType,
10104 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -080010105 &MFPCapable,
10106 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +053010107 pConfig->RSNWPAReqIE[1]+2,
10108 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010109
10110 if( VOS_STATUS_SUCCESS == status )
10111 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010112 /* Now copy over all the security attributes you have
10113 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -070010114 * */
10115 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
10116 pConfig->mcRSNEncryptType = mcRSNEncryptType;
10117 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
10118 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010119 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010120 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010121 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
10122 }
10123 }
10124 }
10125
Kapil Gupta137ef892016-12-13 19:38:00 +053010126 if (pConfig->RSNWPAReqIELength > sizeof(pConfig->RSNWPAReqIE)) {
Jeff Johnson4416a782013-03-25 14:17:50 -070010127 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
10128 return -EINVAL;
10129 }
10130
Jeff Johnson295189b2012-06-20 16:38:30 -070010131 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
10132
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010133#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010134 if (params->ssid != NULL)
10135 {
10136 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
10137 pConfig->SSIDinfo.ssid.length = params->ssid_len;
10138 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
10139 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
10140 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010141#else
10142 if (ssid != NULL)
10143 {
10144 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
10145 pConfig->SSIDinfo.ssid.length = ssid_len;
10146 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
10147 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
10148 }
10149#endif
10150
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010151 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -070010152 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010153
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 /* default value */
10155 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
10156 pConfig->num_accept_mac = 0;
10157 pConfig->num_deny_mac = 0;
10158
10159 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
10160 pBeacon->tail, pBeacon->tail_len);
10161
10162 /* pIe for black list is following form:
10163 type : 1 byte
10164 length : 1 byte
10165 OUI : 4 bytes
10166 acl type : 1 byte
10167 no of mac addr in black list: 1 byte
10168 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010169 */
10170 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010171 {
10172 pConfig->SapMacaddr_acl = pIe[6];
10173 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -080010174 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010175 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053010176 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
10177 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010178 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
10179 for (i = 0; i < pConfig->num_deny_mac; i++)
10180 {
10181 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
10182 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010183 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010184 }
10185 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
10186 pBeacon->tail, pBeacon->tail_len);
10187
10188 /* pIe for white list is following form:
10189 type : 1 byte
10190 length : 1 byte
10191 OUI : 4 bytes
10192 acl type : 1 byte
10193 no of mac addr in white list: 1 byte
10194 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010195 */
10196 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010197 {
10198 pConfig->SapMacaddr_acl = pIe[6];
10199 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -080010200 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010201 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053010202 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
10203 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010204 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
10205 for (i = 0; i < pConfig->num_accept_mac; i++)
10206 {
10207 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
10208 acl_entry++;
10209 }
10210 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053010211
Jeff Johnson295189b2012-06-20 16:38:30 -070010212 wlan_hdd_set_sapHwmode(pHostapdAdapter);
10213
Jeff Johnsone7245742012-09-05 17:12:55 -070010214#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -080010215 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +053010216 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
10217 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +053010218 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
10219 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -080010220 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
10221 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +053010222 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
10223 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010224 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +053010225 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -070010226 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +053010227 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -070010228
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053010229 /* If ACS disable and selected channel <= 14
10230 * OR
10231 * ACS enabled and ACS operating band is choosen as 2.4
10232 * AND
10233 * VHT in 2.4G Disabled
10234 * THEN
10235 * Fallback to 11N mode
10236 */
10237 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
10238 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +053010239 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053010240 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -070010241 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +053010242 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
10243 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -070010244 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
10245 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010246 }
10247#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010248
Jeff Johnson295189b2012-06-20 16:38:30 -070010249 // ht_capab is not what the name conveys,this is used for protection bitmap
10250 pConfig->ht_capab =
10251 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
10252
Kapil Gupta137ef892016-12-13 19:38:00 +053010253 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -070010254 {
10255 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
10256 return -EINVAL;
10257 }
10258
10259 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010260 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
10262 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010263 pConfig->obssProtEnabled =
10264 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -070010265
Chet Lanctot8cecea22014-02-11 19:09:36 -080010266#ifdef WLAN_FEATURE_11W
10267 pConfig->mfpCapable = MFPCapable;
10268 pConfig->mfpRequired = MFPRequired;
10269 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
10270 pConfig->mfpCapable, pConfig->mfpRequired);
10271#endif
10272
Arif Hussain6d2a3322013-11-17 19:50:10 -080010273 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -070010274 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -080010275 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
10276 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
10277 (int)pConfig->channel);
10278 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
10279 pConfig->SapHw_mode, pConfig->privacy,
10280 pConfig->authType);
10281 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
10282 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
10283 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
10284 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010285
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010286 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -070010287 {
10288 //Bss already started. just return.
10289 //TODO Probably it should update some beacon params.
10290 hddLog( LOGE, "Bss Already started...Ignore the request");
10291 EXIT();
10292 return 0;
10293 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010294
Agarwal Ashish51325b52014-06-16 16:50:49 +053010295 if (vos_max_concurrent_connections_reached()) {
10296 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10297 return -EINVAL;
10298 }
10299
Jeff Johnson295189b2012-06-20 16:38:30 -070010300 pConfig->persona = pHostapdAdapter->device_mode;
10301
Peng Xu2446a892014-09-05 17:21:18 +053010302 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
10303 if ( NULL != psmeConfig)
10304 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053010305 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +053010306 sme_GetConfigParam(hHal, psmeConfig);
10307 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053010308#ifdef WLAN_FEATURE_AP_HT40_24G
10309 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
10310 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
10311 && pHddCtx->cfg_ini->apHT40_24GEnabled)
10312 {
10313 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
10314 sme_UpdateConfig (hHal, psmeConfig);
10315 }
10316#endif
Peng Xu2446a892014-09-05 17:21:18 +053010317 vos_mem_free(psmeConfig);
10318 }
Peng Xuafc34e32014-09-25 13:23:55 +053010319 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +053010320
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010321 set_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
10322
Jeff Johnson295189b2012-06-20 16:38:30 -070010323 pSapEventCallback = hdd_hostapd_SAPEventCB;
10324 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
10325 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
10326 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010327 hddLog(LOGE,FL("SAP Start Bss fail"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010328 ret = -EINVAL;
10329 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010330 }
10331
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010332 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
10334
10335 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010336
Jeff Johnson295189b2012-06-20 16:38:30 -070010337 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010338 {
10339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010340 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -070010341 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010342 VOS_ASSERT(0);
10343 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010344
Jeff Johnson295189b2012-06-20 16:38:30 -070010345 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053010346 if (WLANSAP_get_sessionId(pVosContext, &pHostapdAdapter->sessionId) !=
10347 VOS_STATUS_SUCCESS)
10348 {
10349 hddLog(LOGE,FL("Fail to get Softap sessionID"));
10350 VOS_ASSERT(0);
10351 }
Kaushik, Sushantf6070802014-10-15 15:09:23 +053010352 /* Initialize WMM configuation */
10353 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +053010354 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010355
Anurag Chouhan83026002016-12-13 22:46:21 +053010356#ifdef DHCP_SERVER_OFFLOAD
10357 /* set dhcp server offload */
10358 if (iniConfig->enable_dhcp_srv_offload &&
10359 sme_IsFeatureSupportedByFW(SAP_OFFLOADS)) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010360 vos_event_reset(&pHostapdAdapter->dhcp_status.vos_event);
Anurag Chouhan638f5e22017-03-06 12:28:43 +053010361 status = wlan_hdd_set_dhcp_server_offload(pHostapdAdapter, false);
Anurag Chouhan83026002016-12-13 22:46:21 +053010362 if (!VOS_IS_STATUS_SUCCESS(status))
10363 {
10364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10365 ("HDD DHCP Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010366 vos_event_reset(&pHostapdState->vosEvent);
10367 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
10368 status = vos_wait_single_event(&pHostapdState->vosEvent,
10369 10000);
10370 if (!VOS_IS_STATUS_SUCCESS(status)) {
10371 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010372 ret = -EINVAL;
10373 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010374 }
10375 }
Anurag Chouhan83026002016-12-13 22:46:21 +053010376 }
Anurag Chouhan83026002016-12-13 22:46:21 +053010377 status = vos_wait_single_event(&pHostapdAdapter->dhcp_status.vos_event, 2000);
10378 if (!VOS_IS_STATUS_SUCCESS(status) || pHostapdAdapter->dhcp_status.dhcp_offload_status)
10379 {
10380 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10381 ("ERROR: DHCP HDD vos wait for single_event failed!! %d"),
10382 pHostapdAdapter->dhcp_status.dhcp_offload_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010383 vos_event_reset(&pHostapdState->vosEvent);
10384 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
10385 status = vos_wait_single_event(&pHostapdState->vosEvent,
10386 10000);
10387 if (!VOS_IS_STATUS_SUCCESS(status)) {
10388 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010389 ret = -EINVAL;
10390 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010391 }
10392 }
Anurag Chouhan83026002016-12-13 22:46:21 +053010393 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053010394#ifdef MDNS_OFFLOAD
10395 if (iniConfig->enable_mdns_offload) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010396 vos_event_reset(&pHostapdAdapter->mdns_status.vos_event);
Anurag Chouhan0b29de02016-12-16 13:18:40 +053010397 status = wlan_hdd_set_mdns_offload(pHostapdAdapter);
10398 if (VOS_IS_STATUS_SUCCESS(status))
10399 {
10400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10401 ("HDD MDNS Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010402 vos_event_reset(&pHostapdState->vosEvent);
10403 if (VOS_STATUS_SUCCESS ==
10404 WLANSAP_StopBss(pHddCtx->pvosContext)) {
10405 status = vos_wait_single_event(&pHostapdState->vosEvent,
10406 10000);
10407 if (!VOS_IS_STATUS_SUCCESS(status)) {
10408 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010409 ret = -EINVAL;
10410 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010411 }
10412 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053010413 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053010414 status = vos_wait_single_event(&pHostapdAdapter->
10415 mdns_status.vos_event, 2000);
10416 if (!VOS_IS_STATUS_SUCCESS(status) ||
10417 pHostapdAdapter->mdns_status.mdns_enable_status ||
10418 pHostapdAdapter->mdns_status.mdns_fqdn_status ||
10419 pHostapdAdapter->mdns_status.mdns_resp_status)
10420 {
10421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10422 ("MDNS HDD vos wait for single_event failed!! enable %d fqdn %d resp %d"),
10423 pHostapdAdapter->mdns_status.mdns_enable_status,
10424 pHostapdAdapter->mdns_status.mdns_fqdn_status,
10425 pHostapdAdapter->mdns_status.mdns_resp_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010426 vos_event_reset(&pHostapdState->vosEvent);
10427 if (VOS_STATUS_SUCCESS ==
10428 WLANSAP_StopBss(pHddCtx->pvosContext)) {
10429 status = vos_wait_single_event(&pHostapdState->vosEvent,
10430 10000);
10431 if (!VOS_IS_STATUS_SUCCESS(status)) {
10432 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010433 ret = -EINVAL;
10434 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010435 }
10436 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053010437 }
10438 }
10439#endif /* MDNS_OFFLOAD */
10440 } else {
10441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10442 ("DHCP Disabled ini %d, FW %d"),
10443 iniConfig->enable_dhcp_srv_offload,
10444 sme_IsFeatureSupportedByFW(SAP_OFFLOADS));
Anurag Chouhan83026002016-12-13 22:46:21 +053010445 }
10446#endif /* DHCP_SERVER_OFFLOAD */
10447
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010448#ifdef WLAN_FEATURE_P2P_DEBUG
10449 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
10450 {
10451 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
10452 {
10453 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
10454 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -080010455 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010456 }
10457 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
10458 {
10459 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
10460 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -080010461 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010462 }
10463 }
10464#endif
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +053010465 /* Check and restart SAP if it is on Unsafe channel */
10466 hdd_check_for_unsafe_ch(pHostapdAdapter, pHddCtx);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010467
Jeff Johnson295189b2012-06-20 16:38:30 -070010468 pHostapdState->bCommit = TRUE;
10469 EXIT();
10470
10471 return 0;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010472error:
10473 clear_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
10474 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010475}
10476
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010477#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010478static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010479 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010480 struct beacon_parameters *params)
10481{
10482 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010483 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010484 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010485
10486 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010487
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010488 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10489 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
10490 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010491 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
10492 hdd_device_modetoString(pAdapter->device_mode),
10493 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010494
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010495 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10496 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010497 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010498 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010499 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010500 }
10501
Agarwal Ashish51325b52014-06-16 16:50:49 +053010502 if (vos_max_concurrent_connections_reached()) {
10503 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10504 return -EINVAL;
10505 }
10506
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010507 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010509 )
10510 {
10511 beacon_data_t *old,*new;
10512
10513 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010514
Jeff Johnson295189b2012-06-20 16:38:30 -070010515 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010516 {
10517 hddLog(VOS_TRACE_LEVEL_WARN,
10518 FL("already beacon info added to session(%d)"),
10519 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010520 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010522
10523 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
10524
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010525 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -070010526 {
10527 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010528 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010529 return -EINVAL;
10530 }
10531
10532 pAdapter->sessionCtx.ap.beacon = new;
10533
10534 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
10535 }
10536
10537 EXIT();
10538 return status;
10539}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010540
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010541static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
10542 struct net_device *dev,
10543 struct beacon_parameters *params)
10544{
10545 int ret;
10546
10547 vos_ssr_protect(__func__);
10548 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
10549 vos_ssr_unprotect(__func__);
10550
10551 return ret;
10552}
10553
10554static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010555 struct net_device *dev,
10556 struct beacon_parameters *params)
10557{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010558 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010559 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10560 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010561 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010562
10563 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010564
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010565 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10566 TRACE_CODE_HDD_CFG80211_SET_BEACON,
10567 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
10568 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10569 __func__, hdd_device_modetoString(pAdapter->device_mode),
10570 pAdapter->device_mode);
10571
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010572 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10573 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010574 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010575 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010576 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010577 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010578
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010579 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010580 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010581 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010582 {
10583 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010584
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010586
Jeff Johnson295189b2012-06-20 16:38:30 -070010587 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010588 {
10589 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10590 FL("session(%d) old and new heads points to NULL"),
10591 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010592 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010593 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010594
10595 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
10596
10597 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010598 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010599 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010600 return -EINVAL;
10601 }
10602
10603 pAdapter->sessionCtx.ap.beacon = new;
10604
10605 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
10606 }
10607
10608 EXIT();
10609 return status;
10610}
10611
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010612static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
10613 struct net_device *dev,
10614 struct beacon_parameters *params)
10615{
10616 int ret;
10617
10618 vos_ssr_protect(__func__);
10619 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
10620 vos_ssr_unprotect(__func__);
10621
10622 return ret;
10623}
10624
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010625#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10626
10627#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010628static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010630#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010631static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010632 struct net_device *dev)
10633#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010634{
10635 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -070010636 hdd_context_t *pHddCtx = NULL;
10637 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010638 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010639 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010640
10641 ENTER();
10642
10643 if (NULL == pAdapter)
10644 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010645 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010646 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010647 return -ENODEV;
10648 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010649
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010650 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10651 TRACE_CODE_HDD_CFG80211_STOP_AP,
10652 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010653 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10654 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010655 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010656 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010657 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -070010658 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010659
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010660 pScanInfo = &pHddCtx->scan_info;
10661
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010662 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10663 __func__, hdd_device_modetoString(pAdapter->device_mode),
10664 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010665
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010666 ret = wlan_hdd_scan_abort(pAdapter);
10667
Girish Gowli4bf7a632014-06-12 13:42:11 +053010668 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -070010669 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010670 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10671 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010672
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010673 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -070010674 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10676 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -080010677
Jeff Johnsone7245742012-09-05 17:12:55 -070010678 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010679 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -070010680 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010681 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010682 }
10683
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010684 /* Delete all associated STAs before stopping AP/P2P GO */
10685 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +053010686 hdd_hostapd_stop(dev);
10687
Jeff Johnson295189b2012-06-20 16:38:30 -070010688 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010689 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010690 )
10691 {
10692 beacon_data_t *old;
10693
10694 old = pAdapter->sessionCtx.ap.beacon;
10695
10696 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010697 {
10698 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10699 FL("session(%d) beacon data points to NULL"),
10700 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010701 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010702 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010703
Jeff Johnson295189b2012-06-20 16:38:30 -070010704 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010705
10706 mutex_lock(&pHddCtx->sap_lock);
10707 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
10708 {
Jeff Johnson4416a782013-03-25 14:17:50 -070010709 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 {
10711 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
10712
10713 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
10714
10715 if (!VOS_IS_STATUS_SUCCESS(status))
10716 {
10717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010718 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010719 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010720 }
10721 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010722 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +053010723 /* BSS stopped, clear the active sessions for this device mode */
10724 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010725 }
10726 mutex_unlock(&pHddCtx->sap_lock);
10727
10728 if(status != VOS_STATUS_SUCCESS)
10729 {
10730 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010731 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010732 return -EINVAL;
10733 }
10734
Jeff Johnson4416a782013-03-25 14:17:50 -070010735 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070010736 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
10737 ==eHAL_STATUS_FAILURE)
10738 {
10739 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010740 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010741 }
10742
Jeff Johnson4416a782013-03-25 14:17:50 -070010743 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070010744 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
10745 eANI_BOOLEAN_FALSE) )
10746 {
10747 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010748 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010749 }
10750
10751 // Reset WNI_CFG_PROBE_RSP Flags
10752 wlan_hdd_reset_prob_rspies(pAdapter);
10753
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010754 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
10755
Jeff Johnson295189b2012-06-20 16:38:30 -070010756 pAdapter->sessionCtx.ap.beacon = NULL;
10757 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010758#ifdef WLAN_FEATURE_P2P_DEBUG
10759 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
10760 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
10761 {
10762 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
10763 "GO got removed");
10764 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
10765 }
10766#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010767 }
10768 EXIT();
10769 return status;
10770}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010771
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010772#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10773static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
10774 struct net_device *dev)
10775{
10776 int ret;
10777
10778 vos_ssr_protect(__func__);
10779 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
10780 vos_ssr_unprotect(__func__);
10781
10782 return ret;
10783}
10784#else
10785static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
10786 struct net_device *dev)
10787{
10788 int ret;
10789
10790 vos_ssr_protect(__func__);
10791 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
10792 vos_ssr_unprotect(__func__);
10793
10794 return ret;
10795}
10796#endif
10797
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010798#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
10799
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010800static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010801 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010802 struct cfg80211_ap_settings *params)
10803{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010804 hdd_adapter_t *pAdapter;
10805 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010806 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010807
10808 ENTER();
10809
Girish Gowlib143d7a2015-02-18 19:39:55 +053010810 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010811 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010812 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +053010813 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010814 return -ENODEV;
10815 }
10816
10817 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10818 if (NULL == pAdapter)
10819 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010820 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010821 "%s: HDD adapter is Null", __func__);
10822 return -ENODEV;
10823 }
10824
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010825 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10826 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
10827 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010828 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
10829 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010830 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010831 "%s: HDD adapter magic is invalid", __func__);
10832 return -ENODEV;
10833 }
10834
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010835 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
10836
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010837 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010838 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010839 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010840 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010841 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010842 }
10843
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010844 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
10845 __func__, hdd_device_modetoString(pAdapter->device_mode),
10846 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010847
10848 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010849 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010850 )
10851 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010852 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010853
10854 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010855
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010856 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010857 {
10858 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10859 FL("already beacon info added to session(%d)"),
10860 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010861 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010862 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010863
Girish Gowlib143d7a2015-02-18 19:39:55 +053010864#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10865 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10866 &new,
10867 &params->beacon);
10868#else
10869 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10870 &new,
10871 &params->beacon,
10872 params->dtim_period);
10873#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010874
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010875 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010876 {
10877 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010878 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010879 return -EINVAL;
10880 }
10881 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -080010882#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -070010883 wlan_hdd_cfg80211_set_channel(wiphy, dev,
10884#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
10885 params->channel, params->channel_type);
10886#else
10887 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
10888#endif
Viral Modi3a32cc52013-02-08 11:14:52 -080010889#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010890 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010891 params->ssid_len, params->hidden_ssid,
10892 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010893 }
10894
10895 EXIT();
10896 return status;
10897}
10898
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010899static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
10900 struct net_device *dev,
10901 struct cfg80211_ap_settings *params)
10902{
10903 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010904
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010905 vos_ssr_protect(__func__);
10906 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
10907 vos_ssr_unprotect(__func__);
10908
10909 return ret;
10910}
10911
10912static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010913 struct net_device *dev,
10914 struct cfg80211_beacon_data *params)
10915{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010916 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010917 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010918 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010919
10920 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010921
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010922 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10923 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
10924 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -080010925 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010926 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010927
10928 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10929 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010930 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010931 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010932 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010933 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010934
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010935 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010936 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010937 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010938 {
10939 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010940
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010941 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010942
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010943 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010944 {
10945 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10946 FL("session(%d) beacon data points to NULL"),
10947 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010948 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010949 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010950
10951 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
10952
10953 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010954 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010955 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010956 return -EINVAL;
10957 }
10958
10959 pAdapter->sessionCtx.ap.beacon = new;
10960
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010961 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
10962 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010963 }
10964
10965 EXIT();
10966 return status;
10967}
10968
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010969static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
10970 struct net_device *dev,
10971 struct cfg80211_beacon_data *params)
10972{
10973 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010974
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010975 vos_ssr_protect(__func__);
10976 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
10977 vos_ssr_unprotect(__func__);
10978
10979 return ret;
10980}
10981
10982#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010983
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010984static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010985 struct net_device *dev,
10986 struct bss_parameters *params)
10987{
10988 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010989 hdd_context_t *pHddCtx;
10990 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010991
10992 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010993
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010994 if (NULL == pAdapter)
10995 {
10996 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10997 "%s: HDD adapter is Null", __func__);
10998 return -ENODEV;
10999 }
11000 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011001 ret = wlan_hdd_validate_context(pHddCtx);
11002 if (0 != ret)
11003 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011004 return ret;
11005 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011006 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11007 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
11008 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011009 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11010 __func__, hdd_device_modetoString(pAdapter->device_mode),
11011 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011012
11013 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011014 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011015 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011016 {
11017 /* ap_isolate == -1 means that in change bss, upper layer doesn't
11018 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011019 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -070011020 {
11021 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011022 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011023 }
11024
11025 EXIT();
11026 return 0;
11027}
11028
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011029static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
11030 struct net_device *dev,
11031 struct bss_parameters *params)
11032{
11033 int ret;
11034
11035 vos_ssr_protect(__func__);
11036 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
11037 vos_ssr_unprotect(__func__);
11038
11039 return ret;
11040}
Kiet Lam10841362013-11-01 11:36:50 +053011041/* FUNCTION: wlan_hdd_change_country_code_cd
11042* to wait for contry code completion
11043*/
11044void* wlan_hdd_change_country_code_cb(void *pAdapter)
11045{
11046 hdd_adapter_t *call_back_pAdapter = pAdapter;
11047 complete(&call_back_pAdapter->change_country_code);
11048 return NULL;
11049}
11050
Jeff Johnson295189b2012-06-20 16:38:30 -070011051/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053011052 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -070011053 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
11054 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053011055int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011056 struct net_device *ndev,
11057 enum nl80211_iftype type,
11058 u32 *flags,
11059 struct vif_params *params
11060 )
11061{
11062 struct wireless_dev *wdev;
11063 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -080011064 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -070011065 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011066 tCsrRoamProfile *pRoamProfile = NULL;
11067 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011068 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011069 eMib_dot11DesiredBssType connectedBssType;
11070 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011071 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070011072
11073 ENTER();
11074
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011075 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -080011076 {
11077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11078 "%s: Adapter context is null", __func__);
11079 return VOS_STATUS_E_FAILURE;
11080 }
11081
11082 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11083 if (!pHddCtx)
11084 {
11085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11086 "%s: HDD context is null", __func__);
11087 return VOS_STATUS_E_FAILURE;
11088 }
11089
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011090 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11091 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
11092 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011093 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011094 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070011095 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011096 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011097 }
11098
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011099 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11100 __func__, hdd_device_modetoString(pAdapter->device_mode),
11101 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011102
Agarwal Ashish51325b52014-06-16 16:50:49 +053011103 if (vos_max_concurrent_connections_reached()) {
11104 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
11105 return -EINVAL;
11106 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011107 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070011108 wdev = ndev->ieee80211_ptr;
11109
11110#ifdef WLAN_BTAMP_FEATURE
11111 if((NL80211_IFTYPE_P2P_CLIENT == type)||
11112 (NL80211_IFTYPE_ADHOC == type)||
11113 (NL80211_IFTYPE_AP == type)||
11114 (NL80211_IFTYPE_P2P_GO == type))
11115 {
11116 pHddCtx->isAmpAllowed = VOS_FALSE;
11117 // stop AMP traffic
11118 status = WLANBAP_StopAmp();
11119 if(VOS_STATUS_SUCCESS != status )
11120 {
11121 pHddCtx->isAmpAllowed = VOS_TRUE;
11122 hddLog(VOS_TRACE_LEVEL_FATAL,
11123 "%s: Failed to stop AMP", __func__);
11124 return -EINVAL;
11125 }
11126 }
11127#endif //WLAN_BTAMP_FEATURE
11128 /* Reset the current device mode bit mask*/
11129 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
11130
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053011131 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
11132 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
11133 (type == NL80211_IFTYPE_P2P_GO)))
11134 {
11135 /* Notify Mode change in case of concurrency.
11136 * Below function invokes TDLS teardown Functionality Since TDLS is
11137 * not Supported in case of concurrency i.e Once P2P session
11138 * is detected disable offchannel and teardown TDLS links
11139 */
11140 hddLog(LOG1,
11141 FL("Device mode = %d Interface type = %d"),
11142 pAdapter->device_mode, type);
11143 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
11144 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053011145
Jeff Johnson295189b2012-06-20 16:38:30 -070011146 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070011147 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070011148 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070011149 )
11150 {
11151 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080011152 if (!pWextState)
11153 {
11154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11155 "%s: pWextState is null", __func__);
11156 return VOS_STATUS_E_FAILURE;
11157 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011158 pRoamProfile = &pWextState->roamProfile;
11159 LastBSSType = pRoamProfile->BSSType;
11160
11161 switch (type)
11162 {
11163 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070011164 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070011165 hddLog(VOS_TRACE_LEVEL_INFO,
11166 "%s: setting interface Type to INFRASTRUCTURE", __func__);
11167 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070011168#ifdef WLAN_FEATURE_11AC
11169 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
11170 {
11171 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
11172 }
11173#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011174 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070011175 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011176 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080011177 //Check for sub-string p2p to confirm its a p2p interface
11178 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011179 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053011180#ifdef FEATURE_WLAN_TDLS
11181 mutex_lock(&pHddCtx->tdls_lock);
11182 wlan_hdd_tdls_exit(pAdapter, TRUE);
11183 mutex_unlock(&pHddCtx->tdls_lock);
11184#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080011185 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
11186 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
11187 }
11188 else
11189 {
11190 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070011191 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080011192 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011193 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053011194
Jeff Johnson295189b2012-06-20 16:38:30 -070011195 case NL80211_IFTYPE_ADHOC:
11196 hddLog(VOS_TRACE_LEVEL_INFO,
11197 "%s: setting interface Type to ADHOC", __func__);
11198 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
11199 pRoamProfile->phyMode =
11200 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070011201 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011202 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053011203 hdd_set_ibss_ops( pAdapter );
11204 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053011205
11206 status = hdd_sta_id_hash_attach(pAdapter);
11207 if (VOS_STATUS_SUCCESS != status) {
11208 hddLog(VOS_TRACE_LEVEL_ERROR,
11209 FL("Failed to initialize hash for IBSS"));
11210 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011211 break;
11212
11213 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070011214 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070011215 {
11216 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
11217 "%s: setting interface Type to %s", __func__,
11218 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
11219
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080011220 //Cancel any remain on channel for GO mode
11221 if (NL80211_IFTYPE_P2P_GO == type)
11222 {
11223 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
11224 }
Mohit Khanna0f232092012-09-11 14:46:08 -070011225 if (NL80211_IFTYPE_AP == type)
11226 {
11227 /* As Loading WLAN Driver one interface being created for p2p device
11228 * address. This will take one HW STA and the max number of clients
11229 * that can connect to softAP will be reduced by one. so while changing
11230 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
11231 * interface as it is not required in SoftAP mode.
11232 */
11233
11234 // Get P2P Adapter
11235 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
11236
11237 if (pP2pAdapter)
11238 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +053011239 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +053011240 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -070011241 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
11242 }
11243 }
Swaroop Goltia2e32212014-04-09 23:37:33 +053011244 //Disable IMPS & BMPS for SAP/GO
11245 if(VOS_STATUS_E_FAILURE ==
11246 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
11247 {
11248 //Fail to Exit BMPS
11249 VOS_ASSERT(0);
11250 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053011251
11252 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
11253
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011254#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070011255
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011256 /* A Mutex Lock is introduced while changing the mode to
11257 * protect the concurrent access for the Adapters by TDLS
11258 * module.
11259 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011260 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011261#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011262 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053011263 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011264 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070011265 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
11266 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011267#ifdef FEATURE_WLAN_TDLS
11268 mutex_unlock(&pHddCtx->tdls_lock);
11269#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070011270 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
11271 (pConfig->apRandomBssidEnabled))
11272 {
11273 /* To meet Android requirements create a randomized
11274 MAC address of the form 02:1A:11:Fx:xx:xx */
11275 get_random_bytes(&ndev->dev_addr[3], 3);
11276 ndev->dev_addr[0] = 0x02;
11277 ndev->dev_addr[1] = 0x1A;
11278 ndev->dev_addr[2] = 0x11;
11279 ndev->dev_addr[3] |= 0xF0;
11280 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
11281 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080011282 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
11283 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070011284 }
11285
Jeff Johnson295189b2012-06-20 16:38:30 -070011286 hdd_set_ap_ops( pAdapter->dev );
11287
Kiet Lam10841362013-11-01 11:36:50 +053011288 /* This is for only SAP mode where users can
11289 * control country through ini.
11290 * P2P GO follows station country code
11291 * acquired during the STA scanning. */
11292 if((NL80211_IFTYPE_AP == type) &&
11293 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
11294 {
11295 int status = 0;
11296 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
11297 "%s: setting country code from INI ", __func__);
11298 init_completion(&pAdapter->change_country_code);
11299 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
11300 (void *)(tSmeChangeCountryCallback)
11301 wlan_hdd_change_country_code_cb,
11302 pConfig->apCntryCode, pAdapter,
11303 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053011304 eSIR_FALSE,
11305 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053011306 if (eHAL_STATUS_SUCCESS == status)
11307 {
11308 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011309 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053011310 &pAdapter->change_country_code,
11311 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011312 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053011313 {
11314 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011315 FL("SME Timed out while setting country code %ld"),
11316 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080011317
11318 if (pHddCtx->isLogpInProgress)
11319 {
11320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11321 "%s: LOGP in Progress. Ignore!!!", __func__);
11322 return -EAGAIN;
11323 }
Kiet Lam10841362013-11-01 11:36:50 +053011324 }
11325 }
11326 else
11327 {
11328 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011329 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053011330 return -EINVAL;
11331 }
11332 }
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +053011333 status = hdd_init_ap_mode(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -070011334 if(status != VOS_STATUS_SUCCESS)
11335 {
11336 hddLog(VOS_TRACE_LEVEL_FATAL,
11337 "%s: Error initializing the ap mode", __func__);
11338 return -EINVAL;
11339 }
11340 hdd_set_conparam(1);
11341
Nirav Shah7e3c8132015-06-22 23:51:42 +053011342 status = hdd_sta_id_hash_attach(pAdapter);
11343 if (VOS_STATUS_SUCCESS != status)
11344 {
11345 hddLog(VOS_TRACE_LEVEL_ERROR,
11346 FL("Failed to initialize hash for AP"));
11347 return -EINVAL;
11348 }
11349
Jeff Johnson295189b2012-06-20 16:38:30 -070011350 /*interface type changed update in wiphy structure*/
11351 if(wdev)
11352 {
11353 wdev->iftype = type;
11354 pHddCtx->change_iface = type;
11355 }
11356 else
11357 {
11358 hddLog(VOS_TRACE_LEVEL_ERROR,
11359 "%s: ERROR !!!! Wireless dev is NULL", __func__);
11360 return -EINVAL;
11361 }
11362 goto done;
11363 }
11364
11365 default:
11366 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
11367 __func__);
11368 return -EOPNOTSUPP;
11369 }
11370 }
11371 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011372 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070011373 )
11374 {
11375 switch(type)
11376 {
11377 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070011378 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070011379 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053011380
11381 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011382#ifdef FEATURE_WLAN_TDLS
11383
11384 /* A Mutex Lock is introduced while changing the mode to
11385 * protect the concurrent access for the Adapters by TDLS
11386 * module.
11387 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011388 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011389#endif
c_hpothu002231a2015-02-05 14:58:51 +053011390 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011391 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080011392 //Check for sub-string p2p to confirm its a p2p interface
11393 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080011394 {
11395 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
11396 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
11397 }
11398 else
11399 {
11400 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070011401 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080011402 }
Agrawal Ashishcfe83282016-09-29 13:03:45 +053011403
11404 /* set con_mode to STA only when no SAP concurrency mode */
11405 if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO)))
11406 hdd_set_conparam(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011407 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070011408 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
11409 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011410#ifdef FEATURE_WLAN_TDLS
11411 mutex_unlock(&pHddCtx->tdls_lock);
11412#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053011413 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070011414 if( VOS_STATUS_SUCCESS != status )
11415 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070011416 /* In case of JB, for P2P-GO, only change interface will be called,
11417 * This is the right place to enable back bmps_imps()
11418 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053011419 if (pHddCtx->hdd_wlan_suspended)
11420 {
11421 hdd_set_pwrparams(pHddCtx);
11422 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011423 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070011424 goto done;
11425 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070011427 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070011428 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
11429 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011430 goto done;
11431 default:
11432 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
11433 __func__);
11434 return -EOPNOTSUPP;
11435
11436 }
11437
11438 }
11439 else
11440 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011441 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
11442 __func__, hdd_device_modetoString(pAdapter->device_mode),
11443 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 return -EOPNOTSUPP;
11445 }
11446
11447
11448 if(pRoamProfile)
11449 {
11450 if ( LastBSSType != pRoamProfile->BSSType )
11451 {
11452 /*interface type changed update in wiphy structure*/
11453 wdev->iftype = type;
11454
11455 /*the BSS mode changed, We need to issue disconnect
11456 if connected or in IBSS disconnect state*/
11457 if ( hdd_connGetConnectedBssType(
11458 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
11459 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
11460 {
11461 /*need to issue a disconnect to CSR.*/
11462 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11463 if( eHAL_STATUS_SUCCESS ==
11464 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
11465 pAdapter->sessionId,
11466 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
11467 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011468 ret = wait_for_completion_interruptible_timeout(
11469 &pAdapter->disconnect_comp_var,
11470 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11471 if (ret <= 0)
11472 {
11473 hddLog(VOS_TRACE_LEVEL_ERROR,
11474 FL("wait on disconnect_comp_var failed %ld"), ret);
11475 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011476 }
11477 }
11478 }
11479 }
11480
11481done:
11482 /*set bitmask based on updated value*/
11483 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070011484
11485 /* Only STA mode support TM now
11486 * all other mode, TM feature should be disabled */
11487 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
11488 (~VOS_STA & pHddCtx->concurrency_mode) )
11489 {
11490 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
11491 }
11492
Jeff Johnson295189b2012-06-20 16:38:30 -070011493#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011494 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053011495 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070011496 {
11497 //we are ok to do AMP
11498 pHddCtx->isAmpAllowed = VOS_TRUE;
11499 }
11500#endif //WLAN_BTAMP_FEATURE
11501 EXIT();
11502 return 0;
11503}
11504
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053011505/*
11506 * FUNCTION: wlan_hdd_cfg80211_change_iface
11507 * wrapper function to protect the actual implementation from SSR.
11508 */
11509int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
11510 struct net_device *ndev,
11511 enum nl80211_iftype type,
11512 u32 *flags,
11513 struct vif_params *params
11514 )
11515{
11516 int ret;
11517
11518 vos_ssr_protect(__func__);
11519 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
11520 vos_ssr_unprotect(__func__);
11521
11522 return ret;
11523}
11524
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011525#ifdef FEATURE_WLAN_TDLS
11526static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011527 struct net_device *dev,
11528#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11529 const u8 *mac,
11530#else
11531 u8 *mac,
11532#endif
11533 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011534{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011535 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011536 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011537 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011538 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053011539 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053011540 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011541
11542 ENTER();
11543
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053011544 if (!dev) {
11545 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
11546 return -EINVAL;
11547 }
11548
11549 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11550 if (!pAdapter) {
11551 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
11552 return -EINVAL;
11553 }
11554
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053011555 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011556 {
11557 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11558 "Invalid arguments");
11559 return -EINVAL;
11560 }
Hoonki Lee27511902013-03-14 18:19:06 -070011561
11562 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
11563 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
11564 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011565 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070011566 "%s: TDLS mode is disabled OR not enabled in FW."
11567 MAC_ADDRESS_STR " Request declined.",
11568 __func__, MAC_ADDR_ARRAY(mac));
11569 return -ENOTSUPP;
11570 }
11571
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011572 if (pHddCtx->isLogpInProgress)
11573 {
11574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11575 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053011576 wlan_hdd_tdls_set_link_status(pAdapter,
11577 mac,
11578 eTDLS_LINK_IDLE,
11579 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011580 return -EBUSY;
11581 }
11582
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053011583 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053011584 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011585
11586 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011588 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
11589 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053011590 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011591 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011592 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011593
11594 /* in add station, we accept existing valid staId if there is */
11595 if ((0 == update) &&
11596 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
11597 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011598 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011599 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011600 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011601 " link_status %d. staId %d. add station ignored.",
11602 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011603 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011604 return 0;
11605 }
11606 /* in change station, we accept only when staId is valid */
11607 if ((1 == update) &&
11608 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
11609 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
11610 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011611 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011612 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011613 "%s: " MAC_ADDRESS_STR
11614 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011615 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
11616 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
11617 mutex_unlock(&pHddCtx->tdls_lock);
11618 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011619 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011620 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011621
11622 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053011623 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011624 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011625 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11626 "%s: " MAC_ADDRESS_STR
11627 " TDLS setup is ongoing. Request declined.",
11628 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070011629 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011630 }
11631
11632 /* first to check if we reached to maximum supported TDLS peer.
11633 TODO: for now, return -EPERM looks working fine,
11634 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011635 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
11636 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011637 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011638 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11639 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011640 " TDLS Max peer already connected. Request declined."
11641 " Num of peers (%d), Max allowed (%d).",
11642 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
11643 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070011644 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011645 }
11646 else
11647 {
11648 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011649 mutex_lock(&pHddCtx->tdls_lock);
11650 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011651 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011652 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011653 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011654 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11655 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
11656 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011657 return -EPERM;
11658 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011659 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011660 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011661 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053011662 wlan_hdd_tdls_set_link_status(pAdapter,
11663 mac,
11664 eTDLS_LINK_CONNECTING,
11665 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011666
Jeff Johnsond75fe012013-04-06 10:53:06 -070011667 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053011668 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011669 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011671 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070011672 if(StaParams->htcap_present)
11673 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011675 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011677 "ht_capa->extended_capabilities: %0x",
11678 StaParams->HTCap.extendedHtCapInfo);
11679 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011681 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011683 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070011684 if(StaParams->vhtcap_present)
11685 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011687 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
11688 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
11689 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
11690 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011691 {
11692 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011693 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011694 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011696 "[%d]: %x ", i, StaParams->supported_rates[i]);
11697 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070011698 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053011699 else if ((1 == update) && (NULL == StaParams))
11700 {
11701 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11702 "%s : update is true, but staParams is NULL. Error!", __func__);
11703 return -EPERM;
11704 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011705
11706 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
11707
11708 if (!update)
11709 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053011710 /*Before adding sta make sure that device exited from BMPS*/
11711 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
11712 {
11713 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11714 "%s: Adding tdls peer sta. Disable BMPS", __func__);
11715 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
11716 if (status != VOS_STATUS_SUCCESS) {
11717 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
11718 }
11719 }
11720
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011721 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011722 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011723 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053011724 hddLog(VOS_TRACE_LEVEL_ERROR,
11725 FL("Failed to add TDLS peer STA. Enable Bmps"));
11726 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011727 return -EPERM;
11728 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011729 }
11730 else
11731 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011732 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011733 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011734 if (ret != eHAL_STATUS_SUCCESS) {
11735 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
11736 return -EPERM;
11737 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011738 }
11739
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011740 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011741 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
11742
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053011743 mutex_lock(&pHddCtx->tdls_lock);
11744 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
11745
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011746 if ((pTdlsPeer != NULL) &&
11747 (pTdlsPeer->link_status == eTDLS_LINK_TEARING))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011748 {
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011749 hddLog(VOS_TRACE_LEVEL_ERROR,
11750 FL("peer link status %u"), pTdlsPeer->link_status);
11751 mutex_unlock(&pHddCtx->tdls_lock);
11752 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011753 }
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053011754 mutex_unlock(&pHddCtx->tdls_lock);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011755
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011756 if (ret <= 0)
11757 {
11758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11759 "%s: timeout waiting for tdls add station indication %ld",
11760 __func__, ret);
11761 goto error;
11762 }
11763
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011764 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
11765 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011767 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011768 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011769 }
11770
11771 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070011772
11773error:
Atul Mittal115287b2014-07-08 13:26:33 +053011774 wlan_hdd_tdls_set_link_status(pAdapter,
11775 mac,
11776 eTDLS_LINK_IDLE,
11777 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070011778 return -EPERM;
11779
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011780}
11781#endif
11782
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011783static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011784 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011785#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11786 const u8 *mac,
11787#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011789#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011790 struct station_parameters *params)
11791{
11792 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011793 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011794 hdd_context_t *pHddCtx;
11795 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011796 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011797 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011798#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011799 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011800 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011801 tANI_U8 isOffChannelSupported = 0;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011802 tANI_U8 isQosWmmSta = FALSE;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011803#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011804
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011805 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011806
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011807 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011808 if ((NULL == pAdapter))
11809 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011811 "invalid adapter ");
11812 return -EINVAL;
11813 }
11814
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011815 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11816 TRACE_CODE_HDD_CHANGE_STATION,
11817 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053011818 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011819
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011820 ret = wlan_hdd_validate_context(pHddCtx);
11821 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053011822 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011823 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011824 }
11825
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011826 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11827
11828 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011829 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11831 "invalid HDD station context");
11832 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011833 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011834 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
11835
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011836 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
11837 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070011838 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011839 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070011840 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011841 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070011842 WLANTL_STA_AUTHENTICATED);
11843
Gopichand Nakkala29149562013-05-10 21:43:41 +053011844 if (status != VOS_STATUS_SUCCESS)
11845 {
11846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11847 "%s: Not able to change TL state to AUTHENTICATED", __func__);
11848 return -EINVAL;
11849 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011850 }
11851 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070011852 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
11853 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011854#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011855 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
11856 StaParams.capability = params->capability;
11857 StaParams.uapsd_queues = params->uapsd_queues;
11858 StaParams.max_sp = params->max_sp;
11859
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011860 /* Convert (first channel , number of channels) tuple to
11861 * the total list of channels. This goes with the assumption
11862 * that if the first channel is < 14, then the next channels
11863 * are an incremental of 1 else an incremental of 4 till the number
11864 * of channels.
11865 */
11866 if (0 != params->supported_channels_len) {
11867 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
11868 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
11869 {
11870 int wifi_chan_index;
11871 StaParams.supported_channels[j] = params->supported_channels[i];
11872 wifi_chan_index =
11873 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
11874 no_of_channels = params->supported_channels[i+1];
11875 for(k=1; k <= no_of_channels; k++)
11876 {
11877 StaParams.supported_channels[j+1] =
11878 StaParams.supported_channels[j] + wifi_chan_index;
11879 j+=1;
11880 }
11881 }
11882 StaParams.supported_channels_len = j;
11883 }
SaidiReddy Yenuga0f1a1592017-04-05 13:18:26 +053011884 if (params->supported_oper_classes_len >
11885 SIR_MAC_MAX_SUPP_OPER_CLASSES) {
11886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11887 "received oper classes:%d, resetting it to max supported %d",
11888 params->supported_oper_classes_len,
11889 SIR_MAC_MAX_SUPP_OPER_CLASSES);
11890 params->supported_oper_classes_len =
11891 SIR_MAC_MAX_SUPP_OPER_CLASSES;
11892 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011893 vos_mem_copy(StaParams.supported_oper_classes,
11894 params->supported_oper_classes,
11895 params->supported_oper_classes_len);
11896 StaParams.supported_oper_classes_len =
11897 params->supported_oper_classes_len;
11898
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053011899 if (params->ext_capab_len > sizeof(StaParams.extn_capability)) {
11900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11901 "received extn capabilities:%d, resetting it to max supported",
11902 params->ext_capab_len);
11903 params->ext_capab_len = sizeof(StaParams.extn_capability);
11904 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011905 if (0 != params->ext_capab_len)
11906 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053011907 params->ext_capab_len);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011908
11909 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011910 {
11911 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011912 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011913 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011914
11915 StaParams.supported_rates_len = params->supported_rates_len;
11916
11917 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
11918 * The supported_rates array , for all the structures propogating till Add Sta
11919 * to the firmware has to be modified , if the supplicant (ieee80211) is
11920 * modified to send more rates.
11921 */
11922
11923 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
11924 */
11925 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
11926 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
11927
11928 if (0 != StaParams.supported_rates_len) {
11929 int i = 0;
11930 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
11931 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011932 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011933 "Supported Rates with Length %d", StaParams.supported_rates_len);
11934 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011935 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011936 "[%d]: %0x", i, StaParams.supported_rates[i]);
11937 }
11938
11939 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011940 {
11941 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011942 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011943 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011944
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011945 if (0 != params->ext_capab_len ) {
11946 /*Define A Macro : TODO Sunil*/
11947 if ((1<<4) & StaParams.extn_capability[3]) {
11948 isBufSta = 1;
11949 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011950 /* TDLS Channel Switching Support */
11951 if ((1<<6) & StaParams.extn_capability[3]) {
11952 isOffChannelSupported = 1;
11953 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011954 }
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011955
11956 if (pHddCtx->cfg_ini->fEnableTDLSWmmMode &&
Nitesh Shah48df4c02016-08-12 16:27:33 +053011957 (params->ht_capa || params->vht_capa ||
11958 (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME))))
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011959 /* TDLS Peer is WME/QoS capable */
11960 isQosWmmSta = TRUE;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011961
11962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11963 "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d",
11964 __func__, isQosWmmSta, StaParams.htcap_present);
11965
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011966 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
11967 &StaParams, isBufSta,
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011968 isOffChannelSupported,
11969 isQosWmmSta);
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011970
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011971 if (VOS_STATUS_SUCCESS != status) {
11972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11973 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
11974 return -EINVAL;
11975 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011976 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
11977
11978 if (VOS_STATUS_SUCCESS != status) {
11979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11980 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
11981 return -EINVAL;
11982 }
11983 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011984#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053011985 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011986 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011987 return status;
11988}
11989
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011990#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
11991static int wlan_hdd_change_station(struct wiphy *wiphy,
11992 struct net_device *dev,
11993 const u8 *mac,
11994 struct station_parameters *params)
11995#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011996static int wlan_hdd_change_station(struct wiphy *wiphy,
11997 struct net_device *dev,
11998 u8 *mac,
11999 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012000#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012001{
12002 int ret;
12003
12004 vos_ssr_protect(__func__);
12005 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
12006 vos_ssr_unprotect(__func__);
12007
12008 return ret;
12009}
12010
Jeff Johnson295189b2012-06-20 16:38:30 -070012011/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012012 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070012013 * This function is used to initialize the key information
12014 */
12015#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012016static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012017 struct net_device *ndev,
12018 u8 key_index, bool pairwise,
12019 const u8 *mac_addr,
12020 struct key_params *params
12021 )
12022#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012023static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012024 struct net_device *ndev,
12025 u8 key_index, const u8 *mac_addr,
12026 struct key_params *params
12027 )
12028#endif
12029{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012030 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012031 tCsrRoamSetKey setKey;
12032 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012033 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012034 v_U32_t roamId= 0xFF;
12035 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070012036 hdd_hostapd_state_t *pHostapdState;
12037 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012038 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012039 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012040
12041 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012042
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012043 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12044 TRACE_CODE_HDD_CFG80211_ADD_KEY,
12045 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012046 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12047 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012048 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012049 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012050 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012051 }
12052
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012053 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12054 __func__, hdd_device_modetoString(pAdapter->device_mode),
12055 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012056
12057 if (CSR_MAX_NUM_KEY <= key_index)
12058 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012059 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012060 key_index);
12061
12062 return -EINVAL;
12063 }
12064
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012065 if (CSR_MAX_KEY_LEN < params->key_len)
12066 {
12067 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
12068 params->key_len);
12069
12070 return -EINVAL;
12071 }
12072
12073 hddLog(VOS_TRACE_LEVEL_INFO,
12074 "%s: called with key index = %d & key length %d",
12075 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070012076
12077 /*extract key idx, key len and key*/
12078 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12079 setKey.keyId = key_index;
12080 setKey.keyLength = params->key_len;
12081 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
12082
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012083 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070012084 {
12085 case WLAN_CIPHER_SUITE_WEP40:
12086 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12087 break;
12088
12089 case WLAN_CIPHER_SUITE_WEP104:
12090 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
12091 break;
12092
12093 case WLAN_CIPHER_SUITE_TKIP:
12094 {
12095 u8 *pKey = &setKey.Key[0];
12096 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
12097
12098 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
12099
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012100 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070012101
12102 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012103 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070012104 |--------------|----------|----------|
12105 <---16bytes---><--8bytes--><--8bytes-->
12106
12107 */
12108 /*Sme expects the 32 bytes key to be in the below order
12109
12110 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012111 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070012112 |--------------|----------|----------|
12113 <---16bytes---><--8bytes--><--8bytes-->
12114 */
12115 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012116 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012117
12118 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012119 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012120
12121 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012122 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012123
12124
12125 break;
12126 }
12127
12128 case WLAN_CIPHER_SUITE_CCMP:
12129 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
12130 break;
12131
12132#ifdef FEATURE_WLAN_WAPI
12133 case WLAN_CIPHER_SUITE_SMS4:
12134 {
12135 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12136 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
12137 params->key, params->key_len);
12138 return 0;
12139 }
12140#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070012141
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012142#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070012143 case WLAN_CIPHER_SUITE_KRK:
12144 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
12145 break;
12146#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070012147
12148#ifdef WLAN_FEATURE_11W
12149 case WLAN_CIPHER_SUITE_AES_CMAC:
12150 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070012151 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070012152#endif
12153
Jeff Johnson295189b2012-06-20 16:38:30 -070012154 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012155 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070012156 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012157 status = -EOPNOTSUPP;
12158 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070012159 }
12160
12161 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
12162 __func__, setKey.encType);
12163
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012164 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070012165#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12166 (!pairwise)
12167#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012168 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070012169#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012170 )
12171 {
12172 /* set group key*/
12173 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12174 "%s- %d: setting Broadcast key",
12175 __func__, __LINE__);
12176 setKey.keyDirection = eSIR_RX_ONLY;
12177 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
12178 }
12179 else
12180 {
12181 /* set pairwise key*/
12182 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12183 "%s- %d: setting pairwise key",
12184 __func__, __LINE__);
12185 setKey.keyDirection = eSIR_TX_RX;
12186 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
12187 }
12188 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
12189 {
12190 setKey.keyDirection = eSIR_TX_RX;
12191 /*Set the group key*/
12192 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
12193 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012194
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012195 if ( 0 != status )
12196 {
12197 hddLog(VOS_TRACE_LEVEL_ERROR,
12198 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012199 status = -EINVAL;
12200 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012201 }
12202 /*Save the keys here and call sme_RoamSetKey for setting
12203 the PTK after peer joins the IBSS network*/
12204 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
12205 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012206 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012207 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053012208 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
12209 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
12210 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012211 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012212 if( pHostapdState->bssState == BSS_START )
12213 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070012214 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12215 vos_status = wlan_hdd_check_ula_done(pAdapter);
12216
12217 if ( vos_status != VOS_STATUS_SUCCESS )
12218 {
12219 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12220 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
12221 __LINE__, vos_status );
12222
12223 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
12224
12225 status = -EINVAL;
12226 goto end;
12227 }
12228
Jeff Johnson295189b2012-06-20 16:38:30 -070012229 status = WLANSAP_SetKeySta( pVosContext, &setKey);
12230
12231 if ( status != eHAL_STATUS_SUCCESS )
12232 {
12233 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12234 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
12235 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012236 status = -EINVAL;
12237 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070012238 }
12239 }
12240
12241 /* Saving WEP keys */
12242 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
12243 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
12244 {
12245 //Save the wep key in ap context. Issue setkey after the BSS is started.
12246 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
12247 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
12248 }
12249 else
12250 {
12251 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012252 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012253 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
12254 }
12255 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012256 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
12257 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012258 {
12259 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12260 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12261
Gopichand Nakkala3d295922013-05-07 16:19:14 +053012262#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12263 if (!pairwise)
12264#else
12265 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
12266#endif
12267 {
12268 /* set group key*/
12269 if (pHddStaCtx->roam_info.deferKeyComplete)
12270 {
12271 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12272 "%s- %d: Perform Set key Complete",
12273 __func__, __LINE__);
12274 hdd_PerformRoamSetKeyComplete(pAdapter);
12275 }
12276 }
12277
Jeff Johnson295189b2012-06-20 16:38:30 -070012278 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
12279
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080012280 pWextState->roamProfile.Keys.defaultIndex = key_index;
12281
12282
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012283 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012284 params->key, params->key_len);
12285
Gopichand Nakkala3d295922013-05-07 16:19:14 +053012286
Jeff Johnson295189b2012-06-20 16:38:30 -070012287 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
12288
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012289 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070012290 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012291 __func__, setKey.peerMac[0], setKey.peerMac[1],
12292 setKey.peerMac[2], setKey.peerMac[3],
12293 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070012294 setKey.keyDirection);
12295
Nirav Shah4b53d4b2015-05-08 05:35:00 -070012296 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053012297
Nirav Shah4b53d4b2015-05-08 05:35:00 -070012298 if ( vos_status != VOS_STATUS_SUCCESS )
12299 {
12300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012301 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
12302 __LINE__, vos_status );
12303
Nirav Shah4b53d4b2015-05-08 05:35:00 -070012304 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012305
Nirav Shah4b53d4b2015-05-08 05:35:00 -070012306 status = -EINVAL;
12307 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070012308
12309 }
12310
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012311#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053012312 /* The supplicant may attempt to set the PTK once pre-authentication
12313 is done. Save the key in the UMAC and include it in the ADD BSS
12314 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012315 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053012316 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012317 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053012318 hddLog(VOS_TRACE_LEVEL_INFO_MED,
12319 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012320 status = 0;
12321 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053012322 }
12323 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
12324 {
12325 hddLog(VOS_TRACE_LEVEL_ERROR,
12326 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012327 status = -EINVAL;
12328 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012329 }
12330#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070012331
12332 /* issue set key request to SME*/
12333 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
12334 pAdapter->sessionId, &setKey, &roamId );
12335
12336 if ( 0 != status )
12337 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012338 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
12340 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012341 status = -EINVAL;
12342 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070012343 }
12344
12345
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012346 /* in case of IBSS as there was no information available about WEP keys during
12347 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070012348 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012349 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
12350 !( ( IW_AUTH_KEY_MGMT_802_1X
12351 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070012352 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
12353 )
12354 &&
12355 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
12356 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
12357 )
12358 )
12359 {
12360 setKey.keyDirection = eSIR_RX_ONLY;
12361 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
12362
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012363 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070012364 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012365 __func__, setKey.peerMac[0], setKey.peerMac[1],
12366 setKey.peerMac[2], setKey.peerMac[3],
12367 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 setKey.keyDirection);
12369
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012370 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012371 pAdapter->sessionId, &setKey, &roamId );
12372
12373 if ( 0 != status )
12374 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012375 hddLog(VOS_TRACE_LEVEL_ERROR,
12376 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 __func__, status);
12378 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012379 status = -EINVAL;
12380 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070012381 }
12382 }
12383 }
12384
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012385end:
12386 /* Need to clear any trace of key value in the memory.
12387 * Thus zero out the memory even though it is local
12388 * variable.
12389 */
12390 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012391 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012392 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012393}
12394
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012395#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12396static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
12397 struct net_device *ndev,
12398 u8 key_index, bool pairwise,
12399 const u8 *mac_addr,
12400 struct key_params *params
12401 )
12402#else
12403static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
12404 struct net_device *ndev,
12405 u8 key_index, const u8 *mac_addr,
12406 struct key_params *params
12407 )
12408#endif
12409{
12410 int ret;
12411 vos_ssr_protect(__func__);
12412#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12413 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
12414 mac_addr, params);
12415#else
12416 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
12417 params);
12418#endif
12419 vos_ssr_unprotect(__func__);
12420
12421 return ret;
12422}
12423
Jeff Johnson295189b2012-06-20 16:38:30 -070012424/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012425 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 * This function is used to get the key information
12427 */
12428#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012429static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012430 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012431 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012432 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070012433 const u8 *mac_addr, void *cookie,
12434 void (*callback)(void *cookie, struct key_params*)
12435 )
12436#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012437static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012438 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 struct net_device *ndev,
12440 u8 key_index, const u8 *mac_addr, void *cookie,
12441 void (*callback)(void *cookie, struct key_params*)
12442 )
12443#endif
12444{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012445 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012446 hdd_wext_state_t *pWextState = NULL;
12447 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012448 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012449 hdd_context_t *pHddCtx;
12450 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012451
12452 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012453
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012454 if (NULL == pAdapter)
12455 {
12456 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12457 "%s: HDD adapter is Null", __func__);
12458 return -ENODEV;
12459 }
12460
12461 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12462 ret = wlan_hdd_validate_context(pHddCtx);
12463 if (0 != ret)
12464 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012465 return ret;
12466 }
12467
12468 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12469 pRoamProfile = &(pWextState->roamProfile);
12470
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012471 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12472 __func__, hdd_device_modetoString(pAdapter->device_mode),
12473 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012474
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 memset(&params, 0, sizeof(params));
12476
12477 if (CSR_MAX_NUM_KEY <= key_index)
12478 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012479 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070012480 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012481 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012482
12483 switch(pRoamProfile->EncryptionType.encryptionType[0])
12484 {
12485 case eCSR_ENCRYPT_TYPE_NONE:
12486 params.cipher = IW_AUTH_CIPHER_NONE;
12487 break;
12488
12489 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
12490 case eCSR_ENCRYPT_TYPE_WEP40:
12491 params.cipher = WLAN_CIPHER_SUITE_WEP40;
12492 break;
12493
12494 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
12495 case eCSR_ENCRYPT_TYPE_WEP104:
12496 params.cipher = WLAN_CIPHER_SUITE_WEP104;
12497 break;
12498
12499 case eCSR_ENCRYPT_TYPE_TKIP:
12500 params.cipher = WLAN_CIPHER_SUITE_TKIP;
12501 break;
12502
12503 case eCSR_ENCRYPT_TYPE_AES:
12504 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
12505 break;
12506
12507 default:
12508 params.cipher = IW_AUTH_CIPHER_NONE;
12509 break;
12510 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012511
c_hpothuaaf19692014-05-17 17:01:48 +053012512 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12513 TRACE_CODE_HDD_CFG80211_GET_KEY,
12514 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012515
Jeff Johnson295189b2012-06-20 16:38:30 -070012516 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
12517 params.seq_len = 0;
12518 params.seq = NULL;
12519 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
12520 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012521 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 return 0;
12523}
12524
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012525#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12526static int wlan_hdd_cfg80211_get_key(
12527 struct wiphy *wiphy,
12528 struct net_device *ndev,
12529 u8 key_index, bool pairwise,
12530 const u8 *mac_addr, void *cookie,
12531 void (*callback)(void *cookie, struct key_params*)
12532 )
12533#else
12534static int wlan_hdd_cfg80211_get_key(
12535 struct wiphy *wiphy,
12536 struct net_device *ndev,
12537 u8 key_index, const u8 *mac_addr, void *cookie,
12538 void (*callback)(void *cookie, struct key_params*)
12539 )
12540#endif
12541{
12542 int ret;
12543
12544 vos_ssr_protect(__func__);
12545#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12546 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
12547 mac_addr, cookie, callback);
12548#else
12549 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
12550 callback);
12551#endif
12552 vos_ssr_unprotect(__func__);
12553
12554 return ret;
12555}
12556
Jeff Johnson295189b2012-06-20 16:38:30 -070012557/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012558 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070012559 * This function is used to delete the key information
12560 */
12561#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012562static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012563 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012564 u8 key_index,
12565 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 const u8 *mac_addr
12567 )
12568#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012569static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012570 struct net_device *ndev,
12571 u8 key_index,
12572 const u8 *mac_addr
12573 )
12574#endif
12575{
12576 int status = 0;
12577
12578 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012579 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070012580 //it is observed that this is invalidating peer
12581 //key index whenever re-key is done. This is affecting data link.
12582 //It should be ok to ignore del_key.
12583#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012584 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
12585 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070012586 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
12587 tCsrRoamSetKey setKey;
12588 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012589
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 ENTER();
12591
12592 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
12593 __func__,pAdapter->device_mode);
12594
12595 if (CSR_MAX_NUM_KEY <= key_index)
12596 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012597 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012598 key_index);
12599
12600 return -EINVAL;
12601 }
12602
12603 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12604 setKey.keyId = key_index;
12605
12606 if (mac_addr)
12607 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
12608 else
12609 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
12610
12611 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
12612
12613 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012614 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012615 )
12616 {
12617
12618 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070012619 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
12620 if( pHostapdState->bssState == BSS_START)
12621 {
12622 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012623
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 if ( status != eHAL_STATUS_SUCCESS )
12625 {
12626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12627 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
12628 __LINE__, status );
12629 }
12630 }
12631 }
12632 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012633 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 )
12635 {
12636 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12637
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012638 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
12639
12640 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070012641 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012642 __func__, setKey.peerMac[0], setKey.peerMac[1],
12643 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070012644 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012645 if(pAdapter->sessionCtx.station.conn_info.connState ==
12646 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070012647 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012648 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012650
Jeff Johnson295189b2012-06-20 16:38:30 -070012651 if ( 0 != status )
12652 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012653 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 "%s: sme_RoamSetKey failure, returned %d",
12655 __func__, status);
12656 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
12657 return -EINVAL;
12658 }
12659 }
12660 }
12661#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012662 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012663 return status;
12664}
12665
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012666#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12667static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
12668 struct net_device *ndev,
12669 u8 key_index,
12670 bool pairwise,
12671 const u8 *mac_addr
12672 )
12673#else
12674static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
12675 struct net_device *ndev,
12676 u8 key_index,
12677 const u8 *mac_addr
12678 )
12679#endif
12680{
12681 int ret;
12682
12683 vos_ssr_protect(__func__);
12684#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12685 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
12686 mac_addr);
12687#else
12688 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
12689#endif
12690 vos_ssr_unprotect(__func__);
12691
12692 return ret;
12693}
12694
Jeff Johnson295189b2012-06-20 16:38:30 -070012695/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012696 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070012697 * This function is used to set the default tx key index
12698 */
12699#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012700static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 struct net_device *ndev,
12702 u8 key_index,
12703 bool unicast, bool multicast)
12704#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012705static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012706 struct net_device *ndev,
12707 u8 key_index)
12708#endif
12709{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012710 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012711 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053012712 hdd_wext_state_t *pWextState;
12713 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012714 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012715
12716 ENTER();
12717
Gopichand Nakkala29149562013-05-10 21:43:41 +053012718 if ((NULL == pAdapter))
12719 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053012721 "invalid adapter");
12722 return -EINVAL;
12723 }
12724
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012725 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12726 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
12727 pAdapter->sessionId, key_index));
12728
Gopichand Nakkala29149562013-05-10 21:43:41 +053012729 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12730 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12731
12732 if ((NULL == pWextState) || (NULL == pHddStaCtx))
12733 {
12734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
12735 "invalid Wext state or HDD context");
12736 return -EINVAL;
12737 }
12738
Arif Hussain6d2a3322013-11-17 19:50:10 -080012739 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012741
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 if (CSR_MAX_NUM_KEY <= key_index)
12743 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012744 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012745 key_index);
12746
12747 return -EINVAL;
12748 }
12749
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012750 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12751 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012752 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012753 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012754 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012755 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012756
Jeff Johnson295189b2012-06-20 16:38:30 -070012757 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070012758 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012759 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012760 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053012761 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080012762 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012763 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080012764 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070012765 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012766 {
12767 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070012768 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012769
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 tCsrRoamSetKey setKey;
12771 v_U32_t roamId= 0xFF;
12772 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012773
12774 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012775 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012776
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 Keys->defaultIndex = (u8)key_index;
12778 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12779 setKey.keyId = key_index;
12780 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012781
12782 vos_mem_copy(&setKey.Key[0],
12783 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012785
Gopichand Nakkala29149562013-05-10 21:43:41 +053012786 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012787
12788 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 &pHddStaCtx->conn_info.bssId[0],
12790 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012791
Gopichand Nakkala29149562013-05-10 21:43:41 +053012792 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
12793 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
12794 eCSR_ENCRYPT_TYPE_WEP104)
12795 {
12796 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
12797 even though ap is configured for WEP-40 encryption. In this canse the key length
12798 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
12799 type(104) and switching encryption type to 40*/
12800 pWextState->roamProfile.EncryptionType.encryptionType[0] =
12801 eCSR_ENCRYPT_TYPE_WEP40;
12802 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
12803 eCSR_ENCRYPT_TYPE_WEP40;
12804 }
12805
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012806 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012807 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012808
Jeff Johnson295189b2012-06-20 16:38:30 -070012809 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012810 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012811 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012812
Jeff Johnson295189b2012-06-20 16:38:30 -070012813 if ( 0 != status )
12814 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012815 hddLog(VOS_TRACE_LEVEL_ERROR,
12816 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012817 status);
12818 return -EINVAL;
12819 }
12820 }
12821 }
12822
12823 /* In SoftAp mode setting key direction for default mode */
12824 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
12825 {
12826 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
12827 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
12828 (eCSR_ENCRYPT_TYPE_AES !=
12829 pWextState->roamProfile.EncryptionType.encryptionType[0])
12830 )
12831 {
12832 /* Saving key direction for default key index to TX default */
12833 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
12834 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
12835 }
12836 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012837 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 return status;
12839}
12840
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012841#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12842static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12843 struct net_device *ndev,
12844 u8 key_index,
12845 bool unicast, bool multicast)
12846#else
12847static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12848 struct net_device *ndev,
12849 u8 key_index)
12850#endif
12851{
12852 int ret;
12853 vos_ssr_protect(__func__);
12854#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12855 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
12856 multicast);
12857#else
12858 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
12859#endif
12860 vos_ssr_unprotect(__func__);
12861
12862 return ret;
12863}
12864
Jeff Johnson295189b2012-06-20 16:38:30 -070012865/*
12866 * FUNCTION: wlan_hdd_cfg80211_inform_bss
12867 * This function is used to inform the BSS details to nl80211 interface.
12868 */
12869static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
12870 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
12871{
12872 struct net_device *dev = pAdapter->dev;
12873 struct wireless_dev *wdev = dev->ieee80211_ptr;
12874 struct wiphy *wiphy = wdev->wiphy;
12875 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
12876 int chan_no;
12877 int ie_length;
12878 const char *ie;
12879 unsigned int freq;
12880 struct ieee80211_channel *chan;
12881 int rssi = 0;
12882 struct cfg80211_bss *bss = NULL;
12883
Jeff Johnson295189b2012-06-20 16:38:30 -070012884 if( NULL == pBssDesc )
12885 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012886 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012887 return bss;
12888 }
12889
12890 chan_no = pBssDesc->channelId;
12891 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
12892 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
12893
12894 if( NULL == ie )
12895 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012896 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012897 return bss;
12898 }
12899
12900#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
12901 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
12902 {
12903 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12904 }
12905 else
12906 {
12907 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12908 }
12909#else
12910 freq = ieee80211_channel_to_frequency(chan_no);
12911#endif
12912
12913 chan = __ieee80211_get_channel(wiphy, freq);
12914
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053012915 if (!chan) {
12916 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
12917 return NULL;
12918 }
12919
Abhishek Singhaee43942014-06-16 18:55:47 +053012920 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070012921
Anand N Sunkad9f80b742015-07-30 20:05:51 +053012922 return cfg80211_inform_bss(wiphy, chan,
12923#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12924 CFG80211_BSS_FTYPE_UNKNOWN,
12925#endif
12926 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012927 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070012928 pBssDesc->capabilityInfo,
12929 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053012930 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070012931}
12932
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012933/*
12934 * wlan_hdd_cfg80211_update_bss_list :to inform nl80211
12935 * interface that BSS might have been lost.
12936 * @pAdapter: adaptor
12937 * @bssid: bssid which might have been lost
12938 *
12939 * Return: bss which is unlinked from kernel cache
12940 */
12941struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_list(
12942 hdd_adapter_t *pAdapter, tSirMacAddr bssid)
12943{
12944 struct net_device *dev = pAdapter->dev;
12945 struct wireless_dev *wdev = dev->ieee80211_ptr;
12946 struct wiphy *wiphy = wdev->wiphy;
12947 struct cfg80211_bss *bss = NULL;
12948
Abhishek Singh5a597e62016-12-05 15:16:30 +053012949 bss = hdd_get_bss_entry(wiphy,
12950 NULL, bssid,
12951 NULL, 0);
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012952 if (bss == NULL) {
12953 hddLog(LOGE, FL("BSS not present"));
12954 } else {
12955 hddLog(LOG1, FL("cfg80211_unlink_bss called for BSSID "
12956 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(bssid));
12957 cfg80211_unlink_bss(wiphy, bss);
12958 }
12959 return bss;
12960}
Jeff Johnson295189b2012-06-20 16:38:30 -070012961
12962
12963/*
12964 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
12965 * This function is used to inform the BSS details to nl80211 interface.
12966 */
12967struct cfg80211_bss*
12968wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
12969 tSirBssDescription *bss_desc
12970 )
12971{
12972 /*
12973 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
12974 already exists in bss data base of cfg80211 for that particular BSS ID.
12975 Using cfg80211_inform_bss_frame to update the bss entry instead of
12976 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
12977 now there is no possibility to get the mgmt(probe response) frame from PE,
12978 converting bss_desc to ieee80211_mgmt(probe response) and passing to
12979 cfg80211_inform_bss_frame.
12980 */
12981 struct net_device *dev = pAdapter->dev;
12982 struct wireless_dev *wdev = dev->ieee80211_ptr;
12983 struct wiphy *wiphy = wdev->wiphy;
12984 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012985#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12986 qcom_ie_age *qie_age = NULL;
12987 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
12988#else
Jeff Johnson295189b2012-06-20 16:38:30 -070012989 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012990#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012991 const char *ie =
12992 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
12993 unsigned int freq;
12994 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012995 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012996 struct cfg80211_bss *bss_status = NULL;
12997 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
12998 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070012999 hdd_context_t *pHddCtx;
13000 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070013001#ifdef WLAN_OPEN_SOURCE
13002 struct timespec ts;
13003#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013004
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013005
Wilson Yangf80a0542013-10-07 13:02:37 -070013006 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13007 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070013008 if (0 != status)
13009 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070013010 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070013011 }
13012
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053013013 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070013014 if (!mgmt)
13015 {
13016 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13017 "%s: memory allocation failed ", __func__);
13018 return NULL;
13019 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070013020
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013022
13023#ifdef WLAN_OPEN_SOURCE
13024 /* Android does not want the timestamp from the frame.
13025 Instead it wants a monotonic increasing value */
13026 get_monotonic_boottime(&ts);
13027 mgmt->u.probe_resp.timestamp =
13028 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
13029#else
13030 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
13032 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070013033
13034#endif
13035
Jeff Johnson295189b2012-06-20 16:38:30 -070013036 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
13037 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080013038
13039#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
13040 /* GPS Requirement: need age ie per entry. Using vendor specific. */
13041 /* Assuming this is the last IE, copy at the end */
13042 ie_length -=sizeof(qcom_ie_age);
13043 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
13044 qie_age->element_id = QCOM_VENDOR_IE_ID;
13045 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
13046 qie_age->oui_1 = QCOM_OUI1;
13047 qie_age->oui_2 = QCOM_OUI2;
13048 qie_age->oui_3 = QCOM_OUI3;
13049 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
Selvaraj, Sridhar4b3a8362016-10-12 12:34:08 +053013050 /* Lowi expects the timestamp of bss in units of 1/10 ms. In driver all
13051 * bss related timestamp is in units of ms. Due to this when scan results
13052 * are sent to lowi the scan age is high.To address this, send age in units
13053 * of 1/10 ms.
13054 */
13055 qie_age->age = (vos_timer_get_system_time() -
13056 bss_desc->nReceivedTime)/10;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080013057#endif
13058
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053013060 if (bss_desc->fProbeRsp)
13061 {
13062 mgmt->frame_control |=
13063 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
13064 }
13065 else
13066 {
13067 mgmt->frame_control |=
13068 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
13069 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013070
13071#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013072 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070013073 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
13074 {
13075 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
13076 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013077 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070013078 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
13079
13080 {
13081 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
13082 }
13083 else
13084 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013085 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
13086 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 kfree(mgmt);
13088 return NULL;
13089 }
13090#else
13091 freq = ieee80211_channel_to_frequency(chan_no);
13092#endif
13093 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080013094 /*when the band is changed on the fly using the GUI, three things are done
13095 * 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)
13096 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
13097 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
13098 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
13099 * and discards the channels correponding to previous band and calls back with zero bss results.
13100 * 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
13101 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
13102 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
13103 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
13104 * So drop the bss and continue to next bss.
13105 */
13106 if(chan == NULL)
13107 {
Deepthi Gowri306657b2016-04-28 17:10:41 +053013108 hddLog(VOS_TRACE_LEVEL_ERROR,
13109 FL("chan pointer is NULL, chan_no: %d freq: %d"),
13110 chan_no, freq);
Chilam Ngc4244af2013-04-01 15:37:32 -070013111 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080013112 return NULL;
13113 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053013114 /*To keep the rssi icon of the connected AP in the scan window
13115 *and the rssi icon of the wireless networks in sync
13116 * */
13117 if (( eConnectionState_Associated ==
13118 pAdapter->sessionCtx.station.conn_info.connState ) &&
13119 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
13120 pAdapter->sessionCtx.station.conn_info.bssId,
13121 WNI_CFG_BSSID_LEN)) &&
13122 (pHddCtx->hdd_wlan_suspended == FALSE))
13123 {
13124 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
13125 rssi = (pAdapter->rssi * 100);
13126 }
13127 else
13128 {
13129 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
13130 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013131
Nirav Shah20ac06f2013-12-12 18:14:06 +053013132 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053013133 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
13134 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053013135
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
13137 frame_len, rssi, GFP_KERNEL);
13138 kfree(mgmt);
13139 return bss_status;
13140}
13141
13142/*
13143 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
13144 * This function is used to update the BSS data base of CFG8011
13145 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013146struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 tCsrRoamInfo *pRoamInfo
13148 )
13149{
13150 tCsrRoamConnectedProfile roamProfile;
13151 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
13152 struct cfg80211_bss *bss = NULL;
13153
13154 ENTER();
13155
13156 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
13157 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
13158
13159 if (NULL != roamProfile.pBssDesc)
13160 {
Girish Gowlif4b68022014-08-28 23:18:57 +053013161 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
13162 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013163
13164 if (NULL == bss)
13165 {
13166 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
13167 __func__);
13168 }
13169
13170 sme_RoamFreeConnectProfile(hHal, &roamProfile);
13171 }
13172 else
13173 {
13174 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
13175 __func__);
13176 }
13177 return bss;
13178}
13179
13180/*
13181 * FUNCTION: wlan_hdd_cfg80211_update_bss
13182 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013183static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
13184 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013186{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013187 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013188 tCsrScanResultInfo *pScanResult;
13189 eHalStatus status = 0;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013190 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013191 tScanResultHandle pResult;
13192 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070013193 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053013194 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013196
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013197 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13198 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
13199 NO_SESSION, pAdapter->sessionId));
13200
Wilson Yangf80a0542013-10-07 13:02:37 -070013201 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013202 ret = wlan_hdd_validate_context(pHddCtx);
13203 if (0 != ret)
Jeff Johnson295189b2012-06-20 16:38:30 -070013204 {
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013205 return ret;
Wilson Yangf80a0542013-10-07 13:02:37 -070013206 }
13207
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053013208 if (pAdapter->request != NULL)
13209 {
13210 if ((pAdapter->request->n_ssids == 1)
13211 && (pAdapter->request->ssids != NULL)
13212 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
13213 is_p2p_scan = true;
13214 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013215 /*
13216 * start getting scan results and populate cgf80211 BSS database
13217 */
13218 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
13219
13220 /* no scan results */
13221 if (NULL == pResult)
13222 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013223 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
13224 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053013225 wlan_hdd_get_frame_logs(pAdapter,
13226 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070013227 return status;
13228 }
13229
13230 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
13231
13232 while (pScanResult)
13233 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013234 /*
13235 * cfg80211_inform_bss() is not updating ie field of bss entry, if
13236 * entry already exists in bss data base of cfg80211 for that
13237 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
13238 * bss entry instead of cfg80211_inform_bss, But this call expects
13239 * mgmt packet as input. As of now there is no possibility to get
13240 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 * ieee80211_mgmt(probe response) and passing to c
13242 * fg80211_inform_bss_frame.
13243 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053013244 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
13245 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
13246 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053013247 pScanResult = sme_ScanResultGetNext(hHal, pResult);
13248 continue; //Skip the non p2p bss entries
13249 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013250 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
13251 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013252
Jeff Johnson295189b2012-06-20 16:38:30 -070013253
13254 if (NULL == bss_status)
13255 {
13256 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013257 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 }
13259 else
13260 {
Yue Maf49ba872013-08-19 12:04:25 -070013261 cfg80211_put_bss(
13262#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
13263 wiphy,
13264#endif
13265 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 }
13267
13268 pScanResult = sme_ScanResultGetNext(hHal, pResult);
13269 }
13270
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013271 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053013272 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013273 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013274}
13275
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013276void
13277hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
13278{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013279 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080013280 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013281} /****** end hddPrintMacAddr() ******/
13282
13283void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013284hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013285{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013286 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013287 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013288 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
13289 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
13290 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013291} /****** end hddPrintPmkId() ******/
13292
13293//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
13294//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
13295
13296//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
13297//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
13298
13299#define dump_bssid(bssid) \
13300 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070013301 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
13302 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013303 }
13304
13305#define dump_pmkid(pMac, pmkid) \
13306 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070013307 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
13308 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013309 }
13310
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070013311#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013312/*
13313 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
13314 * This function is used to notify the supplicant of a new PMKSA candidate.
13315 */
13316int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013317 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013318 int index, bool preauth )
13319{
Jeff Johnsone7245742012-09-05 17:12:55 -070013320#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013321 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070013322 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013323
13324 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070013325 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013326
13327 if( NULL == pRoamInfo )
13328 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013329 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013330 return -EINVAL;
13331 }
13332
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070013333 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
13334 {
13335 dump_bssid(pRoamInfo->bssid);
13336 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013337 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070013338 }
Jeff Johnsone7245742012-09-05 17:12:55 -070013339#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013340 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013341}
13342#endif //FEATURE_WLAN_LFR
13343
Yue Maef608272013-04-08 23:09:17 -070013344#ifdef FEATURE_WLAN_LFR_METRICS
13345/*
13346 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
13347 * 802.11r/LFR metrics reporting function to report preauth initiation
13348 *
13349 */
13350#define MAX_LFR_METRICS_EVENT_LENGTH 100
13351VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
13352 tCsrRoamInfo *pRoamInfo)
13353{
13354 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
13355 union iwreq_data wrqu;
13356
13357 ENTER();
13358
13359 if (NULL == pAdapter)
13360 {
13361 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
13362 return VOS_STATUS_E_FAILURE;
13363 }
13364
13365 /* create the event */
13366 memset(&wrqu, 0, sizeof(wrqu));
13367 memset(metrics_notification, 0, sizeof(metrics_notification));
13368
13369 wrqu.data.pointer = metrics_notification;
13370 wrqu.data.length = scnprintf(metrics_notification,
13371 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
13372 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
13373
13374 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
13375
13376 EXIT();
13377
13378 return VOS_STATUS_SUCCESS;
13379}
13380
13381/*
13382 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
13383 * 802.11r/LFR metrics reporting function to report preauth completion
13384 * or failure
13385 */
13386VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
13387 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
13388{
13389 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
13390 union iwreq_data wrqu;
13391
13392 ENTER();
13393
13394 if (NULL == pAdapter)
13395 {
13396 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
13397 return VOS_STATUS_E_FAILURE;
13398 }
13399
13400 /* create the event */
13401 memset(&wrqu, 0, sizeof(wrqu));
13402 memset(metrics_notification, 0, sizeof(metrics_notification));
13403
13404 scnprintf(metrics_notification, sizeof(metrics_notification),
13405 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
13406 MAC_ADDR_ARRAY(pRoamInfo->bssid));
13407
13408 if (1 == preauth_status)
13409 strncat(metrics_notification, " TRUE", 5);
13410 else
13411 strncat(metrics_notification, " FALSE", 6);
13412
13413 wrqu.data.pointer = metrics_notification;
13414 wrqu.data.length = strlen(metrics_notification);
13415
13416 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
13417
13418 EXIT();
13419
13420 return VOS_STATUS_SUCCESS;
13421}
13422
13423/*
13424 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
13425 * 802.11r/LFR metrics reporting function to report handover initiation
13426 *
13427 */
13428VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
13429 tCsrRoamInfo *pRoamInfo)
13430{
13431 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
13432 union iwreq_data wrqu;
13433
13434 ENTER();
13435
13436 if (NULL == pAdapter)
13437 {
13438 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
13439 return VOS_STATUS_E_FAILURE;
13440 }
13441
13442 /* create the event */
13443 memset(&wrqu, 0, sizeof(wrqu));
13444 memset(metrics_notification, 0, sizeof(metrics_notification));
13445
13446 wrqu.data.pointer = metrics_notification;
13447 wrqu.data.length = scnprintf(metrics_notification,
13448 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
13449 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
13450
13451 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
13452
13453 EXIT();
13454
13455 return VOS_STATUS_SUCCESS;
13456}
13457#endif
13458
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013459
13460/**
13461 * wlan_hdd_cfg80211_validate_scan_req - validate scan request
13462 * @scan_req: scan request to be checked
13463 *
13464 * Return: true or false
13465 */
13466#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
13467static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
13468 cfg80211_scan_request
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053013469 *scan_req, hdd_context_t
13470 *hdd_ctx)
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013471{
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053013472 if (!scan_req || !scan_req->wiphy ||
13473 scan_req->wiphy != hdd_ctx->wiphy) {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013474 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
13475 return false;
13476 }
13477 if (vos_is_load_unload_in_progress(VOS_MODULE_ID_HDD, NULL)) {
13478 hddLog(VOS_TRACE_LEVEL_ERROR, "Load/Unload in progress");
13479 return false;
13480 }
13481 return true;
13482}
13483#else
13484static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
13485 cfg80211_scan_request
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053013486 *scan_req, hdd_context_t
13487 *hdd_ctx)
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013488{
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053013489 if (!scan_req || !scan_req->wiphy ||
13490 scan_req->wiphy != hdd_ctx->wiphy) {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013491 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
13492 return false;
13493 }
13494 return true;
13495}
13496#endif
13497
13498
Jeff Johnson295189b2012-06-20 16:38:30 -070013499/*
13500 * FUNCTION: hdd_cfg80211_scan_done_callback
13501 * scanning callback function, called after finishing scan
13502 *
13503 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013504static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
13506{
13507 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013508 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070013509 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053013510 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013511 struct cfg80211_scan_request *req = NULL;
13512 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053013513 bool aborted = false;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013514#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13515 bool iface_down = false;
13516#endif
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013517 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013518 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053013519 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013520
13521 ENTER();
13522
c_manjee1b4ab9a2016-10-26 11:36:55 +053013523 if (!pAdapter || pAdapter->magic != WLAN_HDD_ADAPTER_MAGIC ||
13524 !pAdapter->dev) {
13525 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Adapter is not valid"));
13526 return 0;
13527 }
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053013528 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053013529 if (NULL == pHddCtx) {
13530 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013531 return 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053013532 }
13533
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053013534#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13535 if (!(pAdapter->dev->flags & IFF_UP))
13536 {
13537 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013538 iface_down = true;
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053013539 }
13540#endif
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053013541 pScanInfo = &pHddCtx->scan_info;
13542
Jeff Johnson295189b2012-06-20 16:38:30 -070013543 hddLog(VOS_TRACE_LEVEL_INFO,
13544 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080013545 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 __func__, halHandle, pContext, (int) scanId, (int) status);
13547
Kiet Lamac06e2c2013-10-23 16:25:07 +053013548 pScanInfo->mScanPendingCounter = 0;
13549
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013551 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070013552 &pScanInfo->scan_req_completion_event,
13553 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013554 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070013555 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013556 hddLog(VOS_TRACE_LEVEL_ERROR,
13557 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070013558 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070013559 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070013560 }
13561
Yue Maef608272013-04-08 23:09:17 -070013562 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070013563 {
13564 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070013565 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070013566 }
13567
13568 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013569 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013570 {
13571 hddLog(VOS_TRACE_LEVEL_INFO,
13572 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080013573 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013574 (int) scanId);
13575 }
13576
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053013577#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013578 if (!iface_down)
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053013579#endif
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013580 {
13581 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
13582 pAdapter);
13583 if (0 > ret)
13584 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053013585 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013586
Jeff Johnson295189b2012-06-20 16:38:30 -070013587 /* If any client wait scan result through WEXT
13588 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013589 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070013590 {
13591 /* The other scan request waiting for current scan finish
13592 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013593 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070013594 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013595 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 }
13597 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013598 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070013599 {
13600 struct net_device *dev = pAdapter->dev;
13601 union iwreq_data wrqu;
13602 int we_event;
13603 char *msg;
13604
13605 memset(&wrqu, '\0', sizeof(wrqu));
13606 we_event = SIOCGIWSCAN;
13607 msg = NULL;
13608 wireless_send_event(dev, we_event, &wrqu, msg);
13609 }
13610 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013611 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013612
13613 /* Get the Scan Req */
13614 req = pAdapter->request;
mukul sharmae7041822015-12-03 15:09:21 +053013615 pAdapter->request = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013616
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013617 /* Scan is no longer pending */
13618 pScanInfo->mScanPending = VOS_FALSE;
13619
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053013620 if (!wlan_hdd_cfg80211_validate_scan_req(req, pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -070013621 {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013622#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13623 hddLog(VOS_TRACE_LEVEL_ERROR, FL("interface state %s"),
13624 iface_down ? "up" : "down");
13625#endif
13626
13627 if (pAdapter->dev) {
13628 hddLog(VOS_TRACE_LEVEL_ERROR, FL("device name %s"),
13629 pAdapter->dev->name);
13630 }
mukul sharmae7041822015-12-03 15:09:21 +053013631 complete(&pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -070013632 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 }
13634
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013635 /* last_scan_timestamp is used to decide if new scan
13636 * is needed or not on station interface. If last station
13637 * scan time and new station scan time is less then
13638 * last_scan_timestamp ; driver will return cached scan.
13639 */
13640 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
13641 {
13642 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
13643
13644 if ( req->n_channels )
13645 {
13646 for (i = 0; i < req->n_channels ; i++ )
13647 {
13648 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
13649 }
13650 /* store no of channel scanned */
13651 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
13652 }
13653
13654 }
13655
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070013656 /*
13657 * cfg80211_scan_done informing NL80211 about completion
13658 * of scanning
13659 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053013660 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
13661 {
13662 aborted = true;
13663 }
mukul sharmae7041822015-12-03 15:09:21 +053013664
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013665#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13666 if (!iface_down)
13667#endif
13668 cfg80211_scan_done(req, aborted);
mukul sharmae7041822015-12-03 15:09:21 +053013669
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080013670 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070013671
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013672allow_suspend:
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053013673 if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
13674 ) && (pHddCtx->spoofMacAddr.isEnabled
13675 || pHddCtx->spoofMacAddr.isReqDeferred)) {
Siddharth Bhal76972212014-10-15 16:22:51 +053013676 /* Generate new random mac addr for next scan */
13677 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +053013678
13679 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
13680 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhal76972212014-10-15 16:22:51 +053013681 }
13682
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070013683 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013684 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013685
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070013686 /* Acquire wakelock to handle the case where APP's tries to suspend
13687 * immediatly after the driver gets connect request(i.e after scan)
13688 * from supplicant, this result in app's is suspending and not able
13689 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013690 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070013691
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013692#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13693 if (!iface_down)
13694#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070013695#ifdef FEATURE_WLAN_TDLS
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013696 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070013697#endif
13698
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 EXIT();
13700 return 0;
13701}
13702
13703/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053013704 * FUNCTION: hdd_isConnectionInProgress
13705 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013706 *
13707 */
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013708v_BOOL_t hdd_isConnectionInProgress(hdd_context_t *pHddCtx, v_U8_t *session_id,
13709 scan_reject_states *reason)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013710{
13711 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
13712 hdd_station_ctx_t *pHddStaCtx = NULL;
13713 hdd_adapter_t *pAdapter = NULL;
13714 VOS_STATUS status = 0;
13715 v_U8_t staId = 0;
13716 v_U8_t *staMac = NULL;
13717
13718 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
13719
13720 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
13721 {
13722 pAdapter = pAdapterNode->pAdapter;
13723
13724 if( pAdapter )
13725 {
13726 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013727 "%s: Adapter with device mode %s (%d) exists",
13728 __func__, hdd_device_modetoString(pAdapter->device_mode),
13729 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013730 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053013731 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13732 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
13733 (eConnectionState_Connecting ==
13734 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13735 {
13736 hddLog(VOS_TRACE_LEVEL_ERROR,
13737 "%s: %p(%d) Connection is in progress", __func__,
13738 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013739 if (session_id && reason)
13740 {
13741 *session_id = pAdapter->sessionId;
13742 *reason = eHDD_CONNECTION_IN_PROGRESS;
13743 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013744 return VOS_TRUE;
13745 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013746 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013747 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013748 {
13749 hddLog(VOS_TRACE_LEVEL_ERROR,
13750 "%s: %p(%d) Reassociation is in progress", __func__,
13751 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013752 if (session_id && reason)
13753 {
13754 *session_id = pAdapter->sessionId;
13755 *reason = eHDD_REASSOC_IN_PROGRESS;
13756 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013757 return VOS_TRUE;
13758 }
13759 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013760 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13761 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013762 {
13763 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13764 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013765 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013766 {
13767 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
13768 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080013769 "%s: client " MAC_ADDRESS_STR
13770 " is in the middle of WPS/EAPOL exchange.", __func__,
13771 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013772 if (session_id && reason)
13773 {
13774 *session_id = pAdapter->sessionId;
13775 *reason = eHDD_EAPOL_IN_PROGRESS;
13776 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013777 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013778 }
13779 }
13780 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
13781 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
13782 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013783 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13784 ptSapContext pSapCtx = NULL;
13785 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13786 if(pSapCtx == NULL){
13787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13788 FL("psapCtx is NULL"));
13789 return VOS_FALSE;
13790 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013791 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
13792 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013793 if ((pSapCtx->aStaInfo[staId].isUsed) &&
13794 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013795 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013796 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013797
13798 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080013799 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
13800 "middle of WPS/EAPOL exchange.", __func__,
13801 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013802 if (session_id && reason)
13803 {
13804 *session_id = pAdapter->sessionId;
13805 *reason = eHDD_SAP_EAPOL_IN_PROGRESS;
13806 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013807 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013808 }
13809 }
13810 }
13811 }
13812 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
13813 pAdapterNode = pNext;
13814 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013815 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013816}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013817
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053013818/**
13819 * csr_scan_request_assign_bssid() - Set the BSSID received from Supplicant
13820 * to the Scan request
13821 * @scanRequest: Pointer to the csr scan request
13822 * @request: Pointer to the scan request from supplicant
13823 *
13824 * Return: None
13825 */
13826#ifdef CFG80211_SCAN_BSSID
13827static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13828 struct cfg80211_scan_request *request)
13829{
13830 vos_mem_copy(scanRequest->bssid, request->bssid, VOS_MAC_ADDR_SIZE);
13831}
13832#else
13833static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13834 struct cfg80211_scan_request *request)
13835{
13836}
13837#endif
13838
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013839/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013840 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070013841 * this scan respond to scan trigger and update cfg80211 scan database
13842 * later, scan dump command can be used to recieve scan results
13843 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013844int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080013845#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13846 struct net_device *dev,
13847#endif
13848 struct cfg80211_scan_request *request)
13849{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013850 hdd_adapter_t *pAdapter = NULL;
13851 hdd_context_t *pHddCtx = NULL;
13852 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013853 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 tCsrScanRequest scanRequest;
13855 tANI_U8 *channelList = NULL, i;
13856 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013857 int status;
13858 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013859 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013860 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053013861 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013862 bool is_p2p_scan = false;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013863 v_U8_t curr_session_id;
13864 scan_reject_states curr_reason;
Jeff Johnson295189b2012-06-20 16:38:30 -070013865
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013866#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
13867 struct net_device *dev = NULL;
13868 if (NULL == request)
13869 {
13870 hddLog(VOS_TRACE_LEVEL_ERROR,
13871 "%s: scan req param null", __func__);
13872 return -EINVAL;
13873 }
13874 dev = request->wdev->netdev;
13875#endif
13876
13877 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13878 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
13879 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13880
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 ENTER();
13882
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013883 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13884 __func__, hdd_device_modetoString(pAdapter->device_mode),
13885 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013886
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013887 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013888 if (0 != status)
13889 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013890 return status;
13891 }
13892
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013893 if (NULL == pwextBuf)
13894 {
13895 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
13896 __func__);
13897 return -EIO;
13898 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013899 cfg_param = pHddCtx->cfg_ini;
13900 pScanInfo = &pHddCtx->scan_info;
13901
Jeff Johnson295189b2012-06-20 16:38:30 -070013902#ifdef WLAN_BTAMP_FEATURE
13903 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013904 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070013905 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013906 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013907 "%s: No scanning when AMP is on", __func__);
13908 return -EOPNOTSUPP;
13909 }
13910#endif
13911 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013912 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013913 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013914 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013915 "%s: Not scanning on device_mode = %s (%d)",
13916 __func__, hdd_device_modetoString(pAdapter->device_mode),
13917 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 return -EOPNOTSUPP;
13919 }
13920
13921 if (TRUE == pScanInfo->mScanPending)
13922 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013923 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
13924 {
13925 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
13926 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013927 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013928 }
13929
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053013930 // Don't allow scan if PNO scan is going on.
13931 if (pHddCtx->isPnoEnable)
13932 {
13933 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13934 FL("pno scan in progress"));
13935 return -EBUSY;
13936 }
13937
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013938 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070013939 //Channel and action frame is pending
13940 //Otherwise Cancel Remain On Channel and allow Scan
13941 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013942 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070013943 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013944 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070013945 return -EBUSY;
13946 }
13947
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
13949 {
13950 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080013951 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013953 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
13955 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013956 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013957 "%s: MAX TM Level Scan not allowed", __func__);
13958 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013959 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013960 }
13961 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
13962
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013963 /* Check if scan is allowed at this point of time.
13964 */
Hanumanth Reddy Pothulaec960842016-09-14 19:04:26 +053013965 if (TRUE == pHddCtx->btCoexModeSet)
13966 {
13967 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13968 FL("BTCoex Mode operation in progress"));
13969 return -EBUSY;
13970 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013971 if (hdd_isConnectionInProgress(pHddCtx, &curr_session_id, &curr_reason))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013972 {
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053013973 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Scan not allowed"));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013974 if (pHddCtx->last_scan_reject_session_id != curr_session_id ||
13975 pHddCtx->last_scan_reject_reason != curr_reason ||
13976 !pHddCtx->last_scan_reject_timestamp)
13977 {
13978 pHddCtx->last_scan_reject_session_id = curr_session_id;
13979 pHddCtx->last_scan_reject_reason = curr_reason;
Abhishek Singh3e500772017-07-17 10:13:43 +053013980 pHddCtx->last_scan_reject_timestamp =
13981 jiffies_to_msecs(jiffies) + SCAN_REJECT_THRESHOLD_TIME;
Abhishek Singhe4b12562017-06-20 16:53:39 +053013982 pHddCtx->scan_reject_cnt = 0;
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053013983 }
Abhishek Singhe4b12562017-06-20 16:53:39 +053013984 else
13985 {
13986 pHddCtx->scan_reject_cnt++;
13987
Abhishek Singh3e500772017-07-17 10:13:43 +053013988 hddLog(LOGE, FL("Session %d reason %d reject cnt %d threshold time has elapsed? %d"),
13989 curr_session_id, curr_reason, pHddCtx->scan_reject_cnt,
13990 vos_system_time_after(jiffies_to_msecs(jiffies),
Abhishek Singhe4b12562017-06-20 16:53:39 +053013991 pHddCtx->last_scan_reject_timestamp));
13992
13993 if ((pHddCtx->scan_reject_cnt >=
13994 SCAN_REJECT_THRESHOLD) &&
Abhishek Singh3e500772017-07-17 10:13:43 +053013995 vos_system_time_after(jiffies_to_msecs(jiffies),
13996 pHddCtx->last_scan_reject_timestamp))
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013997 {
13998 pHddCtx->last_scan_reject_timestamp = 0;
Abhishek Singhe4b12562017-06-20 16:53:39 +053013999 pHddCtx->scan_reject_cnt = 0;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053014000 if (pHddCtx->cfg_ini->enableFatalEvent)
14001 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
14002 WLAN_LOG_INDICATOR_HOST_DRIVER,
14003 WLAN_LOG_REASON_SCAN_NOT_ALLOWED,
14004 FALSE, FALSE);
14005 else
14006 {
14007 hddLog(LOGE, FL("Triggering SSR"));
14008 vos_wlanRestart();
14009 }
14010 }
14011 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080014012 return -EBUSY;
14013 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053014014 pHddCtx->last_scan_reject_timestamp = 0;
14015 pHddCtx->last_scan_reject_session_id = 0xFF;
14016 pHddCtx->last_scan_reject_reason = 0;
Abhishek Singhe4b12562017-06-20 16:53:39 +053014017 pHddCtx->scan_reject_cnt = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014018
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 vos_mem_zero( &scanRequest, sizeof(scanRequest));
14020
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014021 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
14022 * Becasue of this, driver is assuming that this is not wildcard scan and so
14023 * is not aging out the scan results.
14024 */
14025 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014027 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014028 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014029
14030 if ((request->ssids) && (0 < request->n_ssids))
14031 {
14032 tCsrSSIDInfo *SsidInfo;
14033 int j;
14034 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
14035 /* Allocate num_ssid tCsrSSIDInfo structure */
14036 SsidInfo = scanRequest.SSIDs.SSIDList =
14037 ( tCsrSSIDInfo *)vos_mem_malloc(
14038 request->n_ssids*sizeof(tCsrSSIDInfo));
14039
14040 if(NULL == scanRequest.SSIDs.SSIDList)
14041 {
14042 hddLog(VOS_TRACE_LEVEL_ERROR,
14043 "%s: memory alloc failed SSIDInfo buffer", __func__);
14044 return -ENOMEM;
14045 }
14046
14047 /* copy all the ssid's and their length */
14048 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
14049 {
14050 /* get the ssid length */
14051 SsidInfo->SSID.length = request->ssids[j].ssid_len;
14052 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
14053 SsidInfo->SSID.length);
14054 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
14055 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
14056 j, SsidInfo->SSID.ssId);
14057 }
14058 /* set the scan type to active */
14059 scanRequest.scanType = eSIR_ACTIVE_SCAN;
14060 }
14061 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070014062 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053014063 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14064 TRACE_CODE_HDD_CFG80211_SCAN,
14065 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070014066 /* set the scan type to active */
14067 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014069 else
14070 {
14071 /*Set the scan type to default type, in this case it is ACTIVE*/
14072 scanRequest.scanType = pScanInfo->scan_mode;
14073 }
14074 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
14075 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070014076
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053014077 csr_scan_request_assign_bssid(&scanRequest, request);
14078
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 /* set BSSType to default type */
14080 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
14081
14082 /*TODO: scan the requested channels only*/
14083
14084 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014085 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070014086 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014087 hddLog(VOS_TRACE_LEVEL_WARN,
14088 "No of Scan Channels exceeded limit: %d", request->n_channels);
14089 request->n_channels = MAX_CHANNEL;
14090 }
14091
14092 hddLog(VOS_TRACE_LEVEL_INFO,
14093 "No of Scan Channels: %d", request->n_channels);
14094
14095
14096 if( request->n_channels )
14097 {
14098 char chList [(request->n_channels*5)+1];
14099 int len;
14100 channelList = vos_mem_malloc( request->n_channels );
14101 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053014102 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014103 hddLog(VOS_TRACE_LEVEL_ERROR,
14104 "%s: memory alloc failed channelList", __func__);
14105 status = -ENOMEM;
14106 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053014107 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014108
14109 for( i = 0, len = 0; i < request->n_channels ; i++ )
14110 {
14111 channelList[i] = request->channels[i]->hw_value;
14112 len += snprintf(chList+len, 5, "%d ", channelList[i]);
14113 }
14114
Nirav Shah20ac06f2013-12-12 18:14:06 +053014115 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014116 "Channel-List: %s ", chList);
14117 }
c_hpothu53512302014-04-15 18:49:53 +053014118
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014119 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
14120 scanRequest.ChannelInfo.ChannelList = channelList;
14121
14122 /* set requestType to full scan */
14123 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
14124
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014125 /* if there is back to back scan happening in driver with in
14126 * nDeferScanTimeInterval interval driver should defer new scan request
14127 * and should provide last cached scan results instead of new channel list.
14128 * This rule is not applicable if scan is p2p scan.
14129 * This condition will work only in case when last request no of channels
14130 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053014131 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053014132 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014133 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014134
Sushant Kaushik86592172015-04-27 16:35:03 +053014135 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
14136 /* if wps ie is NULL , then only defer scan */
14137 if ( pWpsIe == NULL &&
14138 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053014139 {
14140 if ( pScanInfo->last_scan_timestamp !=0 &&
14141 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
14142 {
14143 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
14144 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
14145 vos_mem_compare(pScanInfo->last_scan_channelList,
14146 channelList, pScanInfo->last_scan_numChannels))
14147 {
14148 hddLog(VOS_TRACE_LEVEL_WARN,
14149 " New and old station scan time differ is less then %u",
14150 pHddCtx->cfg_ini->nDeferScanTimeInterval);
14151
14152 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014153 pAdapter);
14154
Agarwal Ashish57e84372014-12-05 18:26:53 +053014155 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053014156 "Return old cached scan as all channels and no of channels are same");
14157
Agarwal Ashish57e84372014-12-05 18:26:53 +053014158 if (0 > ret)
14159 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014160
Agarwal Ashish57e84372014-12-05 18:26:53 +053014161 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053014162
14163 status = eHAL_STATUS_SUCCESS;
14164 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053014165 }
14166 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014167 }
14168
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014169 /* Flush the scan results(only p2p beacons) for STA scan and P2P
14170 * search (Flush on both full scan and social scan but not on single
14171 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
14172 */
14173
14174 /* Supplicant does single channel scan after 8-way handshake
14175 * and in that case driver shoudnt flush scan results. If
14176 * driver flushes the scan results here and unfortunately if
14177 * the AP doesnt respond to our probe req then association
14178 * fails which is not desired
14179 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053014180 if ((request->n_ssids == 1)
14181 && (request->ssids != NULL)
14182 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
14183 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014184
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053014185 if( is_p2p_scan ||
14186 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014187 {
14188 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
14189 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
14190 pAdapter->sessionId );
14191 }
14192
14193 if( request->ie_len )
14194 {
14195 /* save this for future association (join requires this) */
14196 /*TODO: Array needs to be converted to dynamic allocation,
14197 * as multiple ie.s can be sent in cfg80211_scan_request structure
14198 * CR 597966
14199 */
14200 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
14201 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
14202 pScanInfo->scanAddIE.length = request->ie_len;
14203
14204 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
14205 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
14206 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070014207 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014208 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070014209 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014210 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
14211 memcpy( pwextBuf->roamProfile.addIEScan,
14212 request->ie, request->ie_len);
14213 }
14214 else
14215 {
14216 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
14217 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070014218 }
14219
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014220 }
14221 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
14222 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
14223
14224 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
14225 request->ie_len);
14226 if (pP2pIe != NULL)
14227 {
14228#ifdef WLAN_FEATURE_P2P_DEBUG
14229 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
14230 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
14231 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053014232 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014233 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
14234 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
14235 "Go nego completed to Connection is started");
14236 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
14237 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053014238 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014239 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
14240 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070014241 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014242 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
14243 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
14244 "Disconnected state to Connection is started");
14245 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
14246 "for 4way Handshake");
14247 }
14248#endif
14249
14250 /* no_cck will be set during p2p find to disable 11b rates */
14251 if(TRUE == request->no_cck)
14252 {
14253 hddLog(VOS_TRACE_LEVEL_INFO,
14254 "%s: This is a P2P Search", __func__);
14255 scanRequest.p2pSearch = 1;
14256
14257 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053014258 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014259 /* set requestType to P2P Discovery */
14260 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
14261 }
14262
14263 /*
14264 Skip Dfs Channel in case of P2P Search
14265 if it is set in ini file
14266 */
14267 if(cfg_param->skipDfsChnlInP2pSearch)
14268 {
14269 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014270 }
14271 else
14272 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014273 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014274 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014275
Agarwal Ashish4f616132013-12-30 23:32:50 +053014276 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014277 }
14278 }
14279
14280 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
14281
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053014282#ifdef FEATURE_WLAN_TDLS
14283 /* if tdls disagree scan right now, return immediately.
14284 tdls will schedule the scan when scan is allowed. (return SUCCESS)
14285 or will reject the scan if any TDLS is in progress. (return -EBUSY)
14286 */
14287 status = wlan_hdd_tdls_scan_callback (pAdapter,
14288 wiphy,
14289#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
14290 dev,
14291#endif
14292 request);
Abhishek Singhe2b63952016-01-05 18:27:29 +053014293 if (status <= 0)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053014294 {
Abhishek Singhe2b63952016-01-05 18:27:29 +053014295 if (!status)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053014296 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
14297 "scan rejected %d", __func__, status);
14298 else
14299 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
14300 __func__, status);
Abhishek Singhe2b63952016-01-05 18:27:29 +053014301 hdd_wlan_block_scan_by_tdls();
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053014302 goto free_mem;
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053014303 }
14304#endif
14305
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070014306 /* acquire the wakelock to avoid the apps suspend during the scan. To
14307 * address the following issues.
14308 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
14309 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
14310 * for long time, this result in apps running at full power for long time.
14311 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
14312 * be stuck in full power because of resume BMPS
14313 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053014314 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070014315
Nirav Shah20ac06f2013-12-12 18:14:06 +053014316 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
14317 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014318 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
14319 scanRequest.requestType, scanRequest.scanType,
14320 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053014321 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
14322
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053014323 if (pHddCtx->spoofMacAddr.isEnabled &&
14324 pHddCtx->cfg_ini->enableMacSpoofing == 1)
Siddharth Bhal76972212014-10-15 16:22:51 +053014325 {
14326 hddLog(VOS_TRACE_LEVEL_INFO,
14327 "%s: MAC Spoofing enabled for current scan", __func__);
14328 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
14329 * to fill TxBds for probe request during current scan
14330 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053014331 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053014332 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053014333
14334 if(status != VOS_STATUS_SUCCESS)
14335 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053014336 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053014337 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053014338#ifdef FEATURE_WLAN_TDLS
14339 wlan_hdd_tdls_scan_done_callback(pAdapter);
14340#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053014341 goto free_mem;
14342 }
Siddharth Bhal76972212014-10-15 16:22:51 +053014343 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053014344 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070014345 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070014346 pAdapter->sessionId, &scanRequest, &scanId,
14347 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070014348
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 if (eHAL_STATUS_SUCCESS != status)
14350 {
14351 hddLog(VOS_TRACE_LEVEL_ERROR,
14352 "%s: sme_ScanRequest returned error %d", __func__, status);
14353 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070014354 if(eHAL_STATUS_RESOURCES == status)
14355 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053014356 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
14357 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070014358 status = -EBUSY;
14359 } else {
14360 status = -EIO;
14361 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053014362 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053014363
14364#ifdef FEATURE_WLAN_TDLS
14365 wlan_hdd_tdls_scan_done_callback(pAdapter);
14366#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014367 goto free_mem;
14368 }
14369
14370 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053014371 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014372 pAdapter->request = request;
14373 pScanInfo->scanId = scanId;
14374
14375 complete(&pScanInfo->scan_req_completion_event);
14376
14377free_mem:
14378 if( scanRequest.SSIDs.SSIDList )
14379 {
14380 vos_mem_free(scanRequest.SSIDs.SSIDList);
14381 }
14382
14383 if( channelList )
14384 vos_mem_free( channelList );
14385
14386 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014387 return status;
14388}
14389
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014390int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
14391#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
14392 struct net_device *dev,
14393#endif
14394 struct cfg80211_scan_request *request)
14395{
14396 int ret;
14397
14398 vos_ssr_protect(__func__);
14399 ret = __wlan_hdd_cfg80211_scan(wiphy,
14400#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
14401 dev,
14402#endif
14403 request);
14404 vos_ssr_unprotect(__func__);
14405
14406 return ret;
14407}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014408
14409void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
14410{
14411 v_U8_t iniDot11Mode =
14412 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
14413 eHddDot11Mode hddDot11Mode = iniDot11Mode;
14414
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014415 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
14416 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014417 switch ( iniDot11Mode )
14418 {
14419 case eHDD_DOT11_MODE_AUTO:
14420 case eHDD_DOT11_MODE_11ac:
14421 case eHDD_DOT11_MODE_11ac_ONLY:
14422#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053014423 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
14424 sme_IsFeatureSupportedByFW(DOT11AC) )
14425 hddDot11Mode = eHDD_DOT11_MODE_11ac;
14426 else
14427 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014428#else
14429 hddDot11Mode = eHDD_DOT11_MODE_11n;
14430#endif
14431 break;
14432 case eHDD_DOT11_MODE_11n:
14433 case eHDD_DOT11_MODE_11n_ONLY:
14434 hddDot11Mode = eHDD_DOT11_MODE_11n;
14435 break;
14436 default:
14437 hddDot11Mode = iniDot11Mode;
14438 break;
14439 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053014440#ifdef WLAN_FEATURE_AP_HT40_24G
14441 if (operationChannel > SIR_11B_CHANNEL_END)
14442#endif
14443 {
14444 /* This call decides required channel bonding mode */
14445 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014446 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
14447 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053014448 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014449}
14450
Jeff Johnson295189b2012-06-20 16:38:30 -070014451/*
14452 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014453 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070014454 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014455int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053014456 const u8 *ssid, size_t ssid_len, const u8 *bssid,
14457 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070014458{
14459 int status = 0;
14460 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080014461 hdd_context_t *pHddCtx;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053014462 hdd_station_ctx_t *hdd_sta_ctx;
Jeff Johnson295189b2012-06-20 16:38:30 -070014463 v_U32_t roamId;
14464 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070014465 eCsrAuthType RSNAuthType;
14466
14467 ENTER();
14468
14469 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080014470 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053014471 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080014472
14473 status = wlan_hdd_validate_context(pHddCtx);
14474 if (status)
14475 {
Yue Mae36e3552014-03-05 17:06:20 -080014476 return status;
14477 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014478
Jeff Johnson295189b2012-06-20 16:38:30 -070014479 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
14480 {
14481 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
14482 return -EINVAL;
14483 }
14484
Nitesh Shah9b066282017-06-06 18:05:52 +053014485 wlan_hdd_tdls_disable_offchan_and_teardown_links(pHddCtx);
14486
Jeff Johnson295189b2012-06-20 16:38:30 -070014487 pRoamProfile = &pWextState->roamProfile;
14488
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014489 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070014490 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014491 hdd_station_ctx_t *pHddStaCtx;
14492 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Abhishek Singh6782c9e2017-06-06 13:37:45 +053014493 pHddStaCtx->get_mgmt_log_sent = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014494
Siddharth Bhalda0d1622015-04-24 15:47:49 +053014495 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
14496
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014497 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070014498 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
14499 {
14500 /*QoS not enabled in cfg file*/
14501 pRoamProfile->uapsd_mask = 0;
14502 }
14503 else
14504 {
14505 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014506 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070014507 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
14508 }
14509
14510 pRoamProfile->SSIDs.numOfSSIDs = 1;
14511 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
14512 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014513 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070014514 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
14515 ssid, ssid_len);
14516
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014517 vos_mem_zero(pRoamProfile->BSSIDs.bssid, WNI_CFG_BSSID_LEN);
14518 vos_mem_zero(pRoamProfile->bssid_hint, WNI_CFG_BSSID_LEN);
14519
Jeff Johnson295189b2012-06-20 16:38:30 -070014520 if (bssid)
14521 {
14522 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014523 vos_mem_copy(pRoamProfile->BSSIDs.bssid, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070014524 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014525 /* Save BSSID in seperate variable as well, as RoamProfile
14526 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070014527 case of join failure we should send valid BSSID to supplicant
14528 */
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014529 vos_mem_copy(pWextState->req_bssId, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070014530 WNI_CFG_BSSID_LEN);
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014531
Jeff Johnson295189b2012-06-20 16:38:30 -070014532 }
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014533 else if (bssid_hint)
Dhanashri Atre51981c62013-06-13 11:47:57 -070014534 {
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014535 /* Store bssid_hint to use in the scan filter. */
14536 vos_mem_copy(pRoamProfile->bssid_hint, bssid_hint,
14537 WNI_CFG_BSSID_LEN);
14538 /*
14539 * Save BSSID in seperate variable as well, as RoamProfile
14540 * BSSID is getting zeroed out in the association process. And in
14541 * case of join failure we should send valid BSSID to supplicant
14542 */
14543 vos_mem_copy(pWextState->req_bssId, bssid_hint,
14544 WNI_CFG_BSSID_LEN);
14545 hddLog(LOG1, FL(" bssid_hint: "MAC_ADDRESS_STR),
14546 MAC_ADDR_ARRAY(pRoamProfile->bssid_hint));
Dhanashri Atre51981c62013-06-13 11:47:57 -070014547 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014548
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014549
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014550 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
14551 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070014552 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
14553 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014554 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014555 /*set gen ie*/
14556 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
14557 /*set auth*/
14558 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
14559 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014560#ifdef FEATURE_WLAN_WAPI
14561 if (pAdapter->wapi_info.nWapiMode)
14562 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014563 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014564 switch (pAdapter->wapi_info.wapiAuthMode)
14565 {
14566 case WAPI_AUTH_MODE_PSK:
14567 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014568 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014569 pAdapter->wapi_info.wapiAuthMode);
14570 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
14571 break;
14572 }
14573 case WAPI_AUTH_MODE_CERT:
14574 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014575 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014576 pAdapter->wapi_info.wapiAuthMode);
14577 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
14578 break;
14579 }
14580 } // End of switch
14581 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
14582 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
14583 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014584 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 pRoamProfile->AuthType.numEntries = 1;
14586 pRoamProfile->EncryptionType.numEntries = 1;
14587 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
14588 pRoamProfile->mcEncryptionType.numEntries = 1;
14589 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
14590 }
14591 }
14592#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014593#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014594 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014595 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
14596 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
14597 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014598 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
14599 sizeof (tSirGtkOffloadParams));
14600 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014601 }
14602#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014603 pRoamProfile->csrPersona = pAdapter->device_mode;
14604
Jeff Johnson32d95a32012-09-10 13:15:23 -070014605 if( operatingChannel )
14606 {
14607 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
14608 pRoamProfile->ChannelInfo.numOfChannels = 1;
14609 }
Chet Lanctot186b5732013-03-18 10:26:30 -070014610 else
14611 {
14612 pRoamProfile->ChannelInfo.ChannelList = NULL;
14613 pRoamProfile->ChannelInfo.numOfChannels = 0;
14614 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014615 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
14616 {
14617 hdd_select_cbmode(pAdapter,operatingChannel);
14618 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014619
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014620 /*
14621 * Change conn_state to connecting before sme_RoamConnect(),
14622 * because sme_RoamConnect() has a direct path to call
14623 * hdd_smeRoamCallback(), which will change the conn_state
14624 * If direct path, conn_state will be accordingly changed
14625 * to NotConnected or Associated by either
14626 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
14627 * in sme_RoamCallback()
14628 * if sme_RomConnect is to be queued,
14629 * Connecting state will remain until it is completed.
14630 * If connection state is not changed,
14631 * connection state will remain in eConnectionState_NotConnected state.
14632 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
14633 * if conn state is eConnectionState_NotConnected.
14634 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
14635 * informed of connect result indication which is an issue.
14636 */
14637
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053014638 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
14639 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053014640 {
14641 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014642 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080014643 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
14644 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053014645 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014646 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070014647 pAdapter->sessionId, pRoamProfile, &roamId);
14648
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053014649 if ((eHAL_STATUS_SUCCESS != status) &&
14650 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
14651 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014652
14653 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014654 hddLog(VOS_TRACE_LEVEL_ERROR,
14655 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
14656 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080014657 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014658 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080014659 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014660 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080014661
14662 pRoamProfile->ChannelInfo.ChannelList = NULL;
14663 pRoamProfile->ChannelInfo.numOfChannels = 0;
14664
Jeff Johnson295189b2012-06-20 16:38:30 -070014665 }
14666 else
14667 {
14668 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
14669 return -EINVAL;
14670 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080014671 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014672 return status;
14673}
14674
14675/*
14676 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
14677 * This function is used to set the authentication type (OPEN/SHARED).
14678 *
14679 */
14680static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
14681 enum nl80211_auth_type auth_type)
14682{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014683 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014684 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14685
14686 ENTER();
14687
14688 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014689 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070014690 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014692 hddLog(VOS_TRACE_LEVEL_INFO,
14693 "%s: set authentication type to AUTOSWITCH", __func__);
14694 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
14695 break;
14696
14697 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014698#ifdef WLAN_FEATURE_VOWIFI_11R
14699 case NL80211_AUTHTYPE_FT:
14700#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014701 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014702 "%s: set authentication type to OPEN", __func__);
14703 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
14704 break;
14705
14706 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014707 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014708 "%s: set authentication type to SHARED", __func__);
14709 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
14710 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014711#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014712 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014713 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014714 "%s: set authentication type to CCKM WPA", __func__);
14715 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
14716 break;
14717#endif
14718
14719
14720 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014721 hddLog(VOS_TRACE_LEVEL_ERROR,
14722 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 auth_type);
14724 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
14725 return -EINVAL;
14726 }
14727
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014728 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014729 pHddStaCtx->conn_info.authType;
14730 return 0;
14731}
14732
14733/*
14734 * FUNCTION: wlan_hdd_set_akm_suite
14735 * This function is used to set the key mgmt type(PSK/8021x).
14736 *
14737 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014738static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014739 u32 key_mgmt
14740 )
14741{
14742 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14743 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053014744 /* Should be in ieee802_11_defs.h */
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053014745#ifndef WLAN_AKM_SUITE_8021X_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053014746#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053014747#endif
14748#ifndef WLAN_AKM_SUITE_PSK_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053014749#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053014750#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014751 /*set key mgmt type*/
14752 switch(key_mgmt)
14753 {
14754 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053014755 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014756#ifdef WLAN_FEATURE_VOWIFI_11R
14757 case WLAN_AKM_SUITE_FT_PSK:
14758#endif
14759 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070014760 __func__);
14761 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
14762 break;
14763
14764 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053014765 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014766#ifdef WLAN_FEATURE_VOWIFI_11R
14767 case WLAN_AKM_SUITE_FT_8021X:
14768#endif
14769 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070014770 __func__);
14771 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
14772 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014773#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014774#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
14775#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
14776 case WLAN_AKM_SUITE_CCKM:
14777 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
14778 __func__);
14779 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
14780 break;
14781#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070014782#ifndef WLAN_AKM_SUITE_OSEN
14783#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
14784 case WLAN_AKM_SUITE_OSEN:
14785 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
14786 __func__);
14787 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
14788 break;
14789#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014790
14791 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014792 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014793 __func__, key_mgmt);
14794 return -EINVAL;
14795
14796 }
14797 return 0;
14798}
14799
14800/*
14801 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014802 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070014803 * (NONE/WEP40/WEP104/TKIP/CCMP).
14804 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014805static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
14806 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070014807 bool ucast
14808 )
14809{
14810 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014811 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014812 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14813
14814 ENTER();
14815
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014816 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070014817 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053014818 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070014819 __func__, cipher);
14820 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14821 }
14822 else
14823 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014824
Jeff Johnson295189b2012-06-20 16:38:30 -070014825 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014826 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070014827 {
14828 case IW_AUTH_CIPHER_NONE:
14829 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14830 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014831
Jeff Johnson295189b2012-06-20 16:38:30 -070014832 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014833 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014835
Jeff Johnson295189b2012-06-20 16:38:30 -070014836 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014837 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070014838 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014839
Jeff Johnson295189b2012-06-20 16:38:30 -070014840 case WLAN_CIPHER_SUITE_TKIP:
14841 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
14842 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014843
Jeff Johnson295189b2012-06-20 16:38:30 -070014844 case WLAN_CIPHER_SUITE_CCMP:
14845 encryptionType = eCSR_ENCRYPT_TYPE_AES;
14846 break;
14847#ifdef FEATURE_WLAN_WAPI
14848 case WLAN_CIPHER_SUITE_SMS4:
14849 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
14850 break;
14851#endif
14852
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014853#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014854 case WLAN_CIPHER_SUITE_KRK:
14855 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
14856 break;
14857#endif
14858 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014859 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014860 __func__, cipher);
14861 return -EOPNOTSUPP;
14862 }
14863 }
14864
14865 if (ucast)
14866 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014867 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 __func__, encryptionType);
14869 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
14870 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014871 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014872 encryptionType;
14873 }
14874 else
14875 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014876 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014877 __func__, encryptionType);
14878 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
14879 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
14880 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
14881 }
14882
14883 return 0;
14884}
14885
14886
14887/*
14888 * FUNCTION: wlan_hdd_cfg80211_set_ie
14889 * This function is used to parse WPA/RSN IE's.
14890 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014891int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014892#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14893 const u8 *ie,
14894#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014895 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014896#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014897 size_t ie_len
14898 )
14899{
14900 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014901#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14902 const u8 *genie = ie;
14903#else
Jeff Johnson295189b2012-06-20 16:38:30 -070014904 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014905#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014906 v_U16_t remLen = ie_len;
14907#ifdef FEATURE_WLAN_WAPI
14908 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
14909 u16 *tmp;
14910 v_U16_t akmsuiteCount;
14911 int *akmlist;
14912#endif
14913 ENTER();
14914
14915 /* clear previous assocAddIE */
14916 pWextState->assocAddIE.length = 0;
14917 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014918 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014919
14920 while (remLen >= 2)
14921 {
14922 v_U16_t eLen = 0;
14923 v_U8_t elementId;
14924 elementId = *genie++;
14925 eLen = *genie++;
14926 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014927
Nachiket Kukade4aba5f02017-06-09 15:43:48 +053014928 /* Sanity check on eLen */
14929 if (eLen > remLen) {
14930 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid IE length[%d] for IE[0x%X]",
14931 __func__, eLen, elementId);
14932 VOS_ASSERT(0);
14933 return -EINVAL;
14934 }
14935
Arif Hussain6d2a3322013-11-17 19:50:10 -080014936 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014938
14939 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070014940 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014941 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014942 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 -070014943 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014944 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014945 "%s: Invalid WPA IE", __func__);
14946 return -EINVAL;
14947 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014948 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 {
14950 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014951 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014952 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014953
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014954 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014955 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014956 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
14957 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014958 VOS_ASSERT(0);
14959 return -ENOMEM;
14960 }
14961 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14962 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14963 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014964
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
14966 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14967 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14968 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014969 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
14970 {
Nachiket Kukade3d72b7e2017-06-09 16:58:24 +053014971 if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) {
14972 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid WPA RSN IE length[%d]",
14973 __func__, eLen);
14974 VOS_ASSERT(0);
14975 return -EINVAL;
14976 }
14977
Jeff Johnson295189b2012-06-20 16:38:30 -070014978 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
14979 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14980 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
14981 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
14982 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
14983 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014984 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053014985 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070014986 {
14987 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014988 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014989 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014990
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014991 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014992 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014993 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14994 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014995 VOS_ASSERT(0);
14996 return -ENOMEM;
14997 }
14998 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14999 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
15000 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015001
Jeff Johnson295189b2012-06-20 16:38:30 -070015002 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
15003 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
15004 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015005#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015006 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
15007 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015008 /*Consider WFD IE, only for P2P Client */
15009 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
15010 {
15011 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015012 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015014
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015015 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 {
Jeff Johnson902c9832012-12-10 14:28:09 -080015017 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
15018 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070015019 VOS_ASSERT(0);
15020 return -ENOMEM;
15021 }
15022 // WFD IE is saved to Additional IE ; it should be accumulated to handle
15023 // WPS IE + P2P IE + WFD IE
15024 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
15025 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015026
Jeff Johnson295189b2012-06-20 16:38:30 -070015027 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
15028 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
15029 }
15030#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015031 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015032 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070015033 HS20_OUI_TYPE_SIZE)) )
15034 {
15035 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015036 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070015037 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015038
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015039 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070015040 {
Jeff Johnson902c9832012-12-10 14:28:09 -080015041 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
15042 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070015043 VOS_ASSERT(0);
15044 return -ENOMEM;
15045 }
15046 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
15047 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015048
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070015049 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
15050 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
15051 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070015052 /* Appending OSEN Information Element in Assiciation Request */
15053 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
15054 OSEN_OUI_TYPE_SIZE)) )
15055 {
15056 v_U16_t curAddIELen = pWextState->assocAddIE.length;
15057 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
15058 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015059
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015060 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070015061 {
15062 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
15063 "Need bigger buffer space");
15064 VOS_ASSERT(0);
15065 return -ENOMEM;
15066 }
15067 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
15068 pWextState->assocAddIE.length += eLen + 2;
15069
15070 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
15071 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
15072 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
15073 }
15074
Abhishek Singh4322e622015-06-10 15:42:54 +053015075 /* Update only for WPA IE */
15076 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
15077 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070015078
15079 /* populating as ADDIE in beacon frames */
15080 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015081 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070015082 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
15083 {
15084 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
15085 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
15086 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
15087 {
15088 hddLog(LOGE,
15089 "Coldn't pass "
15090 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
15091 }
15092 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
15093 else
15094 hddLog(LOGE,
15095 "Could not pass on "
15096 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
15097
15098 /* IBSS mode doesn't contain params->proberesp_ies still
15099 beaconIE's need to be populated in probe response frames */
15100 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
15101 {
15102 u16 rem_probe_resp_ie_len = eLen + 2;
15103 u8 probe_rsp_ie_len[3] = {0};
15104 u8 counter = 0;
15105
15106 /* Check Probe Resp Length if it is greater then 255 then
15107 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
15108 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
15109 not able Store More then 255 bytes into One Variable */
15110
15111 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
15112 {
15113 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
15114 {
15115 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
15116 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
15117 }
15118 else
15119 {
15120 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
15121 rem_probe_resp_ie_len = 0;
15122 }
15123 }
15124
15125 rem_probe_resp_ie_len = 0;
15126
15127 if (probe_rsp_ie_len[0] > 0)
15128 {
15129 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
15130 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
15131 (tANI_U8*)(genie - 2),
15132 probe_rsp_ie_len[0], NULL,
15133 eANI_BOOLEAN_FALSE)
15134 == eHAL_STATUS_FAILURE)
15135 {
15136 hddLog(LOGE,
15137 "Could not pass"
15138 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
15139 }
15140 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
15141 }
15142
15143 if (probe_rsp_ie_len[1] > 0)
15144 {
15145 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
15146 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
15147 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
15148 probe_rsp_ie_len[1], NULL,
15149 eANI_BOOLEAN_FALSE)
15150 == eHAL_STATUS_FAILURE)
15151 {
15152 hddLog(LOGE,
15153 "Could not pass"
15154 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
15155 }
15156 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
15157 }
15158
15159 if (probe_rsp_ie_len[2] > 0)
15160 {
15161 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
15162 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
15163 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
15164 probe_rsp_ie_len[2], NULL,
15165 eANI_BOOLEAN_FALSE)
15166 == eHAL_STATUS_FAILURE)
15167 {
15168 hddLog(LOGE,
15169 "Could not pass"
15170 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
15171 }
15172 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
15173 }
15174
15175 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
15176 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
15177 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
15178 {
15179 hddLog(LOGE,
15180 "Could not pass"
15181 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
15182 }
15183 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070015184 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070015185 break;
15186 case DOT11F_EID_RSN:
15187 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
15188 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
15189 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
15190 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
15191 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
15192 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053015193
Abhishek Singhb16f3562016-01-20 11:08:32 +053015194 /* Appending extended capabilities with Interworking or
15195 * bsstransition bit set in Assoc Req.
Abhishek Singh15d95602015-03-24 15:52:57 +053015196 *
15197 * In assoc req this EXT Cap will only be taken into account if
Abhishek Singhb16f3562016-01-20 11:08:32 +053015198 * interworkingService or bsstransition bit is set to 1.
15199 * Driver is only interested in interworkingService and
15200 * bsstransition capability from supplicant.
15201 * If in future any other EXT Cap info is
Abhishek Singh15d95602015-03-24 15:52:57 +053015202 * required from supplicat, it needs to be handled while
15203 * sending Assoc Req in LIM.
15204 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015205 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015206 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015207 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015208 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015209 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015210
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015211 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015212 {
Jeff Johnson902c9832012-12-10 14:28:09 -080015213 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
15214 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015215 VOS_ASSERT(0);
15216 return -ENOMEM;
15217 }
15218 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
15219 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015220
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015221 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
15222 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
15223 break;
15224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015225#ifdef FEATURE_WLAN_WAPI
15226 case WLAN_EID_WAPI:
15227 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015228 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070015229 pAdapter->wapi_info.nWapiMode);
15230 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015231 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070015232 akmsuiteCount = WPA_GET_LE16(tmp);
15233 tmp = tmp + 1;
15234 akmlist = (int *)(tmp);
15235 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
15236 {
15237 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
15238 }
15239 else
15240 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015241 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070015242 VOS_ASSERT(0);
15243 return -EINVAL;
15244 }
15245
15246 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
15247 {
15248 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070015249 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015250 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015251 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015252 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015253 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015254 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070015255 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015256 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
15257 }
15258 break;
15259#endif
15260 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015261 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015262 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015263 /* when Unknown IE is received we should break and continue
15264 * to the next IE in the buffer instead we were returning
15265 * so changing this to break */
15266 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015267 }
15268 genie += eLen;
15269 remLen -= eLen;
15270 }
15271 EXIT();
15272 return 0;
15273}
15274
15275/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053015276 * FUNCTION: hdd_isWPAIEPresent
15277 * Parse the received IE to find the WPA IE
15278 *
15279 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015280static bool hdd_isWPAIEPresent(
15281#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
15282 const u8 *ie,
15283#else
15284 u8 *ie,
15285#endif
15286 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053015287{
15288 v_U8_t eLen = 0;
15289 v_U16_t remLen = ie_len;
15290 v_U8_t elementId = 0;
15291
15292 while (remLen >= 2)
15293 {
15294 elementId = *ie++;
15295 eLen = *ie++;
15296 remLen -= 2;
15297 if (eLen > remLen)
15298 {
15299 hddLog(VOS_TRACE_LEVEL_ERROR,
15300 "%s: IE length is wrong %d", __func__, eLen);
15301 return FALSE;
15302 }
15303 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
15304 {
15305 /* OUI - 0x00 0X50 0XF2
15306 WPA Information Element - 0x01
15307 WPA version - 0x01*/
15308 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
15309 return TRUE;
15310 }
15311 ie += eLen;
15312 remLen -= eLen;
15313 }
15314 return FALSE;
15315}
15316
15317/*
Jeff Johnson295189b2012-06-20 16:38:30 -070015318 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015319 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070015320 * parameters during connect operation.
15321 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015322int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070015323 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015324 )
Jeff Johnson295189b2012-06-20 16:38:30 -070015325{
15326 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015327 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070015328 ENTER();
15329
15330 /*set wpa version*/
15331 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
15332
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015333 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070015334 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053015335 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070015336 {
15337 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
15338 }
15339 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
15340 {
15341 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
15342 }
15343 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015344
15345 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015346 pWextState->wpaVersion);
15347
15348 /*set authentication type*/
15349 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
15350
15351 if (0 > status)
15352 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015353 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015354 "%s: failed to set authentication type ", __func__);
15355 return status;
15356 }
15357
15358 /*set key mgmt type*/
15359 if (req->crypto.n_akm_suites)
15360 {
15361 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
15362 if (0 > status)
15363 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015364 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070015365 __func__);
15366 return status;
15367 }
15368 }
15369
15370 /*set pairwise cipher type*/
15371 if (req->crypto.n_ciphers_pairwise)
15372 {
15373 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
15374 req->crypto.ciphers_pairwise[0], true);
15375 if (0 > status)
15376 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015377 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015378 "%s: failed to set unicast cipher type", __func__);
15379 return status;
15380 }
15381 }
15382 else
15383 {
15384 /*Reset previous cipher suite to none*/
15385 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
15386 if (0 > status)
15387 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015388 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015389 "%s: failed to set unicast cipher type", __func__);
15390 return status;
15391 }
15392 }
15393
15394 /*set group cipher type*/
15395 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
15396 false);
15397
15398 if (0 > status)
15399 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015400 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070015401 __func__);
15402 return status;
15403 }
15404
Chet Lanctot186b5732013-03-18 10:26:30 -070015405#ifdef WLAN_FEATURE_11W
15406 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
15407#endif
15408
Jeff Johnson295189b2012-06-20 16:38:30 -070015409 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
15410 if (req->ie_len)
15411 {
15412 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
15413 if ( 0 > status)
15414 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015415 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070015416 __func__);
15417 return status;
15418 }
15419 }
15420
15421 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015422 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070015423 {
15424 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
15425 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
15426 )
15427 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015428 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070015429 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
15430 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015431 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070015432 __func__);
15433 return -EOPNOTSUPP;
15434 }
15435 else
15436 {
15437 u8 key_len = req->key_len;
15438 u8 key_idx = req->key_idx;
15439
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015440 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070015441 && (CSR_MAX_NUM_KEY > key_idx)
15442 )
15443 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015444 hddLog(VOS_TRACE_LEVEL_INFO,
15445 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015446 __func__, key_idx, key_len);
15447 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015448 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070015449 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015450 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070015451 (u8)key_len;
15452 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
15453 }
15454 }
15455 }
15456 }
15457
15458 return status;
15459}
15460
15461/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015462 * FUNCTION: wlan_hdd_try_disconnect
15463 * This function is used to disconnect from previous
15464 * connection
15465 */
Agrawal Ashishc407f192017-01-23 17:18:35 +053015466int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015467{
15468 long ret = 0;
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015469 int status, result = 0;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015470 hdd_station_ctx_t *pHddStaCtx;
15471 eMib_dot11DesiredBssType connectedBssType;
Abhishek Singh19a7dd92015-12-30 16:31:51 +053015472 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015473
Abhishek Singh19a7dd92015-12-30 16:31:51 +053015474 ret = wlan_hdd_validate_context(pHddCtx);
15475 if (0 != ret)
15476 {
15477 return ret;
15478 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015479 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15480
15481 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
15482
15483 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
15484 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
Abhishek Singh630ff592016-01-07 18:15:53 +053015485 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) ||
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015486 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
15487 {
Abhishek Singh9f4df782017-03-15 17:29:10 +053015488 /* Indicate disconnect to SME so that in-progress connection or preauth
15489 * can be aborted
15490 */
15491 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
15492 pAdapter->sessionId);
Abhishek Singh19a7dd92015-12-30 16:31:51 +053015493 spin_lock_bh(&pAdapter->lock_for_active_session);
15494 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
15495 {
15496 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
15497 }
15498 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singhf7962582015-10-23 10:54:06 +053015499 hdd_connSetConnectionState(pHddStaCtx,
15500 eConnectionState_Disconnecting);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015501 /* Issue disconnect to CSR */
15502 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015503 status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015504 pAdapter->sessionId,
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015505 eCSR_DISCONNECT_REASON_UNSPECIFIED);
15506 if(eHAL_STATUS_CMD_NOT_QUEUED == status) {
15507 hddLog(LOG1,
15508 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
15509 } else if ( 0 != status ) {
15510 hddLog(LOGE,
15511 FL("csrRoamDisconnect failure, returned %d"),
15512 (int)status );
15513 result = -EINVAL;
15514 goto disconnected;
15515 }
15516 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015517 &pAdapter->disconnect_comp_var,
15518 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015519 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status)) {
15520 hddLog(LOGE,
15521 "%s: Failed to disconnect, timed out", __func__);
15522 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015523 }
15524 }
15525 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
15526 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015527 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015528 &pAdapter->disconnect_comp_var,
15529 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015530 if (!ret)
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015531 {
15532 hddLog(LOGE, FL("Failed to receive disconnect event"));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015533 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015534 }
15535 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015536disconnected:
15537 hddLog(LOG1,
15538 FL("Set HDD connState to eConnectionState_NotConnected"));
15539 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
15540 return result;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015541}
15542
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053015543/**
15544 * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present
15545 * @adapter: Pointer to the HDD adapter
15546 * @req: Pointer to the structure cfg_connect_params receieved from user space
15547 *
15548 * This function will start reassociation if bssid hint, channel hint and
15549 * previous bssid parameters are present in the connect request
15550 *
15551 * Return: success if reassociation is happening
15552 * Error code if reassociation is not permitted or not happening
15553 */
15554#ifdef CFG80211_CONNECT_PREV_BSSID
15555static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
15556 struct cfg80211_connect_params *req)
15557{
15558 int status = -EPERM;
15559 if (req->bssid_hint && req->channel_hint && req->prev_bssid) {
15560 hddLog(VOS_TRACE_LEVEL_INFO,
15561 FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR),
15562 req->channel_hint->hw_value,
15563 MAC_ADDR_ARRAY(req->bssid_hint));
15564 status = hdd_reassoc(adapter, req->bssid_hint,
15565 req->channel_hint->hw_value,
15566 CONNECT_CMD_USERSPACE);
15567 }
15568 return status;
15569}
15570#else
15571static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
15572 struct cfg80211_connect_params *req)
15573{
15574 return -EPERM;
15575}
15576#endif
15577
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015578/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053015579 * FUNCTION: __wlan_hdd_cfg80211_connect
15580 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070015581 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015582static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015583 struct net_device *ndev,
15584 struct cfg80211_connect_params *req
15585 )
15586{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015587 int status;
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015588 u16 channel;
Edhar, Mahesh Kumar496c7f72016-03-18 12:47:44 +053015589#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
15590 defined(CFG80211_BSSID_HINT_BACKPORT)
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015591 const u8 *bssid_hint = req->bssid_hint;
15592#else
15593 const u8 *bssid_hint = NULL;
15594#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015595 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070015596 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053015597 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015598
15599 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015600
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015601 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15602 TRACE_CODE_HDD_CFG80211_CONNECT,
15603 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015604 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015605 "%s: device_mode = %s (%d)", __func__,
15606 hdd_device_modetoString(pAdapter->device_mode),
15607 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015608
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015609 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080015610 if (!pHddCtx)
15611 {
15612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15613 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053015614 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080015615 }
15616
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015617 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015618 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015619 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015620 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015621 }
15622
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053015623 status = wlan_hdd_reassoc_bssid_hint(pAdapter, req);
15624 if (0 == status)
15625 return status;
15626
Agarwal Ashish51325b52014-06-16 16:50:49 +053015627
Jeff Johnson295189b2012-06-20 16:38:30 -070015628#ifdef WLAN_BTAMP_FEATURE
15629 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015630 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070015631 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015632 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015633 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080015634 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070015635 }
15636#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015637
15638 //If Device Mode is Station Concurrent Sessions Exit BMps
15639 //P2P Mode will be taken care in Open/close adapter
15640 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053015641 (vos_concurrent_open_sessions_running())) {
15642 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
15643 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015644 }
15645
15646 /*Try disconnecting if already in connected state*/
15647 status = wlan_hdd_try_disconnect(pAdapter);
15648 if ( 0 > status)
15649 {
15650 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
15651 " connection"));
15652 return -EALREADY;
15653 }
Agrawal Ashish559530c2015-12-01 18:04:20 +053015654 /* Check for max concurrent connections after doing disconnect if any*/
15655 if (vos_max_concurrent_connections_reached()) {
15656 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15657 return -ECONNREFUSED;
15658 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015659
Jeff Johnson295189b2012-06-20 16:38:30 -070015660 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015661 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070015662
15663 if ( 0 > status)
15664 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015665 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070015666 __func__);
15667 return status;
15668 }
Sravan Kumar Kairam589c5722016-01-27 20:28:53 +053015669
15670 if (pHddCtx->spoofMacAddr.isEnabled)
15671 {
15672 hddLog(VOS_TRACE_LEVEL_INFO,
15673 "%s: MAC Spoofing enabled ", __func__);
15674 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
15675 * to fill TxBds for probe request during SSID scan which may happen
15676 * as part of connect command
15677 */
15678 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
15679 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
15680 if (status != VOS_STATUS_SUCCESS)
15681 return -ECONNREFUSED;
15682 }
15683
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015684 if (req->channel)
15685 channel = req->channel->hw_value;
Mohit Khanna765234a2012-09-11 15:08:35 -070015686 else
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015687 channel = 0;
Kapil Gupta312028a2016-10-25 14:15:20 +053015688
15689 /* Abort if any scan is going on */
15690 status = wlan_hdd_scan_abort(pAdapter);
15691 if (0 != status)
15692 hddLog(VOS_TRACE_LEVEL_ERROR, FL("scan abort failed"));
15693
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015694 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
15695 req->ssid_len, req->bssid,
15696 bssid_hint, channel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015697
Sushant Kaushikd7083982015-03-18 14:33:24 +053015698 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015699 {
15700 //ReEnable BMPS if disabled
15701 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
15702 (NULL != pHddCtx))
15703 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053015704 if (pHddCtx->hdd_wlan_suspended)
15705 {
15706 hdd_set_pwrparams(pHddCtx);
15707 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015708 //ReEnable Bmps and Imps back
15709 hdd_enable_bmps_imps(pHddCtx);
15710 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053015711 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015712 return status;
15713 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015714 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015715 EXIT();
15716 return status;
15717}
15718
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015719static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
15720 struct net_device *ndev,
15721 struct cfg80211_connect_params *req)
15722{
15723 int ret;
15724 vos_ssr_protect(__func__);
15725 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
15726 vos_ssr_unprotect(__func__);
15727
15728 return ret;
15729}
Jeff Johnson295189b2012-06-20 16:38:30 -070015730
15731/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015732 * FUNCTION: wlan_hdd_disconnect
15733 * This function is used to issue a disconnect request to SME
15734 */
15735int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
15736{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015737 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015738 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015739 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015740 long ret;
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015741 eConnectionState prev_conn_state;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015742
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015743 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015744
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015745 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015746 if (0 != status)
15747 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015748 return status;
15749 }
Abhishek Singh07e4a892015-11-23 11:29:57 +053015750 /* Indicate sme of disconnect so that in progress connection or preauth
15751 * can be aborted
15752 */
15753 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
Sushant Kaushikb4834d22015-07-15 15:29:05 +053015754 pAdapter->sessionId);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015755 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015756
Agarwal Ashish47d18112014-08-04 19:55:07 +053015757 /* Need to apply spin lock before decreasing active sessions
15758 * as there can be chance for double decrement if context switch
15759 * Calls hdd_DisConnectHandler.
15760 */
15761
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015762 prev_conn_state = pHddStaCtx->conn_info.connState;
15763
Agarwal Ashish47d18112014-08-04 19:55:07 +053015764 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015765 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
15766 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015767 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
15768 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053015769 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
15770 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015771
Abhishek Singhf4669da2014-05-26 15:07:49 +053015772 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053015773 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
15774
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015775 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015776
Mihir Shete182a0b22014-08-18 16:08:48 +053015777 /*
15778 * stop tx queues before deleting STA/BSS context from the firmware.
15779 * tx has to be disabled because the firmware can get busy dropping
15780 * the tx frames after BSS/STA has been deleted and will not send
15781 * back a response resulting in WDI timeout
15782 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053015783 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053015784 netif_tx_disable(pAdapter->dev);
15785 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053015786
Mihir Shete182a0b22014-08-18 16:08:48 +053015787 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015788 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
15789 pAdapter->sessionId, reason);
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015790 if((eHAL_STATUS_CMD_NOT_QUEUED == status) &&
15791 prev_conn_state != eConnectionState_Connecting)
15792 {
15793 hddLog(LOG1,
15794 FL("status = %d, already disconnected"), status);
15795 result = 0;
15796 goto disconnected;
15797 }
15798 /*
15799 * Wait here instead of returning directly, this will block the next
15800 * connect command and allow processing of the scan for ssid and
15801 * the previous connect command in CSR. Else we might hit some
15802 * race conditions leading to SME and HDD out of sync.
15803 */
15804 else if(eHAL_STATUS_CMD_NOT_QUEUED == status)
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015805 {
15806 hddLog(LOG1,
15807 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015808 }
15809 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015810 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015811 hddLog(LOGE,
15812 FL("csrRoamDisconnect failure, returned %d"),
15813 (int)status);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015814 result = -EINVAL;
15815 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015816 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015817 ret = wait_for_completion_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015818 &pAdapter->disconnect_comp_var,
15819 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015820 if (!ret && (eHAL_STATUS_CMD_NOT_QUEUED != status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015821 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015822 hddLog(LOGE,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053015823 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015824 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053015825 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015826disconnected:
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015827 hddLog(LOG1,
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015828 FL("Set HDD connState to eConnectionState_NotConnected"));
15829 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053015830#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
15831 /* Sending disconnect event to userspace for kernel version < 3.11
15832 * is handled by __cfg80211_disconnect call to __cfg80211_disconnected
15833 */
15834 hddLog(LOG1, FL("Send disconnected event to userspace"));
15835
Mahesh A Saptasagarf5859b12016-06-01 17:17:50 +053015836 wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true,
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053015837 WLAN_REASON_UNSPECIFIED);
15838#endif
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015839
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015840 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015841 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015842}
15843
15844
15845/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015846 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070015847 * This function is used to issue a disconnect request to SME
15848 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015849static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015850 struct net_device *dev,
15851 u16 reason
15852 )
15853{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015854 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015855 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015856 tCsrRoamProfile *pRoamProfile;
15857 hdd_station_ctx_t *pHddStaCtx;
15858 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015859#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015860 tANI_U8 staIdx;
15861#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015862
Jeff Johnson295189b2012-06-20 16:38:30 -070015863 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015864
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015865 if (!pAdapter) {
15866 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15867 return -EINVAL;
15868 }
15869
15870 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15871 if (!pHddStaCtx) {
15872 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
15873 return -EINVAL;
15874 }
15875
15876 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15877 status = wlan_hdd_validate_context(pHddCtx);
15878 if (0 != status)
15879 {
15880 return status;
15881 }
15882
15883 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
15884
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015885 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15886 TRACE_CODE_HDD_CFG80211_DISCONNECT,
15887 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015888 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
15889 __func__, hdd_device_modetoString(pAdapter->device_mode),
15890 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015891
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015892 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
15893 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070015894
Jeff Johnson295189b2012-06-20 16:38:30 -070015895 if (NULL != pRoamProfile)
15896 {
15897 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015898 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
15899 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070015900 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015901 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070015902 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015903 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070015904 switch(reason)
15905 {
15906 case WLAN_REASON_MIC_FAILURE:
15907 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
15908 break;
15909
15910 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
15911 case WLAN_REASON_DISASSOC_AP_BUSY:
15912 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
15913 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
15914 break;
15915
15916 case WLAN_REASON_PREV_AUTH_NOT_VALID:
15917 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053015918 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070015919 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
15920 break;
15921
Jeff Johnson295189b2012-06-20 16:38:30 -070015922 default:
15923 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
15924 break;
15925 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015926 pScanInfo = &pHddCtx->scan_info;
15927 if (pScanInfo->mScanPending)
15928 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015929 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015930 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053015931 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015932 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015933 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053015934 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015935#ifdef FEATURE_WLAN_TDLS
15936 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015937 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015938 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015939 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
15940 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015941 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015942 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015943 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015945 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015946 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015947 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015948 status = sme_DeleteTdlsPeerSta(
15949 WLAN_HDD_GET_HAL_CTX(pAdapter),
15950 pAdapter->sessionId,
15951 mac);
15952 if (status != eHAL_STATUS_SUCCESS) {
15953 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15954 return -EPERM;
15955 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015956 }
15957 }
15958#endif
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015959
15960 hddLog(LOG1, FL("Disconnecting with reasoncode:%u connState %d"),
15961 reasonCode,
15962 pHddStaCtx->conn_info.connState);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015963 status = wlan_hdd_disconnect(pAdapter, reasonCode);
15964 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070015965 {
15966 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015967 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015968 __func__, (int)status );
15969 return -EINVAL;
15970 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015971 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015972 else
15973 {
15974 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
15975 "called while in %d state", __func__,
15976 pHddStaCtx->conn_info.connState);
15977 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015978 }
15979 else
15980 {
15981 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
15982 }
15983
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015984 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015985 return status;
15986}
15987
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015988static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
15989 struct net_device *dev,
15990 u16 reason
15991 )
15992{
15993 int ret;
15994 vos_ssr_protect(__func__);
15995 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
15996 vos_ssr_unprotect(__func__);
15997
15998 return ret;
15999}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053016000
Jeff Johnson295189b2012-06-20 16:38:30 -070016001/*
16002 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016003 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070016004 * settings in IBSS mode.
16005 */
16006static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016007 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070016008 struct cfg80211_ibss_params *params
16009 )
16010{
16011 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016012 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016013 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
16014 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016015
Jeff Johnson295189b2012-06-20 16:38:30 -070016016 ENTER();
16017
16018 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070016019 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070016020
16021 if (params->ie_len && ( NULL != params->ie) )
16022 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070016023 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
16024 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070016025 {
16026 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
16027 encryptionType = eCSR_ENCRYPT_TYPE_AES;
16028 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070016029 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070016030 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070016031 tDot11fIEWPA dot11WPAIE;
16032 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070016033 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070016034
Wilson Yang00256342013-10-10 23:13:38 -070016035 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070016036 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
16037 params->ie_len, DOT11F_EID_WPA);
16038 if ( NULL != ie )
16039 {
16040 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
16041 // Unpack the WPA IE
16042 //Skip past the EID byte and length byte - and four byte WiFi OUI
16043 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
16044 &ie[2+4],
16045 ie[1] - 4,
16046 &dot11WPAIE);
16047 /*Extract the multicast cipher, the encType for unicast
16048 cipher for wpa-none is none*/
16049 encryptionType =
16050 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
16051 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016052 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070016053
Jeff Johnson295189b2012-06-20 16:38:30 -070016054 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
16055
16056 if (0 > status)
16057 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016058 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070016059 __func__);
16060 return status;
16061 }
16062 }
16063
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016064 pWextState->roamProfile.AuthType.authType[0] =
16065 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070016066 eCSR_AUTH_TYPE_OPEN_SYSTEM;
16067
16068 if (params->privacy)
16069 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016070 /* Security enabled IBSS, At this time there is no information available
16071 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070016072 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016073 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070016074 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016075 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070016076 *enable privacy bit in beacons */
16077
16078 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
16079 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070016080 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
16081 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070016082 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
16083 pWextState->roamProfile.EncryptionType.numEntries = 1;
16084 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070016085 return status;
16086}
16087
16088/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016089 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016090 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070016091 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016092static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070016093 struct net_device *dev,
16094 struct cfg80211_ibss_params *params
16095 )
16096{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016097 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070016098 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
16099 tCsrRoamProfile *pRoamProfile;
16100 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016101 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16102 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016103 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070016104
16105 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016106
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016107 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16108 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
16109 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016110 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016111 "%s: device_mode = %s (%d)", __func__,
16112 hdd_device_modetoString(pAdapter->device_mode),
16113 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070016114
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016115 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016116 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070016117 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016118 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016119 }
16120
16121 if (NULL == pWextState)
16122 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016123 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070016124 __func__);
16125 return -EIO;
16126 }
16127
Agarwal Ashish51325b52014-06-16 16:50:49 +053016128 if (vos_max_concurrent_connections_reached()) {
16129 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
16130 return -ECONNREFUSED;
16131 }
16132
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016133 /*Try disconnecting if already in connected state*/
16134 status = wlan_hdd_try_disconnect(pAdapter);
16135 if ( 0 > status)
16136 {
16137 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
16138 " IBSS connection"));
16139 return -EALREADY;
16140 }
16141
Jeff Johnson295189b2012-06-20 16:38:30 -070016142 pRoamProfile = &pWextState->roamProfile;
16143
16144 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
16145 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016146 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080016147 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016148 return -EINVAL;
16149 }
16150
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070016151 /* BSSID is provided by upper layers hence no need to AUTO generate */
16152 if (NULL != params->bssid) {
16153 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
16154 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
16155 hddLog (VOS_TRACE_LEVEL_ERROR,
16156 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
16157 return -EIO;
16158 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016159 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070016160 }
krunal sonie9002db2013-11-25 14:24:17 -080016161 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
16162 {
16163 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
16164 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
16165 {
16166 hddLog (VOS_TRACE_LEVEL_ERROR,
16167 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
16168 return -EIO;
16169 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016170
16171 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080016172 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016173 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080016174 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070016175
Jeff Johnson295189b2012-06-20 16:38:30 -070016176 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070016177 if (NULL !=
16178#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
16179 params->chandef.chan)
16180#else
16181 params->channel)
16182#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016183 {
16184 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016185 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
16186 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
16187 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16188 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070016189
16190 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016191 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070016192 ieee80211_frequency_to_channel(
16193#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
16194 params->chandef.chan->center_freq);
16195#else
16196 params->channel->center_freq);
16197#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016198
16199 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
16200 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070016201 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016202 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
16203 __func__);
16204 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070016205 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016206
16207 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016208 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016209 if (channelNum == validChan[indx])
16210 {
16211 break;
16212 }
16213 }
16214 if (indx >= numChans)
16215 {
16216 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016217 __func__, channelNum);
16218 return -EINVAL;
16219 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016220 /* Set the Operational Channel */
16221 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
16222 channelNum);
16223 pRoamProfile->ChannelInfo.numOfChannels = 1;
16224 pHddStaCtx->conn_info.operationChannel = channelNum;
16225 pRoamProfile->ChannelInfo.ChannelList =
16226 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070016227 }
16228
16229 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016230 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070016231 if (status < 0)
16232 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016233 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070016234 __func__);
16235 return status;
16236 }
16237
16238 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016239 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Abhishek Singh4d924682015-11-17 15:23:06 +053016240 params->ssid_len, (const u8 *)&bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016241 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070016242
16243 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070016244 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016245
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016246 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016247 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016248}
16249
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016250static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
16251 struct net_device *dev,
16252 struct cfg80211_ibss_params *params
16253 )
16254{
16255 int ret = 0;
16256
16257 vos_ssr_protect(__func__);
16258 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
16259 vos_ssr_unprotect(__func__);
16260
16261 return ret;
16262}
16263
Jeff Johnson295189b2012-06-20 16:38:30 -070016264/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016265 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016266 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070016267 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016268static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070016269 struct net_device *dev
16270 )
16271{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016272 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016273 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
16274 tCsrRoamProfile *pRoamProfile;
16275 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016276 int status;
Abhishek Singh69de3302016-11-11 16:44:32 +053016277 eHalStatus hal_status;
Abhishek Singh7cd040e2016-01-07 10:51:04 +053016278#ifdef WLAN_FEATURE_RMC
16279 tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN] = {0};
16280#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016281
16282 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016283
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016284 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16285 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
16286 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016287 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016288 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016289 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016290 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016291 }
16292
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016293 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
16294 hdd_device_modetoString(pAdapter->device_mode),
16295 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070016296 if (NULL == pWextState)
16297 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016298 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070016299 __func__);
16300 return -EIO;
16301 }
16302
16303 pRoamProfile = &pWextState->roamProfile;
16304
16305 /* Issue disconnect only if interface type is set to IBSS */
16306 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
16307 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016308 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070016309 __func__);
16310 return -EINVAL;
16311 }
16312
Abhishek Singh7cd040e2016-01-07 10:51:04 +053016313#ifdef WLAN_FEATURE_RMC
16314 /* Clearing add IE of beacon */
16315 if (ccmCfgSetStr(pHddCtx->hHal,
16316 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0],
16317 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN,
16318 NULL, eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
16319 {
16320 hddLog (VOS_TRACE_LEVEL_ERROR,
16321 "%s: unable to clear PROBE_RSP_BCN_ADDNIE_DATA", __func__);
16322 return -EINVAL;
16323 }
16324 if (ccmCfgSetInt(pHddCtx->hHal,
16325 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0, NULL,
16326 eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
16327 {
16328 hddLog (VOS_TRACE_LEVEL_ERROR,
16329 "%s: unable to clear WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
16330 __func__);
16331 return -EINVAL;
16332 }
16333
16334 // Reset WNI_CFG_PROBE_RSP Flags
16335 wlan_hdd_reset_prob_rspies(pAdapter);
16336
16337 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
16338 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 0,NULL,
16339 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
16340 {
16341 hddLog (VOS_TRACE_LEVEL_ERROR,
16342 "%s: unable to clear WNI_CFG_PROBE_RSP_ADDNIE_FLAG",
16343 __func__);
16344 return -EINVAL;
16345 }
16346#endif
16347
Jeff Johnson295189b2012-06-20 16:38:30 -070016348 /* Issue Disconnect request */
16349 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singh69de3302016-11-11 16:44:32 +053016350 hal_status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
16351 pAdapter->sessionId,
16352 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
16353 if (!HAL_STATUS_SUCCESS(hal_status)) {
16354 hddLog(LOGE,
16355 FL("sme_RoamDisconnect failed hal_status(%d)"),
16356 hal_status);
16357 return -EAGAIN;
16358 }
16359 status = wait_for_completion_timeout(
16360 &pAdapter->disconnect_comp_var,
16361 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
16362 if (!status) {
16363 hddLog(LOGE,
16364 FL("wait on disconnect_comp_var failed"));
16365 return -ETIMEDOUT;
16366 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016367
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016368 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016369 return 0;
16370}
16371
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016372static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
16373 struct net_device *dev
16374 )
16375{
16376 int ret = 0;
16377
16378 vos_ssr_protect(__func__);
16379 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
16380 vos_ssr_unprotect(__func__);
16381
16382 return ret;
16383}
16384
Jeff Johnson295189b2012-06-20 16:38:30 -070016385/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016386 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070016387 * This function is used to set the phy parameters
16388 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
16389 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016390static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070016391 u32 changed)
16392{
16393 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16394 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016395 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016396
16397 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016398
16399 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016400 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
16401 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016402
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016403 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016404 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016405 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016406 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016407 }
16408
Jeff Johnson295189b2012-06-20 16:38:30 -070016409 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
16410 {
16411 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
16412 WNI_CFG_RTS_THRESHOLD_STAMAX :
16413 wiphy->rts_threshold;
16414
16415 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016416 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070016417 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016418 hddLog(VOS_TRACE_LEVEL_ERROR,
16419 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016420 __func__, rts_threshold);
16421 return -EINVAL;
16422 }
16423
16424 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
16425 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016426 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016427 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016428 hddLog(VOS_TRACE_LEVEL_ERROR,
16429 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016430 __func__, rts_threshold);
16431 return -EIO;
16432 }
16433
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016434 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016435 rts_threshold);
16436 }
16437
16438 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
16439 {
16440 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
16441 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
16442 wiphy->frag_threshold;
16443
16444 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016445 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070016446 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016447 hddLog(VOS_TRACE_LEVEL_ERROR,
16448 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016449 frag_threshold);
16450 return -EINVAL;
16451 }
16452
16453 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
16454 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016455 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016456 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016457 hddLog(VOS_TRACE_LEVEL_ERROR,
16458 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016459 __func__, frag_threshold);
16460 return -EIO;
16461 }
16462
16463 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
16464 frag_threshold);
16465 }
16466
16467 if ((changed & WIPHY_PARAM_RETRY_SHORT)
16468 || (changed & WIPHY_PARAM_RETRY_LONG))
16469 {
16470 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
16471 wiphy->retry_short :
16472 wiphy->retry_long;
16473
16474 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
16475 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
16476 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016477 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016478 __func__, retry_value);
16479 return -EINVAL;
16480 }
16481
16482 if (changed & WIPHY_PARAM_RETRY_SHORT)
16483 {
16484 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
16485 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016486 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016487 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016488 hddLog(VOS_TRACE_LEVEL_ERROR,
16489 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016490 __func__, retry_value);
16491 return -EIO;
16492 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016493 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016494 __func__, retry_value);
16495 }
16496 else if (changed & WIPHY_PARAM_RETRY_SHORT)
16497 {
16498 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
16499 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016500 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016501 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016502 hddLog(VOS_TRACE_LEVEL_ERROR,
16503 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016504 __func__, retry_value);
16505 return -EIO;
16506 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016507 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016508 __func__, retry_value);
16509 }
16510 }
16511
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016512 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016513 return 0;
16514}
16515
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016516static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
16517 u32 changed)
16518{
16519 int ret;
16520
16521 vos_ssr_protect(__func__);
16522 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
16523 vos_ssr_unprotect(__func__);
16524
16525 return ret;
16526}
16527
Jeff Johnson295189b2012-06-20 16:38:30 -070016528/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016529 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070016530 * This function is used to set the txpower
16531 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016532static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070016533#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16534 struct wireless_dev *wdev,
16535#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016536#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016537 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070016538#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016539 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070016540#endif
16541 int dbm)
16542{
16543 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016544 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016545 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
16546 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016547 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016548
16549 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016550
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016551 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16552 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
16553 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016554 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016555 if (0 != status)
16556 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016557 return status;
16558 }
16559
16560 hHal = pHddCtx->hHal;
16561
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016562 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
16563 dbm, ccmCfgSetCallback,
16564 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016565 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016566 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016567 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
16568 return -EIO;
16569 }
16570
16571 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
16572 dbm);
16573
16574 switch(type)
16575 {
16576 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
16577 /* Fall through */
16578 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
16579 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
16580 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016581 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
16582 __func__);
16583 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070016584 }
16585 break;
16586 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016587 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070016588 __func__);
16589 return -EOPNOTSUPP;
16590 break;
16591 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016592 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
16593 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070016594 return -EIO;
16595 }
16596
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016597 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016598 return 0;
16599}
16600
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016601static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
16602#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16603 struct wireless_dev *wdev,
16604#endif
16605#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
16606 enum tx_power_setting type,
16607#else
16608 enum nl80211_tx_power_setting type,
16609#endif
16610 int dbm)
16611{
16612 int ret;
16613 vos_ssr_protect(__func__);
16614 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
16615#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16616 wdev,
16617#endif
16618#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
16619 type,
16620#else
16621 type,
16622#endif
16623 dbm);
16624 vos_ssr_unprotect(__func__);
16625
16626 return ret;
16627}
16628
Jeff Johnson295189b2012-06-20 16:38:30 -070016629/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016630 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070016631 * This function is used to read the txpower
16632 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016633static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070016634#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16635 struct wireless_dev *wdev,
16636#endif
16637 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070016638{
16639
16640 hdd_adapter_t *pAdapter;
16641 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016642 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016643
Jeff Johnsone7245742012-09-05 17:12:55 -070016644 ENTER();
16645
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016646 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016647 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016648 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016649 *dbm = 0;
16650 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016651 }
16652
Jeff Johnson295189b2012-06-20 16:38:30 -070016653 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
16654 if (NULL == pAdapter)
16655 {
16656 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
16657 return -ENOENT;
16658 }
16659
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016660 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16661 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
16662 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070016663 wlan_hdd_get_classAstats(pAdapter);
16664 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
16665
Jeff Johnsone7245742012-09-05 17:12:55 -070016666 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016667 return 0;
16668}
16669
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016670static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
16671#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16672 struct wireless_dev *wdev,
16673#endif
16674 int *dbm)
16675{
16676 int ret;
16677
16678 vos_ssr_protect(__func__);
16679 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
16680#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16681 wdev,
16682#endif
16683 dbm);
16684 vos_ssr_unprotect(__func__);
16685
16686 return ret;
16687}
16688
Dustin Brown8c1d4092017-07-28 18:08:01 +053016689/*
16690 * wlan_hdd_fill_summary_stats() - populate station_info summary stats
16691 * @stats: summary stats to use as a source
16692 * @info: kernel station_info struct to use as a destination
16693 *
16694 * Return: None
16695 */
16696static void wlan_hdd_fill_summary_stats(tCsrSummaryStatsInfo *stats,
16697 struct station_info *info)
16698{
16699 int i;
16700
16701 info->rx_packets = stats->rx_frm_cnt;
16702 info->tx_packets = 0;
16703 info->tx_retries = 0;
16704 info->tx_failed = 0;
16705
16706 for (i = 0; i < 4; ++i) {
16707 info->tx_packets += stats->tx_frm_cnt[i];
16708 info->tx_retries += stats->multiple_retry_cnt[i];
16709 info->tx_failed += stats->fail_cnt[i];
16710 }
16711
16712 info->filled |= STATION_INFO_TX_PACKETS |
16713 STATION_INFO_TX_RETRIES |
16714 STATION_INFO_TX_FAILED |
16715 STATION_INFO_RX_PACKETS;
16716}
16717
16718/**
16719 * wlan_hdd_get_sap_stats() - get aggregate SAP stats
16720 * @adapter: sap adapter to get stats for
16721 * @info: kernel station_info struct to populate
16722 *
16723 * Fetch the vdev-level aggregate stats for the given SAP adapter. This is to
16724 * support "station dump" and "station get" for SAP vdevs, even though they
16725 * aren't technically stations.
16726 *
16727 * Return: errno
16728 */
16729static int
16730wlan_hdd_get_sap_stats(hdd_adapter_t *adapter, struct station_info *info)
16731{
16732 VOS_STATUS status;
16733
16734 status = wlan_hdd_get_station_stats(adapter);
16735 if (!VOS_IS_STATUS_SUCCESS(status)) {
16736 hddLog(VOS_TRACE_LEVEL_ERROR,
16737 "Failed to get SAP stats; status:%d", status);
16738 return 0;
16739 }
16740
16741 wlan_hdd_fill_summary_stats(&adapter->hdd_stats.summary_stat, info);
16742
16743 return 0;
16744}
16745
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016746static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016747#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16748 const u8* mac,
16749#else
16750 u8* mac,
16751#endif
16752 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070016753{
16754 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
16755 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16756 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053016757 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070016758
16759 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
16760 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070016761
16762 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
16763 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
16764 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
16765 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
16766 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
16767 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
16768 tANI_U16 maxRate = 0;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053016769 int8_t snr = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016770 tANI_U16 myRate;
16771 tANI_U16 currentRate = 0;
16772 tANI_U8 maxSpeedMCS = 0;
16773 tANI_U8 maxMCSIdx = 0;
16774 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053016775 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070016776 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016777 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016778
Leo Chang6f8870f2013-03-26 18:11:36 -070016779#ifdef WLAN_FEATURE_11AC
16780 tANI_U32 vht_mcs_map;
16781 eDataRate11ACMaxMcs vhtMaxMcs;
16782#endif /* WLAN_FEATURE_11AC */
16783
Jeff Johnsone7245742012-09-05 17:12:55 -070016784 ENTER();
16785
Dustin Brown8c1d4092017-07-28 18:08:01 +053016786 status = wlan_hdd_validate_context(pHddCtx);
16787 if (0 != status)
16788 {
16789 return status;
16790 }
16791
16792 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
16793 return wlan_hdd_get_sap_stats(pAdapter, sinfo);
16794
Jeff Johnson295189b2012-06-20 16:38:30 -070016795 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
16796 (0 == ssidlen))
16797 {
16798 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
16799 " Invalid ssidlen, %d", __func__, ssidlen);
16800 /*To keep GUI happy*/
16801 return 0;
16802 }
16803
Mukul Sharma811205f2014-07-09 21:07:30 +053016804 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16805 {
16806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16807 "%s: Roaming in progress, so unable to proceed this request", __func__);
Sachin Ahuja81ab1812016-08-19 21:35:58 +053016808 /* return a cached value */
16809 sinfo->signal = pAdapter->rssi;
Mukul Sharma811205f2014-07-09 21:07:30 +053016810 return 0;
16811 }
16812
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053016813 wlan_hdd_get_station_stats(pAdapter);
16814 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070016815
Kiet Lam3b17fc82013-09-27 05:24:08 +053016816 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053016817 wlan_hdd_get_snr(pAdapter, &snr);
16818 pHddStaCtx->conn_info.signal = sinfo->signal;
16819 pHddStaCtx->conn_info.noise = pHddStaCtx->conn_info.signal - snr;
Kiet Lam3b17fc82013-09-27 05:24:08 +053016820 sinfo->filled |= STATION_INFO_SIGNAL;
16821
c_hpothu09f19542014-05-30 21:53:31 +053016822 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053016823 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
16824 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053016825 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053016826 {
16827 rate_flags = pAdapter->maxRateFlags;
16828 }
c_hpothu44ff4e02014-05-08 00:13:57 +053016829
Jeff Johnson295189b2012-06-20 16:38:30 -070016830 //convert to the UI units of 100kbps
16831 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
16832
16833#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070016834 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 -070016835 sinfo->signal,
16836 pCfg->reportMaxLinkSpeed,
16837 myRate,
16838 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016839 (int) pCfg->linkSpeedRssiMid,
16840 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070016841 (int) rate_flags,
16842 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070016843#endif //LINKSPEED_DEBUG_ENABLED
16844
16845 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
16846 {
16847 // we do not want to necessarily report the current speed
16848 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
16849 {
16850 // report the max possible speed
16851 rssidx = 0;
16852 }
16853 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
16854 {
16855 // report the max possible speed with RSSI scaling
16856 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
16857 {
16858 // report the max possible speed
16859 rssidx = 0;
16860 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016861 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016862 {
16863 // report middle speed
16864 rssidx = 1;
16865 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016866 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
16867 {
16868 // report middle speed
16869 rssidx = 2;
16870 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016871 else
16872 {
16873 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016874 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070016875 }
16876 }
16877 else
16878 {
16879 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
16880 hddLog(VOS_TRACE_LEVEL_ERROR,
16881 "%s: Invalid value for reportMaxLinkSpeed: %u",
16882 __func__, pCfg->reportMaxLinkSpeed);
16883 rssidx = 0;
16884 }
16885
16886 maxRate = 0;
16887
16888 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016889 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
16890 OperationalRates, &ORLeng))
16891 {
16892 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16893 /*To keep GUI happy*/
16894 return 0;
16895 }
16896
Jeff Johnson295189b2012-06-20 16:38:30 -070016897 for (i = 0; i < ORLeng; i++)
16898 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016899 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016900 {
16901 /* Validate Rate Set */
16902 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
16903 {
16904 currentRate = supported_data_rate[j].supported_rate[rssidx];
16905 break;
16906 }
16907 }
16908 /* Update MAX rate */
16909 maxRate = (currentRate > maxRate)?currentRate:maxRate;
16910 }
16911
16912 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016913 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
16914 ExtendedRates, &ERLeng))
16915 {
16916 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16917 /*To keep GUI happy*/
16918 return 0;
16919 }
16920
Jeff Johnson295189b2012-06-20 16:38:30 -070016921 for (i = 0; i < ERLeng; i++)
16922 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016923 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016924 {
16925 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
16926 {
16927 currentRate = supported_data_rate[j].supported_rate[rssidx];
16928 break;
16929 }
16930 }
16931 /* Update MAX rate */
16932 maxRate = (currentRate > maxRate)?currentRate:maxRate;
16933 }
c_hpothu79aab322014-07-14 21:11:01 +053016934
Kiet Lamb69f8dc2013-11-15 15:34:27 +053016935 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053016936 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053016937 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053016938 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070016939 {
c_hpothu79aab322014-07-14 21:11:01 +053016940 if (rate_flags & eHAL_TX_RATE_VHT80)
16941 mode = 2;
16942 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
16943 mode = 1;
16944 else
16945 mode = 0;
16946
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016947 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
16948 MCSRates, &MCSLeng))
16949 {
16950 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16951 /*To keep GUI happy*/
16952 return 0;
16953 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016954 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070016955#ifdef WLAN_FEATURE_11AC
16956 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016957 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070016958 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016959 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016960 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070016961 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070016962 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016963 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070016964 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016965 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070016966 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016967 maxMCSIdx = 7;
16968 }
16969 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
16970 {
16971 maxMCSIdx = 8;
16972 }
16973 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
16974 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016975 //VHT20 is supporting 0~8
16976 if (rate_flags & eHAL_TX_RATE_VHT20)
16977 maxMCSIdx = 8;
16978 else
16979 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070016980 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016981
c_hpothu79aab322014-07-14 21:11:01 +053016982 if (0 != rssidx)/*check for scaled */
16983 {
16984 //get middle rate MCS index if rssi=1/2
16985 for (i=0; i <= maxMCSIdx; i++)
16986 {
16987 if (sinfo->signal <= rssiMcsTbl[mode][i])
16988 {
16989 maxMCSIdx = i;
16990 break;
16991 }
16992 }
16993 }
16994
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016995 if (rate_flags & eHAL_TX_RATE_VHT80)
16996 {
16997 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
16998 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
16999 }
17000 else if (rate_flags & eHAL_TX_RATE_VHT40)
17001 {
17002 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
17003 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
17004 }
17005 else if (rate_flags & eHAL_TX_RATE_VHT20)
17006 {
17007 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
17008 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
17009 }
17010
Leo Chang6f8870f2013-03-26 18:11:36 -070017011 maxSpeedMCS = 1;
17012 if (currentRate > maxRate)
17013 {
17014 maxRate = currentRate;
17015 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053017016
Leo Chang6f8870f2013-03-26 18:11:36 -070017017 }
17018 else
17019#endif /* WLAN_FEATURE_11AC */
17020 {
17021 if (rate_flags & eHAL_TX_RATE_HT40)
17022 {
17023 rateFlag |= 1;
17024 }
17025 if (rate_flags & eHAL_TX_RATE_SGI)
17026 {
17027 rateFlag |= 2;
17028 }
17029
Girish Gowli01abcee2014-07-31 20:18:55 +053017030 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053017031 if (rssidx == 1 || rssidx == 2)
17032 {
17033 //get middle rate MCS index if rssi=1/2
17034 for (i=0; i <= 7; i++)
17035 {
17036 if (sinfo->signal <= rssiMcsTbl[mode][i])
17037 {
17038 temp = i+1;
17039 break;
17040 }
17041 }
17042 }
c_hpothu79aab322014-07-14 21:11:01 +053017043
17044 for (i = 0; i < MCSLeng; i++)
17045 {
Leo Chang6f8870f2013-03-26 18:11:36 -070017046 for (j = 0; j < temp; j++)
17047 {
17048 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
17049 {
17050 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053017051 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070017052 break;
17053 }
17054 }
17055 if ((j < temp) && (currentRate > maxRate))
17056 {
17057 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070017058 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017059 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053017060 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070017061 }
17062 }
17063
Gopichand Nakkala4c705372013-04-24 13:20:33 +053017064 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
17065 {
17066 maxRate = myRate;
17067 maxSpeedMCS = 1;
17068 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
17069 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017070 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053017071 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070017072 {
17073 maxRate = myRate;
17074 if (rate_flags & eHAL_TX_RATE_LEGACY)
17075 {
17076 maxSpeedMCS = 0;
17077 }
17078 else
17079 {
17080 maxSpeedMCS = 1;
17081 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
17082 }
17083 }
17084
Gopichand Nakkala4c705372013-04-24 13:20:33 +053017085 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070017086 {
17087 sinfo->txrate.legacy = maxRate;
17088#ifdef LINKSPEED_DEBUG_ENABLED
17089 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
17090#endif //LINKSPEED_DEBUG_ENABLED
17091 }
17092 else
17093 {
17094 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070017095#ifdef WLAN_FEATURE_11AC
17096 sinfo->txrate.nss = 1;
17097 if (rate_flags & eHAL_TX_RATE_VHT80)
17098 {
17099 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053017100 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070017101 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053017102 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070017103 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053017104 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
17105 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
17106 }
17107 else if (rate_flags & eHAL_TX_RATE_VHT20)
17108 {
17109 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
17110 }
17111#endif /* WLAN_FEATURE_11AC */
17112 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
17113 {
17114 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
17115 if (rate_flags & eHAL_TX_RATE_HT40)
17116 {
17117 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
17118 }
Leo Chang6f8870f2013-03-26 18:11:36 -070017119 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017120 if (rate_flags & eHAL_TX_RATE_SGI)
17121 {
17122 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
17123 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053017124
Jeff Johnson295189b2012-06-20 16:38:30 -070017125#ifdef LINKSPEED_DEBUG_ENABLED
17126 pr_info("Reporting MCS rate %d flags %x\n",
17127 sinfo->txrate.mcs,
17128 sinfo->txrate.flags );
17129#endif //LINKSPEED_DEBUG_ENABLED
17130 }
17131 }
17132 else
17133 {
17134 // report current rate instead of max rate
17135
17136 if (rate_flags & eHAL_TX_RATE_LEGACY)
17137 {
17138 //provide to the UI in units of 100kbps
17139 sinfo->txrate.legacy = myRate;
17140#ifdef LINKSPEED_DEBUG_ENABLED
17141 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
17142#endif //LINKSPEED_DEBUG_ENABLED
17143 }
17144 else
17145 {
17146 //must be MCS
17147 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070017148#ifdef WLAN_FEATURE_11AC
17149 sinfo->txrate.nss = 1;
17150 if (rate_flags & eHAL_TX_RATE_VHT80)
17151 {
17152 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
17153 }
17154 else
17155#endif /* WLAN_FEATURE_11AC */
17156 {
17157 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
17158 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017159 if (rate_flags & eHAL_TX_RATE_SGI)
17160 {
17161 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
17162 }
17163 if (rate_flags & eHAL_TX_RATE_HT40)
17164 {
17165 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
17166 }
Leo Chang6f8870f2013-03-26 18:11:36 -070017167#ifdef WLAN_FEATURE_11AC
17168 else if (rate_flags & eHAL_TX_RATE_VHT80)
17169 {
17170 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
17171 }
17172#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070017173#ifdef LINKSPEED_DEBUG_ENABLED
17174 pr_info("Reporting actual MCS rate %d flags %x\n",
17175 sinfo->txrate.mcs,
17176 sinfo->txrate.flags );
17177#endif //LINKSPEED_DEBUG_ENABLED
17178 }
17179 }
17180 sinfo->filled |= STATION_INFO_TX_BITRATE;
17181
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070017182 sinfo->tx_packets =
17183 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
17184 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
17185 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
17186 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
17187
17188 sinfo->tx_retries =
17189 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
17190 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
17191 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
17192 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
17193
17194 sinfo->tx_failed =
17195 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
17196 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
17197 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
17198 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
17199
17200 sinfo->filled |=
17201 STATION_INFO_TX_PACKETS |
17202 STATION_INFO_TX_RETRIES |
17203 STATION_INFO_TX_FAILED;
17204
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053017205 sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt;
17206 sinfo->filled |= STATION_INFO_RX_PACKETS;
17207
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053017208 vos_mem_copy(&pHddStaCtx->conn_info.txrate,
17209 &sinfo->txrate, sizeof(sinfo->txrate));
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053017210 if (rate_flags & eHAL_TX_RATE_LEGACY)
17211 hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"),
17212 sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets,
17213 sinfo->rx_packets);
17214 else
17215 hddLog(LOG1,
17216 FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"),
17217 sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags,
17218 sinfo->tx_packets, sinfo->rx_packets);
17219
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017220 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17221 TRACE_CODE_HDD_CFG80211_GET_STA,
17222 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070017223 EXIT();
17224 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017225}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017226#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
17227static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
17228 const u8* mac, struct station_info *sinfo)
17229#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017230static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
17231 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017232#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017233{
17234 int ret;
17235
17236 vos_ssr_protect(__func__);
17237 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
17238 vos_ssr_unprotect(__func__);
17239
17240 return ret;
17241}
17242
17243static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070017244 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070017245{
17246 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053017247 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070017248 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017249 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017250
Jeff Johnsone7245742012-09-05 17:12:55 -070017251 ENTER();
17252
Jeff Johnson295189b2012-06-20 16:38:30 -070017253 if (NULL == pAdapter)
17254 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017255 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070017256 return -ENODEV;
17257 }
17258
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017259 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17260 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
17261 pAdapter->sessionId, timeout));
17262
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053017263 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017264 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017265 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017266 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017267 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017268 }
17269
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053017270 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
17271 (TRUE == pHddCtx->hdd_wlan_suspended) &&
17272 (pHddCtx->cfg_ini->fhostArpOffload) &&
17273 (eConnectionState_Associated ==
17274 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
17275 {
Amar Singhald53568e2013-09-26 11:03:45 -070017276
17277 hddLog(VOS_TRACE_LEVEL_INFO,
17278 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053017279 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053017280 if (!VOS_IS_STATUS_SUCCESS(vos_status))
17281 {
17282 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017283 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053017284 __func__, vos_status);
17285 }
17286 }
17287
Jeff Johnson295189b2012-06-20 16:38:30 -070017288 /**The get power cmd from the supplicant gets updated by the nl only
17289 *on successful execution of the function call
17290 *we are oppositely mapped w.r.t mode in the driver
17291 **/
17292 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
17293
17294 if (VOS_STATUS_E_FAILURE == vos_status)
17295 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053017296 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17297 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070017298 return -EINVAL;
17299 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017300 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070017301 return 0;
17302}
17303
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017304static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
17305 struct net_device *dev, bool mode, int timeout)
17306{
17307 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070017308
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017309 vos_ssr_protect(__func__);
17310 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
17311 vos_ssr_unprotect(__func__);
17312
17313 return ret;
17314}
Sushant Kaushik084f6592015-09-10 13:11:56 +053017315
Jeff Johnson295189b2012-06-20 16:38:30 -070017316#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017317static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
17318 struct net_device *netdev,
17319 u8 key_index)
17320{
17321 ENTER();
17322 return 0;
17323}
17324
Jeff Johnson295189b2012-06-20 16:38:30 -070017325static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017326 struct net_device *netdev,
17327 u8 key_index)
17328{
17329 int ret;
17330 vos_ssr_protect(__func__);
17331 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
17332 vos_ssr_unprotect(__func__);
17333 return ret;
17334}
17335#endif //LINUX_VERSION_CODE
17336
17337#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
17338static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
17339 struct net_device *dev,
17340 struct ieee80211_txq_params *params)
17341{
17342 ENTER();
17343 return 0;
17344}
17345#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
17346static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
17347 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070017348{
Jeff Johnsone7245742012-09-05 17:12:55 -070017349 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070017350 return 0;
17351}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017352#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070017353
17354#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
17355static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017356 struct net_device *dev,
17357 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070017358{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017359 int ret;
17360
17361 vos_ssr_protect(__func__);
17362 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
17363 vos_ssr_unprotect(__func__);
17364 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070017365}
17366#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
17367static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
17368 struct ieee80211_txq_params *params)
17369{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017370 int ret;
17371
17372 vos_ssr_protect(__func__);
17373 ret = __wlan_hdd_set_txq_params(wiphy, params);
17374 vos_ssr_unprotect(__func__);
17375 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070017376}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017377#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017378
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017379static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017380 struct net_device *dev,
17381 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070017382{
17383 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017384 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017385 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017386 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017387 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017388 v_CONTEXT_t pVosContext = NULL;
17389 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017390
Jeff Johnsone7245742012-09-05 17:12:55 -070017391 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017392
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017393 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070017394 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017395 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070017396 return -EINVAL;
17397 }
17398
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017399 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17400 TRACE_CODE_HDD_CFG80211_DEL_STA,
17401 pAdapter->sessionId, pAdapter->device_mode));
17402
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017403 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17404 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017405 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017406 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017407 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017408 }
17409
Jeff Johnson295189b2012-06-20 16:38:30 -070017410 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070017411 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070017412 )
17413 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017414 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
17415 pSapCtx = VOS_GET_SAP_CB(pVosContext);
17416 if(pSapCtx == NULL){
17417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17418 FL("psapCtx is NULL"));
17419 return -ENOENT;
17420 }
Agrawal Ashish306b75f2017-01-11 19:16:25 +053017421 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
17422 {
17423 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
17424 "Change reason code to eSIR_MAC_DISASSOC_LEAVING_BSS_REASON in sap auth offload");
17425 pDelStaParams->reason_code = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
17426 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017427 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070017428 {
17429 v_U16_t i;
17430 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
17431 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017432 if ((pSapCtx->aStaInfo[i].isUsed) &&
17433 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070017434 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017435 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017436 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017437 ETHER_ADDR_LEN);
17438
Jeff Johnson295189b2012-06-20 16:38:30 -070017439 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080017440 "%s: Delete STA with MAC::"
17441 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017442 __func__,
17443 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
17444 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070017445 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017446 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017447 }
17448 }
17449 }
17450 else
17451 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017452
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017453 vos_status = hdd_softap_GetStaId(pAdapter,
17454 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017455 if (!VOS_IS_STATUS_SUCCESS(vos_status))
17456 {
17457 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080017458 "%s: Skip this DEL STA as this is not used::"
17459 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017460 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017461 return -ENOENT;
17462 }
17463
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017464 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017465 {
17466 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080017467 "%s: Skip this DEL STA as deauth is in progress::"
17468 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017469 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017470 return -ENOENT;
17471 }
17472
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017473 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017474
Jeff Johnson295189b2012-06-20 16:38:30 -070017475 hddLog(VOS_TRACE_LEVEL_INFO,
17476 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080017477 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070017478 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017479 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017480
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017481 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017482 if (!VOS_IS_STATUS_SUCCESS(vos_status))
17483 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017484 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017485 hddLog(VOS_TRACE_LEVEL_INFO,
17486 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080017487 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017488 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017489 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017490 return -ENOENT;
17491 }
17492
Jeff Johnson295189b2012-06-20 16:38:30 -070017493 }
17494 }
17495
17496 EXIT();
17497
17498 return 0;
17499}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017500
17501#ifdef CFG80211_DEL_STA_V2
Kapil Gupta137ef892016-12-13 19:38:00 +053017502int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017503 struct net_device *dev,
17504 struct station_del_parameters *param)
17505#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017506#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
Kapil Gupta137ef892016-12-13 19:38:00 +053017507int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017508 struct net_device *dev, const u8 *mac)
17509#else
Kapil Gupta137ef892016-12-13 19:38:00 +053017510int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017511 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017512#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017513#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017514{
17515 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017516 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070017517
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017518 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017519
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017520#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017521 if (NULL == param) {
17522 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017523 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017524 return -EINVAL;
17525 }
17526
17527 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
17528 param->subtype, &delStaParams);
17529
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017530#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053017531 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017532 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017533#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017534 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
17535
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017536 vos_ssr_unprotect(__func__);
17537
17538 return ret;
17539}
17540
17541static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017542 struct net_device *dev,
17543#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17544 const u8 *mac,
17545#else
17546 u8 *mac,
17547#endif
17548 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017549{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017550 hdd_adapter_t *pAdapter;
17551 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017552 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017553#ifdef FEATURE_WLAN_TDLS
17554 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017555
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017556 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017557
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017558 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17559 if (NULL == pAdapter)
17560 {
17561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17562 "%s: Adapter is NULL",__func__);
17563 return -EINVAL;
17564 }
17565 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17566 status = wlan_hdd_validate_context(pHddCtx);
17567 if (0 != status)
17568 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017569 return status;
17570 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017571
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017572 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17573 TRACE_CODE_HDD_CFG80211_ADD_STA,
17574 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017575 mask = params->sta_flags_mask;
17576
17577 set = params->sta_flags_set;
17578
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017579 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017580 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
17581 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017582
17583 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
17584 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080017585 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017586 }
17587 }
17588#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017589 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017590 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017591}
17592
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017593#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
17594static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
17595 struct net_device *dev, const u8 *mac,
17596 struct station_parameters *params)
17597#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017598static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
17599 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017600#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017601{
17602 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017603
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017604 vos_ssr_protect(__func__);
17605 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
17606 vos_ssr_unprotect(__func__);
17607
17608 return ret;
17609}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017610#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070017611
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017612static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070017613 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017614{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017615 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17616 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017617 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017618 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017619 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017620 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070017621
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017622 ENTER();
17623
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017624 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017625 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017626 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017627 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017628 return -EINVAL;
17629 }
17630
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017631 if (!pmksa) {
17632 hddLog(LOGE, FL("pmksa is NULL"));
17633 return -EINVAL;
17634 }
17635
17636 if (!pmksa->bssid || !pmksa->pmkid) {
17637 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
17638 pmksa->bssid, pmksa->pmkid);
17639 return -EINVAL;
17640 }
17641
17642 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
17643 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
17644
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017645 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17646 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017647 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017648 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017649 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017650 }
17651
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017652 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017653 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17654
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017655 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
17656 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017657
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017658 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017659 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017660 &pmk_id, 1, FALSE);
17661
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017662 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17663 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
17664 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017665
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017666 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017667 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017668}
17669
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017670static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
17671 struct cfg80211_pmksa *pmksa)
17672{
17673 int ret;
17674
17675 vos_ssr_protect(__func__);
17676 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
17677 vos_ssr_unprotect(__func__);
17678
17679 return ret;
17680}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017681
Wilson Yang6507c4e2013-10-01 20:11:19 -070017682
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017683static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070017684 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017685{
Wilson Yang6507c4e2013-10-01 20:11:19 -070017686 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17687 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017688 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080017689 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017690
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017691 ENTER();
17692
Wilson Yang6507c4e2013-10-01 20:11:19 -070017693 /* Validate pAdapter */
17694 if (NULL == pAdapter)
17695 {
17696 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
17697 return -EINVAL;
17698 }
17699
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017700 if (!pmksa) {
17701 hddLog(LOGE, FL("pmksa is NULL"));
17702 return -EINVAL;
17703 }
17704
17705 if (!pmksa->bssid) {
17706 hddLog(LOGE, FL("pmksa->bssid is NULL"));
17707 return -EINVAL;
17708 }
17709
Kiet Lam98c46a12014-10-31 15:34:57 -070017710 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
17711 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
17712
Wilson Yang6507c4e2013-10-01 20:11:19 -070017713 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17714 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070017715 if (0 != status)
17716 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070017717 return status;
17718 }
17719
17720 /*Retrieve halHandle*/
17721 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17722
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017723 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17724 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
17725 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017726 /* Delete the PMKID CSR cache */
17727 if (eHAL_STATUS_SUCCESS !=
17728 sme_RoamDelPMKIDfromCache(halHandle,
17729 pAdapter->sessionId, pmksa->bssid, FALSE)) {
17730 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
17731 MAC_ADDR_ARRAY(pmksa->bssid));
17732 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017733 }
17734
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017735 EXIT();
17736 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017737}
17738
Wilson Yang6507c4e2013-10-01 20:11:19 -070017739
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017740static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
17741 struct cfg80211_pmksa *pmksa)
17742{
17743 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017744
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017745 vos_ssr_protect(__func__);
17746 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
17747 vos_ssr_unprotect(__func__);
17748
17749 return ret;
17750
17751}
17752
17753static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017754{
Wilson Yang6507c4e2013-10-01 20:11:19 -070017755 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17756 tHalHandle halHandle;
17757 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080017758 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017759
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017760 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070017761
17762 /* Validate pAdapter */
17763 if (NULL == pAdapter)
17764 {
17765 hddLog(VOS_TRACE_LEVEL_ERROR,
17766 "%s: Invalid Adapter" ,__func__);
17767 return -EINVAL;
17768 }
17769
17770 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17771 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070017772 if (0 != status)
17773 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070017774 return status;
17775 }
17776
17777 /*Retrieve halHandle*/
17778 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17779
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017780 /* Flush the PMKID cache in CSR */
17781 if (eHAL_STATUS_SUCCESS !=
17782 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
17783 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
17784 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017785 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017786 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080017787 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017788}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017789
17790static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
17791{
17792 int ret;
17793
17794 vos_ssr_protect(__func__);
17795 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
17796 vos_ssr_unprotect(__func__);
17797
17798 return ret;
17799}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017800#endif
17801
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017802#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017803static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
17804 struct net_device *dev,
17805 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017806{
17807 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17808 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017809 hdd_context_t *pHddCtx;
17810 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017811
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017812 ENTER();
17813
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017814 if (NULL == pAdapter)
17815 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017816 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017817 return -ENODEV;
17818 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017819 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17820 ret = wlan_hdd_validate_context(pHddCtx);
17821 if (0 != ret)
17822 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017823 return ret;
17824 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017825 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017826 if (NULL == pHddStaCtx)
17827 {
17828 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
17829 return -EINVAL;
17830 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017831
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017832 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17833 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
17834 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017835 // Added for debug on reception of Re-assoc Req.
17836 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
17837 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017838 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017839 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080017840 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017841 }
17842
17843#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080017844 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017845 ftie->ie_len);
17846#endif
17847
17848 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053017849 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
17850 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017851 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017852
17853 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017854 return 0;
17855}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017856
17857static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
17858 struct net_device *dev,
17859 struct cfg80211_update_ft_ies_params *ftie)
17860{
17861 int ret;
17862
17863 vos_ssr_protect(__func__);
17864 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
17865 vos_ssr_unprotect(__func__);
17866
17867 return ret;
17868}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017869#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017870
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017871#ifdef FEATURE_WLAN_SCAN_PNO
17872
17873void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
17874 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
17875{
17876 int ret;
17877 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
17878 hdd_context_t *pHddCtx;
17879
Nirav Shah80830bf2013-12-31 16:35:12 +053017880 ENTER();
17881
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017882 if (NULL == pAdapter)
17883 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053017884 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017885 "%s: HDD adapter is Null", __func__);
17886 return ;
17887 }
17888
17889 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17890 if (NULL == pHddCtx)
17891 {
17892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17893 "%s: HDD context is Null!!!", __func__);
17894 return ;
17895 }
17896
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017897 spin_lock(&pHddCtx->schedScan_lock);
17898 if (TRUE == pHddCtx->isWiphySuspended)
17899 {
17900 pHddCtx->isSchedScanUpdatePending = TRUE;
17901 spin_unlock(&pHddCtx->schedScan_lock);
17902 hddLog(VOS_TRACE_LEVEL_INFO,
17903 "%s: Update cfg80211 scan database after it resume", __func__);
17904 return ;
17905 }
17906 spin_unlock(&pHddCtx->schedScan_lock);
17907
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017908 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
17909
17910 if (0 > ret)
17911 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053017912 else
17913 {
17914 /* Acquire wakelock to handle the case where APP's tries to suspend
17915 * immediatly after the driver gets connect request(i.e after pno)
17916 * from supplicant, this result in app's is suspending and not able
17917 * to process the connect request to AP */
17918 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
17919 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017920 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17922 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017923}
17924
17925/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017926 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017927 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017928 */
17929static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
17930{
17931 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
17932 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017933 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017934 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17935 int status = 0;
Agrawal Ashishcff31692016-12-16 17:17:50 +053017936
17937 if (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
17938 {
17939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17940 "%s: PNO is allowed only in STA interface", __func__);
17941 return eHAL_STATUS_FAILURE;
17942 }
17943
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017944 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
17945
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017946 /* The current firmware design does not allow PNO during any
Agrawal Ashishcff31692016-12-16 17:17:50 +053017947 * active sessions. PNO is allowed only in case when sap session
17948 * is present and sapo auth offload feature enabled in firmare.
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017949 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017950 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
17951 {
17952 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017953 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017954
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017955 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
17956 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
17957 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
17958 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
Agrawal Ashishcff31692016-12-16 17:17:50 +053017959 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode &&
17960 !pHddCtx->cfg_ini->enable_sap_auth_offload)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053017961 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017962 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017963 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017964 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017965 }
17966 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
17967 pAdapterNode = pNext;
17968 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017969 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017970}
17971
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017972void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
17973{
17974 hdd_adapter_t *pAdapter = callbackContext;
17975 hdd_context_t *pHddCtx;
17976
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017977 ENTER();
17978
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017979 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
17980 {
17981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17982 FL("Invalid adapter or adapter has invalid magic"));
17983 return;
17984 }
17985
17986 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17987 if (0 != wlan_hdd_validate_context(pHddCtx))
17988 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017989 return;
17990 }
17991
c_hpothub53c45d2014-08-18 16:53:14 +053017992 if (VOS_STATUS_SUCCESS != status)
17993 {
17994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017995 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053017996 pHddCtx->isPnoEnable = FALSE;
17997 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017998
17999 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
18000 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018001 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018002}
18003
Anurag Chouhan343af7e2016-12-16 13:11:19 +053018004#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) || \
18005 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
18006/**
18007 * hdd_config_sched_scan_plan() - configures the sched scan plans
18008 * from the framework.
18009 * @pno_req: pointer to PNO scan request
18010 * @request: pointer to scan request from framework
18011 *
18012 * Return: None
18013 */
18014static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
18015 struct cfg80211_sched_scan_request *request,
18016 hdd_context_t *hdd_ctx)
18017{
18018 v_U32_t i = 0;
18019
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053018020 pno_req->scanTimers.ucScanTimersCount = request->n_scan_plans;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053018021 for (i = 0; i < request->n_scan_plans; i++)
18022 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053018023 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
18024 request->scan_plans[i].iterations;
18025 pno_req->scanTimers.aTimerValues[i].uTimerValue =
18026 request->scan_plans[i].interval;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053018027 }
18028}
18029#else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053018030static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
Anurag Chouhan343af7e2016-12-16 13:11:19 +053018031 struct cfg80211_sched_scan_request *request,
18032 hdd_context_t *hdd_ctx)
18033{
18034 v_U32_t i, temp_int;
18035 /* Driver gets only one time interval which is hardcoded in
18036 * supplicant for 10000ms. Taking power consumption into account 6
18037 * timers will be used, Timervalue is increased exponentially
18038 * i.e 10,20,40, 80,160,320 secs. And number of scan cycle for each
18039 * timer is configurable through INI param gPNOScanTimerRepeatValue.
18040 * If it is set to 0 only one timer will be used and PNO scan cycle
18041 * will be repeated after each interval specified by supplicant
18042 * till PNO is disabled.
18043 */
18044 if (0 == hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue)
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053018045 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053018046 HDD_PNO_SCAN_TIMERS_SET_ONE;
18047 else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053018048 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053018049 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
18050
18051 temp_int = (request->interval)/1000;
18052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18053 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
18054 temp_int, hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue);
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053018055 for ( i = 0; i < pno_req->scanTimers.ucScanTimersCount; i++)
Anurag Chouhan343af7e2016-12-16 13:11:19 +053018056 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053018057 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053018058 hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue;
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053018059 pno_req->scanTimers.aTimerValues[i].uTimerValue = temp_int;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053018060 temp_int *= 2;
18061 }
18062 //Repeat last timer until pno disabled.
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053018063 pno_req->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053018064}
18065#endif
18066
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053018067/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053018068 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
18069 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018070 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053018071static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018072 struct net_device *dev, struct cfg80211_sched_scan_request *request)
18073{
18074 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018075 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018076 hdd_context_t *pHddCtx;
18077 tHalHandle hHal;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053018078 v_U32_t i, indx, num_ch, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053018079 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
18080 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018081 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
18082 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018083 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053018084 hdd_config_t *pConfig = NULL;
18085 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018086
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018087 ENTER();
18088
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018089 if (NULL == pAdapter)
18090 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018092 "%s: HDD adapter is Null", __func__);
18093 return -ENODEV;
18094 }
18095
18096 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018097 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018098
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018099 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018100 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018101 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018102 }
18103
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053018104 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018105 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
18106 if (NULL == hHal)
18107 {
18108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18109 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018110 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018111 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018112 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18113 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
18114 pAdapter->sessionId, pAdapter->device_mode));
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053018115 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053018116 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053018117 {
18118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18119 "%s: aborting the existing scan is unsuccessfull", __func__);
18120 return -EBUSY;
18121 }
18122
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053018123 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053018124 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053018125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053018126 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053018127 return -EBUSY;
18128 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018129
c_hpothu37f21312014-04-09 21:49:54 +053018130 if (TRUE == pHddCtx->isPnoEnable)
18131 {
18132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
18133 FL("already PNO is enabled"));
18134 return -EBUSY;
18135 }
c_hpothu225aa7c2014-10-22 17:45:13 +053018136
18137 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
18138 {
18139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18140 "%s: abort ROC failed ", __func__);
18141 return -EBUSY;
18142 }
18143
c_hpothu37f21312014-04-09 21:49:54 +053018144 pHddCtx->isPnoEnable = TRUE;
18145
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018146 pnoRequest.enable = 1; /*Enable PNO */
18147 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018148
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018149 if (( !pnoRequest.ucNetworksCount ) ||
18150 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018151 {
18152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053018153 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018154 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053018155 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018156 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018157 goto error;
18158 }
18159
18160 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
18161 {
18162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053018163 "%s: Incorrect number of channels %d",
18164 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018165 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018166 goto error;
18167 }
18168
18169 /* Framework provides one set of channels(all)
18170 * common for all saved profile */
18171 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
18172 channels_allowed, &num_channels_allowed))
18173 {
18174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18175 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018176 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018177 goto error;
18178 }
18179 /* Checking each channel against allowed channel list */
18180 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053018181 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018182 {
Nirav Shah80830bf2013-12-31 16:35:12 +053018183 char chList [(request->n_channels*5)+1];
18184 int len;
18185 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018186 {
Nirav Shah80830bf2013-12-31 16:35:12 +053018187 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018188 {
Nirav Shah80830bf2013-12-31 16:35:12 +053018189 if (request->channels[i]->hw_value == channels_allowed[indx])
18190 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053018191 if ((!pConfig->enableDFSPnoChnlScan) &&
18192 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
18193 {
18194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18195 "%s : Dropping DFS channel : %d",
18196 __func__,channels_allowed[indx]);
18197 num_ignore_dfs_ch++;
18198 break;
18199 }
18200
Nirav Shah80830bf2013-12-31 16:35:12 +053018201 valid_ch[num_ch++] = request->channels[i]->hw_value;
18202 len += snprintf(chList+len, 5, "%d ",
18203 request->channels[i]->hw_value);
18204 break ;
18205 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018206 }
18207 }
Nirav Shah80830bf2013-12-31 16:35:12 +053018208 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018209
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053018210 /*If all channels are DFS and dropped, then ignore the PNO request*/
18211 if (num_ignore_dfs_ch == request->n_channels)
18212 {
18213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18214 "%s : All requested channels are DFS channels", __func__);
18215 ret = -EINVAL;
18216 goto error;
18217 }
18218 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018219
18220 pnoRequest.aNetworks =
18221 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
18222 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018223 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018224 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18225 FL("failed to allocate memory aNetworks %u"),
18226 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
18227 goto error;
18228 }
18229 vos_mem_zero(pnoRequest.aNetworks,
18230 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
18231
18232 /* Filling per profile params */
18233 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
18234 {
18235 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018236 request->match_sets[i].ssid.ssid_len;
18237
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018238 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
18239 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018240 {
18241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053018242 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018243 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018244 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018245 goto error;
18246 }
18247
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018248 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018249 request->match_sets[i].ssid.ssid,
18250 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053018251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18252 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018253 i, pnoRequest.aNetworks[i].ssId.ssId);
18254 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
18255 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
18256 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018257
18258 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018259 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
18260 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018261
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018262 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018263 }
18264
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053018265 for (i = 0; i < request->n_ssids; i++)
18266 {
18267 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018268 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053018269 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018270 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053018271 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018272 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053018273 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018274 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053018275 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018276 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053018277 break;
18278 }
18279 j++;
18280 }
18281 }
18282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18283 "Number of hidden networks being Configured = %d",
18284 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053018285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080018286 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018287
18288 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
18289 if (pnoRequest.p24GProbeTemplate == NULL)
18290 {
18291 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18292 FL("failed to allocate memory p24GProbeTemplate %u"),
18293 SIR_PNO_MAX_PB_REQ_SIZE);
18294 goto error;
18295 }
18296
18297 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
18298 if (pnoRequest.p5GProbeTemplate == NULL)
18299 {
18300 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18301 FL("failed to allocate memory p5GProbeTemplate %u"),
18302 SIR_PNO_MAX_PB_REQ_SIZE);
18303 goto error;
18304 }
18305
18306 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
18307 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
18308
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053018309 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
18310 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053018311 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018312 pnoRequest.us24GProbeTemplateLen = request->ie_len;
18313 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
18314 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053018315
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018316 pnoRequest.us5GProbeTemplateLen = request->ie_len;
18317 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
18318 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053018319 }
18320
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053018321 hdd_config_sched_scan_plan(&pnoRequest, request, pHddCtx);
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053018322
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018323 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018324
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018325 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018326 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
18327 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018328 pAdapter->pno_req_status = 0;
18329
Nirav Shah80830bf2013-12-31 16:35:12 +053018330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18331 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018332 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
18333 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053018334
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018335 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018336 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018337 hdd_cfg80211_sched_scan_done_callback, pAdapter);
18338 if (eHAL_STATUS_SUCCESS != status)
18339 {
18340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053018341 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018342 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018343 goto error;
18344 }
18345
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018346 ret = wait_for_completion_timeout(
18347 &pAdapter->pno_comp_var,
18348 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
18349 if (0 >= ret)
18350 {
18351 // Did not receive the response for PNO enable in time.
18352 // Assuming the PNO enable was success.
18353 // Returning error from here, because we timeout, results
18354 // in side effect of Wifi (Wifi Setting) not to work.
18355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18356 FL("Timed out waiting for PNO to be Enabled"));
18357 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018358 }
18359
18360 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053018361 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018362
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018363error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18365 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053018366 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018367 if (pnoRequest.aNetworks)
18368 vos_mem_free(pnoRequest.aNetworks);
18369 if (pnoRequest.p24GProbeTemplate)
18370 vos_mem_free(pnoRequest.p24GProbeTemplate);
18371 if (pnoRequest.p5GProbeTemplate)
18372 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018373
18374 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018375 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018376}
18377
18378/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053018379 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
18380 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018381 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053018382static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
18383 struct net_device *dev, struct cfg80211_sched_scan_request *request)
18384{
18385 int ret;
18386
18387 vos_ssr_protect(__func__);
18388 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
18389 vos_ssr_unprotect(__func__);
18390
18391 return ret;
18392}
18393
18394/*
18395 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
18396 * Function to disable PNO
18397 */
18398static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018399 struct net_device *dev)
18400{
18401 eHalStatus status = eHAL_STATUS_FAILURE;
18402 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18403 hdd_context_t *pHddCtx;
18404 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018405 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018406 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018407
18408 ENTER();
18409
18410 if (NULL == pAdapter)
18411 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018413 "%s: HDD adapter is Null", __func__);
18414 return -ENODEV;
18415 }
18416
18417 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018418
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018419 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018420 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018421 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018422 "%s: HDD context is Null", __func__);
18423 return -ENODEV;
18424 }
18425
18426 /* The return 0 is intentional when isLogpInProgress and
18427 * isLoadUnloadInProgress. We did observe a crash due to a return of
18428 * failure in sched_scan_stop , especially for a case where the unload
18429 * of the happens at the same time. The function __cfg80211_stop_sched_scan
18430 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
18431 * success. If it returns a failure , then its next invocation due to the
18432 * clean up of the second interface will have the dev pointer corresponding
18433 * to the first one leading to a crash.
18434 */
18435 if (pHddCtx->isLogpInProgress)
18436 {
18437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18438 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053018439 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018440 return ret;
18441 }
18442
Mihir Shete18156292014-03-11 15:38:30 +053018443 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018444 {
18445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18446 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
18447 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018448 }
18449
18450 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
18451 if (NULL == hHal)
18452 {
18453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18454 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018455 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018456 }
18457
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018458 pnoRequest.enable = 0; /* Disable PNO */
18459 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018460
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018461 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18462 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
18463 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053018464
18465 INIT_COMPLETION(pAdapter->pno_comp_var);
18466 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
18467 pnoRequest.callbackContext = pAdapter;
18468 pAdapter->pno_req_status = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018469 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018470 pAdapter->sessionId,
18471 NULL, pAdapter);
18472 if (eHAL_STATUS_SUCCESS != status)
18473 {
18474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18475 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018476 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018477 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018478 }
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053018479 ret = wait_for_completion_timeout(
18480 &pAdapter->pno_comp_var,
18481 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
18482 if (0 >= ret)
18483 {
18484 // Did not receive the response for PNO disable in time.
18485 // Assuming the PNO disable was success.
18486 // Returning error from here, because we timeout, results
18487 // in side effect of Wifi (Wifi Setting) not to work.
Anurag Chouhan96b41cb2016-09-28 18:54:47 +053018488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053018489 FL("Timed out waiting for PNO to be disabled"));
18490 ret = 0;
18491 }
18492
18493 ret = pAdapter->pno_req_status;
18494 pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018495
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018496error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018497 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018498 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018499
18500 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018501 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018502}
18503
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053018504/*
18505 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
18506 * NL interface to disable PNO
18507 */
18508static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
18509 struct net_device *dev)
18510{
18511 int ret;
18512
18513 vos_ssr_protect(__func__);
18514 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
18515 vos_ssr_unprotect(__func__);
18516
18517 return ret;
18518}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018519#endif /*FEATURE_WLAN_SCAN_PNO*/
18520
18521
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018522#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018523#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018524static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18525 struct net_device *dev,
18526 u8 *peer, u8 action_code,
18527 u8 dialog_token,
18528 u16 status_code, u32 peer_capability,
18529 const u8 *buf, size_t len)
18530#else /* TDLS_MGMT_VERSION2 */
18531#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
18532static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18533 struct net_device *dev,
18534 const u8 *peer, u8 action_code,
18535 u8 dialog_token, u16 status_code,
18536 u32 peer_capability, bool initiator,
18537 const u8 *buf, size_t len)
18538#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
18539static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18540 struct net_device *dev,
18541 const u8 *peer, u8 action_code,
18542 u8 dialog_token, u16 status_code,
18543 u32 peer_capability, const u8 *buf,
18544 size_t len)
18545#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
18546static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18547 struct net_device *dev,
18548 u8 *peer, u8 action_code,
18549 u8 dialog_token,
18550 u16 status_code, u32 peer_capability,
18551 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018552#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018553static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18554 struct net_device *dev,
18555 u8 *peer, u8 action_code,
18556 u8 dialog_token,
18557 u16 status_code, const u8 *buf,
18558 size_t len)
18559#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018560#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018561{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053018562 hdd_adapter_t *pAdapter;
18563 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018564 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070018565 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080018566 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070018567 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018568 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053018569 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018570#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018571 u32 peer_capability = 0;
18572#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018573 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018574 hdd_station_ctx_t *pHddStaCtx = NULL;
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018575 tdlsCtx_t *pHddTdlsCtx;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018576
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053018577 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18578 if (NULL == pAdapter)
18579 {
18580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18581 "%s: Adapter is NULL",__func__);
18582 return -EINVAL;
18583 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018584 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18585 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
18586 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018587
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053018588 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018589 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018590 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018591 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018592 "Invalid arguments");
18593 return -EINVAL;
18594 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018595
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018596 if (pHddCtx->isLogpInProgress)
18597 {
18598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18599 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053018600 wlan_hdd_tdls_set_link_status(pAdapter,
18601 peer,
18602 eTDLS_LINK_IDLE,
18603 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018604 return -EBUSY;
18605 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018606
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053018607 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
18608 {
18609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18610 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
18611 return -EAGAIN;
18612 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018613
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018614 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
18615 if (!pHddTdlsCtx) {
18616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18617 "%s: pHddTdlsCtx not valid.", __func__);
18618 }
18619
Hoonki Lee27511902013-03-14 18:19:06 -070018620 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018621 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018622 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070018623 "%s: TDLS mode is disabled OR not enabled in FW."
18624 MAC_ADDRESS_STR " action %d declined.",
18625 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018626 return -ENOTSUPP;
18627 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018628
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018629 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18630
18631 if( NULL == pHddStaCtx )
18632 {
18633 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18634 "%s: HDD station context NULL ",__func__);
18635 return -EINVAL;
18636 }
18637
18638 /* STA should be connected and authenticated
18639 * before sending any TDLS frames
18640 */
18641 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
18642 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
18643 {
18644 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18645 "STA is not connected or unauthenticated. "
18646 "connState %u, uIsAuthenticated %u",
18647 pHddStaCtx->conn_info.connState,
18648 pHddStaCtx->conn_info.uIsAuthenticated);
18649 return -EAGAIN;
18650 }
18651
Hoonki Lee27511902013-03-14 18:19:06 -070018652 /* other than teardown frame, other mgmt frames are not sent if disabled */
18653 if (SIR_MAC_TDLS_TEARDOWN != action_code)
18654 {
18655 /* if tdls_mode is disabled to respond to peer's request */
18656 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
18657 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018658 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070018659 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070018660 " TDLS mode is disabled. action %d declined.",
18661 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070018662
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018663 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070018664 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053018665
18666 if (vos_max_concurrent_connections_reached())
18667 {
18668 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
18669 return -EINVAL;
18670 }
Hoonki Lee27511902013-03-14 18:19:06 -070018671 }
18672
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018673 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
18674 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053018675 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018676 {
18677 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018678 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070018679 " TDLS setup is ongoing. action %d declined.",
18680 __func__, MAC_ADDR_ARRAY(peer), action_code);
18681 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018682 }
18683 }
18684
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018685 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
18686 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080018687 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018688 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18689 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080018690 {
18691 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
18692 we return error code at 'add_station()'. Hence we have this
18693 check again in addtion to add_station().
18694 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018695 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080018696 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018697 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18698 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018699 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
18700 __func__, MAC_ADDR_ARRAY(peer), action_code,
18701 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053018702 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080018703 }
18704 else
18705 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018706 /* maximum reached. tweak to send error code to peer and return
18707 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080018708 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018709 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18710 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018711 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
18712 __func__, MAC_ADDR_ARRAY(peer), status_code,
18713 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070018714 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018715 /* fall through to send setup resp with failure status
18716 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080018717 }
18718 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018719 else
18720 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018721 mutex_lock(&pHddCtx->tdls_lock);
18722 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018723 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018724 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018725 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018726 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070018727 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
18728 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018729 return -EPERM;
18730 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018731 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018732 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018733 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018734
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018735 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053018736 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018737 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
18738 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018739
Hoonki Leea34dd892013-02-05 22:56:02 -080018740 /*Except teardown responder will not be used so just make 0*/
18741 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018742 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080018743 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018744
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018745 mutex_lock(&pHddCtx->tdls_lock);
18746 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018747
18748 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
18749 responder = pTdlsPeer->is_responder;
18750 else
Hoonki Leea34dd892013-02-05 22:56:02 -080018751 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018752 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053018753 "%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 -070018754 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
18755 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018756 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018757 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080018758 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018759 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018760 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018761
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053018762 /* Discard TDLS setup if peer is removed by user app */
18763 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
18764 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
18765 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
18766 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
18767
18768 mutex_lock(&pHddCtx->tdls_lock);
18769 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18770 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
18771 mutex_unlock(&pHddCtx->tdls_lock);
18772 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
18773 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
18774 MAC_ADDR_ARRAY(peer), action_code);
18775 return -EINVAL;
18776 }
18777 mutex_unlock(&pHddCtx->tdls_lock);
18778 }
18779
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053018780 /* For explicit trigger of DIS_REQ come out of BMPS for
18781 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070018782 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Deepthi Gowrif78f1f72016-03-21 13:13:28 +053018783 (SIR_MAC_TDLS_SETUP_CNF== action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053018784 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
18785 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070018786 {
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018787 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018788 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018789 "%s: Sending frame action_code %u.Disable BMPS", __func__,
18790 action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018791 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
18792 if (status != VOS_STATUS_SUCCESS) {
18793 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018794 } else {
18795 pHddTdlsCtx->is_tdls_disabled_bmps = true;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018796 }
Hoonki Lee14621352013-04-16 17:51:19 -070018797 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018798 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018799 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018800 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
18801 }
18802 }
Hoonki Lee14621352013-04-16 17:51:19 -070018803 }
18804
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018805 /* make sure doesn't call send_mgmt() while it is pending */
18806 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
18807 {
18808 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080018809 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018810 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018811 ret = -EBUSY;
18812 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018813 }
18814
18815 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018816 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
18817
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018818 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
18819 pAdapter->sessionId, peer, action_code, dialog_token,
18820 status_code, peer_capability, (tANI_U8 *)buf, len,
18821 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018822
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018823 if (VOS_STATUS_SUCCESS != status)
18824 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18826 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018827 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018828 ret = -EINVAL;
18829 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018830 }
18831
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18833 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
18834 WAIT_TIME_TDLS_MGMT);
18835
Hoonki Leed37cbb32013-04-20 00:31:14 -070018836 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
18837 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
18838
18839 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018840 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070018841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070018842 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070018843 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018844 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080018845
18846 if (pHddCtx->isLogpInProgress)
18847 {
18848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18849 "%s: LOGP in Progress. Ignore!!!", __func__);
18850 return -EAGAIN;
18851 }
Abhishek Singh837adf22015-10-01 17:37:37 +053018852 if (rc <= 0)
18853 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
18854 WLAN_LOG_INDICATOR_HOST_DRIVER,
18855 WLAN_LOG_REASON_HDD_TIME_OUT,
18856 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080018857
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018858 ret = -EINVAL;
18859 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018860 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018861 else
18862 {
18863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18864 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
18865 __func__, rc, pAdapter->mgmtTxCompletionStatus);
18866 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018867
Gopichand Nakkala05922802013-03-14 12:23:19 -070018868 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070018869 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018870 ret = max_sta_failed;
18871 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070018872 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018873
Hoonki Leea34dd892013-02-05 22:56:02 -080018874 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
18875 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018876 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018877 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
18878 }
Hoonki Leea34dd892013-02-05 22:56:02 -080018879 }
18880 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
18881 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018882 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018883 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
18884 }
Hoonki Leea34dd892013-02-05 22:56:02 -080018885 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018886
18887 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018888
18889tx_failed:
18890 /* add_station will be called before sending TDLS_SETUP_REQ and
18891 * TDLS_SETUP_RSP and as part of add_station driver will enable
18892 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
18893 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
18894 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
18895 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
18896 */
18897
18898 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
18899 (SIR_MAC_TDLS_SETUP_RSP == action_code))
18900 wlan_hdd_tdls_check_bmps(pAdapter);
18901 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018902}
18903
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018904#if TDLS_MGMT_VERSION2
18905static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
18906 u8 *peer, u8 action_code, u8 dialog_token,
18907 u16 status_code, u32 peer_capability,
18908 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018909#else /* TDLS_MGMT_VERSION2 */
18910#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
18911static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18912 struct net_device *dev,
18913 const u8 *peer, u8 action_code,
18914 u8 dialog_token, u16 status_code,
18915 u32 peer_capability, bool initiator,
18916 const u8 *buf, size_t len)
18917#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
18918static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18919 struct net_device *dev,
18920 const u8 *peer, u8 action_code,
18921 u8 dialog_token, u16 status_code,
18922 u32 peer_capability, const u8 *buf,
18923 size_t len)
18924#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
18925static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18926 struct net_device *dev,
18927 u8 *peer, u8 action_code,
18928 u8 dialog_token,
18929 u16 status_code, u32 peer_capability,
18930 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018931#else
18932static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
18933 u8 *peer, u8 action_code, u8 dialog_token,
18934 u16 status_code, const u8 *buf, size_t len)
18935#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018936#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018937{
18938 int ret;
18939
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018940 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018941#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018942 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18943 dialog_token, status_code,
18944 peer_capability, buf, len);
18945#else /* TDLS_MGMT_VERSION2 */
18946#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
18947 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18948 dialog_token, status_code,
18949 peer_capability, initiator,
18950 buf, len);
18951#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
18952 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18953 dialog_token, status_code,
18954 peer_capability, buf, len);
18955#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
18956 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18957 dialog_token, status_code,
18958 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018959#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018960 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18961 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018962#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018963#endif
18964 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018965
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018966 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018967}
Atul Mittal115287b2014-07-08 13:26:33 +053018968
18969int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018970#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18971 const u8 *peer,
18972#else
Atul Mittal115287b2014-07-08 13:26:33 +053018973 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018974#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018975 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053018976 cfg80211_exttdls_callback callback)
18977{
18978
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018979 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053018980 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018981 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053018982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18983 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
18984 __func__, MAC_ADDR_ARRAY(peer));
18985
18986 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
18987 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
18988
18989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018990 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
18991 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
18992 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053018993 return -ENOTSUPP;
18994 }
18995
18996 /* To cater the requirement of establishing the TDLS link
18997 * irrespective of the data traffic , get an entry of TDLS peer.
18998 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053018999 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053019000 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
19001 if (pTdlsPeer == NULL) {
19002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19003 "%s: peer " MAC_ADDRESS_STR " not existing",
19004 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053019005 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053019006 return -EINVAL;
19007 }
19008
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053019009 /* check FW TDLS Off Channel capability */
19010 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053019011 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053019012 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019013 {
19014 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
19015 pTdlsPeer->peerParams.global_operating_class =
19016 tdls_peer_params->global_operating_class;
19017 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
19018 pTdlsPeer->peerParams.min_bandwidth_kbps =
19019 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053019020 /* check configured channel is valid, non dfs and
19021 * not current operating channel */
19022 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
19023 tdls_peer_params->channel)) &&
19024 (pHddStaCtx) &&
19025 (tdls_peer_params->channel !=
19026 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019027 {
19028 pTdlsPeer->isOffChannelConfigured = TRUE;
19029 }
19030 else
19031 {
19032 pTdlsPeer->isOffChannelConfigured = FALSE;
19033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19034 "%s: Configured Tdls Off Channel is not valid", __func__);
19035
19036 }
19037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053019038 "%s: tdls_off_channel %d isOffChannelConfigured %d "
19039 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019040 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053019041 pTdlsPeer->isOffChannelConfigured,
19042 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019043 }
19044 else
19045 {
19046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053019047 "%s: TDLS off channel FW capability %d, "
19048 "host capab %d or Invalid TDLS Peer Params", __func__,
19049 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
19050 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019051 }
19052
Atul Mittal115287b2014-07-08 13:26:33 +053019053 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
19054
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019055 mutex_unlock(&pHddCtx->tdls_lock);
19056
Atul Mittal115287b2014-07-08 13:26:33 +053019057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19058 " %s TDLS Add Force Peer Failed",
19059 __func__);
19060 return -EINVAL;
19061 }
19062 /*EXT TDLS*/
19063
19064 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019065 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053019066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19067 " %s TDLS set callback Failed",
19068 __func__);
19069 return -EINVAL;
19070 }
19071
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019072 mutex_unlock(&pHddCtx->tdls_lock);
19073
Atul Mittal115287b2014-07-08 13:26:33 +053019074 return(0);
19075
19076}
19077
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019078int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
19079#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
19080 const u8 *peer
19081#else
19082 u8 *peer
19083#endif
19084)
Atul Mittal115287b2014-07-08 13:26:33 +053019085{
19086
19087 hddTdlsPeer_t *pTdlsPeer;
19088 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053019089
Atul Mittal115287b2014-07-08 13:26:33 +053019090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19091 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
19092 __func__, MAC_ADDR_ARRAY(peer));
19093
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053019094 if (0 != wlan_hdd_validate_context(pHddCtx)) {
19095 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
19096 return -EINVAL;
19097 }
19098
Atul Mittal115287b2014-07-08 13:26:33 +053019099 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
19100 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
19101
19102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019103 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
19104 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
19105 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053019106 return -ENOTSUPP;
19107 }
19108
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019109 mutex_lock(&pHddCtx->tdls_lock);
19110 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053019111
19112 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019113 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053019114 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019115 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053019116 __func__, MAC_ADDR_ARRAY(peer));
19117 return -EINVAL;
19118 }
19119 else {
19120 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
19121 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053019122 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL,
19123 pTdlsPeer->peerMac);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019124 /* if channel switch is configured, reset
19125 the channel for this peer */
19126 if (TRUE == pTdlsPeer->isOffChannelConfigured)
19127 {
19128 pTdlsPeer->peerParams.channel = 0;
19129 pTdlsPeer->isOffChannelConfigured = FALSE;
19130 }
Atul Mittal115287b2014-07-08 13:26:33 +053019131 }
19132
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019133 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019134 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019135 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053019136 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019137 }
Atul Mittal115287b2014-07-08 13:26:33 +053019138
19139 /*EXT TDLS*/
19140
19141 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019142 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053019143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19144 " %s TDLS set callback Failed",
19145 __func__);
19146 return -EINVAL;
19147 }
Atul Mittal115287b2014-07-08 13:26:33 +053019148
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019149 mutex_unlock(&pHddCtx->tdls_lock);
19150
19151 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053019152}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019153static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019154#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
19155 const u8 *peer,
19156#else
19157 u8 *peer,
19158#endif
19159 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019160{
19161 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19162 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019163 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070019164 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019165
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019166 ENTER();
19167
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053019168 if (!pAdapter) {
19169 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
19170 return -EINVAL;
19171 }
19172
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019173 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19174 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
19175 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019176 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019177 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080019178 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070019179 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019180 return -EINVAL;
19181 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080019182
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019183 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019184 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080019185 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019186 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080019187 }
19188
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019189
19190 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080019191 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019192 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080019193 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019194 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
19195 "Cannot process TDLS commands",
19196 pHddCtx->cfg_ini->fEnableTDLSSupport,
19197 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019198 return -ENOTSUPP;
19199 }
19200
19201 switch (oper) {
19202 case NL80211_TDLS_ENABLE_LINK:
19203 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019204 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019205 long ret;
Hanumantha Reddy Pothulada389492016-02-11 17:29:27 +053019206 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams = { {0}, 0,
19207 0, 0, 0, 0, 0, 0, {0}, 0, {0} };
Agarwal Ashish16020c42014-12-29 22:01:11 +053019208 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019209 tANI_U16 numCurrTdlsPeers = 0;
19210 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053019211 tANI_U8 suppChannelLen = 0;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019212 tSirMacAddr peerMac;
19213 int channel;
19214 tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019215
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19217 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
19218 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019219
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019220 mutex_lock(&pHddCtx->tdls_lock);
19221 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053019222 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053019223 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019224 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019225 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
19226 " (oper %d) not exsting. ignored",
19227 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
19228 return -EINVAL;
19229 }
19230
19231 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19232 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
19233 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
19234 "NL80211_TDLS_ENABLE_LINK");
19235
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070019236 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
19237 {
19238 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
19239 MAC_ADDRESS_STR " failed",
19240 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019241 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070019242 return -EINVAL;
19243 }
19244
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053019245 /* before starting tdls connection, set tdls
19246 * off channel established status to default value */
19247 pTdlsPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019248
19249 mutex_unlock(&pHddCtx->tdls_lock);
19250
Deepthi Gowri2d85bbf2016-07-25 15:43:31 +053019251 wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019252 /* TDLS Off Channel, Disable tdls channel switch,
19253 when there are more than one tdls link */
19254 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053019255 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019256 {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019257 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019258 /* get connected peer and send disable tdls off chan */
19259 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019260 if ((connPeer) &&
19261 (connPeer->isOffChannelSupported == TRUE) &&
19262 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019263 {
19264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19265 "%s: More then one peer connected, Disable "
19266 "TDLS channel switch", __func__);
19267
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053019268 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019269 vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr));
19270 channel = connPeer->peerParams.channel;
19271
19272 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019273
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019274 ret = sme_SendTdlsChanSwitchReq(
19275 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019276 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019277 peerMac,
19278 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019279 TDLS_OFF_CHANNEL_BW_OFFSET,
19280 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019281 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019282 hddLog(VOS_TRACE_LEVEL_ERROR,
19283 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019284 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019285 }
19286 else
19287 {
19288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19289 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019290 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019291 "isOffChannelConfigured %d",
19292 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019293 (connPeer ? (connPeer->isOffChannelSupported)
19294 : -1),
19295 (connPeer ? (connPeer->isOffChannelConfigured)
19296 : -1));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019297 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019298 }
19299 }
19300
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019301 mutex_lock(&pHddCtx->tdls_lock);
19302 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
19303 if ( NULL == pTdlsPeer ) {
19304 mutex_unlock(&pHddCtx->tdls_lock);
19305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19306 "%s: " MAC_ADDRESS_STR
19307 " (oper %d) peer got freed in other context. ignored",
19308 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
19309 return -EINVAL;
19310 }
19311 peer_status = pTdlsPeer->link_status;
19312 mutex_unlock(&pHddCtx->tdls_lock);
19313
19314 if (eTDLS_LINK_CONNECTED != peer_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019315 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053019316 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053019317
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053019318 if (0 != wlan_hdd_tdls_get_link_establish_params(
19319 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019320 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053019321 return -EINVAL;
19322 }
19323 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053019324
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019325 ret = sme_SendTdlsLinkEstablishParams(
19326 WLAN_HDD_GET_HAL_CTX(pAdapter),
19327 pAdapter->sessionId, peer,
19328 &tdlsLinkEstablishParams);
19329 if (ret != VOS_STATUS_SUCCESS) {
19330 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
19331 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053019332 /* Send TDLS peer UAPSD capabilities to the firmware and
19333 * register with the TL on after the response for this operation
19334 * is received .
19335 */
19336 ret = wait_for_completion_interruptible_timeout(
19337 &pAdapter->tdls_link_establish_req_comp,
19338 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Masti, Narayanraddie1892a52015-12-15 15:01:01 +053019339
19340 mutex_lock(&pHddCtx->tdls_lock);
19341 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
19342 if ( NULL == pTdlsPeer ) {
19343 mutex_unlock(&pHddCtx->tdls_lock);
19344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19345 "%s %d: " MAC_ADDRESS_STR
19346 " (oper %d) peer got freed in other context. ignored",
19347 __func__, __LINE__, MAC_ADDR_ARRAY(peer),
19348 (int)oper);
19349 return -EINVAL;
19350 }
19351 peer_status = pTdlsPeer->link_status;
19352 mutex_unlock(&pHddCtx->tdls_lock);
19353
19354 if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING))
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053019355 {
19356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019357 FL("Link Establish Request Failed Status %ld"),
19358 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053019359 return -EINVAL;
19360 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053019361 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019362
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019363 mutex_lock(&pHddCtx->tdls_lock);
19364 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
19365 if ( NULL == pTdlsPeer ) {
19366 mutex_unlock(&pHddCtx->tdls_lock);
19367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19368 "%s: " MAC_ADDRESS_STR
19369 " (oper %d) peer got freed in other context. ignored",
19370 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
19371 return -EINVAL;
19372 }
19373
Atul Mittal115287b2014-07-08 13:26:33 +053019374 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
19375 eTDLS_LINK_CONNECTED,
19376 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053019377 staDesc.ucSTAId = pTdlsPeer->staId;
19378 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053019379
19380 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19381 "%s: tdlsLinkEstablishParams of peer "
19382 MAC_ADDRESS_STR "uapsdQueues: %d"
19383 "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d"
19384 "isResponder: %d peerstaId: %d",
19385 __func__,
19386 MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac),
19387 tdlsLinkEstablishParams.uapsdQueues,
19388 tdlsLinkEstablishParams.qos,
19389 tdlsLinkEstablishParams.maxSp,
19390 tdlsLinkEstablishParams.isBufSta,
19391 tdlsLinkEstablishParams.isOffChannelSupported,
19392 tdlsLinkEstablishParams.isResponder,
19393 pTdlsPeer->staId);
19394
19395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19396 "%s: StaDesc ucSTAId: %d ucQosEnabled: %d",
19397 __func__,
19398 staDesc.ucSTAId,
19399 staDesc.ucQosEnabled);
19400
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019401 ret = WLANTL_UpdateTdlsSTAClient(
19402 pHddCtx->pvosContext,
19403 &staDesc);
19404 if (ret != VOS_STATUS_SUCCESS) {
19405 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
19406 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053019407
Gopichand Nakkala471708b2013-06-04 20:03:01 +053019408 /* Mark TDLS client Authenticated .*/
19409 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
19410 pTdlsPeer->staId,
19411 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070019412 if (VOS_STATUS_SUCCESS == status)
19413 {
Hoonki Lee14621352013-04-16 17:51:19 -070019414 if (pTdlsPeer->is_responder == 0)
19415 {
19416 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053019417 tdlsConnInfo_t *tdlsInfo;
19418
19419 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
19420
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053019421 if (!vos_timer_is_initialized(
19422 &pTdlsPeer->initiatorWaitTimeoutTimer))
19423 {
19424 /* Initialize initiator wait callback */
19425 vos_timer_init(
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053019426 &pTdlsPeer->initiatorWaitTimeoutTimer,
19427 VOS_TIMER_TYPE_SW,
19428 wlan_hdd_tdls_initiator_wait_cb,
19429 tdlsInfo);
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053019430 }
Hoonki Lee14621352013-04-16 17:51:19 -070019431 wlan_hdd_tdls_timer_restart(pAdapter,
19432 &pTdlsPeer->initiatorWaitTimeoutTimer,
19433 WAIT_TIME_TDLS_INITIATOR);
19434 /* suspend initiator TX until it receives direct packet from the
19435 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019436 ret = WLANTL_SuspendDataTx(
19437 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
19438 &staId, NULL);
19439 if (ret != VOS_STATUS_SUCCESS) {
19440 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
19441 }
Hoonki Lee14621352013-04-16 17:51:19 -070019442 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019443
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053019444 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019445 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053019446 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019447 suppChannelLen =
19448 tdlsLinkEstablishParams.supportedChannelsLen;
19449
19450 if ((suppChannelLen > 0) &&
19451 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
19452 {
19453 tANI_U8 suppPeerChannel = 0;
19454 int i = 0;
19455 for (i = 0U; i < suppChannelLen; i++)
19456 {
19457 suppPeerChannel =
19458 tdlsLinkEstablishParams.supportedChannels[i];
19459
19460 pTdlsPeer->isOffChannelSupported = FALSE;
19461 if (suppPeerChannel ==
19462 pTdlsPeer->peerParams.channel)
19463 {
19464 pTdlsPeer->isOffChannelSupported = TRUE;
19465 break;
19466 }
19467 }
19468 }
19469 else
19470 {
19471 pTdlsPeer->isOffChannelSupported = FALSE;
19472 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053019473 }
19474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19475 "%s: TDLS channel switch request for channel "
19476 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019477 "%d isOffChannelSupported %d", __func__,
19478 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053019479 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019480 suppChannelLen,
19481 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053019482
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019483 /* TDLS Off Channel, Enable tdls channel switch,
19484 when their is only one tdls link and it supports */
19485 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
19486 if ((numCurrTdlsPeers == 1) &&
19487 (TRUE == pTdlsPeer->isOffChannelSupported) &&
19488 (TRUE == pTdlsPeer->isOffChannelConfigured))
19489 {
19490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19491 "%s: Send TDLS channel switch request for channel %d",
19492 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053019493
19494 pTdlsPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019495 vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr));
19496 channel = pTdlsPeer->peerParams.channel;
19497
19498 mutex_unlock(&pHddCtx->tdls_lock);
19499
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019500 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
19501 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019502 peerMac,
19503 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019504 TDLS_OFF_CHANNEL_BW_OFFSET,
19505 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019506 if (ret != VOS_STATUS_SUCCESS) {
19507 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
19508 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019509 }
19510 else
19511 {
19512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19513 "%s: TDLS channel switch request not sent"
19514 " numCurrTdlsPeers %d "
19515 "isOffChannelSupported %d "
19516 "isOffChannelConfigured %d",
19517 __func__, numCurrTdlsPeers,
19518 pTdlsPeer->isOffChannelSupported,
19519 pTdlsPeer->isOffChannelConfigured);
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019520 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019521 }
19522
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070019523 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019524 else
19525 mutex_unlock(&pHddCtx->tdls_lock);
19526
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019527 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053019528
19529 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053019530 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
19531 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053019532 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053019533 int ac;
19534 uint8 ucAc[4] = { WLANTL_AC_VO,
19535 WLANTL_AC_VI,
19536 WLANTL_AC_BK,
19537 WLANTL_AC_BE };
19538 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
19539 for(ac=0; ac < 4; ac++)
19540 {
19541 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
19542 pTdlsPeer->staId, ucAc[ac],
19543 tlTid[ac], tlTid[ac], 0, 0,
19544 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019545 if (status != VOS_STATUS_SUCCESS) {
19546 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
19547 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053019548 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053019549 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019550 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019551
Bhargav Shah66896792015-10-01 18:17:37 +053019552 /* stop TCP delack timer if TDLS is enable */
19553 set_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
19554 hdd_manage_delack_timer(pHddCtx);
Abhishek Singh67fa6bc2016-01-05 15:57:19 +053019555 hdd_wlan_tdls_enable_link_event(peer,
19556 pTdlsPeer->isOffChannelSupported,
19557 pTdlsPeer->isOffChannelConfigured,
19558 pTdlsPeer->isOffChannelEstablished);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019559 }
19560 break;
19561 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080019562 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019563 tANI_U16 numCurrTdlsPeers = 0;
19564 hddTdlsPeer_t *connPeer = NULL;
19565
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19567 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
19568 __func__, MAC_ADDR_ARRAY(peer));
19569
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019570 mutex_lock(&pHddCtx->tdls_lock);
19571 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019572
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019573
Sunil Dutt41de4e22013-11-14 18:09:02 +053019574 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019575 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019576 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
19577 " (oper %d) not exsting. ignored",
19578 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
19579 return -EINVAL;
19580 }
19581
19582 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19583 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
19584 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
19585 "NL80211_TDLS_DISABLE_LINK");
19586
Hoonki Lee5305c3a2013-04-29 23:28:59 -070019587 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080019588 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070019589 long status;
19590
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053019591 /* set tdls off channel status to false for this peer */
19592 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053019593 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
19594 eTDLS_LINK_TEARING,
19595 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
19596 eTDLS_LINK_UNSPECIFIED:
19597 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019598 mutex_unlock(&pHddCtx->tdls_lock);
19599
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070019600 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
19601
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019602 status = sme_DeleteTdlsPeerSta(
19603 WLAN_HDD_GET_HAL_CTX(pAdapter),
19604 pAdapter->sessionId, peer );
19605 if (status != VOS_STATUS_SUCCESS) {
19606 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
19607 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070019608
19609 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
19610 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019611
19612 mutex_lock(&pHddCtx->tdls_lock);
19613 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
19614 if ( NULL == pTdlsPeer ) {
19615 mutex_unlock(&pHddCtx->tdls_lock);
19616 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
19617 " peer was freed in other context",
19618 __func__, MAC_ADDR_ARRAY(peer));
19619 return -EINVAL;
19620 }
19621
Atul Mittal271a7652014-09-12 13:18:22 +053019622 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053019623 eTDLS_LINK_IDLE,
19624 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019625 mutex_unlock(&pHddCtx->tdls_lock);
19626
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070019627 if (status <= 0)
19628 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070019629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19630 "%s: Del station failed status %ld",
19631 __func__, status);
19632 return -EPERM;
19633 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019634
19635 /* TDLS Off Channel, Enable tdls channel switch,
19636 when their is only one tdls link and it supports */
19637 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
19638 if (numCurrTdlsPeers == 1)
19639 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019640 tSirMacAddr peerMac;
19641 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053019642
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019643 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019644 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053019645
19646 if (connPeer == NULL) {
19647 mutex_unlock(&pHddCtx->tdls_lock);
19648 hddLog(VOS_TRACE_LEVEL_ERROR,
19649 "%s connPeer is NULL", __func__);
19650 return -EINVAL;
19651 }
19652
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019653 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
19654 channel = connPeer->peerParams.channel;
19655
19656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19657 "%s: TDLS channel switch "
19658 "isOffChannelSupported %d "
19659 "isOffChannelConfigured %d "
19660 "isOffChannelEstablished %d",
19661 __func__,
19662 (connPeer ? connPeer->isOffChannelSupported : -1),
19663 (connPeer ? connPeer->isOffChannelConfigured : -1),
19664 (connPeer ? connPeer->isOffChannelEstablished : -1));
19665
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019666 if ((connPeer) &&
19667 (connPeer->isOffChannelSupported == TRUE) &&
19668 (connPeer->isOffChannelConfigured == TRUE))
19669 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053019670 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019671 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019672 status = sme_SendTdlsChanSwitchReq(
19673 WLAN_HDD_GET_HAL_CTX(pAdapter),
19674 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019675 peerMac,
19676 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019677 TDLS_OFF_CHANNEL_BW_OFFSET,
19678 TDLS_CHANNEL_SWITCH_ENABLE);
19679 if (status != VOS_STATUS_SUCCESS) {
19680 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
19681 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019682 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019683 else
19684 mutex_unlock(&pHddCtx->tdls_lock);
19685 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019686 else
19687 {
19688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19689 "%s: TDLS channel switch request not sent "
19690 "numCurrTdlsPeers %d ",
19691 __func__, numCurrTdlsPeers);
19692 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080019693 }
19694 else
19695 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019696 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19698 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080019699 }
Bhargav Shah66896792015-10-01 18:17:37 +053019700 if (numCurrTdlsPeers == 0) {
19701 /* start TCP delack timer if TDLS is disable */
19702 clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
19703 hdd_manage_delack_timer(pHddCtx);
19704 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080019705 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019706 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019707 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053019708 {
Atul Mittal115287b2014-07-08 13:26:33 +053019709 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019710
Atul Mittal115287b2014-07-08 13:26:33 +053019711 if (0 != status)
19712 {
19713 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019714 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053019715 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053019716 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053019717 break;
19718 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019719 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053019720 {
Atul Mittal115287b2014-07-08 13:26:33 +053019721 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
19722 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019723 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053019724 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019725
Atul Mittal115287b2014-07-08 13:26:33 +053019726 if (0 != status)
19727 {
19728 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019729 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053019730 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053019731 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053019732 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053019733 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019734 case NL80211_TDLS_DISCOVERY_REQ:
19735 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019737 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019738 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019739 return -ENOTSUPP;
19740 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19742 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019743 return -ENOTSUPP;
19744 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019745
19746 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019747 return 0;
19748}
Chilam NG571c65a2013-01-19 12:27:36 +053019749
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019750static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019751#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
19752 const u8 *peer,
19753#else
19754 u8 *peer,
19755#endif
19756 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019757{
19758 int ret;
19759
19760 vos_ssr_protect(__func__);
19761 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
19762 vos_ssr_unprotect(__func__);
19763
19764 return ret;
19765}
19766
Chilam NG571c65a2013-01-19 12:27:36 +053019767int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
19768 struct net_device *dev, u8 *peer)
19769{
Arif Hussaina7c8e412013-11-20 11:06:42 -080019770 hddLog(VOS_TRACE_LEVEL_INFO,
19771 "tdls send discover req: "MAC_ADDRESS_STR,
19772 MAC_ADDR_ARRAY(peer));
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053019773#if TDLS_MGMT_VERSION2
19774 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19775 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19776#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019777#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
19778 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19779 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
19780#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
19781 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19782 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19783#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
19784 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19785 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19786#else
Chilam NG571c65a2013-01-19 12:27:36 +053019787 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19788 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053019789#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019790#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053019791}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019792#endif
19793
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019794#ifdef WLAN_FEATURE_GTK_OFFLOAD
19795/*
19796 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
19797 * Callback rountine called upon receiving response for
19798 * get offload info
19799 */
19800void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
19801 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
19802{
19803
19804 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019805 tANI_U8 tempReplayCounter[8];
19806 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019807
19808 ENTER();
19809
19810 if (NULL == pAdapter)
19811 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053019812 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019813 "%s: HDD adapter is Null", __func__);
19814 return ;
19815 }
19816
19817 if (NULL == pGtkOffloadGetInfoRsp)
19818 {
19819 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19820 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
19821 return ;
19822 }
19823
19824 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
19825 {
19826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19827 "%s: wlan Failed to get replay counter value",
19828 __func__);
19829 return ;
19830 }
19831
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019832 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19833 /* Update replay counter */
19834 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
19835 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
19836
19837 {
19838 /* changing from little to big endian since supplicant
19839 * works on big endian format
19840 */
19841 int i;
19842 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
19843
19844 for (i = 0; i < 8; i++)
19845 {
19846 tempReplayCounter[7-i] = (tANI_U8)p[i];
19847 }
19848 }
19849
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019850 /* Update replay counter to NL */
19851 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019852 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019853}
19854
19855/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019856 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019857 * This function is used to offload GTK rekeying job to the firmware.
19858 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019859int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019860 struct cfg80211_gtk_rekey_data *data)
19861{
19862 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19863 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
19864 hdd_station_ctx_t *pHddStaCtx;
19865 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019866 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019867 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019868 eHalStatus status = eHAL_STATUS_FAILURE;
19869
19870 ENTER();
19871
19872 if (NULL == pAdapter)
19873 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019874 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019875 "%s: HDD adapter is Null", __func__);
19876 return -ENODEV;
19877 }
19878
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019879 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19880 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
19881 pAdapter->sessionId, pAdapter->device_mode));
19882
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019883 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019884 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019885 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019886 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019887 }
19888
19889 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19890 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
19891 if (NULL == hHal)
19892 {
19893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19894 "%s: HAL context is Null!!!", __func__);
19895 return -EAGAIN;
19896 }
19897
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019898 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
19899 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
19900 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
19901 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019902 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019903 {
19904 /* changing from big to little endian since driver
19905 * works on little endian format
19906 */
19907 tANI_U8 *p =
19908 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
19909 int i;
19910
19911 for (i = 0; i < 8; i++)
19912 {
19913 p[7-i] = data->replay_ctr[i];
19914 }
19915 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019916
19917 if (TRUE == pHddCtx->hdd_wlan_suspended)
19918 {
19919 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019920 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
19921 sizeof (tSirGtkOffloadParams));
19922 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019923 pAdapter->sessionId);
19924
19925 if (eHAL_STATUS_SUCCESS != status)
19926 {
19927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19928 "%s: sme_SetGTKOffload failed, returned %d",
19929 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053019930
19931 /* Need to clear any trace of key value in the memory.
19932 * Thus zero out the memory even though it is local
19933 * variable.
19934 */
19935 vos_mem_zero(&hddGtkOffloadReqParams,
19936 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019937 return status;
19938 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19940 "%s: sme_SetGTKOffload successfull", __func__);
19941 }
19942 else
19943 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19945 "%s: wlan not suspended GTKOffload request is stored",
19946 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019947 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019948
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053019949 /* Need to clear any trace of key value in the memory.
19950 * Thus zero out the memory even though it is local
19951 * variable.
19952 */
19953 vos_mem_zero(&hddGtkOffloadReqParams,
19954 sizeof(hddGtkOffloadReqParams));
19955
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019956 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019957 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019958}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019959
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019960int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
19961 struct cfg80211_gtk_rekey_data *data)
19962{
19963 int ret;
19964
19965 vos_ssr_protect(__func__);
19966 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
19967 vos_ssr_unprotect(__func__);
19968
19969 return ret;
19970}
19971#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019972/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019973 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019974 * This function is used to set access control policy
19975 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019976static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
19977 struct net_device *dev,
19978 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019979{
19980 int i;
19981 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19982 hdd_hostapd_state_t *pHostapdState;
19983 tsap_Config_t *pConfig;
19984 v_CONTEXT_t pVosContext = NULL;
19985 hdd_context_t *pHddCtx;
19986 int status;
19987
19988 ENTER();
19989
19990 if (NULL == pAdapter)
19991 {
19992 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19993 "%s: HDD adapter is Null", __func__);
19994 return -ENODEV;
19995 }
19996
19997 if (NULL == params)
19998 {
19999 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
20000 "%s: params is Null", __func__);
20001 return -EINVAL;
20002 }
20003
20004 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
20005 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020006 if (0 != status)
20007 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020008 return status;
20009 }
20010
20011 pVosContext = pHddCtx->pvosContext;
20012 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
20013
20014 if (NULL == pHostapdState)
20015 {
20016 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
20017 "%s: pHostapdState is Null", __func__);
20018 return -EINVAL;
20019 }
20020
20021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
20022 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053020023 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20024 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
20025 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020026
20027 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
20028 {
20029 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
20030
20031 /* default value */
20032 pConfig->num_accept_mac = 0;
20033 pConfig->num_deny_mac = 0;
20034
20035 /**
20036 * access control policy
20037 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
20038 * listed in hostapd.deny file.
20039 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
20040 * listed in hostapd.accept file.
20041 */
20042 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
20043 {
20044 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
20045 }
20046 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
20047 {
20048 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
20049 }
20050 else
20051 {
20052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20053 "%s:Acl Policy : %d is not supported",
20054 __func__, params->acl_policy);
20055 return -ENOTSUPP;
20056 }
20057
20058 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
20059 {
20060 pConfig->num_accept_mac = params->n_acl_entries;
20061 for (i = 0; i < params->n_acl_entries; i++)
20062 {
20063 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20064 "** Add ACL MAC entry %i in WhiletList :"
20065 MAC_ADDRESS_STR, i,
20066 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
20067
20068 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
20069 sizeof(qcmacaddr));
20070 }
20071 }
20072 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
20073 {
20074 pConfig->num_deny_mac = params->n_acl_entries;
20075 for (i = 0; i < params->n_acl_entries; i++)
20076 {
20077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20078 "** Add ACL MAC entry %i in BlackList :"
20079 MAC_ADDRESS_STR, i,
20080 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
20081
20082 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
20083 sizeof(qcmacaddr));
20084 }
20085 }
20086
20087 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
20088 {
20089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20090 "%s: SAP Set Mac Acl fail", __func__);
20091 return -EINVAL;
20092 }
20093 }
20094 else
20095 {
20096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053020097 "%s: Invalid device_mode = %s (%d)",
20098 __func__, hdd_device_modetoString(pAdapter->device_mode),
20099 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020100 return -EINVAL;
20101 }
20102
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020103 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020104 return 0;
20105}
20106
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020107static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
20108 struct net_device *dev,
20109 const struct cfg80211_acl_data *params)
20110{
20111 int ret;
20112 vos_ssr_protect(__func__);
20113 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
20114 vos_ssr_unprotect(__func__);
20115
20116 return ret;
20117}
20118
Leo Chang9056f462013-08-01 19:21:11 -070020119#ifdef WLAN_NL80211_TESTMODE
20120#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070020121void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070020122(
20123 void *pAdapter,
20124 void *indCont
20125)
20126{
Leo Changd9df8aa2013-09-26 13:32:26 -070020127 tSirLPHBInd *lphbInd;
20128 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053020129 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070020130
20131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070020132 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070020133
c_hpothu73f35e62014-04-18 13:40:08 +053020134 if (pAdapter == NULL)
20135 {
20136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20137 "%s: pAdapter is NULL\n",__func__);
20138 return;
20139 }
20140
Leo Chang9056f462013-08-01 19:21:11 -070020141 if (NULL == indCont)
20142 {
20143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070020144 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070020145 return;
20146 }
20147
c_hpothu73f35e62014-04-18 13:40:08 +053020148 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070020149 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070020150 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053020151 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070020152 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070020153 GFP_ATOMIC);
20154 if (!skb)
20155 {
20156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20157 "LPHB timeout, NL buffer alloc fail");
20158 return;
20159 }
20160
Leo Changac3ba772013-10-07 09:47:04 -070020161 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070020162 {
20163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20164 "WLAN_HDD_TM_ATTR_CMD put fail");
20165 goto nla_put_failure;
20166 }
Leo Changac3ba772013-10-07 09:47:04 -070020167 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070020168 {
20169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20170 "WLAN_HDD_TM_ATTR_TYPE put fail");
20171 goto nla_put_failure;
20172 }
Leo Changac3ba772013-10-07 09:47:04 -070020173 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070020174 sizeof(tSirLPHBInd), lphbInd))
20175 {
20176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20177 "WLAN_HDD_TM_ATTR_DATA put fail");
20178 goto nla_put_failure;
20179 }
Leo Chang9056f462013-08-01 19:21:11 -070020180 cfg80211_testmode_event(skb, GFP_ATOMIC);
20181 return;
20182
20183nla_put_failure:
20184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20185 "NLA Put fail");
20186 kfree_skb(skb);
20187
20188 return;
20189}
20190#endif /* FEATURE_WLAN_LPHB */
20191
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053020192static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070020193{
20194 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
20195 int err = 0;
20196#ifdef FEATURE_WLAN_LPHB
20197 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070020198 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020199
20200 ENTER();
20201
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053020202 err = wlan_hdd_validate_context(pHddCtx);
20203 if (0 != err)
20204 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053020205 return err;
20206 }
Leo Chang9056f462013-08-01 19:21:11 -070020207#endif /* FEATURE_WLAN_LPHB */
20208
20209 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
20210 if (err)
20211 {
20212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20213 "%s Testmode INV ATTR", __func__);
20214 return err;
20215 }
20216
20217 if (!tb[WLAN_HDD_TM_ATTR_CMD])
20218 {
20219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20220 "%s Testmode INV CMD", __func__);
20221 return -EINVAL;
20222 }
20223
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053020224 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20225 TRACE_CODE_HDD_CFG80211_TESTMODE,
20226 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070020227 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
20228 {
20229#ifdef FEATURE_WLAN_LPHB
20230 /* Low Power Heartbeat configuration request */
20231 case WLAN_HDD_TM_CMD_WLAN_HB:
20232 {
20233 int buf_len;
20234 void *buf;
20235 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080020236 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070020237
20238 if (!tb[WLAN_HDD_TM_ATTR_DATA])
20239 {
20240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20241 "%s Testmode INV DATA", __func__);
20242 return -EINVAL;
20243 }
20244
20245 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
20246 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080020247
Manjeet Singh3c577442017-02-10 19:03:38 +053020248 if (buf_len > sizeof(*hb_params)) {
20249 hddLog(LOGE, FL("buf_len=%d exceeded hb_params size limit"),
20250 buf_len);
20251 return -ERANGE;
20252 }
20253
Amar Singhal05852702014-02-04 14:40:00 -080020254 hb_params_temp =(tSirLPHBReq *)buf;
20255 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
20256 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
20257 return -EINVAL;
20258
Leo Chang9056f462013-08-01 19:21:11 -070020259 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
20260 if (NULL == hb_params)
20261 {
20262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20263 "%s Request Buffer Alloc Fail", __func__);
20264 return -EINVAL;
20265 }
20266
Ashish Kumar Dhanotiya3a8c0a72017-07-13 18:58:59 +053020267 vos_mem_zero(hb_params, sizeof(tSirLPHBReq));
Leo Chang9056f462013-08-01 19:21:11 -070020268 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070020269 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
20270 hb_params,
20271 wlan_hdd_cfg80211_lphb_ind_handler);
20272 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070020273 {
Leo Changd9df8aa2013-09-26 13:32:26 -070020274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20275 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070020276 vos_mem_free(hb_params);
20277 }
Leo Chang9056f462013-08-01 19:21:11 -070020278 return 0;
20279 }
20280#endif /* FEATURE_WLAN_LPHB */
20281 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053020282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20283 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070020284 return -EOPNOTSUPP;
20285 }
20286
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020287 EXIT();
20288 return err;
Leo Chang9056f462013-08-01 19:21:11 -070020289}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053020290
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053020291static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
20292#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
20293 struct wireless_dev *wdev,
20294#endif
20295 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053020296{
20297 int ret;
20298
20299 vos_ssr_protect(__func__);
20300 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
20301 vos_ssr_unprotect(__func__);
20302
20303 return ret;
20304}
Leo Chang9056f462013-08-01 19:21:11 -070020305#endif /* CONFIG_NL80211_TESTMODE */
20306
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053020307extern void hdd_set_wlan_suspend_mode(bool suspend);
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053020308static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020309 struct net_device *dev,
20310 int idx, struct survey_info *survey)
20311{
20312 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
20313 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053020314 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020315 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053020316 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020317 v_S7_t snr,rssi;
20318 int status, i, j, filled = 0;
20319
20320 ENTER();
20321
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020322 if (NULL == pAdapter)
20323 {
20324 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
20325 "%s: HDD adapter is Null", __func__);
20326 return -ENODEV;
20327 }
20328
20329 if (NULL == wiphy)
20330 {
20331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
20332 "%s: wiphy is Null", __func__);
20333 return -ENODEV;
20334 }
20335
20336 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
20337 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020338 if (0 != status)
20339 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020340 return status;
20341 }
20342
Mihir Sheted9072e02013-08-21 17:02:29 +053020343 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
20344
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020345 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053020346 0 != pAdapter->survey_idx ||
20347 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020348 {
20349 /* The survey dump ops when implemented completely is expected to
20350 * return a survey of all channels and the ops is called by the
20351 * kernel with incremental values of the argument 'idx' till it
20352 * returns -ENONET. But we can only support the survey for the
20353 * operating channel for now. survey_idx is used to track
20354 * that the ops is called only once and then return -ENONET for
20355 * the next iteration
20356 */
20357 pAdapter->survey_idx = 0;
20358 return -ENONET;
20359 }
20360
Mukul Sharma9d5233b2015-06-11 20:28:20 +053020361 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
20362 {
20363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20364 "%s: Roaming in progress, hence return ", __func__);
20365 return -ENONET;
20366 }
20367
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020368 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
20369
20370 wlan_hdd_get_snr(pAdapter, &snr);
20371 wlan_hdd_get_rssi(pAdapter, &rssi);
20372
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053020373 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20374 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
20375 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020376 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
20377 hdd_wlan_get_freq(channel, &freq);
20378
20379
20380 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
20381 {
20382 if (NULL == wiphy->bands[i])
20383 {
20384 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
20385 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
20386 continue;
20387 }
20388
20389 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
20390 {
20391 struct ieee80211_supported_band *band = wiphy->bands[i];
20392
20393 if (band->channels[j].center_freq == (v_U16_t)freq)
20394 {
20395 survey->channel = &band->channels[j];
20396 /* The Rx BDs contain SNR values in dB for the received frames
20397 * while the supplicant expects noise. So we calculate and
20398 * return the value of noise (dBm)
20399 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
20400 */
20401 survey->noise = rssi - snr;
20402 survey->filled = SURVEY_INFO_NOISE_DBM;
20403 filled = 1;
20404 }
20405 }
20406 }
20407
20408 if (filled)
20409 pAdapter->survey_idx = 1;
20410 else
20411 {
20412 pAdapter->survey_idx = 0;
20413 return -ENONET;
20414 }
20415
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020416 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020417 return 0;
20418}
20419
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053020420static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
20421 struct net_device *dev,
20422 int idx, struct survey_info *survey)
20423{
20424 int ret;
20425
20426 vos_ssr_protect(__func__);
20427 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
20428 vos_ssr_unprotect(__func__);
20429
20430 return ret;
20431}
20432
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020433/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053020434 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020435 * this is called when cfg80211 driver resume
20436 * driver updates latest sched_scan scan result(if any) to cfg80211 database
20437 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053020438int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020439{
20440 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
20441 hdd_adapter_t *pAdapter;
20442 hdd_adapter_list_node_t *pAdapterNode, *pNext;
20443 VOS_STATUS status = VOS_STATUS_SUCCESS;
20444
20445 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020446
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020447 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020448 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020449 return 0;
20450 }
20451
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053020452 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
20453 NO_SESSION, pHddCtx->isWiphySuspended));
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053020454
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053020455 if (pHddCtx->is_ap_mode_wow_supported)
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053020456 {
20457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20458 "%s: Resume SoftAP", __func__);
20459 hdd_set_wlan_suspend_mode(false);
20460 }
20461
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020462 spin_lock(&pHddCtx->schedScan_lock);
20463 pHddCtx->isWiphySuspended = FALSE;
20464 if (TRUE != pHddCtx->isSchedScanUpdatePending)
20465 {
20466 spin_unlock(&pHddCtx->schedScan_lock);
20467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20468 "%s: Return resume is not due to PNO indication", __func__);
20469 return 0;
20470 }
20471 // Reset flag to avoid updatating cfg80211 data old results again
20472 pHddCtx->isSchedScanUpdatePending = FALSE;
20473 spin_unlock(&pHddCtx->schedScan_lock);
20474
20475 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
20476
20477 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
20478 {
20479 pAdapter = pAdapterNode->pAdapter;
20480 if ( (NULL != pAdapter) &&
20481 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
20482 {
20483 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053020484 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
20486 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053020487 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020488 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053020489 {
20490 /* Acquire wakelock to handle the case where APP's tries to
20491 * suspend immediately after updating the scan results. Whis
20492 * results in app's is in suspended state and not able to
20493 * process the connect request to AP
20494 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053020495 hdd_prevent_suspend_timeout(2000,
20496 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020497 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053020498 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020499
20500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20501 "%s : cfg80211 scan result database updated", __func__);
20502
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020503 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020504 return 0;
20505
20506 }
20507 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
20508 pAdapterNode = pNext;
20509 }
20510
20511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20512 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020513 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020514 return 0;
20515}
20516
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053020517int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
20518{
20519 int ret;
20520
20521 vos_ssr_protect(__func__);
20522 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
20523 vos_ssr_unprotect(__func__);
20524
20525 return ret;
20526}
20527
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020528/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053020529 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020530 * this is called when cfg80211 driver suspends
20531 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053020532int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020533 struct cfg80211_wowlan *wow)
20534{
20535 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053020536 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020537
20538 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020539
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053020540 ret = wlan_hdd_validate_context(pHddCtx);
20541 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020542 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053020543 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020544 }
20545
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053020546 if (pHddCtx->is_ap_mode_wow_supported) {
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053020547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20548 "%s: Suspend SoftAP", __func__);
20549 hdd_set_wlan_suspend_mode(true);
20550 }
20551
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053020552
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053020553 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20554 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
20555 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020556 pHddCtx->isWiphySuspended = TRUE;
20557
20558 EXIT();
20559
20560 return 0;
20561}
20562
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053020563int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
20564 struct cfg80211_wowlan *wow)
20565{
20566 int ret;
20567
20568 vos_ssr_protect(__func__);
20569 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
20570 vos_ssr_unprotect(__func__);
20571
20572 return ret;
20573}
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053020574
20575#ifdef FEATURE_OEM_DATA_SUPPORT
20576static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053020577 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053020578{
20579 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
20580
20581 ENTER();
20582
20583 if (wlan_hdd_validate_context(pHddCtx)) {
20584 return;
20585 }
20586 if (!pMsg)
20587 {
20588 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
20589 return;
20590 }
20591
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053020592 send_oem_data_rsp_msg(evLen, pMsg);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053020593
20594 EXIT();
20595 return;
20596
20597}
20598
20599void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053020600 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053020601{
20602 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
20603
20604 ENTER();
20605
20606 if (wlan_hdd_validate_context(pHddCtx)) {
20607 return;
20608 }
20609
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053020610 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d) evLen %d"), evType, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053020611
20612 switch(evType) {
20613 case SIR_HAL_START_OEM_DATA_RSP_IND_NEW:
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053020614 wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053020615 break;
20616 default:
20617 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
20618 break;
20619 }
20620 EXIT();
20621}
20622#endif
20623
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020624#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
20625 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053020626/**
20627 * __wlan_hdd_cfg80211_abort_scan() - cfg80211 abort scan api
20628 * @wiphy: Pointer to wiphy
20629 * @wdev: Pointer to wireless device structure
20630 *
20631 * This function is used to abort an ongoing scan
20632 *
20633 * Return: None
20634 */
20635static void __wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
20636 struct wireless_dev *wdev)
20637{
20638 struct net_device *dev = wdev->netdev;
20639 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
20640 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
20641 int ret;
20642
20643 ENTER();
20644
20645 if (NULL == adapter) {
20646 hddLog(VOS_TRACE_LEVEL_FATAL, FL("HDD adapter is NULL"));
20647 return;
20648 }
20649
20650 ret = wlan_hdd_validate_context(hdd_ctx);
20651 if (0 != ret)
20652 return;
20653
20654 wlan_hdd_scan_abort(adapter);
20655
20656 return;
20657}
20658
20659/**
20660 * wlan_hdd_cfg80211_abort_scan - cfg80211 abort scan api
20661 * @wiphy: Pointer to wiphy
20662 * @wdev: Pointer to wireless device structure
20663 *
20664 * Return: None
20665 */
20666void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
20667 struct wireless_dev *wdev)
20668{
20669 vos_ssr_protect(__func__);
20670 __wlan_hdd_cfg80211_abort_scan(wiphy, wdev);
20671 vos_ssr_unprotect(__func__);
20672
20673 return;
20674}
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020675#endif
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053020676
Jeff Johnson295189b2012-06-20 16:38:30 -070020677/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053020678static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070020679{
20680 .add_virtual_intf = wlan_hdd_add_virtual_intf,
20681 .del_virtual_intf = wlan_hdd_del_virtual_intf,
20682 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
20683 .change_station = wlan_hdd_change_station,
20684#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
20685 .add_beacon = wlan_hdd_cfg80211_add_beacon,
20686 .del_beacon = wlan_hdd_cfg80211_del_beacon,
20687 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070020688#else
20689 .start_ap = wlan_hdd_cfg80211_start_ap,
20690 .change_beacon = wlan_hdd_cfg80211_change_beacon,
20691 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070020692#endif
20693 .change_bss = wlan_hdd_cfg80211_change_bss,
20694 .add_key = wlan_hdd_cfg80211_add_key,
20695 .get_key = wlan_hdd_cfg80211_get_key,
20696 .del_key = wlan_hdd_cfg80211_del_key,
20697 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080020698#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070020699 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080020700#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070020701 .scan = wlan_hdd_cfg80211_scan,
20702 .connect = wlan_hdd_cfg80211_connect,
20703 .disconnect = wlan_hdd_cfg80211_disconnect,
20704 .join_ibss = wlan_hdd_cfg80211_join_ibss,
20705 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
20706 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
20707 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
20708 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070020709 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
20710 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053020711 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070020712#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
20713 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
20714 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
20715 .set_txq_params = wlan_hdd_set_txq_params,
20716#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070020717 .get_station = wlan_hdd_cfg80211_get_station,
20718 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
20719 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070020720 .add_station = wlan_hdd_cfg80211_add_station,
20721#ifdef FEATURE_WLAN_LFR
20722 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
20723 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
20724 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
20725#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070020726#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
20727 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
20728#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020729#ifdef FEATURE_WLAN_TDLS
20730 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
20731 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
20732#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053020733#ifdef WLAN_FEATURE_GTK_OFFLOAD
20734 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
20735#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020736#ifdef FEATURE_WLAN_SCAN_PNO
20737 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
20738 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
20739#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020740 .resume = wlan_hdd_cfg80211_resume_wlan,
20741 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020742 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070020743#ifdef WLAN_NL80211_TESTMODE
20744 .testmode_cmd = wlan_hdd_cfg80211_testmode,
20745#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020746 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020747#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
20748 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053020749 .abort_scan = wlan_hdd_cfg80211_abort_scan,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020750#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070020751};
20752