blob: bbaceff96277471805410cf691d93ff8d2f7b403 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05302 * Copyright (c) 2012-2019 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>
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053066#include <linux/etherdevice.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include <wlan_hdd_includes.h>
68#include <net/arp.h>
69#include <net/cfg80211.h>
70#include <linux/wireless.h>
71#include <wlan_hdd_wowl.h>
72#include <aniGlobal.h>
73#include "ccmApi.h"
74#include "sirParams.h"
75#include "dot11f.h"
76#include "wlan_hdd_assoc.h"
77#include "wlan_hdd_wext.h"
78#include "sme_Api.h"
79#include "wlan_hdd_p2p.h"
80#include "wlan_hdd_cfg80211.h"
81#include "wlan_hdd_hostapd.h"
82#include "sapInternal.h"
83#include "wlan_hdd_softap_tx_rx.h"
84#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053085#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053086#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053087#include "wlan_hdd_trace.h"
88#include "vos_types.h"
89#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070090#ifdef WLAN_BTAMP_FEATURE
91#include "bap_hdd_misc.h"
92#endif
93#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080094#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053095#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053096#include "wlan_qct_wda.h"
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053097#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070098#include "wlan_hdd_dev_pwr.h"
Sushant Kaushik084f6592015-09-10 13:11:56 +053099#include "qwlan_version.h"
c_manjeecfd1efb2015-09-25 19:32:34 +0530100#include "wlan_logging_sock_svc.h"
Agrawal Ashishcfe83282016-09-29 13:03:45 +0530101#include "wlan_hdd_misc.h"
Sushant Kaushik084f6592015-09-10 13:11:56 +0530102
Jeff Johnson295189b2012-06-20 16:38:30 -0700103
104#define g_mode_rates_size (12)
105#define a_mode_rates_size (8)
106#define FREQ_BASE_80211G (2407)
107#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700108#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530109#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700110#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800111 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700112
113#define HDD2GHZCHAN(freq, chan, flag) { \
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +0530114 .band = HDD_NL80211_BAND_2GHZ, \
Jeff Johnson295189b2012-06-20 16:38:30 -0700115 .center_freq = (freq), \
116 .hw_value = (chan),\
117 .flags = (flag), \
118 .max_antenna_gain = 0 ,\
119 .max_power = 30, \
120}
121
122#define HDD5GHZCHAN(freq, chan, flag) { \
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +0530123 .band = HDD_NL80211_BAND_5GHZ, \
Jeff Johnson295189b2012-06-20 16:38:30 -0700124 .center_freq = (freq), \
125 .hw_value = (chan),\
126 .flags = (flag), \
127 .max_antenna_gain = 0 ,\
128 .max_power = 30, \
129}
130
131#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
132{\
133 .bitrate = rate, \
134 .hw_value = rate_id, \
135 .flags = flag, \
136}
137
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530138#ifdef WLAN_FEATURE_VOWIFI_11R
139#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
140#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
141#endif
142
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530143#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530144#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530145
Sunil Duttc69bccb2014-05-26 21:30:20 +0530146#ifdef WLAN_FEATURE_LINK_LAYER_STATS
147/*
148 * Used to allocate the size of 4096 for the link layer stats.
149 * The size of 4096 is considered assuming that all data per
150 * respective event fit with in the limit.Please take a call
151 * on the limit based on the data requirements on link layer
152 * statistics.
153 */
154#define LL_STATS_EVENT_BUF_SIZE 4096
155#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530156#ifdef WLAN_FEATURE_EXTSCAN
157/*
158 * Used to allocate the size of 4096 for the EXTScan NL data.
159 * The size of 4096 is considered assuming that all data per
160 * respective event fit with in the limit.Please take a call
161 * on the limit based on the data requirements.
162 */
163
164#define EXTSCAN_EVENT_BUF_SIZE 4096
165#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
166#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530167
Atul Mittal115287b2014-07-08 13:26:33 +0530168/*EXT TDLS*/
169/*
170 * Used to allocate the size of 4096 for the TDLS.
171 * The size of 4096 is considered assuming that all data per
172 * respective event fit with in the limit.Please take a call
173 * on the limit based on the data requirements on link layer
174 * statistics.
175 */
176#define EXTTDLS_EVENT_BUF_SIZE 4096
177
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +0530178/*
179 * Values for Mac spoofing feature
180 *
181 */
182#define MAC_ADDR_SPOOFING_FW_HOST_DISABLE 0
183#define MAC_ADDR_SPOOFING_FW_HOST_ENABLE 1
184#define MAC_ADDR_SPOOFING_FW_ENABLE_HOST_DISABLE 2
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +0530185#define MAC_ADDR_SPOOFING_DEFER_INTERVAL 10 //in ms
186
Anurag Chouhan343af7e2016-12-16 13:11:19 +0530187/*
188 * max_sched_scan_plans defined to 10
189 */
190#define MAX_SCHED_SCAN_PLANS 10
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +0530191
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530192static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700193{
194 WLAN_CIPHER_SUITE_WEP40,
195 WLAN_CIPHER_SUITE_WEP104,
196 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800197#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700198#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
199 WLAN_CIPHER_SUITE_KRK,
200 WLAN_CIPHER_SUITE_CCMP,
201#else
202 WLAN_CIPHER_SUITE_CCMP,
203#endif
204#ifdef FEATURE_WLAN_WAPI
205 WLAN_CIPHER_SUITE_SMS4,
206#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700207#ifdef WLAN_FEATURE_11W
208 WLAN_CIPHER_SUITE_AES_CMAC,
209#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700210};
211
Agrawal Ashish97dec502015-11-26 20:20:58 +0530212const static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530213{
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 HDD2GHZCHAN(2412, 1, 0) ,
215 HDD2GHZCHAN(2417, 2, 0) ,
216 HDD2GHZCHAN(2422, 3, 0) ,
217 HDD2GHZCHAN(2427, 4, 0) ,
218 HDD2GHZCHAN(2432, 5, 0) ,
219 HDD2GHZCHAN(2437, 6, 0) ,
220 HDD2GHZCHAN(2442, 7, 0) ,
221 HDD2GHZCHAN(2447, 8, 0) ,
222 HDD2GHZCHAN(2452, 9, 0) ,
223 HDD2GHZCHAN(2457, 10, 0) ,
224 HDD2GHZCHAN(2462, 11, 0) ,
225 HDD2GHZCHAN(2467, 12, 0) ,
226 HDD2GHZCHAN(2472, 13, 0) ,
227 HDD2GHZCHAN(2484, 14, 0) ,
228};
229
Agrawal Ashish97dec502015-11-26 20:20:58 +0530230const static struct ieee80211_channel hdd_channels_5_GHZ[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700231{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700232 HDD5GHZCHAN(4920, 240, 0) ,
233 HDD5GHZCHAN(4940, 244, 0) ,
234 HDD5GHZCHAN(4960, 248, 0) ,
235 HDD5GHZCHAN(4980, 252, 0) ,
236 HDD5GHZCHAN(5040, 208, 0) ,
237 HDD5GHZCHAN(5060, 212, 0) ,
238 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 HDD5GHZCHAN(5180, 36, 0) ,
240 HDD5GHZCHAN(5200, 40, 0) ,
241 HDD5GHZCHAN(5220, 44, 0) ,
242 HDD5GHZCHAN(5240, 48, 0) ,
243 HDD5GHZCHAN(5260, 52, 0) ,
244 HDD5GHZCHAN(5280, 56, 0) ,
245 HDD5GHZCHAN(5300, 60, 0) ,
246 HDD5GHZCHAN(5320, 64, 0) ,
247 HDD5GHZCHAN(5500,100, 0) ,
248 HDD5GHZCHAN(5520,104, 0) ,
249 HDD5GHZCHAN(5540,108, 0) ,
250 HDD5GHZCHAN(5560,112, 0) ,
251 HDD5GHZCHAN(5580,116, 0) ,
252 HDD5GHZCHAN(5600,120, 0) ,
253 HDD5GHZCHAN(5620,124, 0) ,
254 HDD5GHZCHAN(5640,128, 0) ,
255 HDD5GHZCHAN(5660,132, 0) ,
256 HDD5GHZCHAN(5680,136, 0) ,
257 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800258#ifdef FEATURE_WLAN_CH144
259 HDD5GHZCHAN(5720,144, 0) ,
260#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 HDD5GHZCHAN(5745,149, 0) ,
262 HDD5GHZCHAN(5765,153, 0) ,
263 HDD5GHZCHAN(5785,157, 0) ,
264 HDD5GHZCHAN(5805,161, 0) ,
265 HDD5GHZCHAN(5825,165, 0) ,
266};
267
268static struct ieee80211_rate g_mode_rates[] =
269{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530270 HDD_G_MODE_RATETAB(10, 0x1, 0),
271 HDD_G_MODE_RATETAB(20, 0x2, 0),
272 HDD_G_MODE_RATETAB(55, 0x4, 0),
273 HDD_G_MODE_RATETAB(110, 0x8, 0),
274 HDD_G_MODE_RATETAB(60, 0x10, 0),
275 HDD_G_MODE_RATETAB(90, 0x20, 0),
276 HDD_G_MODE_RATETAB(120, 0x40, 0),
277 HDD_G_MODE_RATETAB(180, 0x80, 0),
278 HDD_G_MODE_RATETAB(240, 0x100, 0),
279 HDD_G_MODE_RATETAB(360, 0x200, 0),
280 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530282};
Jeff Johnson295189b2012-06-20 16:38:30 -0700283
284static struct ieee80211_rate a_mode_rates[] =
285{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530286 HDD_G_MODE_RATETAB(60, 0x10, 0),
287 HDD_G_MODE_RATETAB(90, 0x20, 0),
288 HDD_G_MODE_RATETAB(120, 0x40, 0),
289 HDD_G_MODE_RATETAB(180, 0x80, 0),
290 HDD_G_MODE_RATETAB(240, 0x100, 0),
291 HDD_G_MODE_RATETAB(360, 0x200, 0),
292 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700293 HDD_G_MODE_RATETAB(540, 0x800, 0),
294};
295
296static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
297{
Agrawal Ashish97dec502015-11-26 20:20:58 +0530298 .channels = NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +0530300 .band = HDD_NL80211_BAND_2GHZ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 .bitrates = g_mode_rates,
302 .n_bitrates = g_mode_rates_size,
303 .ht_cap.ht_supported = 1,
304 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
305 | IEEE80211_HT_CAP_GRN_FLD
306 | IEEE80211_HT_CAP_DSSSCCK40
Abhinav Kumar1ac5cb42018-09-21 16:11:03 +0530307 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
308 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
310 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
311 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
312 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
313 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
Abhinav Kumar73d67c02019-02-22 12:42:41 +0530314 .vht_cap.vht_supported = 1,
315 .vht_cap.cap = IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454
316 | IEEE80211_VHT_CAP_SHORT_GI_80,
Jeff Johnson295189b2012-06-20 16:38:30 -0700317};
318
Jeff Johnson295189b2012-06-20 16:38:30 -0700319static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
320{
Agrawal Ashish97dec502015-11-26 20:20:58 +0530321 .channels = NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700322 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +0530323 .band = HDD_NL80211_BAND_5GHZ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 .bitrates = a_mode_rates,
325 .n_bitrates = a_mode_rates_size,
326 .ht_cap.ht_supported = 1,
327 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
328 | IEEE80211_HT_CAP_GRN_FLD
329 | IEEE80211_HT_CAP_DSSSCCK40
330 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
331 | IEEE80211_HT_CAP_SGI_40
332 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
333 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
334 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
335 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
336 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
337 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
Abhinav Kumar73d67c02019-02-22 12:42:41 +0530338 .vht_cap.vht_supported = 1,
339 .vht_cap.cap = IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454
340 | IEEE80211_VHT_CAP_SHORT_GI_80,
Jeff Johnson295189b2012-06-20 16:38:30 -0700341};
342
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530343/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 TX/RX direction for each kind of interface */
345static const struct ieee80211_txrx_stypes
346wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
347 [NL80211_IFTYPE_STATION] = {
348 .tx = 0xffff,
349 .rx = BIT(SIR_MAC_MGMT_ACTION) |
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530350 BIT(SIR_MAC_MGMT_AUTH) |
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 BIT(SIR_MAC_MGMT_PROBE_REQ),
352 },
353 [NL80211_IFTYPE_AP] = {
354 .tx = 0xffff,
355 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
356 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
357 BIT(SIR_MAC_MGMT_PROBE_REQ) |
358 BIT(SIR_MAC_MGMT_DISASSOC) |
359 BIT(SIR_MAC_MGMT_AUTH) |
360 BIT(SIR_MAC_MGMT_DEAUTH) |
361 BIT(SIR_MAC_MGMT_ACTION),
362 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700363 [NL80211_IFTYPE_ADHOC] = {
364 .tx = 0xffff,
365 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
366 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
367 BIT(SIR_MAC_MGMT_PROBE_REQ) |
368 BIT(SIR_MAC_MGMT_DISASSOC) |
369 BIT(SIR_MAC_MGMT_AUTH) |
370 BIT(SIR_MAC_MGMT_DEAUTH) |
371 BIT(SIR_MAC_MGMT_ACTION),
372 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 [NL80211_IFTYPE_P2P_CLIENT] = {
374 .tx = 0xffff,
375 .rx = BIT(SIR_MAC_MGMT_ACTION) |
376 BIT(SIR_MAC_MGMT_PROBE_REQ),
377 },
378 [NL80211_IFTYPE_P2P_GO] = {
379 /* This is also same as for SoftAP */
380 .tx = 0xffff,
381 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
382 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
383 BIT(SIR_MAC_MGMT_PROBE_REQ) |
384 BIT(SIR_MAC_MGMT_DISASSOC) |
385 BIT(SIR_MAC_MGMT_AUTH) |
386 BIT(SIR_MAC_MGMT_DEAUTH) |
387 BIT(SIR_MAC_MGMT_ACTION),
388 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700389};
390
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800391#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800392static const struct ieee80211_iface_limit
393wlan_hdd_iface_limit[] = {
394 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800395 /* max = 3 ; Our driver create two interfaces during driver init
396 * wlan0 and p2p0 interfaces. p2p0 is considered as station
397 * interface until a group is formed. In JB architecture, once the
398 * group is formed, interface type of p2p0 is changed to P2P GO or
399 * Client.
400 * When supplicant remove the group, it first issue a set interface
401 * cmd to change the mode back to Station. In JB this works fine as
402 * we advertize two station type interface during driver init.
403 * Some vendors create separate interface for P2P GO/Client,
404 * after group formation(Third one). But while group remove
405 * supplicant first tries to change the mode(3rd interface) to STATION
406 * But as we advertized only two sta type interfaces nl80211 was
407 * returning error for the third one which was leading to failure in
408 * delete interface. Ideally while removing the group, supplicant
409 * should not try to change the 3rd interface mode to Station type.
410 * Till we get a fix in wpa_supplicant, we advertize max STA
411 * interface type to 3
412 */
413 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800414 .types = BIT(NL80211_IFTYPE_STATION),
415 },
416 {
417 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700418 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800419 },
420 {
421 .max = 1,
422 .types = BIT(NL80211_IFTYPE_P2P_GO) |
423 BIT(NL80211_IFTYPE_P2P_CLIENT),
424 },
425};
426
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +0530427/* interface limits for sta + monitor SCC */
428static const struct ieee80211_iface_limit
429wlan_hdd_iface_sta_mon_limit[] = {
430 {
431 .max = 1,
432 .types = BIT(NL80211_IFTYPE_STATION),
433 },
434 {
435 .max = 1, /* Monitor interface */
436 .types = BIT(NL80211_IFTYPE_MONITOR),
437 },
438};
439
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800440/* By default, only single channel concurrency is allowed */
441static struct ieee80211_iface_combination
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +0530442wlan_hdd_iface_combination[] = {
443 {
444 .limits = wlan_hdd_iface_limit,
445 .num_different_channels = 1,
446 /*
447 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
448 * and p2p0 interfaces during driver init
449 * Some vendors create separate interface for P2P operations.
450 * wlan0: STA interface
451 * p2p0: P2P Device interface, action frames goes
452 * through this interface.
453 * p2p-xx: P2P interface, After GO negotiation this interface is
454 * created for p2p operations(GO/CLIENT interface).
455 */
456 .max_interfaces = WLAN_MAX_INTERFACES,
457 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
458 .beacon_int_infra_match = false,
459 },
460 {
461 .limits = wlan_hdd_iface_sta_mon_limit,
462 .num_different_channels = 1,
463 .max_interfaces = WLAN_STA_AND_MON_INTERFACES,
464 .n_limits = ARRAY_SIZE(wlan_hdd_iface_sta_mon_limit),
465 .beacon_int_infra_match = false,
466 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800467};
468#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800469
Nachiket Kukade5b2e7332018-04-06 14:40:22 +0530470#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) || defined(WITH_BACKPORTS)
471static const struct wiphy_wowlan_support wowlan_support_cfg80211_init = {
Nachiket Kukade1e1b90e2018-05-10 15:26:13 +0530472 .flags = WIPHY_WOWLAN_ANY |
473 WIPHY_WOWLAN_MAGIC_PKT,
Nachiket Kukade5b2e7332018-04-06 14:40:22 +0530474 .n_patterns = WOWL_MAX_PTRNS_ALLOWED,
475 .pattern_min_len = 1,
476 .pattern_max_len = WOWL_PTRN_MAX_SIZE,
477};
478#endif
479
Jeff Johnson295189b2012-06-20 16:38:30 -0700480static struct cfg80211_ops wlan_hdd_cfg80211_ops;
481
482/* Data rate 100KBPS based on IE Index */
483struct index_data_rate_type
484{
485 v_U8_t beacon_rate_index;
486 v_U16_t supported_rate[4];
487};
488
489/* 11B, 11G Rate table include Basic rate and Extended rate
490 The IDX field is the rate index
491 The HI field is the rate when RSSI is strong or being ignored
492 (in this case we report actual rate)
493 The MID field is the rate when RSSI is moderate
494 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
495 The LO field is the rate when RSSI is low
496 (in this case we don't report rates, actual current rate used)
497 */
498static const struct
499{
500 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700501 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700502} supported_data_rate[] =
503{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700504/* IDX HI HM LM LO (RSSI-based index */
505 {2, { 10, 10, 10, 0}},
506 {4, { 20, 20, 10, 0}},
507 {11, { 55, 20, 10, 0}},
508 {12, { 60, 55, 20, 0}},
509 {18, { 90, 55, 20, 0}},
510 {22, {110, 55, 20, 0}},
511 {24, {120, 90, 60, 0}},
512 {36, {180, 120, 60, 0}},
513 {44, {220, 180, 60, 0}},
514 {48, {240, 180, 90, 0}},
515 {66, {330, 180, 90, 0}},
516 {72, {360, 240, 90, 0}},
517 {96, {480, 240, 120, 0}},
518 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700519};
520
521/* MCS Based rate table */
522static struct index_data_rate_type supported_mcs_rate[] =
523{
524/* MCS L20 L40 S20 S40 */
525 {0, {65, 135, 72, 150}},
526 {1, {130, 270, 144, 300}},
527 {2, {195, 405, 217, 450}},
528 {3, {260, 540, 289, 600}},
529 {4, {390, 810, 433, 900}},
530 {5, {520, 1080, 578, 1200}},
531 {6, {585, 1215, 650, 1350}},
532 {7, {650, 1350, 722, 1500}}
533};
534
Leo Chang6f8870f2013-03-26 18:11:36 -0700535#ifdef WLAN_FEATURE_11AC
536
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530537#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700538
539struct index_vht_data_rate_type
540{
541 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530542 v_U16_t supported_VHT80_rate[2];
543 v_U16_t supported_VHT40_rate[2];
544 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700545};
546
547typedef enum
548{
549 DATA_RATE_11AC_MAX_MCS_7,
550 DATA_RATE_11AC_MAX_MCS_8,
551 DATA_RATE_11AC_MAX_MCS_9,
552 DATA_RATE_11AC_MAX_MCS_NA
553} eDataRate11ACMaxMcs;
554
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530555/* SSID broadcast type */
556typedef enum eSSIDBcastType
557{
558 eBCAST_UNKNOWN = 0,
559 eBCAST_NORMAL = 1,
560 eBCAST_HIDDEN = 2,
561} tSSIDBcastType;
562
Leo Chang6f8870f2013-03-26 18:11:36 -0700563/* MCS Based VHT rate table */
564static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
565{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530566/* MCS L80 S80 L40 S40 L20 S40*/
567 {0, {293, 325}, {135, 150}, {65, 72}},
568 {1, {585, 650}, {270, 300}, {130, 144}},
569 {2, {878, 975}, {405, 450}, {195, 217}},
570 {3, {1170, 1300}, {540, 600}, {260, 289}},
571 {4, {1755, 1950}, {810, 900}, {390, 433}},
572 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
573 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
574 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
575 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
576 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700577};
578#endif /* WLAN_FEATURE_11AC */
579
c_hpothu79aab322014-07-14 21:11:01 +0530580/*array index points to MCS and array value points respective rssi*/
581static int rssiMcsTbl[][10] =
582{
583/*MCS 0 1 2 3 4 5 6 7 8 9*/
584 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
585 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
586 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
587};
588
Jeff Johnson295189b2012-06-20 16:38:30 -0700589extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530590#ifdef FEATURE_WLAN_SCAN_PNO
591static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
592#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700593
Leo Chang9056f462013-08-01 19:21:11 -0700594#ifdef WLAN_NL80211_TESTMODE
595enum wlan_hdd_tm_attr
596{
597 WLAN_HDD_TM_ATTR_INVALID = 0,
598 WLAN_HDD_TM_ATTR_CMD = 1,
599 WLAN_HDD_TM_ATTR_DATA = 2,
600 WLAN_HDD_TM_ATTR_TYPE = 3,
601 /* keep last */
602 WLAN_HDD_TM_ATTR_AFTER_LAST,
603 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
604};
605
606enum wlan_hdd_tm_cmd
607{
608 WLAN_HDD_TM_CMD_WLAN_HB = 1,
609};
610
611#define WLAN_HDD_TM_DATA_MAX_LEN 5000
612
613static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
614{
615 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
616 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
617 .len = WLAN_HDD_TM_DATA_MAX_LEN },
618};
619#endif /* WLAN_NL80211_TESTMODE */
620
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800621#ifdef FEATURE_WLAN_CH_AVOID
622/*
623 * FUNCTION: wlan_hdd_send_avoid_freq_event
624 * This is called when wlan driver needs to send vendor specific
625 * avoid frequency range event to userspace
626 */
627int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
628 tHddAvoidFreqList *pAvoidFreqList)
629{
630 struct sk_buff *vendor_event;
631
632 ENTER();
633
634 if (!pHddCtx)
635 {
636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
637 "%s: HDD context is null", __func__);
638 return -1;
639 }
640
641 if (!pAvoidFreqList)
642 {
643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
644 "%s: pAvoidFreqList is null", __func__);
645 return -1;
646 }
647
648 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530649#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
650 NULL,
651#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800652 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530653 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800654 GFP_KERNEL);
655 if (!vendor_event)
656 {
657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
658 "%s: cfg80211_vendor_event_alloc failed", __func__);
659 return -1;
660 }
661
662 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
663 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
664
665 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
666
667 EXIT();
668 return 0;
669}
670#endif /* FEATURE_WLAN_CH_AVOID */
671
Srinivas Dasari030bad32015-02-18 23:23:54 +0530672/*
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +0530673 * define short names for the global vendor params
674 * used by QCA_NL80211_VENDOR_SUBCMD_HANG
675 */
676#define HANG_REASON_INDEX QCA_NL80211_VENDOR_SUBCMD_HANG_REASON_INDEX
677
678/**
679 * hdd_convert_hang_reason() - Convert cds recovery reason to vendor specific
680 * hang reason
681 * @reason: cds recovery reason
682 *
683 * Return: Vendor specific reason code
684 */
685static enum qca_wlan_vendor_hang_reason
686hdd_convert_hang_reason(enum vos_hang_reason reason)
687{
688 unsigned int ret_val;
689
690 switch (reason) {
691 case VOS_GET_MSG_BUFF_FAILURE:
692 ret_val = QCA_WLAN_HANG_GET_MSG_BUFF_FAILURE;
693 break;
694 case VOS_ACTIVE_LIST_TIMEOUT:
695 ret_val = QCA_WLAN_HANG_ACTIVE_LIST_TIMEOUT;
696 break;
697 case VOS_SCAN_REQ_EXPIRED:
698 ret_val = QCA_WLAN_HANG_SCAN_REQ_EXPIRED;
699 break;
700 case VOS_TRANSMISSIONS_TIMEOUT:
701 ret_val = QCA_WLAN_HANG_TRANSMISSIONS_TIMEOUT;
702 break;
703 case VOS_DXE_FAILURE:
704 ret_val = QCA_WLAN_HANG_DXE_FAILURE;
705 break;
706 case VOS_WDI_FAILURE:
707 ret_val = QCA_WLAN_HANG_WDI_FAILURE;
708 break;
709 case VOS_REASON_UNSPECIFIED:
710 default:
711 ret_val = QCA_WLAN_HANG_REASON_UNSPECIFIED;
712 }
713 return ret_val;
714}
715
716/**
717 * wlan_hdd_send_hang_reason_event() - Send hang reason to the userspace
718 * @hdd_ctx: Pointer to hdd context
719 * @reason: cds recovery reason
720 *
721 * Return: 0 on success or failure reason
722 */
723int wlan_hdd_send_hang_reason_event(hdd_context_t *hdd_ctx,
724 enum vos_hang_reason reason)
725{
726 struct sk_buff *vendor_event;
727 enum qca_wlan_vendor_hang_reason hang_reason;
728
729 ENTER();
730
731 if (!hdd_ctx) {
732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
733 "HDD context is null");
734 return -EINVAL;
735 }
736
737 vendor_event = cfg80211_vendor_event_alloc(hdd_ctx->wiphy,
738#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
739 NULL,
740#endif
741 sizeof(unsigned int),
742 HANG_REASON_INDEX,
743 GFP_KERNEL);
744 if (!vendor_event) {
745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
746 "cfg80211_vendor_event_alloc failed");
747 return -ENOMEM;
748 }
749
750 hang_reason = hdd_convert_hang_reason(reason);
751
752 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_HANG_REASON,
753 (unsigned int) hang_reason)) {
754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
755 "QCA_WLAN_VENDOR_ATTR_HANG_REASON put fail");
756 kfree_skb(vendor_event);
757 return -EINVAL;
758 }
759
760 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
761
762 EXIT();
763 return 0;
764}
765#undef HANG_REASON_INDEX
766
767/*
Srinivas Dasari030bad32015-02-18 23:23:54 +0530768 * FUNCTION: __wlan_hdd_cfg80211_nan_request
769 * This is called when wlan driver needs to send vendor specific
770 * nan request event.
771 */
772static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
773 struct wireless_dev *wdev,
774 const void *data, int data_len)
775{
776 tNanRequestReq nan_req;
777 VOS_STATUS status;
778 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530779 struct net_device *dev = wdev->netdev;
780 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
781 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530782 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
783
784 if (0 == data_len)
785 {
786 hddLog(VOS_TRACE_LEVEL_ERROR,
787 FL("NAN - Invalid Request, length = 0"));
788 return ret_val;
789 }
790
791 if (NULL == data)
792 {
793 hddLog(VOS_TRACE_LEVEL_ERROR,
794 FL("NAN - Invalid Request, data is NULL"));
795 return ret_val;
796 }
797
798 status = wlan_hdd_validate_context(pHddCtx);
799 if (0 != status)
800 {
801 hddLog(VOS_TRACE_LEVEL_ERROR,
802 FL("HDD context is not valid"));
803 return -EINVAL;
804 }
805
806 hddLog(LOG1, FL("Received NAN command"));
807 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
808 (tANI_U8 *)data, data_len);
809
810 /* check the NAN Capability */
811 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
812 {
813 hddLog(VOS_TRACE_LEVEL_ERROR,
814 FL("NAN is not supported by Firmware"));
815 return -EINVAL;
816 }
817
818 nan_req.request_data_len = data_len;
819 nan_req.request_data = data;
820
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530821 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530822 if (VOS_STATUS_SUCCESS == status)
823 {
824 ret_val = 0;
825 }
826 return ret_val;
827}
828
829/*
830 * FUNCTION: wlan_hdd_cfg80211_nan_request
831 * Wrapper to protect the nan vendor command from ssr
832 */
833static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
834 struct wireless_dev *wdev,
835 const void *data, int data_len)
836{
837 int ret;
838
839 vos_ssr_protect(__func__);
840 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
841 vos_ssr_unprotect(__func__);
842
843 return ret;
844}
845
846/*
847 * FUNCTION: wlan_hdd_cfg80211_nan_callback
848 * This is a callback function and it gets called
849 * when we need to report nan response event to
850 * upper layers.
851 */
852static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
853{
854 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
855 struct sk_buff *vendor_event;
856 int status;
857 tSirNanEvent *data;
858
859 ENTER();
860 if (NULL == msg)
861 {
862 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
863 FL(" msg received here is null"));
864 return;
865 }
866 data = msg;
867
868 status = wlan_hdd_validate_context(pHddCtx);
869
870 if (0 != status)
871 {
872 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
873 FL("HDD context is not valid"));
874 return;
875 }
876
877 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530878#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
879 NULL,
880#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530881 data->event_data_len +
882 NLMSG_HDRLEN,
883 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
884 GFP_KERNEL);
885
886 if (!vendor_event)
887 {
888 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
889 FL("cfg80211_vendor_event_alloc failed"));
890 return;
891 }
892 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
893 data->event_data_len, data->event_data))
894 {
895 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
896 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
897 kfree_skb(vendor_event);
898 return;
899 }
900 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
901 EXIT();
902}
903
904/*
905 * FUNCTION: wlan_hdd_cfg80211_nan_init
906 * This function is called to register the callback to sme layer
907 */
908inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
909{
910 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
911}
912
Anurag Chouhanfcd20172017-07-19 17:25:19 +0530913/*
914 * define short names for the global vendor params
915 * used by __wlan_hdd_cfg80211_get_station_cmd()
916 */
917#define STATION_INVALID \
918 QCA_WLAN_VENDOR_ATTR_GET_STATION_INVALID
919#define STATION_INFO \
920 QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO
921#define STATION_ASSOC_FAIL_REASON \
922 QCA_WLAN_VENDOR_ATTR_GET_STATION_ASSOC_FAIL_REASON
Hanumanth Reddy Pothulaa35c4872017-12-14 20:47:59 +0530923#define STATION_REMOTE \
924 QCA_WLAN_VENDOR_ATTR_GET_STATION_REMOTE
Anurag Chouhanfcd20172017-07-19 17:25:19 +0530925#define STATION_MAX \
926 QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX
927
928static const struct nla_policy
929hdd_get_station_policy[STATION_MAX + 1] = {
930 [STATION_INFO] = {.type = NLA_FLAG},
931 [STATION_ASSOC_FAIL_REASON] = {.type = NLA_FLAG},
932};
933
934/**
935 * hdd_get_station_assoc_fail() - Handle get station assoc fail
936 * @hdd_ctx: HDD context within host driver
937 * @wdev: wireless device
938 *
939 * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION_ASSOC_FAIL.
940 * Validate cmd attributes and send the station info to upper layers.
941 *
942 * Return: Success(0) or reason code for failure
943 */
944static int hdd_get_station_assoc_fail(hdd_context_t *hdd_ctx,
945 hdd_adapter_t *adapter)
946{
947 struct sk_buff *skb = NULL;
948 uint32_t nl_buf_len;
949 hdd_station_ctx_t *hdd_sta_ctx;
950
951 nl_buf_len = NLMSG_HDRLEN;
952 nl_buf_len += sizeof(uint32_t);
953 skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len);
954
955 if (!skb) {
956 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"cfg80211_vendor_cmd_alloc_reply_skb failed");
957 return -ENOMEM;
958 }
959
960 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
961
962 if (nla_put_u32(skb, INFO_ASSOC_FAIL_REASON,
963 hdd_sta_ctx->conn_info.assoc_status_code)) {
964 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
965 goto fail;
966 }
967 return cfg80211_vendor_cmd_reply(skb);
968fail:
969 if (skb)
970 kfree_skb(skb);
971 return -EINVAL;
972}
973
974/**
975 * hdd_map_auth_type() - transform auth type specific to
976 * vendor command
977 * @auth_type: csr auth type
978 *
979 * Return: Success(0) or reason code for failure
980 */
981static int hdd_convert_auth_type(uint32_t auth_type)
982{
983 uint32_t ret_val;
984
985 switch (auth_type) {
986 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
987 ret_val = QCA_WLAN_AUTH_TYPE_OPEN;
988 break;
989 case eCSR_AUTH_TYPE_SHARED_KEY:
990 ret_val = QCA_WLAN_AUTH_TYPE_SHARED;
991 break;
992 case eCSR_AUTH_TYPE_WPA:
993 ret_val = QCA_WLAN_AUTH_TYPE_WPA;
994 break;
995 case eCSR_AUTH_TYPE_WPA_PSK:
996 ret_val = QCA_WLAN_AUTH_TYPE_WPA_PSK;
997 break;
998 case eCSR_AUTH_TYPE_AUTOSWITCH:
999 ret_val = QCA_WLAN_AUTH_TYPE_AUTOSWITCH;
1000 break;
1001 case eCSR_AUTH_TYPE_WPA_NONE:
1002 ret_val = QCA_WLAN_AUTH_TYPE_WPA_NONE;
1003 break;
1004 case eCSR_AUTH_TYPE_RSN:
1005 ret_val = QCA_WLAN_AUTH_TYPE_RSN;
1006 break;
1007 case eCSR_AUTH_TYPE_RSN_PSK:
1008 ret_val = QCA_WLAN_AUTH_TYPE_RSN_PSK;
1009 break;
1010 case eCSR_AUTH_TYPE_FT_RSN:
1011 ret_val = QCA_WLAN_AUTH_TYPE_FT;
1012 break;
1013 case eCSR_AUTH_TYPE_FT_RSN_PSK:
1014 ret_val = QCA_WLAN_AUTH_TYPE_FT_PSK;
1015 break;
1016 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
1017 ret_val = QCA_WLAN_AUTH_TYPE_WAI;
1018 break;
1019 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
1020 ret_val = QCA_WLAN_AUTH_TYPE_WAI_PSK;
1021 break;
1022#ifdef FEATURE_WLAN_ESE
1023 case eCSR_AUTH_TYPE_CCKM_WPA:
1024 ret_val = QCA_WLAN_AUTH_TYPE_CCKM_WPA;
1025 break;
1026 case eCSR_AUTH_TYPE_CCKM_RSN:
1027 ret_val = QCA_WLAN_AUTH_TYPE_CCKM_RSN;
1028 break;
1029#endif
1030 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
1031 ret_val = QCA_WLAN_AUTH_TYPE_SHA256_PSK;
1032 break;
1033 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
1034 ret_val = QCA_WLAN_AUTH_TYPE_SHA256;
1035 break;
1036 case eCSR_NUM_OF_SUPPORT_AUTH_TYPE:
1037 case eCSR_AUTH_TYPE_FAILED:
1038 case eCSR_AUTH_TYPE_NONE:
1039 default:
1040 ret_val = QCA_WLAN_AUTH_TYPE_INVALID;
1041 break;
1042 }
1043 return ret_val;
1044}
1045
1046/**
1047 * hdd_map_dot_11_mode() - transform dot11mode type specific to
1048 * vendor command
1049 * @dot11mode: dot11mode
1050 *
1051 * Return: Success(0) or reason code for failure
1052 */
1053static int hdd_convert_dot11mode(uint32_t dot11mode)
1054{
1055 uint32_t ret_val;
1056
1057 switch (dot11mode) {
1058 case eCSR_CFG_DOT11_MODE_11A:
1059 ret_val = QCA_WLAN_802_11_MODE_11A;
1060 break;
1061 case eCSR_CFG_DOT11_MODE_11B:
1062 ret_val = QCA_WLAN_802_11_MODE_11B;
1063 break;
1064 case eCSR_CFG_DOT11_MODE_11G:
1065 ret_val = QCA_WLAN_802_11_MODE_11G;
1066 break;
1067 case eCSR_CFG_DOT11_MODE_11N:
1068 ret_val = QCA_WLAN_802_11_MODE_11N;
1069 break;
1070 case eCSR_CFG_DOT11_MODE_11AC:
1071 ret_val = QCA_WLAN_802_11_MODE_11AC;
1072 break;
1073 case eCSR_CFG_DOT11_MODE_AUTO:
1074 case eCSR_CFG_DOT11_MODE_ABG:
1075 default:
1076 ret_val = QCA_WLAN_802_11_MODE_INVALID;
1077 }
1078 return ret_val;
1079}
1080
1081/**
1082 * hdd_add_tx_bitrate() - add tx bitrate attribute
1083 * @skb: pointer to sk buff
1084 * @hdd_sta_ctx: pointer to hdd station context
1085 * @idx: attribute index
1086 *
1087 * Return: Success(0) or reason code for failure
1088 */
1089static int32_t hdd_add_tx_bitrate(struct sk_buff *skb,
1090 hdd_station_ctx_t *hdd_sta_ctx,
1091 int idx)
1092{
1093 struct nlattr *nla_attr;
1094 uint32_t bitrate, bitrate_compat;
1095
1096 nla_attr = nla_nest_start(skb, idx);
1097 if (!nla_attr)
1098 goto fail;
1099 /* cfg80211_calculate_bitrate will return 0 for mcs >= 32 */
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301100 bitrate = cfg80211_calculate_bitrate(
1101 &hdd_sta_ctx->cache_conn_info.txrate);
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301102
1103 /* report 16-bit bitrate only if we can */
1104 bitrate_compat = bitrate < (1UL << 16) ? bitrate : 0;
1105 if (bitrate > 0 &&
1106 nla_put_u32(skb, NL80211_RATE_INFO_BITRATE32, bitrate)) {
1107 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1108 goto fail;
1109 }
1110 if (bitrate_compat > 0 &&
1111 nla_put_u16(skb, NL80211_RATE_INFO_BITRATE, bitrate_compat)) {
1112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1113 goto fail;
1114 }
1115 if (nla_put_u8(skb, NL80211_RATE_INFO_VHT_NSS,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301116 hdd_sta_ctx->cache_conn_info.txrate.nss)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301117 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1118 goto fail;
1119 }
1120 nla_nest_end(skb, nla_attr);
1121 return 0;
1122fail:
1123 return -EINVAL;
1124}
1125
1126/**
1127 * hdd_add_sta_info() - add station info attribute
1128 * @skb: pointer to sk buff
1129 * @hdd_sta_ctx: pointer to hdd station context
1130 * @idx: attribute index
1131 *
1132 * Return: Success(0) or reason code for failure
1133 */
1134static int32_t hdd_add_sta_info(struct sk_buff *skb,
1135 hdd_station_ctx_t *hdd_sta_ctx, int idx)
1136{
1137 struct nlattr *nla_attr;
1138
1139 nla_attr = nla_nest_start(skb, idx);
1140 if (!nla_attr)
1141 goto fail;
1142 if (nla_put_u8(skb, NL80211_STA_INFO_SIGNAL,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301143 (hdd_sta_ctx->cache_conn_info.signal + 100))) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301144 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1145 goto fail;
1146 }
1147 if (hdd_add_tx_bitrate(skb, hdd_sta_ctx, NL80211_STA_INFO_TX_BITRATE))
1148 goto fail;
1149 nla_nest_end(skb, nla_attr);
1150 return 0;
1151fail:
1152 return -EINVAL;
1153}
1154
1155/**
1156 * hdd_add_survey_info() - add survey info attribute
1157 * @skb: pointer to sk buff
1158 * @hdd_sta_ctx: pointer to hdd station context
1159 * @idx: attribute index
1160 *
1161 * Return: Success(0) or reason code for failure
1162 */
1163static int32_t hdd_add_survey_info(struct sk_buff *skb,
1164 hdd_station_ctx_t *hdd_sta_ctx,
1165 int idx)
1166{
1167 struct nlattr *nla_attr;
1168
1169 nla_attr = nla_nest_start(skb, idx);
1170 if (!nla_attr)
1171 goto fail;
1172 if (nla_put_u32(skb, NL80211_SURVEY_INFO_FREQUENCY,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301173 hdd_sta_ctx->cache_conn_info.freq) ||
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301174 nla_put_u8(skb, NL80211_SURVEY_INFO_NOISE,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301175 (hdd_sta_ctx->cache_conn_info.noise + 100))) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301176 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1177 goto fail;
1178 }
1179 nla_nest_end(skb, nla_attr);
1180 return 0;
1181fail:
1182 return -EINVAL;
1183}
1184
1185/**
1186 * hdd_add_link_standard_info() - add link info attribute
1187 * @skb: pointer to sk buff
1188 * @hdd_sta_ctx: pointer to hdd station context
1189 * @idx: attribute index
1190 *
1191 * Return: Success(0) or reason code for failure
1192 */
1193static int32_t
1194hdd_add_link_standard_info(struct sk_buff *skb,
1195 hdd_station_ctx_t *hdd_sta_ctx, int idx)
1196{
1197 struct nlattr *nla_attr;
1198
1199 nla_attr = nla_nest_start(skb, idx);
1200 if (!nla_attr)
1201 goto fail;
1202 if (nla_put(skb,
1203 NL80211_ATTR_SSID,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301204 hdd_sta_ctx->cache_conn_info.SSID.SSID.length,
1205 hdd_sta_ctx->cache_conn_info.SSID.SSID.ssId)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301206 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1207 goto fail;
1208 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301209 if (nla_put(skb, NL80211_ATTR_MAC, VOS_MAC_ADDR_SIZE,
1210 hdd_sta_ctx->cache_conn_info.bssId))
1211 goto fail;
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301212 if (hdd_add_survey_info(skb, hdd_sta_ctx, NL80211_ATTR_SURVEY_INFO))
1213 goto fail;
1214 if (hdd_add_sta_info(skb, hdd_sta_ctx, NL80211_ATTR_STA_INFO))
1215 goto fail;
1216 nla_nest_end(skb, nla_attr);
1217 return 0;
1218fail:
1219 return -EINVAL;
1220}
1221
1222/**
1223 * hdd_add_ap_standard_info() - add ap info attribute
1224 * @skb: pointer to sk buff
1225 * @hdd_sta_ctx: pointer to hdd station context
1226 * @idx: attribute index
1227 *
1228 * Return: Success(0) or reason code for failure
1229 */
1230static int32_t
1231hdd_add_ap_standard_info(struct sk_buff *skb,
1232 hdd_station_ctx_t *hdd_sta_ctx, int idx)
1233{
1234 struct nlattr *nla_attr;
1235
1236 nla_attr = nla_nest_start(skb, idx);
1237 if (!nla_attr)
1238 goto fail;
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301239 if (hdd_sta_ctx->cache_conn_info.conn_flag.vht_present)
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301240 if (nla_put(skb, NL80211_ATTR_VHT_CAPABILITY,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301241 sizeof(hdd_sta_ctx->cache_conn_info.vht_caps),
1242 &hdd_sta_ctx->cache_conn_info.vht_caps)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301243 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1244 goto fail;
1245 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301246 if (hdd_sta_ctx->cache_conn_info.conn_flag.ht_present)
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301247 if (nla_put(skb, NL80211_ATTR_HT_CAPABILITY,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301248 sizeof(hdd_sta_ctx->cache_conn_info.ht_caps),
1249 &hdd_sta_ctx->cache_conn_info.ht_caps)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301250 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1251 goto fail;
1252 }
1253 nla_nest_end(skb, nla_attr);
1254 return 0;
1255fail:
1256 return -EINVAL;
1257}
1258
1259/**
1260 * hdd_get_station_info() - send BSS information to supplicant
1261 * @hdd_ctx: pointer to hdd context
1262 * @adapter: pointer to adapter
1263 *
1264 * Return: 0 if success else error status
1265 */
1266static int hdd_get_station_info(hdd_context_t *hdd_ctx,
1267 hdd_adapter_t *adapter)
1268{
1269 struct sk_buff *skb = NULL;
1270 uint8_t *tmp_hs20 = NULL;
1271 uint32_t nl_buf_len;
1272 hdd_station_ctx_t *hdd_sta_ctx;
1273
1274 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1275
1276 nl_buf_len = NLMSG_HDRLEN;
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301277
1278 nl_buf_len += sizeof(hdd_sta_ctx->cache_conn_info.SSID.SSID.length) +
1279 VOS_MAC_ADDR_SIZE +
1280 sizeof(hdd_sta_ctx->cache_conn_info.freq) +
1281 sizeof(hdd_sta_ctx->cache_conn_info.noise) +
1282 sizeof(hdd_sta_ctx->cache_conn_info.signal) +
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301283 (sizeof(uint32_t) * 2) +
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301284 sizeof(hdd_sta_ctx->cache_conn_info.txrate.nss) +
1285 sizeof(hdd_sta_ctx->cache_conn_info.roam_count) +
1286 sizeof(hdd_sta_ctx->cache_conn_info.authType) +
1287 sizeof(hdd_sta_ctx->cache_conn_info.dot11Mode);
1288 if (hdd_sta_ctx->cache_conn_info.conn_flag.vht_present)
1289 nl_buf_len += sizeof(hdd_sta_ctx->cache_conn_info.vht_caps);
1290 if (hdd_sta_ctx->cache_conn_info.conn_flag.ht_present)
1291 nl_buf_len += sizeof(hdd_sta_ctx->cache_conn_info.ht_caps);
1292 if (hdd_sta_ctx->cache_conn_info.conn_flag.hs20_present) {
1293 tmp_hs20 = (uint8_t *)&(hdd_sta_ctx->
1294 cache_conn_info.hs20vendor_ie);
1295 nl_buf_len +=
1296 (sizeof(hdd_sta_ctx->cache_conn_info.hs20vendor_ie) -
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301297 1);
1298 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301299 if (hdd_sta_ctx->cache_conn_info.conn_flag.ht_op_present)
1300 nl_buf_len += sizeof(hdd_sta_ctx->cache_conn_info.ht_operation);
1301 if (hdd_sta_ctx->cache_conn_info.conn_flag.vht_op_present)
1302 nl_buf_len +=
1303 sizeof(hdd_sta_ctx->cache_conn_info.vht_operation);
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301304
1305
1306 skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len);
1307 if (!skb) {
1308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: %d cfg80211_vendor_cmd_alloc_reply_skb failed",
1309 __func__, __LINE__);
1310 return -ENOMEM;
1311 }
1312
1313 if (hdd_add_link_standard_info(skb, hdd_sta_ctx,
1314 LINK_INFO_STANDARD_NL80211_ATTR)) {
1315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1316 goto fail;
1317 }
1318 if (hdd_add_ap_standard_info(skb, hdd_sta_ctx,
1319 AP_INFO_STANDARD_NL80211_ATTR)) {
1320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1321 goto fail;
1322 }
1323 if (nla_put_u32(skb, INFO_ROAM_COUNT,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301324 hdd_sta_ctx->cache_conn_info.roam_count) ||
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301325 nla_put_u32(skb, INFO_AKM,
1326 hdd_convert_auth_type(
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301327 hdd_sta_ctx->cache_conn_info.authType)) ||
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301328 nla_put_u32(skb, WLAN802_11_MODE,
1329 hdd_convert_dot11mode(
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301330 hdd_sta_ctx->cache_conn_info.dot11Mode))) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1332 goto fail;
1333 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301334 if (hdd_sta_ctx->cache_conn_info.conn_flag.ht_op_present)
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301335 if (nla_put(skb, HT_OPERATION,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301336 (sizeof(hdd_sta_ctx->cache_conn_info.ht_operation)),
1337 &hdd_sta_ctx->cache_conn_info.ht_operation)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1339 goto fail;
1340 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301341 if (hdd_sta_ctx->cache_conn_info.conn_flag.vht_op_present)
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301342 if (nla_put(skb, VHT_OPERATION,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301343 (sizeof(hdd_sta_ctx->
1344 cache_conn_info.vht_operation)),
1345 &hdd_sta_ctx->cache_conn_info.vht_operation)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1347 goto fail;
1348 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301349 if (hdd_sta_ctx->cache_conn_info.conn_flag.hs20_present)
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301350 if (nla_put(skb, AP_INFO_HS20_INDICATION,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301351 (sizeof(hdd_sta_ctx->cache_conn_info.hs20vendor_ie)
1352 - 1), tmp_hs20 + 1)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1354 goto fail;
1355 }
1356
1357 return cfg80211_vendor_cmd_reply(skb);
1358fail:
1359 if (skb)
1360 kfree_skb(skb);
1361 return -EINVAL;
1362}
1363
1364/**
Hanumanth Reddy Pothulaa35c4872017-12-14 20:47:59 +05301365 * hdd_add_survey_info_sap_get_len - get data length used in
1366 * hdd_add_survey_info_sap()
1367 *
1368 * This function calculates the data length used in hdd_add_survey_info_sap()
1369 *
1370 * Return: total data length used in hdd_add_survey_info_sap()
1371 */
1372static uint32_t hdd_add_survey_info_sap_get_len(void)
1373{
1374 return ((NLA_HDRLEN) + (sizeof(uint32_t) + NLA_HDRLEN));
1375}
1376
1377/**
1378 * hdd_add_survey_info - add survey info attribute
1379 * @skb: pointer to response skb buffer
1380 * @stainfo: station information
1381 * @idx: attribute type index for nla_next_start()
1382 *
1383 * This function adds survey info attribute to response skb buffer
1384 *
1385 * Return : 0 on success and errno on failure
1386 */
1387static int32_t hdd_add_survey_info_sap(struct sk_buff *skb,
1388 struct hdd_cache_sta_info *stainfo,
1389 int idx)
1390{
1391 struct nlattr *nla_attr;
1392
1393 nla_attr = nla_nest_start(skb, idx);
1394 if (!nla_attr)
1395 goto fail;
1396 if (nla_put_u32(skb, NL80211_SURVEY_INFO_FREQUENCY,
1397 stainfo->freq)) {
1398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1399 FL("put fail"));
1400 goto fail;
1401 }
1402 nla_nest_end(skb, nla_attr);
1403 return 0;
1404fail:
1405 return -EINVAL;
1406}
1407
1408/**
1409 * hdd_add_tx_bitrate_sap_get_len - get data length used in
1410 * hdd_add_tx_bitrate_sap()
1411 *
1412 * This function calculates the data length used in hdd_add_tx_bitrate_sap()
1413 *
1414 * Return: total data length used in hdd_add_tx_bitrate_sap()
1415 */
1416static uint32_t hdd_add_tx_bitrate_sap_get_len(void)
1417{
1418 return ((NLA_HDRLEN) + (sizeof(uint8_t) + NLA_HDRLEN));
1419}
1420
1421/**
1422 * hdd_add_tx_bitrate_sap - add vht nss info attribute
1423 * @skb: pointer to response skb buffer
1424 * @stainfo: station information
1425 * @idx: attribute type index for nla_next_start()
1426 *
1427 * This function adds vht nss attribute to response skb buffer
1428 *
1429 * Return : 0 on success and errno on failure
1430 */
1431static int hdd_add_tx_bitrate_sap(struct sk_buff *skb,
1432 struct hdd_cache_sta_info *stainfo,
1433 int idx)
1434{
1435 struct nlattr *nla_attr;
1436
1437 nla_attr = nla_nest_start(skb, idx);
1438 if (!nla_attr)
1439 goto fail;
1440
1441 if (nla_put_u8(skb, NL80211_RATE_INFO_VHT_NSS,
1442 stainfo->nss)) {
1443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1444 FL("put fail"));
1445 goto fail;
1446 }
1447 nla_nest_end(skb, nla_attr);
1448 return 0;
1449fail:
1450 return -EINVAL;
1451}
1452
1453/**
1454 * hdd_add_sta_info_sap_get_len - get data length used in
1455 * hdd_add_sta_info_sap()
1456 *
1457 * This function calculates the data length used in hdd_add_sta_info_sap()
1458 *
1459 * Return: total data length used in hdd_add_sta_info_sap()
1460 */
1461static uint32_t hdd_add_sta_info_sap_get_len(void)
1462{
1463 return ((NLA_HDRLEN) + (sizeof(uint8_t) + NLA_HDRLEN) +
1464 hdd_add_tx_bitrate_sap_get_len());
1465}
1466
1467/**
1468 * hdd_add_sta_info_sap - add sta signal info attribute
1469 * @skb: pointer to response skb buffer
1470 * @rssi: peer rssi value
1471 * @stainfo: station information
1472 * @idx: attribute type index for nla_next_start()
1473 *
1474 * This function adds sta signal attribute to response skb buffer
1475 *
1476 * Return : 0 on success and errno on failure
1477 */
1478static int32_t hdd_add_sta_info_sap(struct sk_buff *skb, int8_t rssi,
1479 struct hdd_cache_sta_info *stainfo, int idx)
1480{
1481 struct nlattr *nla_attr;
1482
1483 nla_attr = nla_nest_start(skb, idx);
1484 if (!nla_attr)
1485 goto fail;
1486
Hanumanth Reddy Pothula14bc86d2018-01-02 20:02:02 +05301487 /* upperlayer expects positive rssi value */
1488 if (nla_put_u8(skb, NL80211_STA_INFO_SIGNAL, (rssi + 96))) {
Hanumanth Reddy Pothulaa35c4872017-12-14 20:47:59 +05301489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1490 FL("put fail"));
1491 goto fail;
1492 }
1493 if (hdd_add_tx_bitrate_sap(skb, stainfo, NL80211_STA_INFO_TX_BITRATE)) {
1494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1495 FL("put fail"));
1496 goto fail;
1497 }
1498
1499 nla_nest_end(skb, nla_attr);
1500 return 0;
1501fail:
1502 return -EINVAL;
1503}
1504
1505/**
1506 * hdd_add_link_standard_info_sap_get_len - get data length used in
1507 * hdd_add_link_standard_info_sap()
1508 *
1509 * This function calculates the data length used in
1510 * hdd_add_link_standard_info_sap()
1511 *
1512 * Return: total data length used in hdd_add_link_standard_info_sap()
1513 */
1514static uint32_t hdd_add_link_standard_info_sap_get_len(void)
1515{
1516 return ((NLA_HDRLEN) +
1517 hdd_add_survey_info_sap_get_len() +
1518 hdd_add_sta_info_sap_get_len() +
1519 (sizeof(uint32_t) + NLA_HDRLEN));
1520}
1521
1522/**
1523 * hdd_add_link_standard_info_sap - add add link info attribut
1524 * @skb: pointer to response skb buffer
1525 * @stainfo: station information
1526 * @idx: attribute type index for nla_next_start()
1527 *
1528 * This function adds link info attribut to response skb buffer
1529 *
1530 * Return : 0 on success and errno on failure
1531 */
1532static int hdd_add_link_standard_info_sap(struct sk_buff *skb, int8_t rssi,
1533 struct hdd_cache_sta_info *stainfo,
1534 int idx)
1535{
1536 struct nlattr *nla_attr;
1537
1538 nla_attr = nla_nest_start(skb, idx);
1539 if (!nla_attr)
1540 goto fail;
1541 if (hdd_add_survey_info_sap(skb, stainfo, NL80211_ATTR_SURVEY_INFO))
1542 goto fail;
1543 if (hdd_add_sta_info_sap(skb, rssi, stainfo, NL80211_ATTR_STA_INFO))
1544 goto fail;
1545
1546 if (nla_put_u32(skb, NL80211_ATTR_REASON_CODE, stainfo->reason_code)) {
1547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1548 FL("put fail"));
1549 goto fail;
1550 }
1551
1552 nla_nest_end(skb, nla_attr);
1553 return 0;
1554fail:
1555 return -EINVAL;
1556}
1557
1558/**
1559 * hdd_add_ap_standard_info_sap_get_len - get data length used in
1560 * hdd_add_ap_standard_info_sap()
1561 * @stainfo: station information
1562 *
1563 * This function calculates the data length used in
1564 * hdd_add_ap_standard_info_sap()
1565 *
1566 * Return: total data length used in hdd_add_ap_standard_info_sap()
1567 */
1568static uint32_t hdd_add_ap_standard_info_sap_get_len(
1569 struct hdd_cache_sta_info *stainfo)
1570{
1571 uint32_t len;
1572
1573 len = NLA_HDRLEN;
1574 if (stainfo->vht_present)
1575 len += (sizeof(stainfo->vht_caps) + NLA_HDRLEN);
1576 if (stainfo->ht_present)
1577 len += (sizeof(stainfo->ht_caps) + NLA_HDRLEN);
1578
1579 return len;
1580}
1581
1582/**
1583 * hdd_add_ap_standard_info_sap - add HT and VHT info attributes
1584 * @skb: pointer to response skb buffer
1585 * @stainfo: station information
1586 * @idx: attribute type index for nla_next_start()
1587 *
1588 * This function adds HT and VHT info attributes to response skb buffer
1589 *
1590 * Return : 0 on success and errno on failure
1591 */
1592static int hdd_add_ap_standard_info_sap(struct sk_buff *skb,
1593 struct hdd_cache_sta_info *stainfo,
1594 int idx)
1595{
1596 struct nlattr *nla_attr;
1597
1598 nla_attr = nla_nest_start(skb, idx);
1599 if (!nla_attr)
1600 goto fail;
1601
1602 if (stainfo->vht_present) {
1603 if (nla_put(skb, NL80211_ATTR_VHT_CAPABILITY,
1604 sizeof(stainfo->vht_caps),
1605 &stainfo->vht_caps)) {
1606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1607 FL("put fail"));
1608 goto fail;
1609 }
1610 }
1611 if (stainfo->ht_present) {
1612 if (nla_put(skb, NL80211_ATTR_HT_CAPABILITY,
1613 sizeof(stainfo->ht_caps),
1614 &stainfo->ht_caps)) {
1615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1616 FL("put fail"));
1617 goto fail;
1618 }
1619 }
1620 nla_nest_end(skb, nla_attr);
1621 return 0;
1622fail:
1623 return -EINVAL;
1624}
1625
1626/**
1627 * hdd_decode_ch_width - decode channel band width based
1628 * @ch_width: encoded enum value holding channel band width
1629 *
1630 * This function decodes channel band width from the given encoded enum value.
1631 *
1632 * Returns: decoded channel band width.
1633 */
1634static uint8_t hdd_decode_ch_width(tSirMacHTChannelWidth ch_width)
1635{
1636 switch (ch_width) {
1637 case 0:
1638 return 20;
1639 case 1:
1640 return 40;
1641 case 2:
1642 return 80;
1643 default:
1644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1645 "invalid enum: %d", ch_width);
1646 return 20;
1647 }
1648}
1649
1650/**
1651 * hdd_get_cached_station_remote() - get cached(deleted) peer's info
1652 * @hdd_ctx: hdd context
1653 * @adapter: hostapd interface
1654 * @mac_addr: mac address of requested peer
1655 *
1656 * This function collect and indicate the cached(deleted) peer's info
1657 *
1658 * Return: 0 on success, otherwise error value
1659 */
1660static int hdd_get_cached_station_remote(hdd_context_t *hdd_ctx,
1661 hdd_adapter_t *adapter,
1662 v_MACADDR_t mac_addr)
1663{
1664 struct hdd_cache_sta_info *stainfo;
1665 struct sk_buff *skb = NULL;
1666 uint32_t nl_buf_len;
1667 uint8_t cw;
1668 ptSapContext sap_ctx;
1669 v_CONTEXT_t vos_ctx = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
1670
1671 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
1672 if(sap_ctx == NULL){
1673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1674 FL("psapCtx is NULL"));
1675 return -ENOENT;
1676 }
1677
1678 stainfo = hdd_get_cache_stainfo(sap_ctx->cache_sta_info,
1679 mac_addr.bytes);
1680 if (!stainfo) {
1681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1682 "peer " MAC_ADDRESS_STR " not found",
1683 MAC_ADDR_ARRAY(mac_addr.bytes));
1684 return -EINVAL;
1685 }
Bala Venkatesha3fe9262019-08-14 11:36:53 +05301686 if (sap_ctx->aStaInfo[stainfo->ucSTAId].isUsed == TRUE &&
1687 !sap_ctx->aStaInfo[stainfo->ucSTAId].isDeauthInProgress) {
Hanumanth Reddy Pothulaa35c4872017-12-14 20:47:59 +05301688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1689 "peer " MAC_ADDRESS_STR " is in connected state",
1690 MAC_ADDR_ARRAY(mac_addr.bytes));
1691 return -EINVAL;
1692 }
1693
1694
1695 nl_buf_len = NLMSG_HDRLEN + hdd_add_link_standard_info_sap_get_len() +
1696 hdd_add_ap_standard_info_sap_get_len(stainfo) +
1697 (sizeof(stainfo->dot11_mode) + NLA_HDRLEN) +
1698 (sizeof(cw) + NLA_HDRLEN) +
1699 (sizeof(stainfo->rx_rate) + NLA_HDRLEN);
1700
1701 skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len);
1702 if (!skb) {
1703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "cfg80211_vendor_cmd_alloc_reply_skb failed");
1704 return -ENOMEM;
1705 }
1706
1707 if (hdd_add_link_standard_info_sap(skb, stainfo->rssi, stainfo,
1708 LINK_INFO_STANDARD_NL80211_ATTR)) {
1709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "link standard put fail");
1710 goto fail;
1711 }
1712
1713 if (hdd_add_ap_standard_info_sap(skb, stainfo,
1714 AP_INFO_STANDARD_NL80211_ATTR)) {
1715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ap standard put fail");
1716 goto fail;
1717 }
1718
1719 /* upper layer expects decoded channel BW */
1720 cw = hdd_decode_ch_width(stainfo->ch_width);
1721 if (nla_put_u32(skb, REMOTE_SUPPORTED_MODE, stainfo->dot11_mode) ||
1722 nla_put_u8(skb, REMOTE_CH_WIDTH, cw)) {
1723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "remote ch put fail");
1724 goto fail;
1725 }
Hanumanth Reddy Pothula504fe152018-01-02 20:41:03 +05301726 if (nla_put_u32(skb, REMOTE_LAST_RX_RATE, (stainfo->rx_rate * 100))) {
Hanumanth Reddy Pothulaa35c4872017-12-14 20:47:59 +05301727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "rx rate put fail");
1728 goto fail;
1729 }
1730
1731 vos_mem_zero(stainfo, sizeof(*stainfo));
1732
1733 return cfg80211_vendor_cmd_reply(skb);
1734fail:
1735 if (skb)
1736 kfree_skb(skb);
1737
1738 return -EINVAL;
1739}
1740
1741/**
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301742 * __hdd_cfg80211_get_station_cmd() - Handle get station vendor cmd
1743 * @wiphy: corestack handler
1744 * @wdev: wireless device
1745 * @data: data
1746 * @data_len: data length
1747 *
1748 * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION.
1749 * Validate cmd attributes and send the station info to upper layers.
1750 *
1751 * Return: Success(0) or reason code for failure
1752 */
1753static int32_t
1754__hdd_cfg80211_get_station_cmd(struct wiphy *wiphy,
1755 struct wireless_dev *wdev,
1756 const void *data,
1757 int data_len)
1758{
1759 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
1760 struct net_device *dev = wdev->netdev;
1761 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1762 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX + 1];
1763 int32_t status;
1764
1765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"Enter");
1766 if (VOS_FTM_MODE == hdd_get_conparam()) {
1767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"Command not allowed in FTM mode");
1768 status = -EPERM;
1769 goto out;
1770 }
1771
1772 status = wlan_hdd_validate_context(hdd_ctx);
1773 if (0 != status)
1774 goto out;
1775
1776
1777 status = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX,
1778 data, data_len, NULL);
1779 if (status) {
1780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"Invalid ATTR");
1781 goto out;
1782 }
1783
1784 /* Parse and fetch Command Type*/
1785 if (tb[STATION_INFO]) {
1786 status = hdd_get_station_info(hdd_ctx, adapter);
1787 } else if (tb[STATION_ASSOC_FAIL_REASON]) {
1788 status = hdd_get_station_assoc_fail(hdd_ctx, adapter);
Hanumanth Reddy Pothulaa35c4872017-12-14 20:47:59 +05301789 } else if (tb[STATION_REMOTE]) {
1790 v_MACADDR_t mac_addr;
1791
1792 if (adapter->device_mode != WLAN_HDD_SOFTAP &&
1793 adapter->device_mode != WLAN_HDD_P2P_GO) {
1794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"invalid device_mode:%d",
1795 adapter->device_mode);
1796 status = -EINVAL;
1797 goto out;
1798 }
1799
1800 nla_memcpy(mac_addr.bytes, tb[STATION_REMOTE],
1801 VOS_MAC_ADDRESS_LEN);
1802
1803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "STATION_REMOTE "MAC_ADDRESS_STR"",
1804 MAC_ADDR_ARRAY(mac_addr.bytes));
1805
1806 status = hdd_get_cached_station_remote(hdd_ctx, adapter,
1807 mac_addr);
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301808 } else {
1809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"get station info cmd type failed");
1810 status = -EINVAL;
1811 goto out;
1812 }
1813 EXIT();
1814out:
1815 return status;
1816}
1817
1818/**
1819 * wlan_hdd_cfg80211_get_station_cmd() - Handle get station vendor cmd
1820 * @wiphy: corestack handler
1821 * @wdev: wireless device
1822 * @data: data
1823 * @data_len: data length
1824 *
1825 * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION.
1826 * Validate cmd attributes and send the station info to upper layers.
1827 *
1828 * Return: Success(0) or reason code for failure
1829 */
1830static int32_t
1831hdd_cfg80211_get_station_cmd(struct wiphy *wiphy,
1832 struct wireless_dev *wdev,
1833 const void *data,
1834 int data_len)
1835{
1836 int ret;
1837
1838 vos_ssr_protect(__func__);
1839 ret = __hdd_cfg80211_get_station_cmd(wiphy, wdev, data, data_len);
1840 vos_ssr_unprotect(__func__);
1841
1842 return ret;
1843}
1844
1845/*
1846 * undef short names defined for get station command
1847 * used by __wlan_hdd_cfg80211_get_station_cmd()
1848 */
1849#undef STATION_INVALID
1850#undef STATION_INFO
1851#undef STATION_ASSOC_FAIL_REASON
1852#undef STATION_MAX
Srinivas Dasari030bad32015-02-18 23:23:54 +05301853
Sunil Duttc69bccb2014-05-26 21:30:20 +05301854#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1855
1856static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
1857 struct sk_buff *vendor_event)
1858{
1859 if (nla_put_u8(vendor_event,
1860 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
1861 stats->rate.preamble) ||
1862 nla_put_u8(vendor_event,
1863 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
1864 stats->rate.nss) ||
1865 nla_put_u8(vendor_event,
1866 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
1867 stats->rate.bw) ||
1868 nla_put_u8(vendor_event,
1869 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
1870 stats->rate.rateMcsIdx) ||
1871 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
1872 stats->rate.bitrate ) ||
1873 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
1874 stats->txMpdu ) ||
1875 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
1876 stats->rxMpdu ) ||
1877 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
1878 stats->mpduLost ) ||
1879 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
1880 stats->retries) ||
1881 nla_put_u32(vendor_event,
1882 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
1883 stats->retriesShort ) ||
1884 nla_put_u32(vendor_event,
1885 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
1886 stats->retriesLong))
1887 {
1888 hddLog(VOS_TRACE_LEVEL_ERROR,
1889 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1890 return FALSE;
1891 }
1892 return TRUE;
1893}
1894
1895static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
1896 struct sk_buff *vendor_event)
1897{
1898 u32 i = 0;
1899 struct nlattr *rateInfo;
1900 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
1901 stats->type) ||
1902 nla_put(vendor_event,
1903 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
1904 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
1905 nla_put_u32(vendor_event,
1906 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
1907 stats->capabilities) ||
1908 nla_put_u32(vendor_event,
1909 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
1910 stats->numRate))
1911 {
1912 hddLog(VOS_TRACE_LEVEL_ERROR,
1913 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1914 goto error;
1915 }
1916
1917 rateInfo = nla_nest_start(vendor_event,
1918 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301919 if(!rateInfo)
1920 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301921 for (i = 0; i < stats->numRate; i++)
1922 {
1923 struct nlattr *rates;
1924 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
1925 stats->rateStats +
1926 (i * sizeof(tSirWifiRateStat)));
1927 rates = nla_nest_start(vendor_event, i);
Sourav Mohapatra37aa80a2018-10-31 10:57:00 +05301928
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301929 if(!rates)
1930 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301931
1932 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
1933 {
1934 hddLog(VOS_TRACE_LEVEL_ERROR,
1935 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1936 return FALSE;
1937 }
1938 nla_nest_end(vendor_event, rates);
1939 }
1940 nla_nest_end(vendor_event, rateInfo);
1941
1942 return TRUE;
1943error:
1944 return FALSE;
1945}
1946
1947static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
1948 struct sk_buff *vendor_event)
1949{
1950 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
1951 stats->ac ) ||
1952 nla_put_u32(vendor_event,
1953 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
1954 stats->txMpdu ) ||
1955 nla_put_u32(vendor_event,
1956 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
1957 stats->rxMpdu ) ||
1958 nla_put_u32(vendor_event,
1959 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
1960 stats->txMcast ) ||
1961 nla_put_u32(vendor_event,
1962 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
1963 stats->rxMcast ) ||
1964 nla_put_u32(vendor_event,
1965 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
1966 stats->rxAmpdu ) ||
1967 nla_put_u32(vendor_event,
1968 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
1969 stats->txAmpdu ) ||
1970 nla_put_u32(vendor_event,
1971 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
1972 stats->mpduLost )||
1973 nla_put_u32(vendor_event,
1974 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
1975 stats->retries ) ||
1976 nla_put_u32(vendor_event,
1977 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
1978 stats->retriesShort ) ||
1979 nla_put_u32(vendor_event,
1980 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
1981 stats->retriesLong ) ||
1982 nla_put_u32(vendor_event,
1983 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
1984 stats->contentionTimeMin ) ||
1985 nla_put_u32(vendor_event,
1986 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
1987 stats->contentionTimeMax ) ||
1988 nla_put_u32(vendor_event,
1989 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
1990 stats->contentionTimeAvg ) ||
1991 nla_put_u32(vendor_event,
1992 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
1993 stats->contentionNumSamples ))
1994 {
1995 hddLog(VOS_TRACE_LEVEL_ERROR,
1996 FL("QCA_WLAN_VENDOR_ATTR put fail") );
1997 return FALSE;
1998 }
1999 return TRUE;
2000}
2001
2002static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
2003 struct sk_buff *vendor_event)
2004{
Dino Myclec8f3f332014-07-21 16:48:27 +05302005 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302006 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
2007 nla_put(vendor_event,
2008 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
2009 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
2010 nla_put_u32(vendor_event,
2011 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
2012 stats->state ) ||
2013 nla_put_u32(vendor_event,
2014 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
2015 stats->roaming ) ||
2016 nla_put_u32(vendor_event,
2017 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
2018 stats->capabilities ) ||
2019 nla_put(vendor_event,
2020 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
2021 strlen(stats->ssid), stats->ssid) ||
2022 nla_put(vendor_event,
2023 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
2024 WNI_CFG_BSSID_LEN, stats->bssid) ||
2025 nla_put(vendor_event,
2026 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
2027 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
2028 nla_put(vendor_event,
2029 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
2030 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
2031 )
2032 {
2033 hddLog(VOS_TRACE_LEVEL_ERROR,
2034 FL("QCA_WLAN_VENDOR_ATTR put fail") );
2035 return FALSE;
2036 }
2037 return TRUE;
2038}
2039
Dino Mycle3b9536d2014-07-09 22:05:24 +05302040static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
2041 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302042 struct sk_buff *vendor_event)
2043{
2044 int i = 0;
2045 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302046 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2047 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05302048 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302049
Sunil Duttc69bccb2014-05-26 21:30:20 +05302050 if (FALSE == put_wifi_interface_info(
2051 &pWifiIfaceStat->info,
2052 vendor_event))
2053 {
2054 hddLog(VOS_TRACE_LEVEL_ERROR,
2055 FL("QCA_WLAN_VENDOR_ATTR put fail") );
2056 return FALSE;
2057
2058 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05302059 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
2060 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
2061 if (NULL == pWifiIfaceStatTL)
2062 {
2063 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
2064 return FALSE;
2065 }
2066
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05302067 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
2068 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
2069 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
2070 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
2071
2072 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
2073 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
2074 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
2075 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302076
2077 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
2078 {
2079 if (VOS_STATUS_SUCCESS ==
2080 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2081 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
2082 {
2083 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
2084 * obtained from TL structure
2085 */
2086
2087 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
2088 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302089 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
2090
Srinivas Dasari98947432014-11-07 19:41:24 +05302091 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
2092 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
2093 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
2094 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
2095 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
2096 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
2097 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
2098 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302099
Srinivas Dasari98947432014-11-07 19:41:24 +05302100 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
2101 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
2102 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
2103 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
2104 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
2105 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
2106 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
2107 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302108
Srinivas Dasari98947432014-11-07 19:41:24 +05302109 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
2110 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
2111 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
2112 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
2113 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
2114 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
2115 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
2116 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302117 }
2118 else
2119 {
2120 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
2121 }
2122
Dino Mycle3b9536d2014-07-09 22:05:24 +05302123 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
2124 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
2125 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
2126 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
2127 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
2128 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
2129 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
2130 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
2131 }
2132 else
2133 {
2134 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
2135 }
2136
2137
Sunil Duttc69bccb2014-05-26 21:30:20 +05302138
2139 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302140 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
2141 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
2142 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302143 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
2144 pWifiIfaceStat->beaconRx) ||
2145 nla_put_u32(vendor_event,
2146 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
2147 pWifiIfaceStat->mgmtRx) ||
2148 nla_put_u32(vendor_event,
2149 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
2150 pWifiIfaceStat->mgmtActionRx) ||
2151 nla_put_u32(vendor_event,
2152 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
2153 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05302154 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302155 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
2156 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05302157 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302158 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
2159 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05302160 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302161 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
2162 pWifiIfaceStat->rssiAck))
2163 {
2164 hddLog(VOS_TRACE_LEVEL_ERROR,
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05302165 FL("QCA_WLAN_VENDOR_ATTR put fail"));
2166 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302167 return FALSE;
2168 }
2169
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05302170#ifdef FEATURE_EXT_LL_STAT
2171 /*
2172 * Ensure when EXT_LL_STAT is supported by both host and fwr,
2173 * then host should send Leaky AP stats to upper layer,
2174 * otherwise no need to send these stats.
2175 */
2176 if(sme_IsFeatureSupportedByFW(EXT_LL_STAT) &&
2177 sme_IsFeatureSupportedByDriver(EXT_LL_STAT)
2178 )
2179 {
2180 hddLog(VOS_TRACE_LEVEL_INFO,
2181 FL("EXT_LL_STAT is supported by fwr and host %u %u %u %llu"),
2182 pWifiIfaceStat->leakyApStat.is_leaky_ap,
2183 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked,
2184 pWifiIfaceStat->leakyApStat.rx_leak_window,
2185 pWifiIfaceStat->leakyApStat.avg_bcn_spread);
2186 if (nla_put_u32(vendor_event,
2187 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_DETECTED,
2188 pWifiIfaceStat->leakyApStat.is_leaky_ap) ||
2189 nla_put_u32(vendor_event,
2190 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_AVG_NUM_FRAMES_LEAKED,
2191 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked) ||
2192 nla_put_u32(vendor_event,
2193 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_GUARD_TIME,
2194 pWifiIfaceStat->leakyApStat.rx_leak_window) ||
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302195 hdd_wlan_nla_put_u64(vendor_event,
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05302196 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_AVERAGE_TSF_OFFSET,
2197 pWifiIfaceStat->leakyApStat.avg_bcn_spread))
2198 {
2199 hddLog(VOS_TRACE_LEVEL_ERROR,
2200 FL("EXT_LL_STAT put fail"));
2201 vos_mem_free(pWifiIfaceStatTL);
2202 return FALSE;
2203 }
2204 }
2205#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +05302206 wmmInfo = nla_nest_start(vendor_event,
2207 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302208 if(!wmmInfo)
2209 {
2210 vos_mem_free(pWifiIfaceStatTL);
2211 return FALSE;
2212 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302213 for (i = 0; i < WIFI_AC_MAX; i++)
2214 {
2215 struct nlattr *wmmStats;
2216 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302217 if(!wmmStats)
2218 {
2219 vos_mem_free(pWifiIfaceStatTL);
2220 return FALSE;
2221 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302222 if (FALSE == put_wifi_wmm_ac_stat(
2223 &pWifiIfaceStat->AccessclassStats[i],
2224 vendor_event))
2225 {
2226 hddLog(VOS_TRACE_LEVEL_ERROR,
2227 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05302228 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302229 return FALSE;
2230 }
2231
2232 nla_nest_end(vendor_event, wmmStats);
2233 }
2234 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05302235 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302236 return TRUE;
2237}
2238
2239static tSirWifiInterfaceMode
2240 hdd_map_device_to_ll_iface_mode ( int deviceMode )
2241{
2242 switch (deviceMode)
2243 {
2244 case WLAN_HDD_INFRA_STATION:
2245 return WIFI_INTERFACE_STA;
2246 case WLAN_HDD_SOFTAP:
2247 return WIFI_INTERFACE_SOFTAP;
2248 case WLAN_HDD_P2P_CLIENT:
2249 return WIFI_INTERFACE_P2P_CLIENT;
2250 case WLAN_HDD_P2P_GO:
2251 return WIFI_INTERFACE_P2P_GO;
2252 case WLAN_HDD_IBSS:
2253 return WIFI_INTERFACE_IBSS;
2254 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05302255 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302256 }
2257}
2258
2259static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
2260 tpSirWifiInterfaceInfo pInfo)
2261{
2262 v_U8_t *staMac = NULL;
2263 hdd_station_ctx_t *pHddStaCtx;
2264 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2265 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2266
2267 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
2268
2269 vos_mem_copy(pInfo->macAddr,
2270 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
2271
2272 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
2273 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
2274 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
2275 {
2276 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2277 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
2278 {
2279 pInfo->state = WIFI_DISCONNECTED;
2280 }
2281 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
2282 {
2283 hddLog(VOS_TRACE_LEVEL_ERROR,
2284 "%s: Session ID %d, Connection is in progress", __func__,
2285 pAdapter->sessionId);
2286 pInfo->state = WIFI_ASSOCIATING;
2287 }
2288 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
2289 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
2290 {
2291 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
2292 hddLog(VOS_TRACE_LEVEL_ERROR,
2293 "%s: client " MAC_ADDRESS_STR
2294 " is in the middle of WPS/EAPOL exchange.", __func__,
2295 MAC_ADDR_ARRAY(staMac));
2296 pInfo->state = WIFI_AUTHENTICATING;
2297 }
2298 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
2299 {
2300 pInfo->state = WIFI_ASSOCIATED;
2301 vos_mem_copy(pInfo->bssid,
2302 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
2303 vos_mem_copy(pInfo->ssid,
2304 pHddStaCtx->conn_info.SSID.SSID.ssId,
2305 pHddStaCtx->conn_info.SSID.SSID.length);
2306 //NULL Terminate the string.
2307 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
2308 }
2309 }
2310 vos_mem_copy(pInfo->countryStr,
2311 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
2312
2313 vos_mem_copy(pInfo->apCountryStr,
2314 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
2315
2316 return TRUE;
2317}
2318
2319/*
2320 * hdd_link_layer_process_peer_stats () - This function is called after
2321 * receiving Link Layer Peer statistics from FW.This function converts
2322 * the firmware data to the NL data and sends the same to the kernel/upper
2323 * layers.
2324 */
2325static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
2326 v_VOID_t *pData)
2327{
2328 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302329 tpSirWifiPeerStat pWifiPeerStat;
2330 tpSirWifiPeerInfo pWifiPeerInfo;
2331 struct nlattr *peerInfo;
2332 struct sk_buff *vendor_event;
2333 int status, i;
2334
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302335 ENTER();
2336
Sunil Duttc69bccb2014-05-26 21:30:20 +05302337 status = wlan_hdd_validate_context(pHddCtx);
2338 if (0 != status)
2339 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302340 return;
2341 }
2342
2343 pWifiPeerStat = (tpSirWifiPeerStat) pData;
2344
2345 hddLog(VOS_TRACE_LEVEL_INFO,
2346 "LL_STATS_PEER_ALL : numPeers %u",
2347 pWifiPeerStat->numPeers);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302348 /*
2349 * Allocate a size of 4096 for the peer stats comprising
2350 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
2351 * sizeof (tSirWifiRateStat).Each field is put with an
2352 * NL attribute.The size of 4096 is considered assuming
2353 * that number of rates shall not exceed beyond 50 with
2354 * the sizeof (tSirWifiRateStat) being 32.
2355 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302356 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
2357 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302358 if (!vendor_event)
2359 {
2360 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302361 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05302362 __func__);
2363 return;
2364 }
2365 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302366 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
2367 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
2368 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302369 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
2370 pWifiPeerStat->numPeers))
2371 {
2372 hddLog(VOS_TRACE_LEVEL_ERROR,
2373 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
2374 kfree_skb(vendor_event);
2375 return;
2376 }
2377
2378 peerInfo = nla_nest_start(vendor_event,
2379 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302380 if(!peerInfo)
2381 {
2382 hddLog(VOS_TRACE_LEVEL_ERROR,
2383 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
2384 __func__);
2385 kfree_skb(vendor_event);
2386 return;
2387 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302388
2389 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
2390 pWifiPeerStat->peerInfo);
2391
2392 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
2393 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302394 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302395 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302396
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302397 if(!peers)
2398 {
2399 hddLog(VOS_TRACE_LEVEL_ERROR,
2400 "%s: peer stats put fail",
2401 __func__);
2402 kfree_skb(vendor_event);
2403 return;
2404 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302405 if (FALSE == put_wifi_peer_info(
2406 pWifiPeerInfo, vendor_event))
2407 {
2408 hddLog(VOS_TRACE_LEVEL_ERROR,
2409 "%s: put_wifi_peer_info put fail", __func__);
2410 kfree_skb(vendor_event);
2411 return;
2412 }
2413
Sourav Mohapatra37aa80a2018-10-31 10:57:00 +05302414 pWifiPeerInfo = (tpSirWifiPeerInfo)((uint8 *)pWifiPeerInfo +
2415 (sizeof(tSirWifiPeerInfo) - sizeof(tSirWifiRateStat)) +
2416 (numRate * sizeof(tSirWifiRateStat)));
2417
Sunil Duttc69bccb2014-05-26 21:30:20 +05302418 nla_nest_end(vendor_event, peers);
2419 }
2420 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302421 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302422 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302423}
2424
2425/*
2426 * hdd_link_layer_process_iface_stats () - This function is called after
2427 * receiving Link Layer Interface statistics from FW.This function converts
2428 * the firmware data to the NL data and sends the same to the kernel/upper
2429 * layers.
2430 */
2431static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
2432 v_VOID_t *pData)
2433{
2434 tpSirWifiIfaceStat pWifiIfaceStat;
2435 struct sk_buff *vendor_event;
2436 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2437 int status;
2438
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302439 ENTER();
2440
Sunil Duttc69bccb2014-05-26 21:30:20 +05302441 status = wlan_hdd_validate_context(pHddCtx);
2442 if (0 != status)
2443 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302444 return;
2445 }
2446 /*
2447 * Allocate a size of 4096 for the interface stats comprising
2448 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
2449 * assuming that all these fit with in the limit.Please take
2450 * a call on the limit based on the data requirements on
2451 * interface statistics.
2452 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302453 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
2454 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302455 if (!vendor_event)
2456 {
2457 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302458 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05302459 return;
2460 }
2461
2462 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
2463
Dino Mycle3b9536d2014-07-09 22:05:24 +05302464
2465 if (FALSE == hdd_get_interface_info( pAdapter,
2466 &pWifiIfaceStat->info))
2467 {
2468 hddLog(VOS_TRACE_LEVEL_ERROR,
2469 FL("hdd_get_interface_info get fail") );
2470 kfree_skb(vendor_event);
2471 return;
2472 }
2473
2474 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
2475 vendor_event))
2476 {
2477 hddLog(VOS_TRACE_LEVEL_ERROR,
2478 FL("put_wifi_iface_stats fail") );
2479 kfree_skb(vendor_event);
2480 return;
2481 }
2482
Sunil Duttc69bccb2014-05-26 21:30:20 +05302483 hddLog(VOS_TRACE_LEVEL_INFO,
2484 "WMI_LINK_STATS_IFACE Data");
2485
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302486 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302487
2488 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302489}
2490
2491/*
2492 * hdd_link_layer_process_radio_stats () - This function is called after
2493 * receiving Link Layer Radio statistics from FW.This function converts
2494 * the firmware data to the NL data and sends the same to the kernel/upper
2495 * layers.
2496 */
2497static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
2498 v_VOID_t *pData)
2499{
2500 int status, i;
2501 tpSirWifiRadioStat pWifiRadioStat;
2502 tpSirWifiChannelStats pWifiChannelStats;
2503 struct sk_buff *vendor_event;
2504 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2505 struct nlattr *chList;
2506
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302507 ENTER();
2508
Sunil Duttc69bccb2014-05-26 21:30:20 +05302509 status = wlan_hdd_validate_context(pHddCtx);
2510 if (0 != status)
2511 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302512 return;
2513 }
2514 pWifiRadioStat = (tpSirWifiRadioStat) pData;
2515
2516 hddLog(VOS_TRACE_LEVEL_INFO,
2517 "LL_STATS_RADIO"
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05302518 " number of radios = %u"
Sunil Duttc69bccb2014-05-26 21:30:20 +05302519 " radio is %d onTime is %u "
2520 " txTime is %u rxTime is %u "
2521 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05302522 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05302523 " onTimePnoScan is %u onTimeHs20 is %u "
2524 " numChannels is %u",
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05302525 NUM_RADIOS,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302526 pWifiRadioStat->radio, pWifiRadioStat->onTime,
2527 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
2528 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302529 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302530 pWifiRadioStat->onTimeRoamScan,
2531 pWifiRadioStat->onTimePnoScan,
2532 pWifiRadioStat->onTimeHs20,
2533 pWifiRadioStat->numChannels);
2534 /*
2535 * Allocate a size of 4096 for the Radio stats comprising
2536 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
2537 * (tSirWifiChannelStats).Each channel data is put with an
2538 * NL attribute.The size of 4096 is considered assuming that
2539 * number of channels shall not exceed beyond 60 with the
2540 * sizeof (tSirWifiChannelStats) being 24 bytes.
2541 */
2542
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302543 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
2544 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302545 if (!vendor_event)
2546 {
2547 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302548 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05302549 return;
2550 }
2551
2552 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302553 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
2554 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
2555 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302556 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
2557 pWifiRadioStat->radio) ||
2558 nla_put_u32(vendor_event,
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05302559 QCA_WLAN_VENDOR_ATTR_LL_STATS_NUM_RADIOS,
2560 NUM_RADIOS) ||
2561 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302562 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
2563 pWifiRadioStat->onTime) ||
2564 nla_put_u32(vendor_event,
2565 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
2566 pWifiRadioStat->txTime) ||
2567 nla_put_u32(vendor_event,
2568 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
2569 pWifiRadioStat->rxTime) ||
2570 nla_put_u32(vendor_event,
2571 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
2572 pWifiRadioStat->onTimeScan) ||
2573 nla_put_u32(vendor_event,
2574 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
2575 pWifiRadioStat->onTimeNbd) ||
2576 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302577 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
2578 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05302579 nla_put_u32(vendor_event,
2580 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
2581 pWifiRadioStat->onTimeRoamScan) ||
2582 nla_put_u32(vendor_event,
2583 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
2584 pWifiRadioStat->onTimePnoScan) ||
2585 nla_put_u32(vendor_event,
2586 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
2587 pWifiRadioStat->onTimeHs20) ||
2588 nla_put_u32(vendor_event,
2589 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
2590 pWifiRadioStat->numChannels))
2591 {
2592 hddLog(VOS_TRACE_LEVEL_ERROR,
2593 FL("QCA_WLAN_VENDOR_ATTR put fail"));
2594 kfree_skb(vendor_event);
2595 return ;
2596 }
2597
2598 chList = nla_nest_start(vendor_event,
2599 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302600 if(!chList)
2601 {
2602 hddLog(VOS_TRACE_LEVEL_ERROR,
2603 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
2604 __func__);
2605 kfree_skb(vendor_event);
2606 return;
2607 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302608 for (i = 0; i < pWifiRadioStat->numChannels; i++)
2609 {
2610 struct nlattr *chInfo;
2611
2612 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
2613 pWifiRadioStat->channels +
2614 (i * sizeof(tSirWifiChannelStats)));
2615
Sunil Duttc69bccb2014-05-26 21:30:20 +05302616 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302617 if(!chInfo)
2618 {
2619 hddLog(VOS_TRACE_LEVEL_ERROR,
2620 "%s: failed to put chInfo",
2621 __func__);
2622 kfree_skb(vendor_event);
2623 return;
2624 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302625
2626 if (nla_put_u32(vendor_event,
2627 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
2628 pWifiChannelStats->channel.width) ||
2629 nla_put_u32(vendor_event,
2630 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
2631 pWifiChannelStats->channel.centerFreq) ||
2632 nla_put_u32(vendor_event,
2633 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
2634 pWifiChannelStats->channel.centerFreq0) ||
2635 nla_put_u32(vendor_event,
2636 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
2637 pWifiChannelStats->channel.centerFreq1) ||
2638 nla_put_u32(vendor_event,
2639 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
2640 pWifiChannelStats->onTime) ||
2641 nla_put_u32(vendor_event,
2642 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
2643 pWifiChannelStats->ccaBusyTime))
2644 {
2645 hddLog(VOS_TRACE_LEVEL_ERROR,
2646 FL("cfg80211_vendor_event_alloc failed") );
2647 kfree_skb(vendor_event);
2648 return ;
2649 }
2650 nla_nest_end(vendor_event, chInfo);
2651 }
2652 nla_nest_end(vendor_event, chList);
2653
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302654 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302655
2656 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302657 return;
2658}
2659
2660/*
2661 * hdd_link_layer_stats_ind_callback () - This function is called after
2662 * receiving Link Layer indications from FW.This callback converts the firmware
2663 * data to the NL data and send the same to the kernel/upper layers.
2664 */
2665static void hdd_link_layer_stats_ind_callback ( void *pCtx,
2666 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05302667 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302668{
Dino Mycled3d50022014-07-07 12:58:25 +05302669 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
2670 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302671 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05302672 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302673 int status;
2674
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302675 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302676
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302677 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302678 if (0 != status)
2679 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302680 return;
2681 }
2682
Dino Mycled3d50022014-07-07 12:58:25 +05302683 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
2684 if (NULL == pAdapter)
2685 {
2686 hddLog(VOS_TRACE_LEVEL_ERROR,
2687 FL(" MAC address %pM does not exist with host"),
2688 macAddr);
2689 return;
2690 }
2691
Sunil Duttc69bccb2014-05-26 21:30:20 +05302692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302693 "%s: Interface: %s LLStats indType: %d", __func__,
2694 pAdapter->dev->name, indType);
2695
Sunil Duttc69bccb2014-05-26 21:30:20 +05302696 switch (indType)
2697 {
2698 case SIR_HAL_LL_STATS_RESULTS_RSP:
2699 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302700 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302701 "LL_STATS RESP paramID = 0x%x, ifaceId = %u MAC: %pM "
2702 "respId = %u, moreResultToFollow = %u",
2703 linkLayerStatsResults->paramId, linkLayerStatsResults->ifaceId,
2704 macAddr, linkLayerStatsResults->respId,
2705 linkLayerStatsResults->moreResultToFollow);
2706
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302707 spin_lock(&hdd_context_lock);
2708 context = &pHddCtx->ll_stats_context;
2709 /* validate response received from target */
2710 if ((context->request_id != linkLayerStatsResults->respId) ||
2711 !(context->request_bitmap & linkLayerStatsResults->paramId))
2712 {
2713 spin_unlock(&hdd_context_lock);
2714 hddLog(LOGE,
2715 FL("Error : Request id %d response id %d request bitmap 0x%x"
2716 "response bitmap 0x%x"),
2717 context->request_id, linkLayerStatsResults->respId,
2718 context->request_bitmap, linkLayerStatsResults->paramId);
2719 return;
2720 }
2721 spin_unlock(&hdd_context_lock);
2722
Sunil Duttc69bccb2014-05-26 21:30:20 +05302723 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
2724 {
2725 hdd_link_layer_process_radio_stats(pAdapter,
2726 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302727 spin_lock(&hdd_context_lock);
2728 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
2729 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302730 }
2731 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
2732 {
2733 hdd_link_layer_process_iface_stats(pAdapter,
2734 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302735 spin_lock(&hdd_context_lock);
2736 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
2737 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302738 }
2739 else if ( linkLayerStatsResults->paramId &
2740 WMI_LINK_STATS_ALL_PEER )
2741 {
2742 hdd_link_layer_process_peer_stats(pAdapter,
2743 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302744 spin_lock(&hdd_context_lock);
2745 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
2746 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302747 } /* WMI_LINK_STATS_ALL_PEER */
2748 else
2749 {
2750 hddLog(VOS_TRACE_LEVEL_ERROR,
2751 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
2752 }
2753
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302754 spin_lock(&hdd_context_lock);
2755 /* complete response event if all requests are completed */
2756 if (0 == context->request_bitmap)
2757 complete(&context->response_event);
2758 spin_unlock(&hdd_context_lock);
2759
Sunil Duttc69bccb2014-05-26 21:30:20 +05302760 break;
2761 }
2762 default:
2763 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
2764 break;
2765 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302766
2767 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302768 return;
2769}
2770
2771const struct
2772nla_policy
2773qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
2774{
2775 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
2776 { .type = NLA_U32 },
2777 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
2778 { .type = NLA_U32 },
2779};
2780
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302781static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
2782 struct wireless_dev *wdev,
2783 const void *data,
2784 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302785{
2786 int status;
2787 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302788 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302789 struct net_device *dev = wdev->netdev;
2790 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2791 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2792
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302793 ENTER();
2794
Sunil Duttc69bccb2014-05-26 21:30:20 +05302795 status = wlan_hdd_validate_context(pHddCtx);
2796 if (0 != status)
2797 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302798 return -EINVAL;
2799 }
2800
2801 if (NULL == pAdapter)
2802 {
2803 hddLog(VOS_TRACE_LEVEL_ERROR,
2804 FL("HDD adapter is Null"));
2805 return -ENODEV;
2806 }
Ashish Kumar Dhanotiyabdcafda2018-12-11 18:54:41 +05302807
2808 if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
2809 hddLog(VOS_TRACE_LEVEL_DEBUG,
2810 "Cannot set LL_STATS for device mode %d",
2811 pAdapter->device_mode);
2812 return -EINVAL;
2813 }
2814
Dino Mycledf0a5d92014-07-04 09:41:55 +05302815 /* check the LLStats Capability */
2816 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2817 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2818 {
Anurag Chouhan65ea6dc2016-10-25 19:59:14 +05302819 hddLog(VOS_TRACE_LEVEL_WARN,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302820 FL("Link Layer Statistics not supported by Firmware"));
2821 return -EINVAL;
2822 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302823
2824 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
2825 (struct nlattr *)data,
2826 data_len, qca_wlan_vendor_ll_set_policy))
2827 {
2828 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2829 return -EINVAL;
2830 }
2831 if (!tb_vendor
2832 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
2833 {
2834 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
2835 return -EINVAL;
2836 }
2837 if (!tb_vendor[
2838 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
2839 {
2840 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
2841 return -EINVAL;
2842 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302843 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302844 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302845
Dino Mycledf0a5d92014-07-04 09:41:55 +05302846 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302847 nla_get_u32(
2848 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
2849
Dino Mycledf0a5d92014-07-04 09:41:55 +05302850 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302851 nla_get_u32(
2852 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
2853
Dino Mycled3d50022014-07-07 12:58:25 +05302854 vos_mem_copy(linkLayerStatsSetReq.macAddr,
2855 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302856
2857
2858 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302859 "LL_STATS_SET reqId = %d, MAC = %pM, mpduSizeThreshold = %d "
2860 "Statistics Gathering = %d ",
2861 linkLayerStatsSetReq.reqId, linkLayerStatsSetReq.macAddr,
2862 linkLayerStatsSetReq.mpduSizeThreshold,
2863 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302864
2865 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
2866 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05302867 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302868 {
2869 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2870 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302871 return -EINVAL;
2872
2873 }
Srinivas Dasari98947432014-11-07 19:41:24 +05302874
Sunil Duttc69bccb2014-05-26 21:30:20 +05302875 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302876 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302877 {
2878 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2879 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302880 return -EINVAL;
2881 }
2882
2883 pAdapter->isLinkLayerStatsSet = 1;
2884
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302885 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302886 return 0;
2887}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302888static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
2889 struct wireless_dev *wdev,
2890 const void *data,
2891 int data_len)
2892{
2893 int ret = 0;
2894
2895 vos_ssr_protect(__func__);
2896 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
2897 vos_ssr_unprotect(__func__);
2898
2899 return ret;
2900}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302901
2902const struct
2903nla_policy
2904qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
2905{
2906 /* Unsigned 32bit value provided by the caller issuing the GET stats
2907 * command. When reporting
2908 * the stats results, the driver uses the same value to indicate
2909 * which GET request the results
2910 * correspond to.
2911 */
2912 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
2913
2914 /* Unsigned 32bit value . bit mask to identify what statistics are
2915 requested for retrieval */
2916 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
2917};
2918
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302919static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2920 struct wireless_dev *wdev,
2921 const void *data,
2922 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302923{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302924 unsigned long rc;
2925 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302926 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2927 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302928 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302929 struct net_device *dev = wdev->netdev;
2930 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05302931 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302932 int status;
2933
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302934 ENTER();
2935
Sunil Duttc69bccb2014-05-26 21:30:20 +05302936 status = wlan_hdd_validate_context(pHddCtx);
2937 if (0 != status)
2938 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302939 return -EINVAL ;
2940 }
2941
2942 if (NULL == pAdapter)
2943 {
2944 hddLog(VOS_TRACE_LEVEL_FATAL,
2945 "%s: HDD adapter is Null", __func__);
2946 return -ENODEV;
2947 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05302948
2949 if (pHddStaCtx == NULL)
2950 {
2951 hddLog(VOS_TRACE_LEVEL_FATAL,
2952 "%s: HddStaCtx is Null", __func__);
2953 return -ENODEV;
2954 }
2955
Dino Mycledf0a5d92014-07-04 09:41:55 +05302956 /* check the LLStats Capability */
2957 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2958 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2959 {
2960 hddLog(VOS_TRACE_LEVEL_ERROR,
2961 FL("Link Layer Statistics not supported by Firmware"));
2962 return -EINVAL;
2963 }
2964
Sunil Duttc69bccb2014-05-26 21:30:20 +05302965
2966 if (!pAdapter->isLinkLayerStatsSet)
2967 {
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05302968 hddLog(VOS_TRACE_LEVEL_ERROR,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302969 "%s: isLinkLayerStatsSet : %d",
2970 __func__, pAdapter->isLinkLayerStatsSet);
2971 return -EINVAL;
2972 }
2973
Mukul Sharma10313ba2015-07-29 19:14:39 +05302974 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
2975 {
2976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2977 "%s: Roaming in progress, so unable to proceed this request", __func__);
2978 return -EBUSY;
2979 }
2980
Sunil Duttc69bccb2014-05-26 21:30:20 +05302981 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2982 (struct nlattr *)data,
2983 data_len, qca_wlan_vendor_ll_get_policy))
2984 {
2985 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2986 return -EINVAL;
2987 }
2988
2989 if (!tb_vendor
2990 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2991 {
2992 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2993 return -EINVAL;
2994 }
2995
2996 if (!tb_vendor
2997 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2998 {
2999 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
3000 return -EINVAL;
3001 }
3002
Sunil Duttc69bccb2014-05-26 21:30:20 +05303003
Dino Mycledf0a5d92014-07-04 09:41:55 +05303004 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05303005 nla_get_u32( tb_vendor[
3006 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05303007 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05303008 nla_get_u32( tb_vendor[
3009 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
3010
Dino Mycled3d50022014-07-07 12:58:25 +05303011 vos_mem_copy(linkLayerStatsGetReq.macAddr,
3012 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05303013
3014 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05303015 "LL_STATS_GET reqId = %d, MAC = %pM, paramIdMask = %d",
3016 linkLayerStatsGetReq.reqId, linkLayerStatsGetReq.macAddr,
Dino Mycledf0a5d92014-07-04 09:41:55 +05303017 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05303018
mukul sharma4bd8d2e2015-08-13 20:33:25 +05303019 spin_lock(&hdd_context_lock);
3020 context = &pHddCtx->ll_stats_context;
3021 context->request_id = linkLayerStatsGetReq.reqId;
3022 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
3023 INIT_COMPLETION(context->response_event);
3024 spin_unlock(&hdd_context_lock);
3025
Sunil Duttc69bccb2014-05-26 21:30:20 +05303026 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05303027 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05303028 {
3029 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
3030 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05303031 return -EINVAL;
3032 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303033
mukul sharma4bd8d2e2015-08-13 20:33:25 +05303034 rc = wait_for_completion_timeout(&context->response_event,
3035 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
3036 if (!rc)
3037 {
3038 hddLog(LOGE,
3039 FL("Target response timed out request id %d request bitmap 0x%x"),
3040 context->request_id, context->request_bitmap);
3041 return -ETIMEDOUT;
3042 }
3043
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303044 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05303045 return 0;
3046}
3047
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303048static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
3049 struct wireless_dev *wdev,
3050 const void *data,
3051 int data_len)
3052{
3053 int ret = 0;
3054
3055 vos_ssr_protect(__func__);
3056 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
3057 vos_ssr_unprotect(__func__);
3058
3059 return ret;
3060}
3061
Sunil Duttc69bccb2014-05-26 21:30:20 +05303062const struct
3063nla_policy
3064qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
3065{
3066 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
3067 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
3068 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
3069 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
3070};
3071
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303072static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
3073 struct wireless_dev *wdev,
3074 const void *data,
3075 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05303076{
3077 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3078 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05303079 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05303080 struct net_device *dev = wdev->netdev;
3081 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3082 u32 statsClearReqMask;
3083 u8 stopReq;
3084 int status;
3085
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303086 ENTER();
3087
Sunil Duttc69bccb2014-05-26 21:30:20 +05303088 status = wlan_hdd_validate_context(pHddCtx);
3089 if (0 != status)
3090 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05303091 return -EINVAL;
3092 }
3093
3094 if (NULL == pAdapter)
3095 {
3096 hddLog(VOS_TRACE_LEVEL_FATAL,
3097 "%s: HDD adapter is Null", __func__);
3098 return -ENODEV;
3099 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05303100 /* check the LLStats Capability */
3101 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
3102 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
3103 {
3104 hddLog(VOS_TRACE_LEVEL_ERROR,
3105 FL("Enable LLStats Capability"));
3106 return -EINVAL;
3107 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05303108
3109 if (!pAdapter->isLinkLayerStatsSet)
3110 {
3111 hddLog(VOS_TRACE_LEVEL_FATAL,
3112 "%s: isLinkLayerStatsSet : %d",
3113 __func__, pAdapter->isLinkLayerStatsSet);
3114 return -EINVAL;
3115 }
3116
3117 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
3118 (struct nlattr *)data,
3119 data_len, qca_wlan_vendor_ll_clr_policy))
3120 {
3121 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
3122 return -EINVAL;
3123 }
3124
3125 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
3126
3127 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
3128 {
3129 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
3130 return -EINVAL;
3131
3132 }
3133
Sunil Duttc69bccb2014-05-26 21:30:20 +05303134
Dino Mycledf0a5d92014-07-04 09:41:55 +05303135 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05303136 nla_get_u32(
3137 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
3138
Dino Mycledf0a5d92014-07-04 09:41:55 +05303139 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05303140 nla_get_u8(
3141 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
3142
3143 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05303144 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05303145
Dino Mycled3d50022014-07-07 12:58:25 +05303146 vos_mem_copy(linkLayerStatsClearReq.macAddr,
3147 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05303148
3149 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05303150 "LL_STATS_CLEAR reqId = %d, MAC = %pM,"
3151 "statsClearReqMask = 0x%X, stopReq = %d",
3152 linkLayerStatsClearReq.reqId,
3153 linkLayerStatsClearReq.macAddr,
3154 linkLayerStatsClearReq.statsClearReqMask,
Dino Mycledf0a5d92014-07-04 09:41:55 +05303155 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05303156
3157 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05303158 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05303159 {
3160 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05303161 hdd_station_ctx_t *pHddStaCtx;
3162
3163 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3164 if (VOS_STATUS_SUCCESS !=
3165 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
3166 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
3167 {
3168 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
3169 "WLANTL_ClearInterfaceStats Failed", __func__);
3170 return -EINVAL;
3171 }
3172 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
3173 (statsClearReqMask & WIFI_STATS_IFACE)) {
3174 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
3175 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
3176 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
3177 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
3178 }
3179
Sunil Duttc69bccb2014-05-26 21:30:20 +05303180 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
3181 2 * sizeof(u32) +
3182 NLMSG_HDRLEN);
3183
3184 if (temp_skbuff != NULL)
3185 {
3186
3187 if (nla_put_u32(temp_skbuff,
3188 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
3189 statsClearReqMask) ||
3190 nla_put_u32(temp_skbuff,
3191 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
3192 stopReq))
3193 {
3194 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
3195 kfree_skb(temp_skbuff);
3196 return -EINVAL;
3197 }
3198 /* If the ask is to stop the stats collection as part of clear
3199 * (stopReq = 1) , ensure that no further requests of get
3200 * go to the firmware by having isLinkLayerStatsSet set to 0.
3201 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05303202 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05303203 * case the firmware is just asked to clear the statistics.
3204 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05303205 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05303206 pAdapter->isLinkLayerStatsSet = 0;
3207 return cfg80211_vendor_cmd_reply(temp_skbuff);
3208 }
3209 return -ENOMEM;
3210 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303211
3212 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05303213 return -EINVAL;
3214}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303215static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
3216 struct wireless_dev *wdev,
3217 const void *data,
3218 int data_len)
3219{
3220 int ret = 0;
3221
3222 vos_ssr_protect(__func__);
3223 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
3224 vos_ssr_unprotect(__func__);
3225
3226 return ret;
3227
3228
3229}
Sunil Duttc69bccb2014-05-26 21:30:20 +05303230#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
3231
Dino Mycle6fb96c12014-06-10 11:52:40 +05303232#ifdef WLAN_FEATURE_EXTSCAN
3233static const struct nla_policy
3234wlan_hdd_extscan_config_policy
3235 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
3236{
3237 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
3238 { .type = NLA_U32 },
3239 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
3240 { .type = NLA_U32 },
SaidiReddy Yenugaf2145922017-05-26 18:19:31 +05303241 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS] =
3242 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05303243 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
3244 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
3245 { .type = NLA_U32 },
3246 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
3247 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
3248
3249 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
3250 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
3251 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
3252 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
3253 { .type = NLA_U8 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303254 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD] =
3255 { .type = NLA_U32 },
3256 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT] =
3257 { .type = NLA_U32 },
3258 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT] =
3259 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05303260 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
3261 { .type = NLA_U32 },
3262 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
3263 { .type = NLA_U32 },
3264 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
3265 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303266 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT] =
3267 { .type = NLA_U8 },
3268 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05303269 { .type = NLA_U8 },
3270 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
3271 { .type = NLA_U8 },
3272 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
3273 { .type = NLA_U8 },
3274
3275 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
3276 { .type = NLA_U32 },
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05303277 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] = {
3278 .type = NLA_UNSPEC,
3279 .len = HDD_MAC_ADDR_LEN},
Dino Mycle6fb96c12014-06-10 11:52:40 +05303280 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
3281 { .type = NLA_S32 },
3282 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
3283 { .type = NLA_S32 },
3284 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
3285 { .type = NLA_U32 },
3286 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
3287 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303288 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE] =
3289 { .type = NLA_U32 },
3290 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID] =
3291 { .type = NLA_BINARY,
3292 .len = IEEE80211_MAX_SSID_LEN + 1 },
3293 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05303294 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303295 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID] =
3296 { .type = NLA_U32 },
3297 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND] =
3298 { .type = NLA_U8 },
3299 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW] =
3300 { .type = NLA_S32 },
3301 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH] =
3302 { .type = NLA_S32 },
3303 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS] =
3304 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05303305};
3306
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303307/**
3308 * wlan_hdd_cfg80211_extscan_get_capabilities_rsp() - response from target
3309 * @ctx: hdd global context
3310 * @data: capabilities data
3311 *
3312 * Return: none
3313 */
3314static void
3315wlan_hdd_cfg80211_extscan_get_capabilities_rsp(void *ctx, void *pMsg)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303316{
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303317 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303318 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303319 tSirEXTScanCapabilitiesEvent *data =
3320 (tSirEXTScanCapabilitiesEvent *) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303321
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303322 ENTER();
3323
3324 if (wlan_hdd_validate_context(pHddCtx))
3325 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303326 return;
3327 }
3328
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303329 if (!pMsg)
3330 {
3331 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3332 return;
3333 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303334
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303335 vos_spin_lock_acquire(&hdd_context_lock);
3336
3337 context = &pHddCtx->ext_scan_context;
3338 /* validate response received from target*/
3339 if (context->request_id != data->requestId)
3340 {
3341 vos_spin_lock_release(&hdd_context_lock);
3342 hddLog(LOGE,
3343 FL("Target response id did not match: request_id %d resposne_id %d"),
3344 context->request_id, data->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303345 return;
3346 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303347 else
3348 {
3349 context->capability_response = *data;
3350 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303351 }
3352
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303353 vos_spin_lock_release(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303354
Dino Mycle6fb96c12014-06-10 11:52:40 +05303355 return;
3356}
3357
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303358/*
3359 * define short names for the global vendor params
3360 * used by wlan_hdd_send_ext_scan_capability()
3361 */
3362#define PARAM_REQUEST_ID \
3363 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
3364#define PARAM_STATUS \
3365 QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS
3366#define MAX_SCAN_CACHE_SIZE \
3367 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE
3368#define MAX_SCAN_BUCKETS \
3369 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS
3370#define MAX_AP_CACHE_PER_SCAN \
3371 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN
3372#define MAX_RSSI_SAMPLE_SIZE \
3373 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE
3374#define MAX_SCAN_RPT_THRHOLD \
3375 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD
3376#define MAX_HOTLIST_BSSIDS \
3377 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS
3378#define MAX_BSSID_HISTORY_ENTRIES \
3379 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES
3380#define MAX_HOTLIST_SSIDS \
3381 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303382#define MAX_SIGNIFICANT_WIFI_CHANGE_APS \
3383 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303384
3385static int wlan_hdd_send_ext_scan_capability(void *ctx)
3386{
3387 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3388 struct sk_buff *skb = NULL;
3389 int ret;
3390 tSirEXTScanCapabilitiesEvent *data;
3391 tANI_U32 nl_buf_len;
3392
3393 ret = wlan_hdd_validate_context(pHddCtx);
3394 if (0 != ret)
3395 {
3396 return ret;
3397 }
3398
3399 data = &(pHddCtx->ext_scan_context.capability_response);
3400
3401 nl_buf_len = NLMSG_HDRLEN;
3402 nl_buf_len += (sizeof(data->requestId) + NLA_HDRLEN) +
3403 (sizeof(data->status) + NLA_HDRLEN) +
3404 (sizeof(data->scanCacheSize) + NLA_HDRLEN) +
3405 (sizeof(data->scanBuckets) + NLA_HDRLEN) +
3406 (sizeof(data->maxApPerScan) + NLA_HDRLEN) +
3407 (sizeof(data->maxRssiSampleSize) + NLA_HDRLEN) +
3408 (sizeof(data->maxScanReportingThreshold) + NLA_HDRLEN) +
3409 (sizeof(data->maxHotlistAPs) + NLA_HDRLEN) +
3410 (sizeof(data->maxBsidHistoryEntries) + NLA_HDRLEN) +
3411 (sizeof(data->maxHotlistSSIDs) + NLA_HDRLEN);
3412
3413 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, nl_buf_len);
3414
3415 if (!skb)
3416 {
3417 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
3418 return -ENOMEM;
3419 }
3420
3421 hddLog(LOG1, "Req Id (%u) Status (%u)", data->requestId, data->status);
3422 hddLog(LOG1, "Scan cache size (%u) Scan buckets (%u) Max AP per scan (%u)",
3423 data->scanCacheSize, data->scanBuckets, data->maxApPerScan);
3424 hddLog(LOG1, "max_rssi_sample_size (%u) max_scan_reporting_threshold (%u)",
3425 data->maxRssiSampleSize, data->maxScanReportingThreshold);
3426 hddLog(LOG1, "max_hotlist_bssids (%u) max_bssid_history_entries (%u)"
3427 "max_hotlist_ssids (%u)", data->maxHotlistAPs,
3428 data->maxBsidHistoryEntries, data->maxHotlistSSIDs);
3429
3430 if (nla_put_u32(skb, PARAM_REQUEST_ID, data->requestId) ||
3431 nla_put_u32(skb, PARAM_STATUS, data->status) ||
3432 nla_put_u32(skb, MAX_SCAN_CACHE_SIZE, data->scanCacheSize) ||
3433 nla_put_u32(skb, MAX_SCAN_BUCKETS, data->scanBuckets) ||
3434 nla_put_u32(skb, MAX_AP_CACHE_PER_SCAN,
3435 data->maxApPerScan) ||
3436 nla_put_u32(skb, MAX_RSSI_SAMPLE_SIZE,
3437 data->maxRssiSampleSize) ||
3438 nla_put_u32(skb, MAX_SCAN_RPT_THRHOLD,
3439 data->maxScanReportingThreshold) ||
3440 nla_put_u32(skb, MAX_HOTLIST_BSSIDS, data->maxHotlistAPs) ||
3441 nla_put_u32(skb, MAX_BSSID_HISTORY_ENTRIES,
3442 data->maxBsidHistoryEntries) ||
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303443 nla_put_u32(skb, MAX_HOTLIST_SSIDS, data->maxHotlistSSIDs) ||
3444 nla_put_u32(skb, MAX_SIGNIFICANT_WIFI_CHANGE_APS, 0))
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303445 {
3446 hddLog(LOGE, FL("nla put fail"));
3447 goto nla_put_failure;
3448 }
3449
3450 cfg80211_vendor_cmd_reply(skb);
3451 return 0;
3452
3453nla_put_failure:
3454 kfree_skb(skb);
3455 return -EINVAL;;
3456}
3457
3458/*
3459 * done with short names for the global vendor params
3460 * used by wlan_hdd_send_ext_scan_capability()
3461 */
3462#undef PARAM_REQUEST_ID
3463#undef PARAM_STATUS
3464#undef MAX_SCAN_CACHE_SIZE
3465#undef MAX_SCAN_BUCKETS
3466#undef MAX_AP_CACHE_PER_SCAN
3467#undef MAX_RSSI_SAMPLE_SIZE
3468#undef MAX_SCAN_RPT_THRHOLD
3469#undef MAX_HOTLIST_BSSIDS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303470#undef MAX_BSSID_HISTORY_ENTRIES
3471#undef MAX_HOTLIST_SSIDS
Dino Mycle6fb96c12014-06-10 11:52:40 +05303472
3473static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
3474{
3475 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
3476 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303477 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303478 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303479
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303480 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303481
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303482 if (wlan_hdd_validate_context(pHddCtx))
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303483 return;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303484
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303485 if (!pMsg)
3486 {
3487 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303488 return;
3489 }
3490
Dino Mycle6fb96c12014-06-10 11:52:40 +05303491 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3492 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
3493
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303494 context = &pHddCtx->ext_scan_context;
3495 spin_lock(&hdd_context_lock);
3496 if (context->request_id == pData->requestId) {
3497 context->response_status = pData->status ? -EINVAL : 0;
3498 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303499 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303500 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303501
3502 /*
3503 * Store the Request ID for comparing with the requestID obtained
3504 * in other requests.HDD shall return a failure is the extscan_stop
3505 * request is issued with a different requestId as that of the
3506 * extscan_start request. Also, This requestId shall be used while
3507 * indicating the full scan results to the upper layers.
3508 * The requestId is stored with the assumption that the firmware
3509 * shall return the ext scan start request's requestId in ext scan
3510 * start response.
3511 */
3512 if (pData->status == 0)
3513 pMac->sme.extScanStartReqId = pData->requestId;
3514
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303515 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303516 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303517}
3518
3519
3520static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
3521{
3522 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
3523 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05303524 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303525
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303526 ENTER();
3527
3528 if (wlan_hdd_validate_context(pHddCtx)){
3529 return;
3530 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05303531
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303532 if (!pMsg)
3533 {
3534 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303535 return;
3536 }
3537
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05303538 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
3539 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303540
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05303541 context = &pHddCtx->ext_scan_context;
3542 spin_lock(&hdd_context_lock);
3543 if (context->request_id == pData->requestId) {
3544 context->response_status = pData->status ? -EINVAL : 0;
3545 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303546 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05303547 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303548
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303549 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303550 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303551}
3552
Dino Mycle6fb96c12014-06-10 11:52:40 +05303553static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
3554 void *pMsg)
3555{
3556 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303557 tpSirEXTScanSetBssidHotListRspParams pData =
3558 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303559 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303560
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303561 ENTER();
3562
3563 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05303564 return;
3565 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303566
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303567 if (!pMsg)
3568 {
3569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3570 return;
3571 }
3572
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303573 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
3574 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303575
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303576 context = &pHddCtx->ext_scan_context;
3577 spin_lock(&hdd_context_lock);
3578 if (context->request_id == pData->requestId) {
3579 context->response_status = pData->status ? -EINVAL : 0;
3580 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303581 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303582 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303583
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303584 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303585 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303586}
3587
3588static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
3589 void *pMsg)
3590{
3591 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303592 tpSirEXTScanResetBssidHotlistRspParams pData =
3593 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05303594 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303595
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303596 ENTER();
3597
3598 if (wlan_hdd_validate_context(pHddCtx)) {
3599 return;
3600 }
3601 if (!pMsg)
3602 {
3603 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303604 return;
3605 }
3606
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05303607 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
3608 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303609
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05303610 context = &pHddCtx->ext_scan_context;
3611 spin_lock(&hdd_context_lock);
3612 if (context->request_id == pData->requestId) {
3613 context->response_status = pData->status ? -EINVAL : 0;
3614 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303615 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05303616 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303617
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303618 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303619 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303620}
3621
Dino Mycle6fb96c12014-06-10 11:52:40 +05303622static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
3623 void *pMsg)
3624{
3625 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3626 struct sk_buff *skb = NULL;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303627 tANI_U32 i = 0, j, resultsPerEvent, scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303628 tANI_S32 totalResults;
3629 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303630 tpSirWifiScanResult pSirWifiScanResult, head_ptr;
3631 struct hdd_ext_scan_context *context;
3632 bool ignore_cached_results = false;
3633 tExtscanCachedScanResult *result;
3634 struct nlattr *nla_results;
3635 tANI_U16 ieLength= 0;
3636 tANI_U8 *ie = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303637
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303638 ENTER();
3639
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303640 if (wlan_hdd_validate_context(pHddCtx))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303641 return;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303642
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303643 if (!pMsg)
3644 {
3645 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3646 return;
3647 }
3648
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303649 spin_lock(&hdd_context_lock);
3650 context = &pHddCtx->ext_scan_context;
3651 ignore_cached_results = context->ignore_cached_results;
3652 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303653
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303654 if (ignore_cached_results) {
3655 hddLog(LOGE,
3656 FL("Ignore the cached results received after timeout"));
3657 return;
3658 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303659
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303660 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u More Data %u No of scan ids %u",
3661 pData->requestId, pData->moreData, pData->scanResultSize);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303662
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303663 result = (tExtscanCachedScanResult *)&(pData->result);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303664
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303665 for (scan_id_index = 0; scan_id_index < pData->scanResultSize;
3666 scan_id_index++) {
3667 result+= scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303668
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303669 totalResults = result->num_results;
3670 hddLog(VOS_TRACE_LEVEL_INFO, "scan_id %u flags %u Num results %u",
3671 result->scan_id, result->flags, totalResults);
3672 i = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303673
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303674 do{
3675 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
3676 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
3677 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303678
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303679 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
3680 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN);
3681
3682 if (!skb) {
3683 hddLog(VOS_TRACE_LEVEL_ERROR,
3684 FL("cfg80211_vendor_event_alloc failed"));
3685 return;
3686 }
3687
3688 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
3689
3690 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3691 pData->requestId) ||
3692 nla_put_u32(skb,
3693 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3694 resultsPerEvent)) {
3695 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3696 goto fail;
3697 }
3698 if (nla_put_u8(skb,
3699 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3700 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303701 {
3702 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3703 goto fail;
3704 }
3705
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303706 if (nla_put_u32(skb,
3707 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
3708 result->scan_id)) {
3709 hddLog(LOGE, FL("put fail"));
3710 goto fail;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303711 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303712
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303713 nla_results = nla_nest_start(skb,
3714 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST);
3715 if (!nla_results)
3716 goto fail;
3717
3718 if (resultsPerEvent) {
3719 struct nlattr *aps;
3720 struct nlattr *nla_result;
3721
3722 nla_result = nla_nest_start(skb, scan_id_index);
3723 if(!nla_result)
3724 goto fail;
3725
3726 if (nla_put_u32(skb,
3727 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
3728 result->scan_id) ||
3729 nla_put_u32(skb,
3730 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_FLAGS,
3731 result->flags) ||
3732 nla_put_u32(skb,
3733 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3734 totalResults)) {
3735 hddLog(LOGE, FL("put fail"));
3736 goto fail;
3737 }
3738
3739 aps = nla_nest_start(skb,
3740 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3741 if (!aps)
3742 {
3743 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3744 goto fail;
3745 }
3746
3747 head_ptr = (tpSirWifiScanResult) &(result->ap);
3748
3749 for (j = 0; j < resultsPerEvent; j++, i++) {
3750 struct nlattr *ap;
3751 pSirWifiScanResult = head_ptr + i;
3752
3753 /*
Srinivas Dasari91727c12016-03-23 17:59:06 +05303754 * Firmware returns timestamp from extscan_start till
3755 * BSSID was cached (in micro seconds). Add this with
3756 * time gap between system boot up to extscan_start
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303757 * to derive the time since boot when the
3758 * BSSID was cached.
3759 */
Srinivas Dasari91727c12016-03-23 17:59:06 +05303760 pSirWifiScanResult->ts +=
3761 pHddCtx->extscan_start_time_since_boot;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303762 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
3763 "Ssid (%s)"
3764 "Bssid: %pM "
3765 "Channel (%u)"
3766 "Rssi (%d)"
3767 "RTT (%u)"
3768 "RTT_SD (%u)"
3769 "Beacon Period %u"
3770 "Capability 0x%x "
3771 "Ie length %d",
3772 i,
3773 pSirWifiScanResult->ts,
3774 pSirWifiScanResult->ssid,
3775 pSirWifiScanResult->bssid,
3776 pSirWifiScanResult->channel,
3777 pSirWifiScanResult->rssi,
3778 pSirWifiScanResult->rtt,
3779 pSirWifiScanResult->rtt_sd,
3780 pSirWifiScanResult->beaconPeriod,
3781 pSirWifiScanResult->capability,
3782 ieLength);
3783
3784 ap = nla_nest_start(skb, j + 1);
3785 if (!ap)
3786 {
3787 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3788 goto fail;
3789 }
3790
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05303791 if (hdd_wlan_nla_put_u64(skb,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303792 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3793 pSirWifiScanResult->ts) )
3794 {
3795 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3796 goto fail;
3797 }
3798 if (nla_put(skb,
3799 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3800 sizeof(pSirWifiScanResult->ssid),
3801 pSirWifiScanResult->ssid) )
3802 {
3803 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3804 goto fail;
3805 }
3806 if (nla_put(skb,
3807 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3808 sizeof(pSirWifiScanResult->bssid),
3809 pSirWifiScanResult->bssid) )
3810 {
3811 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3812 goto fail;
3813 }
3814 if (nla_put_u32(skb,
3815 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3816 pSirWifiScanResult->channel) )
3817 {
3818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3819 goto fail;
3820 }
3821 if (nla_put_s32(skb,
3822 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3823 pSirWifiScanResult->rssi) )
3824 {
3825 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3826 goto fail;
3827 }
3828 if (nla_put_u32(skb,
3829 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3830 pSirWifiScanResult->rtt) )
3831 {
3832 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3833 goto fail;
3834 }
3835 if (nla_put_u32(skb,
3836 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3837 pSirWifiScanResult->rtt_sd))
3838 {
3839 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3840 goto fail;
3841 }
3842 if (nla_put_u32(skb,
3843 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3844 pSirWifiScanResult->beaconPeriod))
3845 {
3846 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3847 goto fail;
3848 }
3849 if (nla_put_u32(skb,
3850 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3851 pSirWifiScanResult->capability))
3852 {
3853 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3854 goto fail;
3855 }
3856 if (nla_put_u32(skb,
3857 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3858 ieLength))
3859 {
3860 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3861 goto fail;
3862 }
3863
3864 if (ieLength)
3865 if (nla_put(skb,
3866 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3867 ieLength, ie)) {
3868 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3869 goto fail;
3870 }
3871
3872 nla_nest_end(skb, ap);
3873 }
3874 nla_nest_end(skb, aps);
3875 nla_nest_end(skb, nla_result);
3876 }
3877
3878 nla_nest_end(skb, nla_results);
3879
3880 cfg80211_vendor_cmd_reply(skb);
3881
3882 } while (totalResults > 0);
3883 }
3884
3885 if (!pData->moreData) {
3886 spin_lock(&hdd_context_lock);
3887 context->response_status = 0;
3888 complete(&context->response_event);
3889 spin_unlock(&hdd_context_lock);
3890 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303891
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303892 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303893 return;
3894fail:
3895 kfree_skb(skb);
3896 return;
3897}
3898
3899static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
3900 void *pMsg)
3901{
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303902 tpSirEXTScanHotlistMatch pData = (tpSirEXTScanHotlistMatch) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303903 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3904 struct sk_buff *skb = NULL;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303905 tANI_U32 i, index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303906
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303907 ENTER();
3908
3909 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303910 hddLog(LOGE,
3911 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303912 return;
3913 }
3914 if (!pMsg)
3915 {
3916 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303917 return;
3918 }
3919
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303920 if (pData->bss_found)
3921 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX;
3922 else
3923 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX;
3924
Dino Mycle6fb96c12014-06-10 11:52:40 +05303925 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303926#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3927 NULL,
3928#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303929 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303930 index, GFP_KERNEL);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303931
3932 if (!skb) {
3933 hddLog(VOS_TRACE_LEVEL_ERROR,
3934 FL("cfg80211_vendor_event_alloc failed"));
3935 return;
3936 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303937
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303938 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3939 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numHotlistBss);
3940 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
3941 hddLog(VOS_TRACE_LEVEL_INFO, "ap_found %u", pData->bss_found);
3942
3943 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303944 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
3945 "Ssid (%s) "
3946 "Bssid (" MAC_ADDRESS_STR ") "
3947 "Channel (%u) "
3948 "Rssi (%d) "
3949 "RTT (%u) "
3950 "RTT_SD (%u) ",
3951 i,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303952 pData->bssHotlist[i].ts,
3953 pData->bssHotlist[i].ssid,
3954 MAC_ADDR_ARRAY(pData->bssHotlist[i].bssid),
3955 pData->bssHotlist[i].channel,
3956 pData->bssHotlist[i].rssi,
3957 pData->bssHotlist[i].rtt,
3958 pData->bssHotlist[i].rtt_sd);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303959 }
3960
3961 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3962 pData->requestId) ||
3963 nla_put_u32(skb,
3964 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303965 pData->numHotlistBss)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303966 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3967 goto fail;
3968 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303969 if (pData->numHotlistBss) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303970 struct nlattr *aps;
3971
3972 aps = nla_nest_start(skb,
3973 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3974 if (!aps)
3975 goto fail;
3976
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303977 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303978 struct nlattr *ap;
3979
3980 ap = nla_nest_start(skb, i + 1);
3981 if (!ap)
3982 goto fail;
3983
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05303984 if (hdd_wlan_nla_put_u64(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303985 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303986 pData->bssHotlist[i].ts) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303987 nla_put(skb,
3988 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303989 sizeof(pData->bssHotlist[i].ssid),
3990 pData->bssHotlist[i].ssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303991 nla_put(skb,
3992 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303993 sizeof(pData->bssHotlist[i].bssid),
3994 pData->bssHotlist[i].bssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303995 nla_put_u32(skb,
3996 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303997 pData->bssHotlist[i].channel) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303998 nla_put_s32(skb,
3999 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304000 pData->bssHotlist[i].rssi) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05304001 nla_put_u32(skb,
4002 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304003 pData->bssHotlist[i].rtt) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05304004 nla_put_u32(skb,
4005 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304006 pData->bssHotlist[i].rtt_sd))
Dino Mycle6fb96c12014-06-10 11:52:40 +05304007 goto fail;
4008
4009 nla_nest_end(skb, ap);
4010 }
4011 nla_nest_end(skb, aps);
4012
4013 if (nla_put_u8(skb,
4014 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
4015 pData->moreData))
4016 goto fail;
4017 }
4018
4019 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304020 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304021 return;
4022
4023fail:
4024 kfree_skb(skb);
4025 return;
4026
4027}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304028
4029static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
4030 void *pMsg)
4031{
4032 struct sk_buff *skb;
4033 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
4034 tpSirWifiFullScanResultEvent pData =
4035 (tpSirWifiFullScanResultEvent) (pMsg);
4036
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304037 ENTER();
4038
4039 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304040 hddLog(LOGE,
4041 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304042 return;
4043 }
4044 if (!pMsg)
4045 {
4046 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304047 return;
4048 }
4049
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304050 /*
4051 * If the full scan result including IE data exceeds NL 4K size
4052 * limitation, drop that beacon/probe rsp frame.
4053 */
4054 if ((sizeof(*pData) + pData->ieLength) >= EXTSCAN_EVENT_BUF_SIZE) {
4055 hddLog(LOGE, FL("Frame exceeded NL size limilation, drop it!"));
4056 return;
4057 }
4058
Dino Mycle6fb96c12014-06-10 11:52:40 +05304059 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304060#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4061 NULL,
4062#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05304063 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4064 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
4065 GFP_KERNEL);
4066
4067 if (!skb) {
4068 hddLog(VOS_TRACE_LEVEL_ERROR,
4069 FL("cfg80211_vendor_event_alloc failed"));
4070 return;
4071 }
4072
Dino Mycle6fb96c12014-06-10 11:52:40 +05304073 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
4074 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
4075 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
4076 "Ssid (%s)"
4077 "Bssid (" MAC_ADDRESS_STR ")"
4078 "Channel (%u)"
4079 "Rssi (%d)"
4080 "RTT (%u)"
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304081 "RTT_SD (%u)"
4082 "Bcn Period %d"
4083 "Capability 0x%X "),
Dino Mycle6fb96c12014-06-10 11:52:40 +05304084 pData->ap.ts,
4085 pData->ap.ssid,
4086 MAC_ADDR_ARRAY(pData->ap.bssid),
4087 pData->ap.channel,
4088 pData->ap.rssi,
4089 pData->ap.rtt,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304090 pData->ap.rtt_sd,
4091 pData->ap.beaconPeriod,
4092 pData->ap.capability);
4093
Dino Mycle6fb96c12014-06-10 11:52:40 +05304094 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
4095 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
4096 pData->requestId) ||
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05304097 hdd_wlan_nla_put_u64(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304098 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
4099 pData->ap.ts) ||
4100 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
4101 sizeof(pData->ap.ssid),
4102 pData->ap.ssid) ||
4103 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
4104 WNI_CFG_BSSID_LEN,
4105 pData->ap.bssid) ||
4106 nla_put_u32(skb,
4107 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
4108 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05304109 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304110 pData->ap.rssi) ||
4111 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
4112 pData->ap.rtt) ||
4113 nla_put_u32(skb,
4114 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
4115 pData->ap.rtt_sd) ||
4116 nla_put_u16(skb,
4117 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
4118 pData->ap.beaconPeriod) ||
4119 nla_put_u16(skb,
4120 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
4121 pData->ap.capability) ||
4122 nla_put_u32(skb,
4123 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304124 pData->ieLength) ||
4125 nla_put_u8(skb,
4126 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
4127 pData->moreData))
Dino Mycle6fb96c12014-06-10 11:52:40 +05304128 {
4129 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4130 goto nla_put_failure;
4131 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304132
4133 if (pData->ieLength) {
4134 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
4135 pData->ieLength,
4136 pData->ie))
4137 {
4138 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4139 goto nla_put_failure;
4140 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05304141 }
4142
4143 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304144 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304145 return;
4146
4147nla_put_failure:
4148 kfree_skb(skb);
4149 return;
4150}
4151
4152static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
4153 void *pMsg)
4154{
4155 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
4156 struct sk_buff *skb = NULL;
4157 tpSirEXTScanResultsAvailableIndParams pData =
4158 (tpSirEXTScanResultsAvailableIndParams) pMsg;
4159
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304160 ENTER();
4161
4162 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304163 hddLog(LOGE,
4164 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304165 return;
4166 }
4167 if (!pMsg)
4168 {
4169 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304170 return;
4171 }
4172
4173 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304174#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4175 NULL,
4176#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05304177 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4178 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
4179 GFP_KERNEL);
4180
4181 if (!skb) {
4182 hddLog(VOS_TRACE_LEVEL_ERROR,
4183 FL("cfg80211_vendor_event_alloc failed"));
4184 return;
4185 }
4186
Dino Mycle6fb96c12014-06-10 11:52:40 +05304187 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
4188 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
4189 pData->numResultsAvailable);
4190 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
4191 pData->requestId) ||
4192 nla_put_u32(skb,
4193 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
4194 pData->numResultsAvailable)) {
4195 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4196 goto nla_put_failure;
4197 }
4198
4199 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304200 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304201 return;
4202
4203nla_put_failure:
4204 kfree_skb(skb);
4205 return;
4206}
4207
4208static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
4209{
4210 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
4211 struct sk_buff *skb = NULL;
4212 tpSirEXTScanProgressIndParams pData =
4213 (tpSirEXTScanProgressIndParams) pMsg;
4214
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304215 ENTER();
4216
4217 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304218 hddLog(LOGE,
4219 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304220 return;
4221 }
4222 if (!pMsg)
4223 {
4224 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304225 return;
4226 }
4227
4228 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304229#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4230 NULL,
4231#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05304232 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4233 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
4234 GFP_KERNEL);
4235
4236 if (!skb) {
4237 hddLog(VOS_TRACE_LEVEL_ERROR,
4238 FL("cfg80211_vendor_event_alloc failed"));
4239 return;
4240 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304241 hddLog(VOS_TRACE_LEVEL_INFO, FL("Request Id (%u) "), pData->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304242 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
4243 pData->extScanEventType);
4244 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
4245 pData->status);
4246
4247 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
4248 pData->extScanEventType) ||
4249 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05304250 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
4251 pData->requestId) ||
4252 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304253 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
4254 pData->status)) {
4255 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4256 goto nla_put_failure;
4257 }
4258
4259 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304260 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304261 return;
4262
4263nla_put_failure:
4264 kfree_skb(skb);
4265 return;
4266}
4267
4268void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
4269 void *pMsg)
4270{
4271 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
4272
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304273 ENTER();
4274
Dino Mycle6fb96c12014-06-10 11:52:40 +05304275 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304276 return;
4277 }
4278
4279 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
4280
4281
4282 switch(evType) {
4283 case SIR_HAL_EXTSCAN_START_RSP:
4284 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
4285 break;
4286
4287 case SIR_HAL_EXTSCAN_STOP_RSP:
4288 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
4289 break;
4290 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
4291 /* There is no need to send this response to upper layer
4292 Just log the message */
4293 hddLog(VOS_TRACE_LEVEL_INFO,
4294 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
4295 break;
4296 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
4297 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
4298 break;
4299
4300 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
4301 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
4302 break;
4303
Dino Mycle6fb96c12014-06-10 11:52:40 +05304304 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05304305 wlan_hdd_cfg80211_extscan_get_capabilities_rsp(ctx, pMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304306 break;
4307 case SIR_HAL_EXTSCAN_PROGRESS_IND:
4308 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
4309 break;
4310 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
4311 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
4312 break;
4313 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
4314 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
4315 break;
4316 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
4317 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
4318 break;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304319 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
4320 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
4321 break;
4322 default:
4323 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
4324 break;
4325 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304326 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304327}
4328
Ashish Kumar Dhanotiya4830bba2018-11-15 12:26:29 +05304329static bool wlan_hdd_is_extscan_supported(hdd_adapter_t *adapter,
4330 hdd_context_t *hdd_ctx)
4331{
4332 int status;
4333
4334 status = wlan_hdd_validate_context(hdd_ctx);
4335 if (status)
4336 return false;
4337
4338 if (!adapter) {
4339 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid adapter"));
4340 return false;
4341 }
4342
4343 if (adapter->device_mode != WLAN_HDD_INFRA_STATION) {
4344 hddLog(VOS_TRACE_LEVEL_INFO,
4345 FL("ext scans only supported on STA ifaces"));
4346 return false;
4347 }
4348
4349 if (VOS_FTM_MODE == hdd_get_conparam()) {
4350 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4351 return false;
4352 }
4353
4354 /* check the EXTScan Capability */
4355 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
4356 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4357 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED))) {
4358 hddLog(VOS_TRACE_LEVEL_ERROR,
4359 FL("EXTScan not enabled/supported by Firmware"));
4360 return false;
4361 }
4362 return true;
4363}
4364
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304365static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
4366 struct wireless_dev *wdev,
4367 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304368{
Dino Myclee8843b32014-07-04 14:21:45 +05304369 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304370 struct net_device *dev = wdev->netdev;
4371 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4372 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4373 struct nlattr
4374 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4375 eHalStatus status;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05304376 struct hdd_ext_scan_context *context;
4377 unsigned long rc;
4378 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304379
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304380 ENTER();
4381
Ashish Kumar Dhanotiya4830bba2018-11-15 12:26:29 +05304382 if (!wlan_hdd_is_extscan_supported(pAdapter, pHddCtx))
Dino Mycle6fb96c12014-06-10 11:52:40 +05304383 return -EINVAL;
Dino Myclee8843b32014-07-04 14:21:45 +05304384
Dino Mycle6fb96c12014-06-10 11:52:40 +05304385 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4386 data, dataLen,
4387 wlan_hdd_extscan_config_policy)) {
4388 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4389 return -EINVAL;
4390 }
4391
4392 /* Parse and fetch request Id */
4393 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4394 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4395 return -EINVAL;
4396 }
4397
Dino Myclee8843b32014-07-04 14:21:45 +05304398 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304399 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304400 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304401
Dino Myclee8843b32014-07-04 14:21:45 +05304402 reqMsg.sessionId = pAdapter->sessionId;
4403 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304404
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05304405 vos_spin_lock_acquire(&hdd_context_lock);
4406 context = &pHddCtx->ext_scan_context;
4407 context->request_id = reqMsg.requestId;
4408 INIT_COMPLETION(context->response_event);
4409 vos_spin_lock_release(&hdd_context_lock);
4410
Dino Myclee8843b32014-07-04 14:21:45 +05304411 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304412 if (!HAL_STATUS_SUCCESS(status)) {
4413 hddLog(VOS_TRACE_LEVEL_ERROR,
4414 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304415 return -EINVAL;
4416 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05304417
4418 rc = wait_for_completion_timeout(&context->response_event,
4419 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4420 if (!rc) {
4421 hddLog(LOGE, FL("Target response timed out"));
4422 return -ETIMEDOUT;
4423 }
4424
4425 ret = wlan_hdd_send_ext_scan_capability(pHddCtx);
4426 if (ret)
4427 hddLog(LOGE, FL("Failed to send ext scan capability to user space"));
4428
4429 return ret;
4430
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304431 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304432 return 0;
4433}
4434
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304435static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
4436 struct wireless_dev *wdev,
4437 const void *data, int dataLen)
4438{
4439 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304440
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304441 vos_ssr_protect(__func__);
4442 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
4443 vos_ssr_unprotect(__func__);
4444
4445 return ret;
4446}
4447
4448static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
4449 struct wireless_dev *wdev,
4450 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304451{
Dino Myclee8843b32014-07-04 14:21:45 +05304452 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304453 struct net_device *dev = wdev->netdev;
4454 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4455 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4456 struct nlattr
4457 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4458 eHalStatus status;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304459 struct hdd_ext_scan_context *context;
4460 unsigned long rc;
4461 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304462
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304463 ENTER();
4464
Ashish Kumar Dhanotiya4830bba2018-11-15 12:26:29 +05304465 if (!wlan_hdd_is_extscan_supported(pAdapter, pHddCtx))
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304466 return -EINVAL;
Dino Myclee8843b32014-07-04 14:21:45 +05304467
Dino Mycle6fb96c12014-06-10 11:52:40 +05304468 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4469 data, dataLen,
4470 wlan_hdd_extscan_config_policy)) {
4471 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4472 return -EINVAL;
4473 }
4474 /* Parse and fetch request Id */
4475 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4476 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4477 return -EINVAL;
4478 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05304479
Dino Myclee8843b32014-07-04 14:21:45 +05304480 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304481 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4482
Dino Myclee8843b32014-07-04 14:21:45 +05304483 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304484
Dino Myclee8843b32014-07-04 14:21:45 +05304485 reqMsg.sessionId = pAdapter->sessionId;
4486 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304487
4488 /* Parse and fetch flush parameter */
4489 if (!tb
4490 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
4491 {
4492 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
4493 goto failed;
4494 }
Dino Myclee8843b32014-07-04 14:21:45 +05304495 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304496 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
4497
Dino Myclee8843b32014-07-04 14:21:45 +05304498 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304499
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304500 spin_lock(&hdd_context_lock);
4501 context = &pHddCtx->ext_scan_context;
4502 context->request_id = reqMsg.requestId;
4503 context->ignore_cached_results = false;
4504 INIT_COMPLETION(context->response_event);
4505 spin_unlock(&hdd_context_lock);
4506
Dino Myclee8843b32014-07-04 14:21:45 +05304507 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304508 if (!HAL_STATUS_SUCCESS(status)) {
4509 hddLog(VOS_TRACE_LEVEL_ERROR,
4510 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304511 return -EINVAL;
4512 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304513
4514 rc = wait_for_completion_timeout(&context->response_event,
4515 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4516 if (!rc) {
4517 hddLog(LOGE, FL("Target response timed out"));
4518 retval = -ETIMEDOUT;
4519 spin_lock(&hdd_context_lock);
4520 context->ignore_cached_results = true;
4521 spin_unlock(&hdd_context_lock);
4522 } else {
4523 spin_lock(&hdd_context_lock);
4524 retval = context->response_status;
4525 spin_unlock(&hdd_context_lock);
4526 }
4527
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304528 EXIT();
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304529 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304530
4531failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05304532 return -EINVAL;
4533}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304534static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
4535 struct wireless_dev *wdev,
4536 const void *data, int dataLen)
4537{
4538 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304539
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304540 vos_ssr_protect(__func__);
4541 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
4542 vos_ssr_unprotect(__func__);
4543
4544 return ret;
4545}
4546
4547static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304548 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05304549 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304550{
4551 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
4552 struct net_device *dev = wdev->netdev;
4553 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4554 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4555 struct nlattr
4556 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4557 struct nlattr
4558 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4559 struct nlattr *apTh;
4560 eHalStatus status;
4561 tANI_U8 i = 0;
4562 int rem;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304563 struct hdd_ext_scan_context *context;
4564 tANI_U32 request_id;
4565 unsigned long rc;
4566 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304567
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304568 ENTER();
4569
Ashish Kumar Dhanotiya4830bba2018-11-15 12:26:29 +05304570 if (!wlan_hdd_is_extscan_supported(pAdapter, pHddCtx))
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304571 return -EINVAL;
Dino Myclee8843b32014-07-04 14:21:45 +05304572
Dino Mycle6fb96c12014-06-10 11:52:40 +05304573 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4574 data, dataLen,
4575 wlan_hdd_extscan_config_policy)) {
4576 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4577 return -EINVAL;
4578 }
4579
4580 /* Parse and fetch request Id */
4581 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4582 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4583 return -EINVAL;
4584 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05304585 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
4586 vos_mem_malloc(sizeof(*pReqMsg));
4587 if (!pReqMsg) {
4588 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4589 return -ENOMEM;
4590 }
4591
Dino Myclee8843b32014-07-04 14:21:45 +05304592
Dino Mycle6fb96c12014-06-10 11:52:40 +05304593 pReqMsg->requestId = nla_get_u32(
4594 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4595 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4596
4597 /* Parse and fetch number of APs */
4598 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
4599 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
4600 goto fail;
4601 }
4602
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304603 /* Parse and fetch lost ap sample size */
4604 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]) {
4605 hddLog(LOGE, FL("attr lost ap sample size failed"));
4606 goto fail;
4607 }
4608
4609 pReqMsg->lostBssidSampleSize = nla_get_u32(
4610 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]);
4611 hddLog(LOG1, FL("Lost ap sample size %d"), pReqMsg->lostBssidSampleSize);
4612
Dino Mycle6fb96c12014-06-10 11:52:40 +05304613 pReqMsg->sessionId = pAdapter->sessionId;
4614 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4615
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304616 pReqMsg->numBssid = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304617 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05304618 if (pReqMsg->numBssid > WLAN_EXTSCAN_MAX_HOTLIST_APS) {
4619 hddLog(LOGE, FL("Number of AP: %u exceeds max: %u"),
4620 pReqMsg->numBssid, WLAN_EXTSCAN_MAX_HOTLIST_APS);
4621 goto fail;
4622 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304623 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304624
4625 nla_for_each_nested(apTh,
4626 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05304627 if (i == pReqMsg->numBssid) {
4628 hddLog(LOGW, FL("Ignoring excess AP"));
4629 break;
4630 }
4631
Dino Mycle6fb96c12014-06-10 11:52:40 +05304632 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4633 nla_data(apTh), nla_len(apTh),
4634 NULL)) {
4635 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4636 goto fail;
4637 }
4638
4639 /* Parse and fetch MAC address */
4640 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
4641 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
4642 goto fail;
4643 }
4644 memcpy(pReqMsg->ap[i].bssid, nla_data(
4645 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
4646 sizeof(tSirMacAddr));
4647 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
4648
4649 /* Parse and fetch low RSSI */
4650 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
4651 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
4652 goto fail;
4653 }
4654 pReqMsg->ap[i].low = nla_get_s32(
4655 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
4656 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
4657
4658 /* Parse and fetch high RSSI */
4659 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
4660 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
4661 goto fail;
4662 }
4663 pReqMsg->ap[i].high = nla_get_s32(
4664 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
4665 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
4666 pReqMsg->ap[i].high);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304667 i++;
4668 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304669
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05304670 if (i < pReqMsg->numBssid) {
4671 hddLog(LOGW, FL("Number of AP %u less than expected %u"),
4672 i, pReqMsg->numBssid);
4673 pReqMsg->numBssid = i;
4674 }
4675
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304676 context = &pHddCtx->ext_scan_context;
4677 spin_lock(&hdd_context_lock);
4678 INIT_COMPLETION(context->response_event);
4679 context->request_id = request_id = pReqMsg->requestId;
4680 spin_unlock(&hdd_context_lock);
4681
Dino Mycle6fb96c12014-06-10 11:52:40 +05304682 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
4683 if (!HAL_STATUS_SUCCESS(status)) {
4684 hddLog(VOS_TRACE_LEVEL_ERROR,
4685 FL("sme_SetBssHotlist failed(err=%d)"), status);
4686 vos_mem_free(pReqMsg);
4687 return -EINVAL;
4688 }
4689
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304690 /* request was sent -- wait for the response */
4691 rc = wait_for_completion_timeout(&context->response_event,
4692 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4693
4694 if (!rc) {
4695 hddLog(LOGE, FL("sme_SetBssHotlist timed out"));
4696 retval = -ETIMEDOUT;
4697 } else {
4698 spin_lock(&hdd_context_lock);
4699 if (context->request_id == request_id)
4700 retval = context->response_status;
4701 else
4702 retval = -EINVAL;
4703 spin_unlock(&hdd_context_lock);
4704 }
4705
Dino Myclee8843b32014-07-04 14:21:45 +05304706 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304707 EXIT();
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304708 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304709
4710fail:
4711 vos_mem_free(pReqMsg);
4712 return -EINVAL;
4713}
4714
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304715static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
4716 struct wireless_dev *wdev,
4717 const void *data, int dataLen)
4718{
4719 int ret = 0;
4720
4721 vos_ssr_protect(__func__);
4722 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
4723 dataLen);
4724 vos_ssr_unprotect(__func__);
4725
4726 return ret;
4727}
4728
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304729static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304730 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304731 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304732{
Agrawal Ashish16abf782016-08-18 22:42:59 +05304733 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4734 struct net_device *dev = wdev->netdev;
4735 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4736 uint32_t chan_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4737 uint8_t num_channels = 0;
4738 uint8_t num_chan_new = 0;
4739 uint8_t buf[256] = {0};
Dino Mycle6fb96c12014-06-10 11:52:40 +05304740 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304741 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304742 tWifiBand wifiBand;
4743 eHalStatus status;
4744 struct sk_buff *replySkb;
Agrawal Ashish16abf782016-08-18 22:42:59 +05304745 tANI_U8 i,j,k;
4746 int ret,len = 0;;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304747
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304748 ENTER();
Ashish Kumar Dhanotiya747e9ce2019-09-16 12:47:03 +05304749 ret = wlan_hdd_validate_context(pHddCtx);
4750 if (ret)
4751 return false;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304752
Ashish Kumar Dhanotiya747e9ce2019-09-16 12:47:03 +05304753 if (!pAdapter) {
4754 hddLog(VOS_TRACE_LEVEL_DEBUG, FL("Invalid adapter"));
4755 return false;
4756 }
4757
4758 if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
4759 hddLog(VOS_TRACE_LEVEL_DEBUG,
4760 FL("ext scans only supported on STA ifaces"));
4761 return false;
4762 }
4763
4764 if (VOS_FTM_MODE == hdd_get_conparam()) {
4765 hddLog(VOS_TRACE_LEVEL_DEBUG, FL("Command not allowed in FTM mode"));
4766 return false;
4767 }
Dino Myclee8843b32014-07-04 14:21:45 +05304768
Dino Mycle6fb96c12014-06-10 11:52:40 +05304769 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4770 data, dataLen,
4771 wlan_hdd_extscan_config_policy)) {
4772 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4773 return -EINVAL;
4774 }
4775
4776 /* Parse and fetch request Id */
4777 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4778 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4779 return -EINVAL;
4780 }
4781 requestId = nla_get_u32(
4782 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4783 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
4784
4785 /* Parse and fetch wifi band */
4786 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
4787 {
4788 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4789 return -EINVAL;
4790 }
4791 wifiBand = nla_get_u32(
4792 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
4793 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
4794
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304795 /* Parse and fetch max channels */
4796 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
4797 {
4798 hddLog(LOGE, FL("attr max channels failed"));
4799 return -EINVAL;
4800 }
4801 maxChannels = nla_get_u32(
4802 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
4803 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
4804
Dino Mycle6fb96c12014-06-10 11:52:40 +05304805 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
Agrawal Ashish16abf782016-08-18 22:42:59 +05304806 wifiBand, chan_list,
4807 &num_channels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304808 if (eHAL_STATUS_SUCCESS != status) {
4809 hddLog(VOS_TRACE_LEVEL_ERROR,
4810 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4811 return -EINVAL;
4812 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304813
Agrawal Ashish16abf782016-08-18 22:42:59 +05304814 num_channels = VOS_MIN(num_channels, maxChannels);
4815 num_chan_new = num_channels;
4816 /* remove the indoor only channels if iface is SAP */
4817 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
4818 {
4819 num_chan_new = 0;
4820 for (i = 0; i < num_channels; i++)
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05304821 for (j = 0; j < HDD_NUM_NL80211_BANDS; j++) {
Agrawal Ashish16abf782016-08-18 22:42:59 +05304822 if (wiphy->bands[j] == NULL)
4823 continue;
4824 for (k = 0; k < wiphy->bands[j]->n_channels; k++) {
4825 if ((chan_list[i] ==
4826 wiphy->bands[j]->channels[k].center_freq) &&
4827 (!(wiphy->bands[j]->channels[k].flags &
4828 IEEE80211_CHAN_INDOOR_ONLY))) {
4829 chan_list[num_chan_new] = chan_list[i];
4830 num_chan_new++;
4831 }
4832 }
4833 }
4834 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304835
Agrawal Ashish16abf782016-08-18 22:42:59 +05304836 hddLog(LOG1, FL("Number of channels: %d"), num_chan_new);
4837 for (i = 0; i < num_chan_new; i++)
4838 len += scnprintf(buf + len, sizeof(buf) - len, "%u ", chan_list[i]);
4839 hddLog(LOG1, "Channels: %s", buf);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304840
4841 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
Agrawal Ashish16abf782016-08-18 22:42:59 +05304842 sizeof(u32) * num_chan_new +
Dino Mycle6fb96c12014-06-10 11:52:40 +05304843 NLMSG_HDRLEN);
4844
4845 if (!replySkb) {
4846 hddLog(VOS_TRACE_LEVEL_ERROR,
4847 FL("valid channels: buffer alloc fail"));
4848 return -EINVAL;
4849 }
4850 if (nla_put_u32(replySkb,
4851 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05304852 num_chan_new) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05304853 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05304854 sizeof(u32) * num_chan_new, chan_list)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304855
4856 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4857 kfree_skb(replySkb);
4858 return -EINVAL;
4859 }
4860
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304861 ret = cfg80211_vendor_cmd_reply(replySkb);
4862
4863 EXIT();
4864 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304865}
4866
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304867static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4868 struct wireless_dev *wdev,
4869 const void *data, int dataLen)
4870{
4871 int ret = 0;
4872
4873 vos_ssr_protect(__func__);
4874 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4875 dataLen);
4876 vos_ssr_unprotect(__func__);
4877
4878 return ret;
4879}
4880
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304881static int hdd_extscan_start_fill_bucket_channel_spec(
4882 hdd_context_t *pHddCtx,
4883 tpSirEXTScanStartReqParams pReqMsg,
4884 struct nlattr **tb)
4885{
4886 struct nlattr *bucket[
4887 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4888 struct nlattr *channel[
4889 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4890 struct nlattr *buckets;
4891 struct nlattr *channels;
4892 int rem1, rem2;
4893 eHalStatus status;
4894 tANI_U8 bktIndex, j, numChannels;
Ashish Kumar Dhanotiyacb407902017-08-14 19:57:32 +05304895 uint32_t expected_buckets;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304896 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4897 tANI_U32 passive_max_chn_time, active_max_chn_time;
4898
Ashish Kumar Dhanotiyacb407902017-08-14 19:57:32 +05304899 expected_buckets = pReqMsg->numBuckets;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304900 bktIndex = 0;
4901
4902 nla_for_each_nested(buckets,
4903 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
Ashish Kumar Dhanotiyacb407902017-08-14 19:57:32 +05304904 if (bktIndex >= expected_buckets) {
4905 hddLog(LOGW, FL("ignoring excess buckets"));
4906 break;
4907 }
4908
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304909 if (nla_parse(bucket,
Ashish Kumar Dhanotiya9c93f562017-06-20 12:13:33 +05304910 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4911 nla_data(buckets), nla_len(buckets),
4912 wlan_hdd_extscan_config_policy)) {
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304913 hddLog(LOGE, FL("nla_parse failed"));
4914 return -EINVAL;
4915 }
4916
4917 /* Parse and fetch bucket spec */
4918 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4919 hddLog(LOGE, FL("attr bucket index failed"));
4920 return -EINVAL;
4921 }
4922 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
4923 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4924 hddLog(LOG1, FL("Bucket spec Index %d"),
4925 pReqMsg->buckets[bktIndex].bucket);
4926
4927 /* Parse and fetch wifi band */
4928 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4929 hddLog(LOGE, FL("attr wifi band failed"));
4930 return -EINVAL;
4931 }
4932 pReqMsg->buckets[bktIndex].band = nla_get_u8(
4933 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4934 hddLog(LOG1, FL("Wifi band %d"),
4935 pReqMsg->buckets[bktIndex].band);
4936
4937 /* Parse and fetch period */
4938 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4939 hddLog(LOGE, FL("attr period failed"));
4940 return -EINVAL;
4941 }
4942 pReqMsg->buckets[bktIndex].period = nla_get_u32(
4943 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4944 hddLog(LOG1, FL("period %d"),
4945 pReqMsg->buckets[bktIndex].period);
4946
4947 /* Parse and fetch report events */
4948 if (!bucket[
4949 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4950 hddLog(LOGE, FL("attr report events failed"));
4951 return -EINVAL;
4952 }
4953 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
4954 bucket[
4955 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4956 hddLog(LOG1, FL("report events %d"),
4957 pReqMsg->buckets[bktIndex].reportEvents);
4958
4959 /* Parse and fetch max period */
4960 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
4961 hddLog(LOGE, FL("attr max period failed"));
4962 return -EINVAL;
4963 }
4964 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
4965 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
4966 hddLog(LOG1, FL("max period %u"),
4967 pReqMsg->buckets[bktIndex].max_period);
4968
4969 /* Parse and fetch exponent */
4970 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
4971 hddLog(LOGE, FL("attr exponent failed"));
4972 return -EINVAL;
4973 }
4974 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
4975 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
4976 hddLog(LOG1, FL("exponent %u"),
4977 pReqMsg->buckets[bktIndex].exponent);
4978
4979 /* Parse and fetch step count */
4980 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
4981 hddLog(LOGE, FL("attr step count failed"));
4982 return -EINVAL;
4983 }
4984 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
4985 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
4986 hddLog(LOG1, FL("Step count %u"),
4987 pReqMsg->buckets[bktIndex].step_count);
4988
4989 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
4990 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
4991
4992 /* Framework shall pass the channel list if the input WiFi band is
4993 * WIFI_BAND_UNSPECIFIED.
4994 * If the input WiFi band is specified (any value other than
4995 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
4996 */
4997 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
4998 numChannels = 0;
4999 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
5000 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
5001 pReqMsg->buckets[bktIndex].band,
5002 chanList, &numChannels);
5003 if (!HAL_STATUS_SUCCESS(status)) {
5004 hddLog(LOGE,
5005 FL("sme_GetValidChannelsByBand failed (err=%d)"),
5006 status);
5007 return -EINVAL;
5008 }
5009
5010 pReqMsg->buckets[bktIndex].numChannels =
5011 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
5012 hddLog(LOG1, FL("Num channels %d"),
5013 pReqMsg->buckets[bktIndex].numChannels);
5014
5015 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
5016 j++) {
5017 pReqMsg->buckets[bktIndex].channels[j].channel =
5018 chanList[j];
5019 pReqMsg->buckets[bktIndex].channels[j].
5020 chnlClass = 0;
5021 if (CSR_IS_CHANNEL_DFS(
5022 vos_freq_to_chan(chanList[j]))) {
5023 pReqMsg->buckets[bktIndex].channels[j].
5024 passive = 1;
5025 pReqMsg->buckets[bktIndex].channels[j].
5026 dwellTimeMs = passive_max_chn_time;
5027 } else {
5028 pReqMsg->buckets[bktIndex].channels[j].
5029 passive = 0;
5030 pReqMsg->buckets[bktIndex].channels[j].
5031 dwellTimeMs = active_max_chn_time;
5032 }
5033
5034 hddLog(LOG1,
5035 "Channel %u Passive %u Dwell time %u ms",
5036 pReqMsg->buckets[bktIndex].channels[j].channel,
5037 pReqMsg->buckets[bktIndex].channels[j].passive,
5038 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
5039 }
5040
5041 bktIndex++;
5042 continue;
5043 }
5044
5045 /* Parse and fetch number of channels */
5046 if (!bucket[
5047 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
5048 hddLog(LOGE, FL("attr num channels failed"));
5049 return -EINVAL;
5050 }
5051
5052 pReqMsg->buckets[bktIndex].numChannels =
5053 nla_get_u32(bucket[
5054 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
5055 hddLog(LOG1, FL("num channels %d"),
5056 pReqMsg->buckets[bktIndex].numChannels);
5057
5058 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
5059 hddLog(LOGE, FL("attr channel spec failed"));
5060 return -EINVAL;
5061 }
5062
5063 j = 0;
5064 nla_for_each_nested(channels,
5065 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
5066 if (nla_parse(channel,
5067 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
5068 nla_data(channels), nla_len(channels),
5069 wlan_hdd_extscan_config_policy)) {
5070 hddLog(LOGE, FL("nla_parse failed"));
5071 return -EINVAL;
5072 }
5073
5074 /* Parse and fetch channel */
5075 if (!channel[
5076 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
5077 hddLog(LOGE, FL("attr channel failed"));
5078 return -EINVAL;
5079 }
5080 pReqMsg->buckets[bktIndex].channels[j].channel =
5081 nla_get_u32(channel[
5082 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
5083 hddLog(LOG1, FL("channel %u"),
5084 pReqMsg->buckets[bktIndex].channels[j].channel);
5085
5086 /* Parse and fetch dwell time */
5087 if (!channel[
5088 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
5089 hddLog(LOGE, FL("attr dwelltime failed"));
5090 return -EINVAL;
5091 }
5092 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
5093 nla_get_u32(channel[
5094 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
5095
5096 hddLog(LOG1, FL("Dwell time (%u ms)"),
5097 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
5098
5099
5100 /* Parse and fetch channel spec passive */
5101 if (!channel[
5102 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
5103 hddLog(LOGE,
5104 FL("attr channel spec passive failed"));
5105 return -EINVAL;
5106 }
5107 pReqMsg->buckets[bktIndex].channels[j].passive =
5108 nla_get_u8(channel[
5109 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
5110 hddLog(LOG1, FL("Chnl spec passive %u"),
5111 pReqMsg->buckets[bktIndex].channels[j].passive);
5112
5113 j++;
5114 }
5115
Dundi Raviteja18d0c062018-11-13 19:56:45 +05305116 if (j != pReqMsg->buckets[bktIndex].numChannels) {
5117 hddLog(LOG1, FL("Input parameters didn't match"));
5118 return -EINVAL;
5119 }
5120
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305121 bktIndex++;
5122 }
5123
5124 return 0;
5125}
5126
5127
5128/*
5129 * define short names for the global vendor params
5130 * used by wlan_hdd_cfg80211_extscan_start()
5131 */
5132#define PARAM_MAX \
5133QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
5134#define PARAM_REQUEST_ID \
5135QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
5136#define PARAM_BASE_PERIOD \
5137QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
5138#define PARAM_MAX_AP_PER_SCAN \
5139QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
5140#define PARAM_RPT_THRHLD_PERCENT \
5141QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
5142#define PARAM_RPT_THRHLD_NUM_SCANS \
5143QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
5144#define PARAM_NUM_BUCKETS \
5145QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
5146
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305147static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05305148 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305149 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05305150{
Dino Myclee8843b32014-07-04 14:21:45 +05305151 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305152 struct net_device *dev = wdev->netdev;
5153 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5154 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5155 struct nlattr *tb[PARAM_MAX + 1];
5156 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305157 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305158 tANI_U32 request_id;
5159 struct hdd_ext_scan_context *context;
5160 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305161
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305162 ENTER();
5163
Ashish Kumar Dhanotiya4830bba2018-11-15 12:26:29 +05305164 if (!wlan_hdd_is_extscan_supported(pAdapter, pHddCtx))
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305165 return -EINVAL;
Dino Myclee8843b32014-07-04 14:21:45 +05305166
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305167 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05305168 data, dataLen,
5169 wlan_hdd_extscan_config_policy)) {
5170 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5171 return -EINVAL;
5172 }
5173
5174 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305175 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05305176 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
5177 return -EINVAL;
5178 }
5179
Dino Myclee8843b32014-07-04 14:21:45 +05305180 pReqMsg = (tpSirEXTScanStartReqParams)
5181 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05305182 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05305183 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
5184 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305185 }
5186
5187 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305188 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305189 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
5190
5191 pReqMsg->sessionId = pAdapter->sessionId;
5192 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
5193
5194 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305195 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05305196 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
5197 goto fail;
5198 }
5199 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305200 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305201 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
5202 pReqMsg->basePeriod);
5203
5204 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305205 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05305206 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
5207 goto fail;
5208 }
5209 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305210 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305211 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
5212 pReqMsg->maxAPperScan);
5213
5214 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305215 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05305216 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
5217 goto fail;
5218 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305219 pReqMsg->reportThresholdPercent = nla_get_u8(
5220 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305221 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305222 pReqMsg->reportThresholdPercent);
5223
5224 /* Parse and fetch report threshold num scans */
5225 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
5226 hddLog(LOGE, FL("attr report_threshold num scans failed"));
5227 goto fail;
5228 }
5229 pReqMsg->reportThresholdNumScans = nla_get_u8(
5230 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
5231 hddLog(LOG1, FL("Report Threshold num scans %d"),
5232 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305233
5234 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305235 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05305236 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
5237 goto fail;
5238 }
5239 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305240 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305241 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
5242 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
5243 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
5244 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
5245 }
5246 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
5247 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305248
Dino Mycle6fb96c12014-06-10 11:52:40 +05305249 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
5250 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
5251 goto fail;
5252 }
5253
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305254 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305255
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305256 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
5257 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05305258
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305259 context = &pHddCtx->ext_scan_context;
5260 spin_lock(&hdd_context_lock);
5261 INIT_COMPLETION(context->response_event);
5262 context->request_id = request_id = pReqMsg->requestId;
5263 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05305264
Dino Mycle6fb96c12014-06-10 11:52:40 +05305265 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
5266 if (!HAL_STATUS_SUCCESS(status)) {
5267 hddLog(VOS_TRACE_LEVEL_ERROR,
5268 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305269 goto fail;
5270 }
5271
Srinivas Dasari91727c12016-03-23 17:59:06 +05305272 pHddCtx->extscan_start_time_since_boot = vos_get_monotonic_boottime();
5273
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305274 /* request was sent -- wait for the response */
5275 rc = wait_for_completion_timeout(&context->response_event,
5276 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
5277
5278 if (!rc) {
5279 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
5280 retval = -ETIMEDOUT;
5281 } else {
5282 spin_lock(&hdd_context_lock);
5283 if (context->request_id == request_id)
5284 retval = context->response_status;
5285 else
5286 retval = -EINVAL;
5287 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305288 }
5289
Dino Myclee8843b32014-07-04 14:21:45 +05305290 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305291 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305292 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305293
5294fail:
5295 vos_mem_free(pReqMsg);
5296 return -EINVAL;
5297}
5298
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305299/*
5300 * done with short names for the global vendor params
5301 * used by wlan_hdd_cfg80211_extscan_start()
5302 */
5303#undef PARAM_MAX
5304#undef PARAM_REQUEST_ID
5305#undef PARAM_BASE_PERIOD
5306#undef PARAMS_MAX_AP_PER_SCAN
5307#undef PARAMS_RPT_THRHLD_PERCENT
5308#undef PARAMS_RPT_THRHLD_NUM_SCANS
5309#undef PARAMS_NUM_BUCKETS
5310
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305311static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
5312 struct wireless_dev *wdev,
5313 const void *data, int dataLen)
5314{
5315 int ret = 0;
5316
5317 vos_ssr_protect(__func__);
5318 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
5319 vos_ssr_unprotect(__func__);
5320
5321 return ret;
5322}
5323
5324static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05305325 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305326 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05305327{
Dino Myclee8843b32014-07-04 14:21:45 +05305328 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305329 struct net_device *dev = wdev->netdev;
5330 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5331 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5332 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
5333 eHalStatus status;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05305334 int retval;
5335 unsigned long rc;
5336 struct hdd_ext_scan_context *context;
5337 tANI_U32 request_id;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305338
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305339 ENTER();
5340
Ashish Kumar Dhanotiya4830bba2018-11-15 12:26:29 +05305341 if (!wlan_hdd_is_extscan_supported(pAdapter, pHddCtx))
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05305342 return -EINVAL;
Dino Myclee8843b32014-07-04 14:21:45 +05305343
Dino Mycle6fb96c12014-06-10 11:52:40 +05305344 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
5345 data, dataLen,
5346 wlan_hdd_extscan_config_policy)) {
5347 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5348 return -EINVAL;
5349 }
5350
5351 /* Parse and fetch request Id */
5352 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
5353 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
5354 return -EINVAL;
5355 }
5356
Dino Myclee8843b32014-07-04 14:21:45 +05305357 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05305358 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05305359 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305360
Dino Myclee8843b32014-07-04 14:21:45 +05305361 reqMsg.sessionId = pAdapter->sessionId;
5362 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305363
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05305364 context = &pHddCtx->ext_scan_context;
5365 spin_lock(&hdd_context_lock);
5366 INIT_COMPLETION(context->response_event);
Sravanti Palakonda7539fb92016-02-26 17:49:21 +05305367 context->request_id = request_id = reqMsg.requestId;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05305368 spin_unlock(&hdd_context_lock);
5369
Dino Myclee8843b32014-07-04 14:21:45 +05305370 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305371 if (!HAL_STATUS_SUCCESS(status)) {
5372 hddLog(VOS_TRACE_LEVEL_ERROR,
5373 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305374 return -EINVAL;
5375 }
5376
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05305377 /* request was sent -- wait for the response */
5378 rc = wait_for_completion_timeout(&context->response_event,
5379 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
5380
5381 if (!rc) {
5382 hddLog(LOGE, FL("sme_ExtScanStop timed out"));
5383 retval = -ETIMEDOUT;
5384 } else {
5385 spin_lock(&hdd_context_lock);
5386 if (context->request_id == request_id)
5387 retval = context->response_status;
5388 else
5389 retval = -EINVAL;
5390 spin_unlock(&hdd_context_lock);
5391 }
5392
5393 return retval;
5394
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305395 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05305396 return 0;
5397}
5398
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305399static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
5400 struct wireless_dev *wdev,
5401 const void *data, int dataLen)
5402{
5403 int ret = 0;
5404
5405 vos_ssr_protect(__func__);
5406 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
5407 vos_ssr_unprotect(__func__);
5408
5409 return ret;
5410}
5411
5412static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05305413 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305414 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05305415{
Dino Myclee8843b32014-07-04 14:21:45 +05305416 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305417 struct net_device *dev = wdev->netdev;
5418 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5419 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5420 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
5421 eHalStatus status;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05305422 struct hdd_ext_scan_context *context;
5423 tANI_U32 request_id;
5424 unsigned long rc;
5425 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305426
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305427 ENTER();
5428
Ashish Kumar Dhanotiya4830bba2018-11-15 12:26:29 +05305429 if (!wlan_hdd_is_extscan_supported(pAdapter, pHddCtx))
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05305430 return -EINVAL;
Dino Myclee8843b32014-07-04 14:21:45 +05305431
Dino Mycle6fb96c12014-06-10 11:52:40 +05305432 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
5433 data, dataLen,
5434 wlan_hdd_extscan_config_policy)) {
5435 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5436 return -EINVAL;
5437 }
5438
5439 /* Parse and fetch request Id */
5440 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
5441 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
5442 return -EINVAL;
5443 }
5444
Dino Myclee8843b32014-07-04 14:21:45 +05305445 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05305446 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05305447 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305448
Dino Myclee8843b32014-07-04 14:21:45 +05305449 reqMsg.sessionId = pAdapter->sessionId;
5450 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305451
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05305452 context = &pHddCtx->ext_scan_context;
5453 spin_lock(&hdd_context_lock);
5454 INIT_COMPLETION(context->response_event);
5455 context->request_id = request_id = reqMsg.requestId;
5456 spin_unlock(&hdd_context_lock);
5457
Dino Myclee8843b32014-07-04 14:21:45 +05305458 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305459 if (!HAL_STATUS_SUCCESS(status)) {
5460 hddLog(VOS_TRACE_LEVEL_ERROR,
5461 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305462 return -EINVAL;
5463 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05305464
5465 /* request was sent -- wait for the response */
5466 rc = wait_for_completion_timeout(&context->response_event,
5467 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
5468 if (!rc) {
5469 hddLog(LOGE, FL("sme_ResetBssHotlist timed out"));
5470 retval = -ETIMEDOUT;
5471 } else {
5472 spin_lock(&hdd_context_lock);
5473 if (context->request_id == request_id)
5474 retval = context->response_status;
5475 else
5476 retval = -EINVAL;
5477 spin_unlock(&hdd_context_lock);
5478 }
5479
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305480 EXIT();
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05305481 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305482}
5483
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305484static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
5485 struct wireless_dev *wdev,
5486 const void *data, int dataLen)
5487{
5488 int ret = 0;
5489
5490 vos_ssr_protect(__func__);
5491 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
5492 vos_ssr_unprotect(__func__);
5493
5494 return ret;
5495}
Dino Mycle6fb96c12014-06-10 11:52:40 +05305496#endif /* WLAN_FEATURE_EXTSCAN */
5497
Atul Mittal115287b2014-07-08 13:26:33 +05305498/*EXT TDLS*/
5499static const struct nla_policy
5500wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
5501{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305502 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {
5503 .type = NLA_UNSPEC,
5504 .len = HDD_MAC_ADDR_LEN},
Atul Mittal115287b2014-07-08 13:26:33 +05305505 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
5506 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
5507 {.type = NLA_S32 },
5508 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
5509 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
5510
5511};
5512
5513static const struct nla_policy
5514wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
5515{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305516 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {
5517 .type = NLA_UNSPEC,
5518 .len = HDD_MAC_ADDR_LEN},
Atul Mittal115287b2014-07-08 13:26:33 +05305519
5520};
5521
5522static const struct nla_policy
5523wlan_hdd_tdls_config_state_change_policy[
5524 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
5525{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305526 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {
5527 .type = NLA_UNSPEC,
5528 .len = HDD_MAC_ADDR_LEN},
Atul Mittal115287b2014-07-08 13:26:33 +05305529 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
5530 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305531 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
5532 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
5533 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305534
5535};
5536
5537static const struct nla_policy
5538wlan_hdd_tdls_config_get_status_policy[
5539 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
5540{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305541 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {
5542 .type = NLA_UNSPEC,
5543 .len = HDD_MAC_ADDR_LEN},
Atul Mittal115287b2014-07-08 13:26:33 +05305544 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
5545 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305546 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
5547 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
5548 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305549
5550};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305551
5552static const struct nla_policy
5553wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
5554{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305555 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {
5556 .type = NLA_UNSPEC,
5557 .len = VOS_MAC_ADDR_FIRST_3_BYTES},
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305558};
5559
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305560static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305561 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305562 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305563 int data_len)
5564{
5565
5566 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Sourav Mohapatraaf2cc672018-10-30 17:43:29 +05305567 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(wdev->netdev);
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305568 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
5569
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305570 ENTER();
5571
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305572 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305573 return -EINVAL;
5574 }
Sourav Mohapatraaf2cc672018-10-30 17:43:29 +05305575
5576 if (!adapter) {
5577 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5578 return -EINVAL;
5579 }
5580
5581 if (adapter->device_mode != WLAN_HDD_INFRA_STATION) {
5582 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN allowed only in STA"));
5583 return -ENOTSUPP;
5584 }
5585
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +05305586 if (0 == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05305587 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305588 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05305589 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305590 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05305591 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305592 return -ENOTSUPP;
5593 }
5594
5595 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
5596 data, data_len, wlan_hdd_mac_config)) {
5597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5598 return -EINVAL;
5599 }
5600
5601 /* Parse and fetch mac address */
5602 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
5603 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5604 return -EINVAL;
5605 }
5606
5607 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
5608 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5609 VOS_MAC_ADDR_LAST_3_BYTES);
5610
Siddharth Bhal76972212014-10-15 16:22:51 +05305611 pHddCtx->spoofMacAddr.isEnabled = TRUE;
5612
5613 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305614 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5615 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05305616 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
5617 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
5618 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
5619 {
5620 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
5621 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
5622 VOS_MAC_ADDRESS_LEN);
5623 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305624 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305625
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +05305626 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
5627 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305628
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305629 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305630 return 0;
5631}
5632
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305633static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
5634 struct wireless_dev *wdev,
5635 const void *data,
5636 int data_len)
5637{
5638 int ret = 0;
5639
5640 vos_ssr_protect(__func__);
5641 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
5642 vos_ssr_unprotect(__func__);
5643
5644 return ret;
5645}
5646
5647static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305648 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305649 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305650 int data_len)
5651{
5652 u8 peer[6] = {0};
5653 struct net_device *dev = wdev->netdev;
5654 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5655 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5656 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
5657 eHalStatus ret;
5658 tANI_S32 state;
5659 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305660 tANI_S32 global_operating_class = 0;
5661 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05305662 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305663 int retVal;
5664
5665 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305666
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305667 if (!pAdapter) {
5668 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5669 return -EINVAL;
5670 }
5671
Atul Mittal115287b2014-07-08 13:26:33 +05305672 ret = wlan_hdd_validate_context(pHddCtx);
5673 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305674 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305675 return -EINVAL;
5676 }
5677 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305678 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305679 return -ENOTSUPP;
5680 }
5681 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
5682 data, data_len,
5683 wlan_hdd_tdls_config_get_status_policy)) {
5684 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5685 return -EINVAL;
5686 }
5687
5688 /* Parse and fetch mac address */
5689 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
5690 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5691 return -EINVAL;
5692 }
5693
5694 memcpy(peer, nla_data(
5695 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
5696 sizeof(peer));
5697 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5698
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05305699 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05305700
Atul Mittal115287b2014-07-08 13:26:33 +05305701 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305702 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05305703 NLMSG_HDRLEN);
5704
5705 if (!skb) {
5706 hddLog(VOS_TRACE_LEVEL_ERROR,
5707 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5708 return -EINVAL;
5709 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305710 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 +05305711 reason,
5712 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305713 global_operating_class,
5714 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05305715 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305716 if (nla_put_s32(skb,
5717 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
5718 state) ||
5719 nla_put_s32(skb,
5720 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
5721 reason) ||
5722 nla_put_s32(skb,
5723 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
5724 global_operating_class) ||
5725 nla_put_s32(skb,
5726 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
5727 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05305728
5729 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5730 goto nla_put_failure;
5731 }
5732
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305733 retVal = cfg80211_vendor_cmd_reply(skb);
5734 EXIT();
5735 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05305736
5737nla_put_failure:
5738 kfree_skb(skb);
5739 return -EINVAL;
5740}
5741
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305742static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
5743 struct wireless_dev *wdev,
5744 const void *data,
5745 int data_len)
5746{
5747 int ret = 0;
5748
5749 vos_ssr_protect(__func__);
5750 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
5751 vos_ssr_unprotect(__func__);
5752
5753 return ret;
5754}
5755
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05305756static int wlan_hdd_cfg80211_exttdls_callback(
5757#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
5758 const tANI_U8* mac,
5759#else
5760 tANI_U8* mac,
5761#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305762 tANI_S32 state,
5763 tANI_S32 reason,
5764 void *ctx)
5765{
5766 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05305767 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305768 tANI_S32 global_operating_class = 0;
5769 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305770 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05305771
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305772 ENTER();
5773
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305774 if (!pAdapter) {
5775 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5776 return -EINVAL;
5777 }
5778
5779 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05305780 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305781 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305782 return -EINVAL;
5783 }
5784
5785 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305786 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305787 return -ENOTSUPP;
5788 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05305789 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
5790#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
5791 NULL,
5792#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305793 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
5794 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
5795 GFP_KERNEL);
5796
5797 if (!skb) {
5798 hddLog(VOS_TRACE_LEVEL_ERROR,
5799 FL("cfg80211_vendor_event_alloc failed"));
5800 return -EINVAL;
5801 }
5802 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305803 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
5804 reason,
5805 state,
5806 global_operating_class,
5807 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05305808 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
5809 MAC_ADDR_ARRAY(mac));
5810
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305811 if (nla_put(skb,
5812 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
5813 VOS_MAC_ADDR_SIZE, mac) ||
5814 nla_put_s32(skb,
5815 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
5816 state) ||
5817 nla_put_s32(skb,
5818 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
5819 reason) ||
5820 nla_put_s32(skb,
5821 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
5822 channel) ||
5823 nla_put_s32(skb,
5824 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
5825 global_operating_class)
5826 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05305827 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5828 goto nla_put_failure;
5829 }
5830
5831 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305832 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05305833 return (0);
5834
5835nla_put_failure:
5836 kfree_skb(skb);
5837 return -EINVAL;
5838}
5839
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305840static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305841 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305842 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305843 int data_len)
5844{
5845 u8 peer[6] = {0};
5846 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305847 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5848 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
5849 eHalStatus status;
5850 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305851 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305852 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305853
5854 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305855
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305856 if (!dev) {
5857 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5858 return -EINVAL;
5859 }
5860
5861 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5862 if (!pAdapter) {
5863 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5864 return -EINVAL;
5865 }
5866
Atul Mittal115287b2014-07-08 13:26:33 +05305867 status = wlan_hdd_validate_context(pHddCtx);
5868 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305869 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305870 return -EINVAL;
5871 }
5872 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305873 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305874 return -ENOTSUPP;
5875 }
5876 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
5877 data, data_len,
5878 wlan_hdd_tdls_config_enable_policy)) {
5879 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5880 return -EINVAL;
5881 }
5882
5883 /* Parse and fetch mac address */
5884 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
5885 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5886 return -EINVAL;
5887 }
5888
5889 memcpy(peer, nla_data(
5890 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
5891 sizeof(peer));
5892 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5893
5894 /* Parse and fetch channel */
5895 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
5896 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
5897 return -EINVAL;
5898 }
5899 pReqMsg.channel = nla_get_s32(
5900 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
5901 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
5902
5903 /* Parse and fetch global operating class */
5904 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
5905 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
5906 return -EINVAL;
5907 }
5908 pReqMsg.global_operating_class = nla_get_s32(
5909 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
5910 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
5911 pReqMsg.global_operating_class);
5912
5913 /* Parse and fetch latency ms */
5914 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
5915 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
5916 return -EINVAL;
5917 }
5918 pReqMsg.max_latency_ms = nla_get_s32(
5919 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
5920 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
5921 pReqMsg.max_latency_ms);
5922
5923 /* Parse and fetch required bandwidth kbps */
5924 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
5925 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
5926 return -EINVAL;
5927 }
5928
5929 pReqMsg.min_bandwidth_kbps = nla_get_s32(
5930 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
5931 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
5932 pReqMsg.min_bandwidth_kbps);
5933
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305934 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05305935 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05305936 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305937 wlan_hdd_cfg80211_exttdls_callback);
5938
5939 EXIT();
5940 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305941}
5942
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305943static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
5944 struct wireless_dev *wdev,
5945 const void *data,
5946 int data_len)
5947{
5948 int ret = 0;
5949
5950 vos_ssr_protect(__func__);
5951 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
5952 vos_ssr_unprotect(__func__);
5953
5954 return ret;
5955}
5956
5957static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305958 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305959 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305960 int data_len)
5961{
5962 u8 peer[6] = {0};
5963 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305964 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5965 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
5966 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305967 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305968 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305969
5970 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305971
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305972 if (!dev) {
5973 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5974 return -EINVAL;
5975 }
5976
5977 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5978 if (!pAdapter) {
5979 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
5980 return -EINVAL;
5981 }
5982
Atul Mittal115287b2014-07-08 13:26:33 +05305983 status = wlan_hdd_validate_context(pHddCtx);
5984 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305985 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305986 return -EINVAL;
5987 }
5988 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305989 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305990 return -ENOTSUPP;
5991 }
5992 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
5993 data, data_len,
5994 wlan_hdd_tdls_config_disable_policy)) {
5995 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5996 return -EINVAL;
5997 }
5998 /* Parse and fetch mac address */
5999 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
6000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
6001 return -EINVAL;
6002 }
6003
6004 memcpy(peer, nla_data(
6005 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
6006 sizeof(peer));
6007 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
6008
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306009 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
6010
6011 EXIT();
6012 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05306013}
6014
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306015static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
6016 struct wireless_dev *wdev,
6017 const void *data,
6018 int data_len)
6019{
6020 int ret = 0;
6021
6022 vos_ssr_protect(__func__);
6023 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
6024 vos_ssr_unprotect(__func__);
6025
6026 return ret;
6027}
6028
Dasari Srinivas7875a302014-09-26 17:50:57 +05306029static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306030__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05306031 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306032 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05306033{
6034 struct net_device *dev = wdev->netdev;
6035 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6036 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6037 struct sk_buff *skb = NULL;
6038 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306039 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05306040
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306041 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306042
6043 ret = wlan_hdd_validate_context(pHddCtx);
6044 if (0 != ret)
6045 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306046 return ret;
6047 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05306048 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
6049 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
6050 fset |= WIFI_FEATURE_INFRA;
6051 }
6052
6053 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
6054 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
6055 fset |= WIFI_FEATURE_INFRA_5G;
6056 }
6057
6058#ifdef WLAN_FEATURE_P2P
6059 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
6060 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
6061 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
6062 fset |= WIFI_FEATURE_P2P;
6063 }
6064#endif
6065
6066 /* Soft-AP is supported currently by default */
6067 fset |= WIFI_FEATURE_SOFT_AP;
6068
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05306069 /* HOTSPOT is a supplicant feature, enable it by default */
6070 fset |= WIFI_FEATURE_HOTSPOT;
6071
Dasari Srinivas7875a302014-09-26 17:50:57 +05306072#ifdef WLAN_FEATURE_EXTSCAN
6073 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05306074 sme_IsFeatureSupportedByFW(EXTENDED_SCAN) &&
6075 sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)) {
6076 hddLog(LOG1, FL("Enhanced EXTScan is supported by firmware"));
Dasari Srinivas7875a302014-09-26 17:50:57 +05306077 fset |= WIFI_FEATURE_EXTSCAN;
6078 }
6079#endif
6080
Dasari Srinivas7875a302014-09-26 17:50:57 +05306081 if (sme_IsFeatureSupportedByFW(NAN)) {
6082 hddLog(LOG1, FL("NAN is supported by firmware"));
6083 fset |= WIFI_FEATURE_NAN;
6084 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05306085
6086 /* D2D RTT is not supported currently by default */
Sourav Mohapatradf8b23c2017-11-17 17:50:31 +05306087 if (sme_IsFeatureSupportedByFW(RTT) &&
6088 pHddCtx->cfg_ini->enable_rtt_support) {
6089 hddLog(LOG1, FL("RTT is supported by firmware and framework"));
Dasari Srinivas7875a302014-09-26 17:50:57 +05306090 fset |= WIFI_FEATURE_D2AP_RTT;
6091 }
6092
Padma, Santhosh Kumaraac4c4d2015-12-08 16:07:47 +05306093 if (sme_IsFeatureSupportedByFW(RTT3)) {
6094 hddLog(LOG1, FL("RTT3 is supported by firmware"));
6095 fset |= WIFI_FEATURE_RTT3;
6096 }
6097
Dasari Srinivas7875a302014-09-26 17:50:57 +05306098#ifdef FEATURE_WLAN_BATCH_SCAN
6099 if (fset & WIFI_FEATURE_EXTSCAN) {
6100 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
6101 fset &= ~WIFI_FEATURE_BATCH_SCAN;
6102 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
6103 hddLog(LOG1, FL("Batch scan is supported by firmware"));
6104 fset |= WIFI_FEATURE_BATCH_SCAN;
6105 }
6106#endif
6107
6108#ifdef FEATURE_WLAN_SCAN_PNO
6109 if (pHddCtx->cfg_ini->configPNOScanSupport &&
6110 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
6111 hddLog(LOG1, FL("PNO is supported by firmware"));
6112 fset |= WIFI_FEATURE_PNO;
6113 }
6114#endif
6115
6116 /* STA+STA is supported currently by default */
6117 fset |= WIFI_FEATURE_ADDITIONAL_STA;
6118
6119#ifdef FEATURE_WLAN_TDLS
6120 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
6121 sme_IsFeatureSupportedByFW(TDLS)) {
6122 hddLog(LOG1, FL("TDLS is supported by firmware"));
6123 fset |= WIFI_FEATURE_TDLS;
6124 }
6125
6126 /* TDLS_OFFCHANNEL is not supported currently by default */
6127#endif
6128
6129#ifdef WLAN_AP_STA_CONCURRENCY
6130 /* AP+STA concurrency is supported currently by default */
6131 fset |= WIFI_FEATURE_AP_STA;
6132#endif
6133
Mukul Sharma5add0532015-08-17 15:57:47 +05306134#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Ajit Vaishya8353cfb2017-11-10 16:22:36 +05306135 if ((TRUE == pHddCtx->cfg_ini->fEnableLLStats) &&
6136 (TRUE == sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS))) {
Mukul Sharma5add0532015-08-17 15:57:47 +05306137 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
6138 hddLog(LOG1, FL("Link layer stats is supported by driver"));
Ajit Vaishya8353cfb2017-11-10 16:22:36 +05306139 }
Mukul Sharma5add0532015-08-17 15:57:47 +05306140#endif
6141
Dasari Srinivas7875a302014-09-26 17:50:57 +05306142 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
6143 NLMSG_HDRLEN);
6144
6145 if (!skb) {
6146 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6147 return -EINVAL;
6148 }
6149 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
6150
6151 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
6152 hddLog(LOGE, FL("nla put fail"));
6153 goto nla_put_failure;
6154 }
6155
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306156 ret = cfg80211_vendor_cmd_reply(skb);
6157 EXIT();
6158 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05306159
6160nla_put_failure:
6161 kfree_skb(skb);
6162 return -EINVAL;
6163}
6164
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306165static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306166wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
6167 struct wireless_dev *wdev,
6168 const void *data, int data_len)
6169{
6170 int ret = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306171 vos_ssr_protect(__func__);
6172 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
6173 vos_ssr_unprotect(__func__);
6174
6175 return ret;
6176}
6177
Sachin Ahujac08f72a2015-09-22 15:25:47 +05306178
6179static const struct
6180nla_policy
6181qca_wlan_vendor_wifi_logger_get_ring_data_policy
6182[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = {
6183 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]
6184 = {.type = NLA_U32 },
6185};
6186
6187static int
6188 __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
6189 struct wireless_dev *wdev,
6190 const void *data,
6191 int data_len)
6192{
6193 int ret;
6194 VOS_STATUS status;
6195 uint32_t ring_id;
6196 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6197 struct nlattr *tb
6198 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1];
6199
6200 ENTER();
6201
6202 ret = wlan_hdd_validate_context(hdd_ctx);
6203 if (0 != ret) {
6204 return ret;
6205 }
6206
6207 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX,
6208 data, data_len,
6209 qca_wlan_vendor_wifi_logger_get_ring_data_policy)) {
6210 hddLog(LOGE, FL("Invalid attribute"));
6211 return -EINVAL;
6212 }
6213
6214 /* Parse and fetch ring id */
6215 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) {
6216 hddLog(LOGE, FL("attr ATTR failed"));
6217 return -EINVAL;
6218 }
6219
6220 ring_id = nla_get_u32(
6221 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]);
6222
6223 hddLog(LOG1, FL("Bug report triggered by framework"));
6224
6225 status = vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
6226 WLAN_LOG_INDICATOR_FRAMEWORK,
6227 WLAN_LOG_REASON_CODE_FRAMEWORK,
Abhishek Singh837adf22015-10-01 17:37:37 +05306228 TRUE, TRUE
Sachin Ahujac08f72a2015-09-22 15:25:47 +05306229 );
6230 if (VOS_STATUS_SUCCESS != status) {
6231 hddLog(LOGE, FL("Failed to trigger bug report"));
6232
6233 return -EINVAL;
6234 }
6235
6236 return 0;
6237
6238
6239}
6240
6241
6242static int
6243 wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
6244 struct wireless_dev *wdev,
6245 const void *data,
6246 int data_len)
6247{
6248 int ret = 0;
6249
6250 vos_ssr_protect(__func__);
6251 ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy,
6252 wdev, data, data_len);
6253 vos_ssr_unprotect(__func__);
6254
6255 return ret;
6256
6257}
6258
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05306259#define MAX_CONCURRENT_MATRIX \
6260 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX
6261#define MATRIX_CONFIG_PARAM_SET_SIZE_MAX \
6262 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX
6263static const struct nla_policy
6264wlan_hdd_get_concurrency_matrix_policy[MAX_CONCURRENT_MATRIX + 1] = {
6265 [MATRIX_CONFIG_PARAM_SET_SIZE_MAX] = {.type = NLA_U32},
6266};
Sachin Ahujac08f72a2015-09-22 15:25:47 +05306267
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306268static int
6269__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306270 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306271 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306272{
6273 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
6274 uint8_t i, feature_sets, max_feature_sets;
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05306275 struct nlattr *tb[MAX_CONCURRENT_MATRIX + 1];
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306276 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306277 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6278 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306279
6280 ENTER();
6281
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306282 ret = wlan_hdd_validate_context(pHddCtx);
6283 if (0 != ret)
6284 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306285 return ret;
6286 }
6287
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05306288 if (nla_parse(tb, MAX_CONCURRENT_MATRIX, data, data_len,
6289 wlan_hdd_get_concurrency_matrix_policy)) {
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306290 hddLog(LOGE, FL("Invalid ATTR"));
6291 return -EINVAL;
6292 }
6293
6294 /* Parse and fetch max feature set */
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05306295 if (!tb[MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306296 hddLog(LOGE, FL("Attr max feature set size failed"));
6297 return -EINVAL;
6298 }
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05306299 max_feature_sets = nla_get_u32(tb[MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306300 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
6301
6302 /* Fill feature combination matrix */
6303 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306304 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
6305 WIFI_FEATURE_P2P;
6306
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306307 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
6308 WIFI_FEATURE_SOFT_AP;
6309
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306310 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
6311 WIFI_FEATURE_SOFT_AP;
6312
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306313 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
6314 WIFI_FEATURE_SOFT_AP |
6315 WIFI_FEATURE_P2P;
6316
6317 /* Add more feature combinations here */
6318
6319 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
6320 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
6321 hddLog(LOG1, "Feature set matrix");
6322 for (i = 0; i < feature_sets; i++)
6323 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
6324
6325 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
6326 sizeof(u32) * feature_sets +
6327 NLMSG_HDRLEN);
6328
6329 if (reply_skb) {
6330 if (nla_put_u32(reply_skb,
6331 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
6332 feature_sets) ||
6333 nla_put(reply_skb,
6334 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
6335 sizeof(u32) * feature_sets, feature_set_matrix)) {
6336 hddLog(LOGE, FL("nla put fail"));
6337 kfree_skb(reply_skb);
6338 return -EINVAL;
6339 }
6340
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306341 ret = cfg80211_vendor_cmd_reply(reply_skb);
6342 EXIT();
6343 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306344 }
6345 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
6346 return -ENOMEM;
6347
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306348}
6349
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05306350#undef MAX_CONCURRENT_MATRIX
6351#undef MATRIX_CONFIG_PARAM_SET_SIZE_MAX
6352
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306353static int
6354wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
6355 struct wireless_dev *wdev,
6356 const void *data, int data_len)
6357{
6358 int ret = 0;
6359
6360 vos_ssr_protect(__func__);
6361 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
6362 data_len);
6363 vos_ssr_unprotect(__func__);
6364
6365 return ret;
6366}
6367
c_manjeecfd1efb2015-09-25 19:32:34 +05306368
6369static int
6370__wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
6371 struct wireless_dev *wdev,
6372 const void *data, int data_len)
6373{
6374 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6375 int ret;
6376 ENTER();
6377
6378 ret = wlan_hdd_validate_context(pHddCtx);
6379 if (0 != ret)
6380 {
6381 return ret;
6382 }
6383
6384 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
6385 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
6386 {
6387 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
Ajit Vaishyac5ba8482017-11-16 14:10:37 +05306388 return -EOPNOTSUPP;
c_manjeecfd1efb2015-09-25 19:32:34 +05306389 }
6390 /*call common API for FW mem dump req*/
6391 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
6392
Abhishek Singhc783fa72015-12-09 18:07:34 +05306393 if (!ret)
c_manjee04b4c5c2015-10-13 18:35:01 +05306394 {
6395 /*indicate to userspace the status of fw mem dump */
6396 wlan_indicate_mem_dump_complete(true);
6397 }
6398 else
6399 {
6400 /*else send failure to userspace */
6401 wlan_indicate_mem_dump_complete(false);
6402 }
c_manjeecfd1efb2015-09-25 19:32:34 +05306403 EXIT();
6404 return ret;
6405}
6406
6407/**
6408 * wlan_hdd_cfg80211_get_fw_mem_dump() - Get FW memory dump
6409 * @wiphy: pointer to wireless wiphy structure.
6410 * @wdev: pointer to wireless_dev structure.
6411 * @data: Pointer to the NL data.
6412 * @data_len:Length of @data
6413 *
6414 * This is called when wlan driver needs to get the firmware memory dump
6415 * via vendor specific command.
6416 *
6417 * Return: 0 on success, error number otherwise.
6418 */
6419
6420static int
6421wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
6422 struct wireless_dev *wdev,
6423 const void *data, int data_len)
Sushant Kaushik8e644982015-09-23 12:18:54 +05306424{
6425 int ret = 0;
6426 vos_ssr_protect(__func__);
6427 ret = __wlan_hdd_cfg80211_get_fw_mem_dump(wiphy, wdev, data,
6428 data_len);
6429 vos_ssr_unprotect(__func__);
6430 return ret;
6431}
c_manjeecfd1efb2015-09-25 19:32:34 +05306432
Sushant Kaushik8e644982015-09-23 12:18:54 +05306433static const struct
6434nla_policy
6435qca_wlan_vendor_wifi_logger_start_policy
6436[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = {
6437 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]
6438 = {.type = NLA_U32 },
6439 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]
6440 = {.type = NLA_U32 },
6441 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]
6442 = {.type = NLA_U32 },
6443};
6444
6445/**
6446 * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable
6447 * or disable the collection of packet statistics from the firmware
6448 * @wiphy: WIPHY structure pointer
6449 * @wdev: Wireless device structure pointer
6450 * @data: Pointer to the data received
6451 * @data_len: Length of the data received
6452 *
6453 * This function is used to enable or disable the collection of packet
6454 * statistics from the firmware
6455 *
6456 * Return: 0 on success and errno on failure
6457 */
6458static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
6459 struct wireless_dev *wdev,
6460 const void *data,
6461 int data_len)
6462{
6463 eHalStatus status;
6464 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6465 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1];
6466 tAniWifiStartLog start_log;
6467
6468 status = wlan_hdd_validate_context(hdd_ctx);
6469 if (0 != status) {
6470 return -EINVAL;
6471 }
6472
6473 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX,
6474 data, data_len,
6475 qca_wlan_vendor_wifi_logger_start_policy)) {
6476 hddLog(LOGE, FL("Invalid attribute"));
6477 return -EINVAL;
6478 }
6479
6480 /* Parse and fetch ring id */
6481 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) {
6482 hddLog(LOGE, FL("attr ATTR failed"));
6483 return -EINVAL;
6484 }
6485 start_log.ringId = nla_get_u32(
6486 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]);
6487 hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId);
6488
6489 /* Parse and fetch verbose level */
6490 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) {
6491 hddLog(LOGE, FL("attr verbose_level failed"));
6492 return -EINVAL;
6493 }
6494 start_log.verboseLevel = nla_get_u32(
6495 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]);
6496 hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel);
6497
6498 /* Parse and fetch flag */
6499 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) {
6500 hddLog(LOGE, FL("attr flag failed"));
6501 return -EINVAL;
6502 }
6503 start_log.flag = nla_get_u32(
6504 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]);
6505 hddLog(LOG1, FL("flag=%d"), start_log.flag);
6506
6507 if ((RING_ID_PER_PACKET_STATS == start_log.ringId) &&
Sushant Kaushik33200572015-08-05 16:46:20 +05306508 (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable ||
6509 !vos_isPktStatsEnabled()))
6510
Sushant Kaushik8e644982015-09-23 12:18:54 +05306511 {
6512 hddLog(LOGE, FL("per pkt stats not enabled"));
6513 return -EINVAL;
6514 }
Sushant Kaushik8e644982015-09-23 12:18:54 +05306515
Sushant Kaushik33200572015-08-05 16:46:20 +05306516 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
Sushant Kaushik8e644982015-09-23 12:18:54 +05306517 return 0;
6518}
6519
6520/**
6521 * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable
6522 * or disable the collection of packet statistics from the firmware
6523 * @wiphy: WIPHY structure pointer
6524 * @wdev: Wireless device structure pointer
6525 * @data: Pointer to the data received
6526 * @data_len: Length of the data received
6527 *
6528 * This function is used to enable or disable the collection of packet
6529 * statistics from the firmware
6530 *
6531 * Return: 0 on success and errno on failure
6532 */
6533static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
6534 struct wireless_dev *wdev,
6535 const void *data,
6536 int data_len)
c_manjeecfd1efb2015-09-25 19:32:34 +05306537{
6538 int ret = 0;
6539
6540 vos_ssr_protect(__func__);
Sushant Kaushik8e644982015-09-23 12:18:54 +05306541
6542 ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy,
6543 wdev, data, data_len);
c_manjeecfd1efb2015-09-25 19:32:34 +05306544 vos_ssr_unprotect(__func__);
6545
6546 return ret;
c_manjeecfd1efb2015-09-25 19:32:34 +05306547}
6548
6549
Agarwal Ashish738843c2014-09-25 12:27:56 +05306550static const struct nla_policy
6551wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
6552 +1] =
6553{
6554 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
6555};
6556
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306557static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306558 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306559 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306560 int data_len)
6561{
6562 struct net_device *dev = wdev->netdev;
6563 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6564 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6565 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6566 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
6567 eHalStatus status;
6568 u32 dfsFlag = 0;
6569
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306570 ENTER();
6571
Agarwal Ashish738843c2014-09-25 12:27:56 +05306572 status = wlan_hdd_validate_context(pHddCtx);
6573 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05306574 return -EINVAL;
6575 }
6576 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
6577 data, data_len,
6578 wlan_hdd_set_no_dfs_flag_config_policy)) {
6579 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6580 return -EINVAL;
6581 }
6582
6583 /* Parse and fetch required bandwidth kbps */
6584 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
6585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
6586 return -EINVAL;
6587 }
6588
6589 dfsFlag = nla_get_u32(
6590 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
6591 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
6592 dfsFlag);
6593
6594 pHddCtx->disable_dfs_flag = dfsFlag;
6595
6596 sme_disable_dfs_channel(hHal, dfsFlag);
6597 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306598
6599 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05306600 return 0;
6601}
Atul Mittal115287b2014-07-08 13:26:33 +05306602
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306603static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
6604 struct wireless_dev *wdev,
6605 const void *data,
6606 int data_len)
6607{
6608 int ret = 0;
6609
6610 vos_ssr_protect(__func__);
6611 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
6612 vos_ssr_unprotect(__func__);
6613
6614 return ret;
6615
6616}
6617
Mukul Sharma2a271632014-10-13 14:59:01 +05306618const struct
6619nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
6620{
6621 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05306622 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = {
6623 .type = NLA_UNSPEC,
6624 .len = HDD_MAC_ADDR_LEN},
Mukul Sharma2a271632014-10-13 14:59:01 +05306625};
6626
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306627static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05306628 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05306629{
6630
6631 u8 bssid[6] = {0};
6632 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6633 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6634 eHalStatus status = eHAL_STATUS_SUCCESS;
6635 v_U32_t isFwrRoamEnabled = FALSE;
6636 int ret;
6637
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306638 ENTER();
6639
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306640 ret = wlan_hdd_validate_context(pHddCtx);
6641 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306642 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05306643 }
6644
6645 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
6646 data, data_len,
6647 qca_wlan_vendor_attr);
6648 if (ret){
6649 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6650 return -EINVAL;
6651 }
6652
6653 /* Parse and fetch Enable flag */
6654 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
6655 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
6656 return -EINVAL;
6657 }
6658
6659 isFwrRoamEnabled = nla_get_u32(
6660 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
6661
6662 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
6663
6664 /* Parse and fetch bssid */
6665 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6666 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
6667 return -EINVAL;
6668 }
6669
6670 memcpy(bssid, nla_data(
6671 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6672 sizeof(bssid));
6673 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
6674
6675 //Update roaming
6676 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306677 if (!HAL_STATUS_SUCCESS(status)) {
6678 hddLog(LOGE,
6679 FL("sme_ConfigFwrRoaming failed (err=%d)"), status);
6680 return -EINVAL;
6681 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306682 EXIT();
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306683 return 0;
Mukul Sharma2a271632014-10-13 14:59:01 +05306684}
6685
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306686static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
6687 struct wireless_dev *wdev, const void *data, int data_len)
6688{
6689 int ret = 0;
6690
6691 vos_ssr_protect(__func__);
6692 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
6693 vos_ssr_unprotect(__func__);
6694
6695 return ret;
6696}
6697
Sushant Kaushik847890c2015-09-28 16:05:17 +05306698static const struct
6699nla_policy
6700qca_wlan_vendor_get_wifi_info_policy[
6701 QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = {
6702 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
6703 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
6704};
6705
6706
6707/**
6708 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6709 * @wiphy: pointer to wireless wiphy structure.
6710 * @wdev: pointer to wireless_dev structure.
6711 * @data: Pointer to the data to be passed via vendor interface
6712 * @data_len:Length of the data to be passed
6713 *
6714 * This is called when wlan driver needs to send wifi driver related info
6715 * (driver/fw version) to the user space application upon request.
6716 *
6717 * Return: Return the Success or Failure code.
6718 */
6719static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6720 struct wireless_dev *wdev,
6721 const void *data, int data_len)
6722{
6723 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6724 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
6725 tSirVersionString version;
6726 uint32 version_len;
6727 uint8 attr;
6728 int status;
6729 struct sk_buff *reply_skb = NULL;
6730
6731 if (VOS_FTM_MODE == hdd_get_conparam()) {
6732 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6733 return -EINVAL;
6734 }
6735
6736 status = wlan_hdd_validate_context(hdd_ctx);
6737 if (0 != status) {
6738 hddLog(LOGE, FL("HDD context is not valid"));
6739 return -EINVAL;
6740 }
6741
6742 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
6743 data_len, qca_wlan_vendor_get_wifi_info_policy)) {
6744 hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
6745 return -EINVAL;
6746 }
6747
6748 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
6749 hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"),
6750 QWLAN_VERSIONSTR);
6751 strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
6752 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
6753 } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
6754 hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"),
6755 hdd_ctx->fw_Version);
6756 strlcpy(version, hdd_ctx->fw_Version, sizeof(version));
6757 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
6758 } else {
6759 hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
6760 return -EINVAL;
6761 }
6762
6763 version_len = strlen(version);
6764 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6765 version_len + NLA_HDRLEN + NLMSG_HDRLEN);
6766 if (!reply_skb) {
6767 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6768 return -ENOMEM;
6769 }
6770
6771 if (nla_put(reply_skb, attr, version_len, version)) {
6772 hddLog(LOGE, FL("nla put fail"));
6773 kfree_skb(reply_skb);
6774 return -EINVAL;
6775 }
6776
6777 return cfg80211_vendor_cmd_reply(reply_skb);
6778}
6779
6780/**
6781 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6782 * @wiphy: pointer to wireless wiphy structure.
6783 * @wdev: pointer to wireless_dev structure.
6784 * @data: Pointer to the data to be passed via vendor interface
6785 * @data_len:Length of the data to be passed
6786 * @data_len: Length of the data received
6787 *
6788 * This function is used to enable or disable the collection of packet
6789 * statistics from the firmware
6790 *
6791 * Return: 0 on success and errno on failure
6792 */
6793
6794static int
6795wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6796 struct wireless_dev *wdev,
6797 const void *data, int data_len)
6798
6799
6800{
6801 int ret = 0;
6802
6803 vos_ssr_protect(__func__);
6804 ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy,
6805 wdev, data, data_len);
6806 vos_ssr_unprotect(__func__);
6807
6808 return ret;
6809}
6810
6811
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306812/*
6813 * define short names for the global vendor params
6814 * used by __wlan_hdd_cfg80211_monitor_rssi()
6815 */
6816#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX
6817#define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID
6818#define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL
6819#define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI
6820#define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI
6821
6822/**---------------------------------------------------------------------------
6823
6824 \brief hdd_rssi_monitor_start_done - callback to be executed when rssi
6825 monitor start is completed successfully.
6826
6827 \return - None
6828
6829 --------------------------------------------------------------------------*/
6830void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6831{
6832 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6833
6834 if (NULL == pHddCtx)
6835 {
6836 hddLog(VOS_TRACE_LEVEL_ERROR,
6837 "%s: HDD context is NULL",__func__);
6838 return;
6839 }
6840
6841 if (VOS_STATUS_SUCCESS == status)
6842 {
6843 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful"));
6844 }
6845 else
6846 {
6847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful"));
6848 }
6849
6850 return;
6851}
6852
6853/**---------------------------------------------------------------------------
6854
6855 \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor
6856 stop is completed successfully.
6857
6858 \return - None
6859
6860 --------------------------------------------------------------------------*/
6861void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6862{
6863 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6864
6865 if (NULL == pHddCtx)
6866 {
6867 hddLog(VOS_TRACE_LEVEL_ERROR,
6868 "%s: HDD context is NULL",__func__);
6869 return;
6870 }
6871
6872 if (VOS_STATUS_SUCCESS == status)
6873 {
6874 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful"));
6875 }
6876 else
6877 {
6878 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful"));
6879 }
6880
6881 return;
6882}
6883
6884/**
6885 * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi
6886 * @wiphy: Pointer to wireless phy
6887 * @wdev: Pointer to wireless device
6888 * @data: Pointer to data
6889 * @data_len: Data length
6890 *
6891 * Return: 0 on success, negative errno on failure
6892 */
6893
6894static int
6895__wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy,
6896 struct wireless_dev *wdev,
6897 const void *data,
6898 int data_len)
6899{
6900 struct net_device *dev = wdev->netdev;
6901 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6902 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6903 hdd_station_ctx_t *pHddStaCtx;
6904 struct nlattr *tb[PARAM_MAX + 1];
6905 tpSirRssiMonitorReq pReq;
6906 eHalStatus status;
6907 int ret;
6908 uint32_t control;
6909 static const struct nla_policy policy[PARAM_MAX + 1] = {
6910 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6911 [PARAM_CONTROL] = { .type = NLA_U32 },
6912 [PARAM_MIN_RSSI] = { .type = NLA_S8 },
6913 [PARAM_MAX_RSSI] = { .type = NLA_S8 },
6914 };
6915
6916 ENTER();
6917
6918 ret = wlan_hdd_validate_context(hdd_ctx);
6919 if (0 != ret) {
6920 return -EINVAL;
6921 }
6922
6923 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6924 hddLog(LOGE, FL("Not in Connected state!"));
6925 return -ENOTSUPP;
6926 }
6927
6928 if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) {
6929 hddLog(LOGE, FL("Invalid ATTR"));
6930 return -EINVAL;
6931 }
6932
6933 if (!tb[PARAM_REQUEST_ID]) {
6934 hddLog(LOGE, FL("attr request id failed"));
6935 return -EINVAL;
6936 }
6937
6938 if (!tb[PARAM_CONTROL]) {
6939 hddLog(LOGE, FL("attr control failed"));
6940 return -EINVAL;
6941 }
6942
6943 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6944
6945 pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq));
6946 if(NULL == pReq)
6947 {
6948 hddLog(LOGE,
6949 FL("vos_mem_alloc failed "));
6950 return eHAL_STATUS_FAILED_ALLOC;
6951 }
6952 vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0);
6953
6954 pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
6955 pReq->sessionId = pAdapter->sessionId;
6956 pReq->rssiMonitorCbContext = hdd_ctx;
6957 control = nla_get_u32(tb[PARAM_CONTROL]);
6958 vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6959
6960 hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"),
6961 pReq->requestId, pReq->sessionId, control);
6962
6963 if (control == QCA_WLAN_RSSI_MONITORING_START) {
6964 if (!tb[PARAM_MIN_RSSI]) {
6965 hddLog(LOGE, FL("attr min rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306966 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306967 }
6968
6969 if (!tb[PARAM_MAX_RSSI]) {
6970 hddLog(LOGE, FL("attr max rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306971 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306972 }
6973
6974 pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]);
6975 pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]);
6976 pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done;
6977
6978 if (!(pReq->minRssi < pReq->maxRssi)) {
6979 hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"),
6980 pReq->minRssi, pReq->maxRssi);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306981 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306982 }
6983 hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"),
6984 pReq->minRssi, pReq->maxRssi);
6985 status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq);
6986
6987 }
6988 else if (control == QCA_WLAN_RSSI_MONITORING_STOP) {
6989 pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done;
6990 status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq);
6991 }
6992 else {
6993 hddLog(LOGE, FL("Invalid control cmd: %d"), control);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306994 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306995 }
6996
6997 if (!HAL_STATUS_SUCCESS(status)) {
6998 hddLog(LOGE,
6999 FL("sme_set_rssi_monitoring failed(err=%d)"), status);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05307000 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307001 }
7002
7003 return 0;
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05307004fail:
7005 vos_mem_free(pReq);
7006 return -EINVAL;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307007}
7008
7009/*
7010 * done with short names for the global vendor params
7011 * used by __wlan_hdd_cfg80211_monitor_rssi()
7012 */
7013#undef PARAM_MAX
7014#undef PARAM_CONTROL
7015#undef PARAM_REQUEST_ID
7016#undef PARAM_MAX_RSSI
7017#undef PARAM_MIN_RSSI
7018
7019/**
7020 * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
7021 * @wiphy: wiphy structure pointer
7022 * @wdev: Wireless device structure pointer
7023 * @data: Pointer to the data received
7024 * @data_len: Length of @data
7025 *
7026 * Return: 0 on success; errno on failure
7027 */
7028static int
7029wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
7030 const void *data, int data_len)
7031{
7032 int ret;
7033
7034 vos_ssr_protect(__func__);
7035 ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len);
7036 vos_ssr_unprotect(__func__);
7037
7038 return ret;
7039}
7040
7041/**
7042 * hdd_rssi_threshold_breached_cb() - rssi breached NL event
7043 * @hddctx: HDD context
7044 * @data: rssi breached event data
7045 *
7046 * This function reads the rssi breached event %data and fill in the skb with
7047 * NL attributes and send up the NL event.
7048 * This callback execute in atomic context and must not invoke any
7049 * blocking calls.
7050 *
7051 * Return: none
7052 */
7053void hdd_rssi_threshold_breached_cb(void *hddctx,
7054 struct rssi_breach_event *data)
7055{
7056 hdd_context_t *pHddCtx = (hdd_context_t *)hddctx;
7057 int status;
7058 struct sk_buff *skb;
7059
7060 ENTER();
7061 status = wlan_hdd_validate_context(pHddCtx);
7062
7063 if (0 != status) {
7064 return;
7065 }
7066
7067 if (!data) {
7068 hddLog(LOGE, FL("data is null"));
7069 return;
7070 }
7071
7072 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
7073#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
7074 NULL,
7075#endif
7076 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
7077 QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
7078 GFP_KERNEL);
7079
7080 if (!skb) {
7081 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
7082 return;
7083 }
7084
7085 hddLog(LOG1, "Req Id: %u Current rssi: %d",
7086 data->request_id, data->curr_rssi);
7087 hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR,
7088 MAC_ADDR_ARRAY(data->curr_bssid.bytes));
7089
7090 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID,
7091 data->request_id) ||
7092 nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID,
7093 sizeof(data->curr_bssid), data->curr_bssid.bytes) ||
7094 nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI,
7095 data->curr_rssi)) {
7096 hddLog(LOGE, FL("nla put fail"));
7097 goto fail;
7098 }
7099
7100 cfg80211_vendor_event(skb, GFP_KERNEL);
7101 return;
7102
7103fail:
7104 kfree_skb(skb);
7105 return;
7106}
7107
7108
7109
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307110/**
7111 * __wlan_hdd_cfg80211_setband() - set band
7112 * @wiphy: Pointer to wireless phy
7113 * @wdev: Pointer to wireless device
7114 * @data: Pointer to data
7115 * @data_len: Data length
7116 *
7117 * Return: 0 on success, negative errno on failure
7118 */
7119static int
7120__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
7121 struct wireless_dev *wdev,
7122 const void *data,
7123 int data_len)
7124{
7125 struct net_device *dev = wdev->netdev;
7126 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7127 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
7128 int ret;
7129 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
7130 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
7131
7132 ENTER();
7133
7134 ret = wlan_hdd_validate_context(hdd_ctx);
7135 if (0 != ret) {
7136 hddLog(LOGE, FL("HDD context is not valid"));
7137 return ret;
7138 }
7139
7140 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7141 policy)) {
7142 hddLog(LOGE, FL("Invalid ATTR"));
7143 return -EINVAL;
7144 }
7145
7146 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
7147 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
7148 return -EINVAL;
7149 }
7150
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05307151 hdd_ctx->isSetBandByNL = TRUE;
7152 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307153 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05307154 hdd_ctx->isSetBandByNL = FALSE;
7155
7156 EXIT();
7157 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307158}
7159
7160/**
7161 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
7162 * @wiphy: wiphy structure pointer
7163 * @wdev: Wireless device structure pointer
7164 * @data: Pointer to the data received
7165 * @data_len: Length of @data
7166 *
7167 * Return: 0 on success; errno on failure
7168 */
7169static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
7170 struct wireless_dev *wdev,
7171 const void *data,
7172 int data_len)
7173{
7174 int ret = 0;
7175
7176 vos_ssr_protect(__func__);
7177 ret = __wlan_hdd_cfg80211_setband(wiphy,
7178 wdev, data, data_len);
7179 vos_ssr_unprotect(__func__);
7180
7181 return ret;
7182}
7183
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307184#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
7185/**
7186 * hdd_map_req_id_to_pattern_id() - map request id to pattern id
7187 * @hdd_ctx: HDD context
7188 * @request_id: [input] request id
7189 * @pattern_id: [output] pattern id
7190 *
7191 * This function loops through request id to pattern id array
7192 * if the slot is available, store the request id and return pattern id
7193 * if entry exists, return the pattern id
7194 *
7195 * Return: 0 on success and errno on failure
7196 */
7197static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
7198 uint32_t request_id,
7199 uint8_t *pattern_id)
7200{
7201 uint32_t i;
7202
7203 mutex_lock(&hdd_ctx->op_ctx.op_lock);
7204 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
7205 {
7206 if (hdd_ctx->op_ctx.op_table[i].request_id == 0)
7207 {
7208 hdd_ctx->op_ctx.op_table[i].request_id = request_id;
7209 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
7210 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7211 return 0;
7212 } else if (hdd_ctx->op_ctx.op_table[i].request_id ==
7213 request_id) {
7214 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
7215 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7216 return 0;
7217 }
7218 }
7219 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7220 return -EINVAL;
7221}
7222
7223/**
7224 * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id
7225 * @hdd_ctx: HDD context
7226 * @request_id: [input] request id
7227 * @pattern_id: [output] pattern id
7228 *
7229 * This function loops through request id to pattern id array
7230 * reset request id to 0 (slot available again) and
7231 * return pattern id
7232 *
7233 * Return: 0 on success and errno on failure
7234 */
7235static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
7236 uint32_t request_id,
7237 uint8_t *pattern_id)
7238{
7239 uint32_t i;
7240
7241 mutex_lock(&hdd_ctx->op_ctx.op_lock);
7242 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
7243 {
7244 if (hdd_ctx->op_ctx.op_table[i].request_id == request_id)
7245 {
7246 hdd_ctx->op_ctx.op_table[i].request_id = 0;
7247 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
7248 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7249 return 0;
7250 }
7251 }
7252 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7253 return -EINVAL;
7254}
7255
7256
7257/*
7258 * define short names for the global vendor params
7259 * used by __wlan_hdd_cfg80211_offloaded_packets()
7260 */
7261#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX
7262#define PARAM_REQUEST_ID \
7263 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID
7264#define PARAM_CONTROL \
7265 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL
7266#define PARAM_IP_PACKET \
7267 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA
7268#define PARAM_SRC_MAC_ADDR \
7269 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR
7270#define PARAM_DST_MAC_ADDR \
7271 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR
7272#define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD
7273
7274/**
7275 * wlan_hdd_add_tx_ptrn() - add tx pattern
7276 * @adapter: adapter pointer
7277 * @hdd_ctx: hdd context
7278 * @tb: nl attributes
7279 *
7280 * This function reads the NL attributes and forms a AddTxPtrn message
7281 * posts it to SME.
7282 *
7283 */
7284static int
7285wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
7286 struct nlattr **tb)
7287{
7288 struct sSirAddPeriodicTxPtrn *add_req;
7289 eHalStatus status;
7290 uint32_t request_id, ret, len;
7291 uint8_t pattern_id = 0;
7292 v_MACADDR_t dst_addr;
7293 uint16_t eth_type = htons(ETH_P_IP);
7294
7295 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
7296 {
7297 hddLog(LOGE, FL("Not in Connected state!"));
7298 return -ENOTSUPP;
7299 }
7300
7301 add_req = vos_mem_malloc(sizeof(*add_req));
7302 if (!add_req)
7303 {
7304 hddLog(LOGE, FL("memory allocation failed"));
7305 return -ENOMEM;
7306 }
7307
7308 /* Parse and fetch request Id */
7309 if (!tb[PARAM_REQUEST_ID])
7310 {
7311 hddLog(LOGE, FL("attr request id failed"));
7312 goto fail;
7313 }
7314
7315 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
7316 hddLog(LOG1, FL("Request Id: %u"), request_id);
7317 if (request_id == 0)
7318 {
7319 hddLog(LOGE, FL("request_id cannot be zero"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05307320 goto fail;
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307321 }
7322
7323 if (!tb[PARAM_PERIOD])
7324 {
7325 hddLog(LOGE, FL("attr period failed"));
7326 goto fail;
7327 }
7328 add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]);
7329 hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs);
7330 if (add_req->usPtrnIntervalMs == 0)
7331 {
7332 hddLog(LOGE, FL("Invalid interval zero, return failure"));
7333 goto fail;
7334 }
7335
7336 if (!tb[PARAM_SRC_MAC_ADDR])
7337 {
7338 hddLog(LOGE, FL("attr source mac address failed"));
7339 goto fail;
7340 }
7341 nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR],
7342 VOS_MAC_ADDR_SIZE);
7343 hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR,
7344 MAC_ADDR_ARRAY(add_req->macAddress));
7345
7346 if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes,
7347 VOS_MAC_ADDR_SIZE))
7348 {
7349 hddLog(LOGE,
7350 FL("input src mac address and connected ap bssid are different"));
7351 goto fail;
7352 }
7353
7354 if (!tb[PARAM_DST_MAC_ADDR])
7355 {
7356 hddLog(LOGE, FL("attr dst mac address failed"));
7357 goto fail;
7358 }
7359 nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE);
7360 hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR,
7361 MAC_ADDR_ARRAY(dst_addr.bytes));
7362
7363 if (!tb[PARAM_IP_PACKET])
7364 {
7365 hddLog(LOGE, FL("attr ip packet failed"));
7366 goto fail;
7367 }
7368 add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]);
7369 hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize);
7370
7371 if (add_req->ucPtrnSize < 0 ||
7372 add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE -
7373 HDD_ETH_HEADER_LEN))
7374 {
7375 hddLog(LOGE, FL("Invalid IP packet len: %d"),
7376 add_req->ucPtrnSize);
7377 goto fail;
7378 }
7379
7380 len = 0;
7381 vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE);
7382 len += VOS_MAC_ADDR_SIZE;
7383 vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress,
7384 VOS_MAC_ADDR_SIZE);
7385 len += VOS_MAC_ADDR_SIZE;
7386 vos_mem_copy(&add_req->ucPattern[len], &eth_type, 2);
7387 len += 2;
7388
7389 /*
7390 * This is the IP packet, add 14 bytes Ethernet (802.3) header
7391 * ------------------------------------------------------------
7392 * | 14 bytes Ethernet (802.3) header | IP header and payload |
7393 * ------------------------------------------------------------
7394 */
7395 vos_mem_copy(&add_req->ucPattern[len],
7396 nla_data(tb[PARAM_IP_PACKET]),
7397 add_req->ucPtrnSize);
7398 add_req->ucPtrnSize += len;
7399
7400 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7401 add_req->ucPattern, add_req->ucPtrnSize);
7402
7403 ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
7404 if (ret)
7405 {
7406 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
7407 goto fail;
7408 }
7409 add_req->ucPtrnId = pattern_id;
7410 hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId);
7411
7412 status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req);
7413 if (!HAL_STATUS_SUCCESS(status))
7414 {
7415 hddLog(LOGE,
7416 FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status);
7417 goto fail;
7418 }
7419
7420 EXIT();
7421 vos_mem_free(add_req);
7422 return 0;
7423
7424fail:
7425 vos_mem_free(add_req);
7426 return -EINVAL;
7427}
7428
7429/**
7430 * wlan_hdd_del_tx_ptrn() - delete tx pattern
7431 * @adapter: adapter pointer
7432 * @hdd_ctx: hdd context
7433 * @tb: nl attributes
7434 *
7435 * This function reads the NL attributes and forms a DelTxPtrn message
7436 * posts it to SME.
7437 *
7438 */
7439static int
7440wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
7441 struct nlattr **tb)
7442{
7443 struct sSirDelPeriodicTxPtrn *del_req;
7444 eHalStatus status;
7445 uint32_t request_id, ret;
7446 uint8_t pattern_id = 0;
7447
7448 /* Parse and fetch request Id */
7449 if (!tb[PARAM_REQUEST_ID])
7450 {
7451 hddLog(LOGE, FL("attr request id failed"));
7452 return -EINVAL;
7453 }
7454 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
7455 if (request_id == 0)
7456 {
7457 hddLog(LOGE, FL("request_id cannot be zero"));
7458 return -EINVAL;
7459 }
7460
7461 ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
7462 if (ret)
7463 {
7464 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
7465 return -EINVAL;
7466 }
7467
7468 del_req = vos_mem_malloc(sizeof(*del_req));
7469 if (!del_req)
7470 {
7471 hddLog(LOGE, FL("memory allocation failed"));
7472 return -ENOMEM;
7473 }
7474
7475 vos_mem_set(del_req, sizeof(*del_req), 0);
7476 vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes,
7477 VOS_MAC_ADDR_SIZE);
7478 hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress));
7479 del_req->ucPatternIdBitmap |= (0x1 << pattern_id);
7480 hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"),
7481 request_id, pattern_id, del_req->ucPatternIdBitmap);
7482
7483 status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req);
7484 if (!HAL_STATUS_SUCCESS(status))
7485 {
7486 hddLog(LOGE,
7487 FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status);
7488 goto fail;
7489 }
7490
7491 EXIT();
7492 vos_mem_free(del_req);
7493 return 0;
7494
7495fail:
7496 vos_mem_free(del_req);
7497 return -EINVAL;
7498}
7499
7500
7501/**
7502 * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets
7503 * @wiphy: Pointer to wireless phy
7504 * @wdev: Pointer to wireless device
7505 * @data: Pointer to data
7506 * @data_len: Data length
7507 *
7508 * Return: 0 on success, negative errno on failure
7509 */
7510static int
7511__wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7512 struct wireless_dev *wdev,
7513 const void *data,
7514 int data_len)
7515{
7516 struct net_device *dev = wdev->netdev;
7517 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7518 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7519 struct nlattr *tb[PARAM_MAX + 1];
7520 uint8_t control;
7521 int ret;
7522 static const struct nla_policy policy[PARAM_MAX + 1] =
7523 {
7524 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
7525 [PARAM_CONTROL] = { .type = NLA_U32 },
7526 [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY,
7527 .len = VOS_MAC_ADDR_SIZE },
7528 [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY,
7529 .len = VOS_MAC_ADDR_SIZE },
7530 [PARAM_PERIOD] = { .type = NLA_U32 },
7531 };
7532
7533 ENTER();
7534
7535 ret = wlan_hdd_validate_context(hdd_ctx);
7536 if (0 != ret)
7537 {
7538 hddLog(LOGE, FL("HDD context is not valid"));
7539 return ret;
7540 }
7541
7542 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
7543 {
7544 hddLog(LOGE,
7545 FL("Periodic Tx Pattern Offload feature is not supported in FW!"));
7546 return -ENOTSUPP;
7547 }
7548
7549 if (nla_parse(tb, PARAM_MAX, data, data_len, policy))
7550 {
7551 hddLog(LOGE, FL("Invalid ATTR"));
7552 return -EINVAL;
7553 }
7554
7555 if (!tb[PARAM_CONTROL])
7556 {
7557 hddLog(LOGE, FL("attr control failed"));
7558 return -EINVAL;
7559 }
7560 control = nla_get_u32(tb[PARAM_CONTROL]);
7561 hddLog(LOG1, FL("Control: %d"), control);
7562
7563 if (control == WLAN_START_OFFLOADED_PACKETS)
7564 return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb);
7565 else if (control == WLAN_STOP_OFFLOADED_PACKETS)
7566 return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb);
7567 else
7568 {
7569 hddLog(LOGE, FL("Invalid control: %d"), control);
7570 return -EINVAL;
7571 }
7572}
7573
7574/*
7575 * done with short names for the global vendor params
7576 * used by __wlan_hdd_cfg80211_offloaded_packets()
7577 */
7578#undef PARAM_MAX
7579#undef PARAM_REQUEST_ID
7580#undef PARAM_CONTROL
7581#undef PARAM_IP_PACKET
7582#undef PARAM_SRC_MAC_ADDR
7583#undef PARAM_DST_MAC_ADDR
7584#undef PARAM_PERIOD
7585
7586/**
7587 * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets
7588 * @wiphy: wiphy structure pointer
7589 * @wdev: Wireless device structure pointer
7590 * @data: Pointer to the data received
7591 * @data_len: Length of @data
7592 *
7593 * Return: 0 on success; errno on failure
7594 */
7595static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7596 struct wireless_dev *wdev,
7597 const void *data,
7598 int data_len)
7599{
7600 int ret = 0;
7601
7602 vos_ssr_protect(__func__);
7603 ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy,
7604 wdev, data, data_len);
7605 vos_ssr_unprotect(__func__);
7606
7607 return ret;
7608}
7609#endif
7610
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307611static const struct
7612nla_policy
7613qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = {
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05307614 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = {
7615 .type = NLA_BINARY,
7616 .len = HDD_MAC_ADDR_LEN},
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307617};
7618
7619/**
7620 * wlan_hdd_cfg80211_get_link_properties() - This function is used to
7621 * get link properties like nss, rate flags and operating frequency for
7622 * the connection with the given peer.
7623 * @wiphy: WIPHY structure pointer
7624 * @wdev: Wireless device structure pointer
7625 * @data: Pointer to the data received
7626 * @data_len: Length of the data received
7627 *
7628 * This function return the above link properties on success.
7629 *
7630 * Return: 0 on success and errno on failure
7631 */
7632static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
7633 struct wireless_dev *wdev,
7634 const void *data,
7635 int data_len)
7636{
7637 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7638 struct net_device *dev = wdev->netdev;
7639 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7640 hdd_station_ctx_t *hdd_sta_ctx;
7641 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1];
7642 uint8_t peer_mac[VOS_MAC_ADDR_SIZE];
7643 uint32_t sta_id;
7644 struct sk_buff *reply_skb;
7645 uint32_t rate_flags = 0;
7646 uint8_t nss;
7647 uint8_t final_rate_flags = 0;
7648 uint32_t freq;
7649 v_CONTEXT_t pVosContext = NULL;
7650 ptSapContext pSapCtx = NULL;
7651
7652 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
7653 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
7654 return -EINVAL;
7655 }
7656
7657 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7658 qca_wlan_vendor_attr_policy)) {
7659 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute"));
7660 return -EINVAL;
7661 }
7662
7663 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
7664 hddLog(VOS_TRACE_LEVEL_ERROR,
7665 FL("Attribute peerMac not provided for mode=%d"),
7666 adapter->device_mode);
7667 return -EINVAL;
7668 }
7669
Ashish Kumar Dhanotiyaddaf0482017-06-23 15:22:42 +05307670 if (nla_len(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) < sizeof(peer_mac)) {
7671 hddLog(VOS_TRACE_LEVEL_ERROR,
7672 FL("Attribute peerMac is invalid=%d"),
7673 adapter->device_mode);
7674 return -EINVAL;
7675 }
7676
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307677 memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
7678 sizeof(peer_mac));
7679 hddLog(VOS_TRACE_LEVEL_INFO,
7680 FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"),
7681 MAC_ADDR_ARRAY(peer_mac), adapter->device_mode);
7682
7683 if (adapter->device_mode == WLAN_HDD_INFRA_STATION ||
7684 adapter->device_mode == WLAN_HDD_P2P_CLIENT) {
7685 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
7686 if ((hdd_sta_ctx->conn_info.connState !=
7687 eConnectionState_Associated) ||
7688 !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac,
7689 VOS_MAC_ADDRESS_LEN)) {
7690 hddLog(VOS_TRACE_LEVEL_ERROR,
7691 FL("Not Associated to mac "MAC_ADDRESS_STR),
7692 MAC_ADDR_ARRAY(peer_mac));
7693 return -EINVAL;
7694 }
7695
7696 nss = 1; //pronto supports only one spatial stream
7697 freq = vos_chan_to_freq(
7698 hdd_sta_ctx->conn_info.operationChannel);
7699 rate_flags = hdd_sta_ctx->conn_info.rate_flags;
7700
7701 } else if (adapter->device_mode == WLAN_HDD_P2P_GO ||
7702 adapter->device_mode == WLAN_HDD_SOFTAP) {
7703
7704 pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext;
7705 pSapCtx = VOS_GET_SAP_CB(pVosContext);
7706 if(pSapCtx == NULL){
7707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7708 FL("psapCtx is NULL"));
7709 return -ENOENT;
7710 }
7711
7712
7713 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
7714 if (pSapCtx->aStaInfo[sta_id].isUsed &&
7715 !vos_is_macaddr_broadcast(
7716 &pSapCtx->aStaInfo[sta_id].macAddrSTA) &&
7717 vos_mem_compare(
7718 &pSapCtx->aStaInfo[sta_id].macAddrSTA,
7719 peer_mac, VOS_MAC_ADDRESS_LEN))
7720 break;
7721 }
7722
7723 if (WLAN_MAX_STA_COUNT == sta_id) {
7724 hddLog(VOS_TRACE_LEVEL_ERROR,
7725 FL("No active peer with mac="MAC_ADDRESS_STR),
7726 MAC_ADDR_ARRAY(peer_mac));
7727 return -EINVAL;
7728 }
7729
7730 nss = 1; //pronto supports only one spatial stream
7731 freq = vos_chan_to_freq(
7732 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel);
7733 rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags;
7734 } else {
7735 hddLog(VOS_TRACE_LEVEL_ERROR,
7736 FL("Not Associated! with mac"MAC_ADDRESS_STR),
7737 MAC_ADDR_ARRAY(peer_mac));
7738 return -EINVAL;
7739 }
7740
7741 if (!(rate_flags & eHAL_TX_RATE_LEGACY)) {
7742 if (rate_flags & eHAL_TX_RATE_VHT80) {
7743 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307744#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
7745 !defined(WITH_BACKPORTS)
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307746 final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307747#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307748 } else if (rate_flags & eHAL_TX_RATE_VHT40) {
7749 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307750#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
7751 !defined(WITH_BACKPORTS)
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307752 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307753#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307754 } else if (rate_flags & eHAL_TX_RATE_VHT20) {
7755 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7756 } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) {
7757 final_rate_flags |= RATE_INFO_FLAGS_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307758#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
7759 !defined(WITH_BACKPORTS)
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307760 if (rate_flags & eHAL_TX_RATE_HT40)
7761 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307762#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307763 }
7764
7765 if (rate_flags & eHAL_TX_RATE_SGI) {
7766 if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS))
7767 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7768 final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI;
7769 }
7770 }
7771
7772 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7773 sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN);
7774
7775 if (NULL == reply_skb) {
7776 hddLog(VOS_TRACE_LEVEL_ERROR,
7777 FL("getLinkProperties: skb alloc failed"));
7778 return -EINVAL;
7779 }
7780
7781 if (nla_put_u8(reply_skb,
7782 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS,
7783 nss) ||
7784 nla_put_u8(reply_skb,
7785 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS,
7786 final_rate_flags) ||
7787 nla_put_u32(reply_skb,
7788 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ,
7789 freq)) {
7790 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed"));
7791 kfree_skb(reply_skb);
7792 return -EINVAL;
7793 }
7794
7795 return cfg80211_vendor_cmd_reply(reply_skb);
7796}
7797
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307798#define BEACON_MISS_THRESH_2_4 \
7799 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24
7800#define BEACON_MISS_THRESH_5_0 \
7801 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307802#define PARAM_WIFICONFIG_MAX QCA_WLAN_VENDOR_ATTR_CONFIG_MAX
7803#define PARAM_MODULATED_DTIM QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM
7804#define PARAM_STATS_AVG_FACTOR QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR
7805#define PARAM_GUARD_TIME QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307806#define PARAM_BCNMISS_PENALTY_PARAM_COUNT \
7807 QCA_WLAN_VENDOR_ATTR_CONFIG_PENALIZE_AFTER_NCONS_BEACON_MISS
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05307808#define PARAM_FORCE_RSN_IE \
7809 QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE
Ashish Kumar Dhanotiyaf59c7762018-04-10 17:54:25 +05307810/*
7811 * hdd_set_qpower() - Process the qpower command and invoke the SME api
7812 * @hdd_ctx: hdd context
7813 * @enable: Value received in the command, 1 for disable and 2 for enable
7814 *
7815 * Return: void
7816 */
7817static void hdd_set_qpower(hdd_context_t *hdd_ctx, uint8_t enable)
7818{
7819 if (!hdd_ctx) {
7820 hddLog(LOGE, "hdd_ctx NULL");
7821 return;
7822 }
7823
7824 sme_set_qpower(hdd_ctx->hHal, enable);
7825}
7826
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307827/**
7828 * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7829 * vendor command
7830 *
7831 * @wiphy: wiphy device pointer
7832 * @wdev: wireless device pointer
7833 * @data: Vendor command data buffer
7834 * @data_len: Buffer length
7835 *
7836 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7837 *
7838 * Return: EOK or other error codes.
7839 */
7840
7841static int __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7842 struct wireless_dev *wdev,
7843 const void *data,
7844 int data_len)
7845{
7846 struct net_device *dev = wdev->netdev;
7847 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7848 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7849 hdd_station_ctx_t *pHddStaCtx;
7850 struct nlattr *tb[PARAM_WIFICONFIG_MAX + 1];
7851 tpSetWifiConfigParams pReq;
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307852 tModifyRoamParamsReqParams modifyRoamParamsReq;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307853 eHalStatus status;
7854 int ret_val;
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307855 uint8_t hb_thresh_val;
Ashish Kumar Dhanotiyaf59c7762018-04-10 17:54:25 +05307856 uint8_t qpower;
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307857
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307858 static const struct nla_policy policy[PARAM_WIFICONFIG_MAX + 1] = {
7859 [PARAM_STATS_AVG_FACTOR] = { .type = NLA_U16 },
7860 [PARAM_MODULATED_DTIM] = { .type = NLA_U32 },
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307861 [PARAM_GUARD_TIME] = { .type = NLA_U32},
7862 [PARAM_BCNMISS_PENALTY_PARAM_COUNT] =
7863 { .type = NLA_U32},
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307864 [BEACON_MISS_THRESH_2_4] = { .type = NLA_U8 },
7865 [BEACON_MISS_THRESH_5_0] = { .type = NLA_U8 },
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05307866 [PARAM_FORCE_RSN_IE] = {.type = NLA_U8 },
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307867 };
7868
7869 ENTER();
7870
7871 if (VOS_FTM_MODE == hdd_get_conparam()) {
7872 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7873 return -EINVAL;
7874 }
7875
7876 ret_val = wlan_hdd_validate_context(pHddCtx);
7877 if (ret_val) {
7878 return ret_val;
7879 }
7880
7881 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7882
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307883 if (nla_parse(tb, PARAM_WIFICONFIG_MAX, data, data_len, policy)) {
7884 hddLog(LOGE, FL("Invalid ATTR"));
7885 return -EINVAL;
7886 }
7887
7888 /* check the Wifi Capability */
7889 if ( (TRUE != pHddCtx->cfg_ini->fEnableWifiConfig) &&
7890 (TRUE != sme_IsFeatureSupportedByFW(WIFI_CONFIG)))
7891 {
7892 hddLog(VOS_TRACE_LEVEL_ERROR,
7893 FL("WIFICONFIG not supported by Firmware"));
7894 return -EINVAL;
7895 }
7896
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307897 if (tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]) {
7898 modifyRoamParamsReq.param = WIFI_CONFIG_SET_BCNMISS_PENALTY_COUNT;
7899 modifyRoamParamsReq.value =
7900 nla_get_u32(tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]);
7901
7902 if (eHAL_STATUS_SUCCESS !=
7903 sme_setBcnMissPenaltyCount(pHddCtx->hHal,&modifyRoamParamsReq))
7904 {
7905 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed", __func__);
7906 ret_val = -EINVAL;
7907 }
7908 return ret_val;
7909 }
7910
7911 /* Moved this down in order to provide provision to set beacon
7912 * miss penalty count irrespective of connection state.
7913 */
7914 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
7915 hddLog(LOGE, FL("Not in Connected state!"));
7916 return -ENOTSUPP;
7917 }
7918
7919 pReq = vos_mem_malloc(sizeof(tSetWifiConfigParams));
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307920
7921 if (!pReq) {
7922 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7923 "%s: Not able to allocate memory for tSetWifiConfigParams",
7924 __func__);
7925 return eHAL_STATUS_E_MALLOC_FAILED;
7926 }
7927
7928 vos_mem_set(pReq, sizeof(tSetWifiConfigParams), 0);
7929
7930 pReq->sessionId = pAdapter->sessionId;
7931 vos_mem_copy( &pReq->bssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
7932
7933 if (tb[PARAM_MODULATED_DTIM]) {
7934 pReq->paramValue = nla_get_u32(
7935 tb[PARAM_MODULATED_DTIM]);
7936 hddLog(LOG1, FL("Modulated DTIM: pReq->paramValue:%d "),
7937 pReq->paramValue);
Arun Khandavalli876886f2015-11-23 11:42:27 +05307938 pHddCtx->cfg_ini->enableDynamicDTIM = pReq->paramValue;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307939 hdd_set_pwrparams(pHddCtx);
7940 if (BMPS == pmcGetPmcState(pHddCtx->hHal)) {
7941 hddLog( LOG1, FL("WifiConfig: Requesting FullPower!"));
7942
7943 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
7944 iw_full_power_cbfn, pAdapter,
7945 eSME_FULL_PWR_NEEDED_BY_HDD);
7946 }
7947 else
7948 {
7949 hddLog( LOG1, FL("WifiConfig Not in BMPS state"));
7950 }
7951 }
7952
7953 if (tb[PARAM_STATS_AVG_FACTOR]) {
7954 pReq->paramType = WIFI_CONFIG_SET_AVG_STATS_FACTOR;
7955 pReq->paramValue = nla_get_u16(
7956 tb[PARAM_STATS_AVG_FACTOR]);
7957 hddLog(LOG1, FL("AVG_STATS_FACTOR pReq->paramType:%d,pReq->paramValue:%d "),
7958 pReq->paramType, pReq->paramValue);
7959 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7960
7961 if (eHAL_STATUS_SUCCESS != status)
7962 {
7963 vos_mem_free(pReq);
7964 pReq = NULL;
7965 ret_val = -EPERM;
7966 return ret_val;
7967 }
7968 }
7969
7970
7971 if (tb[PARAM_GUARD_TIME]) {
7972 pReq->paramType = WIFI_CONFIG_SET_GUARD_TIME;
7973 pReq->paramValue = nla_get_u32(
7974 tb[PARAM_GUARD_TIME]);
7975 hddLog(LOG1, FL("GUARD_TIME pReq->paramType:%d,pReq->paramValue:%d "),
7976 pReq->paramType, pReq->paramValue);
7977 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7978
7979 if (eHAL_STATUS_SUCCESS != status)
7980 {
7981 vos_mem_free(pReq);
7982 pReq = NULL;
7983 ret_val = -EPERM;
7984 return ret_val;
7985 }
7986
7987 }
7988
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307989 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]) {
7990 hb_thresh_val = nla_get_u8(
7991 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]);
7992
7993 hddLog(LOG1, "WLAN set heartbeat threshold for 2.4Ghz %d",
7994 hb_thresh_val);
7995 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7996 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
7997 NULL, eANI_BOOLEAN_FALSE);
7998
7999 status = sme_update_hb_threshold(
8000 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
8001 WNI_CFG_HEART_BEAT_THRESHOLD,
8002 hb_thresh_val, eCSR_BAND_24);
8003 if (eHAL_STATUS_SUCCESS != status) {
8004 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
8005 vos_mem_free(pReq);
8006 pReq = NULL;
8007 return -EPERM;
8008 }
8009 }
8010
8011 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]) {
8012 hb_thresh_val = nla_get_u8(
8013 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]);
8014
8015 hddLog(LOG1, "WLAN set heartbeat threshold for 5Ghz %d",
8016 hb_thresh_val);
8017 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
8018 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
8019 NULL, eANI_BOOLEAN_FALSE);
8020
8021 status = sme_update_hb_threshold(
8022 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
8023 WNI_CFG_HEART_BEAT_THRESHOLD,
8024 hb_thresh_val, eCSR_BAND_5G);
8025 if (eHAL_STATUS_SUCCESS != status) {
8026 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
8027 vos_mem_free(pReq);
8028 pReq = NULL;
8029 return -EPERM;
8030 }
8031 }
8032
Ashish Kumar Dhanotiyaf59c7762018-04-10 17:54:25 +05308033 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER]) {
8034 qpower = nla_get_u8(
8035 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER]);
8036
8037 if(qpower > 1) {
8038 hddLog(LOGE, "Invalid QPOWER value %d", qpower);
8039 vos_mem_free(pReq);
8040 pReq = NULL;
8041 return -EINVAL;
8042 }
8043 /* FW is expacting qpower as 1 for Disable and 2 for enable */
8044 qpower++;
8045 hdd_set_qpower(pHddCtx, qpower);
8046 }
8047
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05308048 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE] &&
8049 pHddCtx->cfg_ini->force_rsne_override) {
8050 uint8_t force_rsne_override;
8051
8052 force_rsne_override =
8053 nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE]);
8054 if (force_rsne_override > 1) {
8055 hddLog(LOGE, "Invalid test_mode %d", force_rsne_override);
8056 ret_val = -EINVAL;
8057 }
8058 pHddCtx->force_rsne_override = force_rsne_override;
8059 hddLog(LOG1, "force_rsne_override - %d",
8060 pHddCtx->force_rsne_override);
8061 }
8062
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05308063 EXIT();
8064 return ret_val;
8065}
8066
8067/**
8068 * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
8069 * vendor command
8070 *
8071 * @wiphy: wiphy device pointer
8072 * @wdev: wireless device pointer
8073 * @data: Vendor command data buffer
8074 * @data_len: Buffer length
8075 *
8076 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
8077 *
8078 * Return: EOK or other error codes.
8079 */
8080static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
8081 struct wireless_dev *wdev,
8082 const void *data,
8083 int data_len)
8084{
8085 int ret;
8086
8087 vos_ssr_protect(__func__);
8088 ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev,
8089 data, data_len);
8090 vos_ssr_unprotect(__func__);
8091
8092 return ret;
8093}
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308094
8095/*
8096 * define short names for the global vendor params
8097 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
8098 */
8099#define STATS_SET_INVALID \
8100 QCA_ATTR_NUD_STATS_SET_INVALID
8101#define STATS_SET_START \
8102 QCA_ATTR_NUD_STATS_SET_START
8103#define STATS_GW_IPV4 \
8104 QCA_ATTR_NUD_STATS_GW_IPV4
8105#define STATS_SET_MAX \
8106 QCA_ATTR_NUD_STATS_SET_MAX
8107
8108const struct nla_policy
8109qca_wlan_vendor_set_nud_stats[STATS_SET_MAX +1] =
8110{
8111 [STATS_SET_START] = {.type = NLA_FLAG },
8112 [STATS_GW_IPV4] = {.type = NLA_U32 },
8113};
8114
8115/**
8116 * hdd_set_nud_stats_cb() - hdd callback api to get status
8117 * @data: pointer to adapter
8118 * @rsp: status
8119 *
8120 * Return: None
8121 */
8122static void hdd_set_nud_stats_cb(void *data, VOS_STATUS rsp)
8123{
8124
8125 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
8126
8127 if (NULL == adapter)
8128 return;
8129
8130 if (VOS_STATUS_SUCCESS == rsp) {
8131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8132 "%s success received STATS_SET_START", __func__);
8133 } else {
8134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8135 "%s STATS_SET_START Failed!!", __func__);
8136 }
8137 return;
8138}
8139
8140/**
8141 * __wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
8142 * @wiphy: pointer to wireless wiphy structure.
8143 * @wdev: pointer to wireless_dev structure.
8144 * @data: pointer to apfind configuration data.
8145 * @data_len: the length in byte of apfind data.
8146 *
8147 * This is called when wlan driver needs to send arp stats to
8148 * firmware.
8149 *
8150 * Return: An error code or 0 on success.
8151 */
8152static int __wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
8153 struct wireless_dev *wdev,
8154 const void *data, int data_len)
8155{
8156 struct nlattr *tb[STATS_SET_MAX + 1];
8157 struct net_device *dev = wdev->netdev;
8158 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8159 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308160 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308161 setArpStatsParams arp_stats_params;
8162 int err = 0;
8163
8164 ENTER();
8165
8166 err = wlan_hdd_validate_context(hdd_ctx);
8167 if (0 != err)
8168 return err;
8169
8170 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
8171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8172 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
8173 return -EINVAL;
8174 }
8175
8176 err = nla_parse(tb, STATS_SET_MAX, data, data_len,
8177 qca_wlan_vendor_set_nud_stats);
8178 if (err)
8179 {
8180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8181 "%s STATS_SET_START ATTR", __func__);
8182 return err;
8183 }
8184
8185 if (tb[STATS_SET_START])
8186 {
8187 if (!tb[STATS_GW_IPV4]) {
8188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8189 "%s STATS_SET_START CMD", __func__);
8190 return -EINVAL;
8191 }
8192 arp_stats_params.flag = true;
8193 arp_stats_params.ip_addr = nla_get_u32(tb[STATS_GW_IPV4]);
8194 } else {
8195 arp_stats_params.flag = false;
8196 }
Anurag Chouhan630c5562017-03-23 14:51:47 +05308197 if (arp_stats_params.flag)
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8199 "%s STATS_SET_START Cleared!!", __func__);
Anurag Chouhan630c5562017-03-23 14:51:47 +05308200 vos_mem_zero(&adapter->hdd_stats.hddArpStats,
8201 sizeof(adapter->hdd_stats.hddArpStats));
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308202
8203 arp_stats_params.pkt_type = 1; // ARP packet type
8204
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308205 if (arp_stats_params.flag) {
8206 hdd_ctx->track_arp_ip = arp_stats_params.ip_addr;
8207 WLANTL_SetARPFWDatapath(pVosContext, true);
8208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8209 "%s Set FW in data path for ARP with tgt IP :%d",
8210 __func__, hdd_ctx->track_arp_ip);
8211 }
8212 else {
8213 WLANTL_SetARPFWDatapath(pVosContext, false);
8214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8215 "%s Remove FW from data path", __func__);
8216 }
8217
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308218 arp_stats_params.rsp_cb_fn = hdd_set_nud_stats_cb;
8219 arp_stats_params.data_ctx = adapter;
8220
8221 if (eHAL_STATUS_SUCCESS !=
8222 sme_set_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
8223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8224 "%s STATS_SET_START CMD Failed!!", __func__);
8225 return -EINVAL;
8226 }
8227
8228 EXIT();
8229
8230 return err;
8231}
8232
8233/**
8234 * wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
8235 * @wiphy: pointer to wireless wiphy structure.
8236 * @wdev: pointer to wireless_dev structure.
8237 * @data: pointer to apfind configuration data.
8238 * @data_len: the length in byte of apfind data.
8239 *
8240 * This is called when wlan driver needs to send arp stats to
8241 * firmware.
8242 *
8243 * Return: An error code or 0 on success.
8244 */
8245static int wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
8246 struct wireless_dev *wdev,
8247 const void *data, int data_len)
8248{
8249 int ret;
8250
8251 vos_ssr_protect(__func__);
8252 ret = __wlan_hdd_cfg80211_set_nud_stats(wiphy, wdev, data, data_len);
8253 vos_ssr_unprotect(__func__);
8254
8255 return ret;
8256}
8257#undef STATS_SET_INVALID
8258#undef STATS_SET_START
8259#undef STATS_GW_IPV4
8260#undef STATS_SET_MAX
8261
8262/*
8263 * define short names for the global vendor params
8264 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
8265 */
8266#define STATS_GET_INVALID \
8267 QCA_ATTR_NUD_STATS_SET_INVALID
8268#define COUNT_FROM_NETDEV \
8269 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
8270#define COUNT_TO_LOWER_MAC \
8271 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
8272#define RX_COUNT_BY_LOWER_MAC \
8273 QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
8274#define COUNT_TX_SUCCESS \
8275 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
8276#define RSP_RX_COUNT_BY_LOWER_MAC \
8277 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
8278#define RSP_RX_COUNT_BY_UPPER_MAC \
8279 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
8280#define RSP_COUNT_TO_NETDEV \
8281 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
8282#define RSP_COUNT_OUT_OF_ORDER_DROP \
8283 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
8284#define AP_LINK_ACTIVE \
8285 QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
8286#define AP_LINK_DAD \
8287 QCA_ATTR_NUD_STATS_AP_LINK_DAD
8288#define STATS_GET_MAX \
8289 QCA_ATTR_NUD_STATS_GET_MAX
8290
8291const struct nla_policy
8292qca_wlan_vendor_get_nud_stats[STATS_GET_MAX +1] =
8293{
8294 [COUNT_FROM_NETDEV] = {.type = NLA_U16 },
8295 [COUNT_TO_LOWER_MAC] = {.type = NLA_U16 },
8296 [RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
8297 [COUNT_TX_SUCCESS] = {.type = NLA_U16 },
8298 [RSP_RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
8299 [RSP_RX_COUNT_BY_UPPER_MAC] = {.type = NLA_U16 },
8300 [RSP_COUNT_TO_NETDEV] = {.type = NLA_U16 },
8301 [RSP_COUNT_OUT_OF_ORDER_DROP] = {.type = NLA_U16 },
8302 [AP_LINK_ACTIVE] = {.type = NLA_FLAG },
8303 [AP_LINK_DAD] = {.type = NLA_FLAG },
8304};
8305
8306static void hdd_get_nud_stats_cb(void *data, rsp_stats *rsp)
8307{
8308
8309 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
Hanumanth Reddy Pothula8f528c72018-02-26 16:49:25 +05308310 hdd_context_t *hdd_ctx;
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308311 struct hdd_nud_stats_context *context;
8312 int status;
8313
8314 ENTER();
8315
8316 if (NULL == adapter)
8317 return;
8318
Hanumanth Reddy Pothula8f528c72018-02-26 16:49:25 +05308319 if (!rsp) {
8320 hddLog(LOGE, FL("data is null"));
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308321 return;
8322 }
8323
Hanumanth Reddy Pothula8f528c72018-02-26 16:49:25 +05308324 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
8325 status = wlan_hdd_validate_context(hdd_ctx);
8326 if (0 != status) {
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308327 return;
8328 }
8329
8330 adapter->hdd_stats.hddArpStats.tx_fw_cnt = rsp->tx_fw_cnt;
8331 adapter->hdd_stats.hddArpStats.rx_fw_cnt = rsp->rx_fw_cnt;
8332 adapter->hdd_stats.hddArpStats.tx_ack_cnt = rsp->tx_ack_cnt;
8333 adapter->dad |= rsp->dad;
8334
8335 spin_lock(&hdd_context_lock);
8336 context = &hdd_ctx->nud_stats_context;
8337 complete(&context->response_event);
8338 spin_unlock(&hdd_context_lock);
8339
8340 return;
8341}
8342static int __wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
8343 struct wireless_dev *wdev,
8344 const void *data, int data_len)
8345{
8346 int err = 0;
8347 unsigned long rc;
8348 struct hdd_nud_stats_context *context;
8349 struct net_device *dev = wdev->netdev;
8350 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8351 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
8352 getArpStatsParams arp_stats_params;
8353 struct sk_buff *skb;
8354
8355 ENTER();
8356
8357 err = wlan_hdd_validate_context(hdd_ctx);
8358 if (0 != err)
8359 return err;
8360
8361 arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE;
8362 arp_stats_params.get_rsp_cb_fn = hdd_get_nud_stats_cb;
8363 arp_stats_params.data_ctx = adapter;
8364
8365 spin_lock(&hdd_context_lock);
8366 context = &hdd_ctx->nud_stats_context;
8367 INIT_COMPLETION(context->response_event);
8368 spin_unlock(&hdd_context_lock);
8369
8370 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
8371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8372 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
8373 return -EINVAL;
8374 }
8375
8376 if (eHAL_STATUS_SUCCESS !=
8377 sme_get_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
8378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8379 "%s STATS_SET_START CMD Failed!!", __func__);
8380 return -EINVAL;
8381 }
8382
8383 rc = wait_for_completion_timeout(&context->response_event,
8384 msecs_to_jiffies(WLAN_WAIT_TIME_NUD_STATS));
8385 if (!rc)
8386 {
8387 hddLog(LOGE,
8388 FL("Target response timed out request "));
8389 return -ETIMEDOUT;
8390 }
8391
8392 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
8393 WLAN_NUD_STATS_LEN);
8394 if (!skb)
8395 {
8396 hddLog(VOS_TRACE_LEVEL_ERROR,
8397 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
8398 __func__);
8399 return -ENOMEM;
8400 }
8401
8402 if (nla_put_u16(skb, COUNT_FROM_NETDEV,
8403 adapter->hdd_stats.hddArpStats.txCount) ||
8404 nla_put_u16(skb, COUNT_TO_LOWER_MAC,
8405 adapter->hdd_stats.hddArpStats.tx_host_fw_sent) ||
8406 nla_put_u16(skb, RX_COUNT_BY_LOWER_MAC,
8407 adapter->hdd_stats.hddArpStats.tx_fw_cnt) ||
8408 nla_put_u16(skb, COUNT_TX_SUCCESS,
8409 adapter->hdd_stats.hddArpStats.tx_ack_cnt) ||
8410 nla_put_u16(skb, RSP_RX_COUNT_BY_LOWER_MAC,
8411 adapter->hdd_stats.hddArpStats.rx_fw_cnt) ||
8412 nla_put_u16(skb, RSP_RX_COUNT_BY_UPPER_MAC,
8413 adapter->hdd_stats.hddArpStats.rxCount) ||
8414 nla_put_u16(skb, RSP_COUNT_TO_NETDEV,
8415 adapter->hdd_stats.hddArpStats.rxDelivered) ||
8416 nla_put_u16(skb, RSP_COUNT_OUT_OF_ORDER_DROP,
8417 adapter->hdd_stats.hddArpStats.rx_host_drop_reorder)) {
8418 hddLog(LOGE, FL("nla put fail"));
8419 kfree_skb(skb);
8420 return -EINVAL;
8421 }
8422 if (adapter->con_status)
8423 nla_put_flag(skb, AP_LINK_ACTIVE);
8424 if (adapter->dad)
8425 nla_put_flag(skb, AP_LINK_DAD);
8426
8427 cfg80211_vendor_cmd_reply(skb);
8428 return err;
8429}
8430
8431static int wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
8432 struct wireless_dev *wdev,
8433 const void *data, int data_len)
8434{
8435 int ret;
8436
8437 vos_ssr_protect(__func__);
8438 ret = __wlan_hdd_cfg80211_get_nud_stats(wiphy, wdev, data, data_len);
8439 vos_ssr_unprotect(__func__);
8440
8441 return ret;
8442}
8443
8444#undef QCA_ATTR_NUD_STATS_SET_INVALID
8445#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
8446#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
8447#undef QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
8448#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
8449#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
8450#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
8451#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
8452#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
8453#undef QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
8454#undef QCA_ATTR_NUD_STATS_GET_MAX
8455
8456
8457
Kapil Guptaee33bf12016-12-20 18:27:37 +05308458#ifdef WLAN_FEATURE_APFIND
8459/**
8460 * __wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
8461 * @wiphy: pointer to wireless wiphy structure.
8462 * @wdev: pointer to wireless_dev structure.
8463 * @data: pointer to apfind configuration data.
8464 * @data_len: the length in byte of apfind data.
8465 *
8466 * This is called when wlan driver needs to send APFIND configurations to
8467 * firmware.
8468 *
8469 * Return: An error code or 0 on success.
8470 */
8471static int __wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
8472 struct wireless_dev *wdev,
8473 const void *data, int data_len)
8474{
8475 struct sme_ap_find_request_req apfind_req;
8476 VOS_STATUS status;
8477 int ret_val;
8478 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
8479
8480 ENTER();
8481
8482 ret_val = wlan_hdd_validate_context(hdd_ctx);
8483 if (ret_val)
8484 return ret_val;
8485
8486 if (VOS_FTM_MODE == hdd_get_conparam()) {
8487 hddLog(LOGE, FL("Command not allowed in FTM mode"));
8488 return -EPERM;
8489 }
8490
8491 apfind_req.request_data_len = data_len;
8492 apfind_req.request_data = data;
8493
8494 status = sme_apfind_set_cmd(&apfind_req);
8495 if (VOS_STATUS_SUCCESS != status) {
8496 ret_val = -EIO;
8497 }
8498 return ret_val;
8499}
8500
8501/**
8502 * wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
8503 * @wiphy: pointer to wireless wiphy structure.
8504 * @wdev: pointer to wireless_dev structure.
8505 * @data: pointer to apfind configuration data.
8506 * @data_len: the length in byte of apfind data.
8507 *
8508 * This is called when wlan driver needs to send APFIND configurations to
8509 * firmware.
8510 *
8511 * Return: An error code or 0 on success.
8512 */
8513static int wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
8514 struct wireless_dev *wdev,
8515 const void *data, int data_len)
8516{
8517 int ret;
8518
8519 vos_ssr_protect(__func__);
8520 ret = __wlan_hdd_cfg80211_apfind_cmd(wiphy, wdev, data, data_len);
8521 vos_ssr_unprotect(__func__);
8522
8523 return ret;
8524}
8525#endif /* WLAN_FEATURE_APFIND */
Hanumanth Reddy Pothula49c3f902018-02-16 16:01:13 +05308526
8527/**
8528 * __wlan_hdd_cfg80211_get_logger_supp_feature() - Get the wifi logger features
8529 * @wiphy: pointer to wireless wiphy structure.
8530 * @wdev: pointer to wireless_dev structure.
8531 * @data: Pointer to the data to be passed via vendor interface
8532 * @data_len:Length of the data to be passed
8533 *
8534 * This is called by userspace to know the supported logger features
8535 *
8536 * Return: Return the Success or Failure code.
8537 */
8538static int
8539__wlan_hdd_cfg80211_get_logger_supp_feature(struct wiphy *wiphy,
8540 struct wireless_dev *wdev,
8541 const void *data, int data_len)
8542{
8543 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
8544 int status;
8545 uint32_t features;
8546 struct sk_buff *reply_skb = NULL;
8547
8548 if (VOS_FTM_MODE == hdd_get_conparam()) {
8549 hddLog(LOGE, FL("Command not allowed in FTM mode"));
8550 return -EINVAL;
8551 }
8552
8553 status = wlan_hdd_validate_context(hdd_ctx);
8554 if (0 != status)
8555 return -EINVAL;
8556
8557 features = 0;
8558
8559 if (hdd_is_memdump_supported())
8560 features |= WIFI_LOGGER_MEMORY_DUMP_SUPPORTED;
8561
Hanumanth Reddy Pothula49c3f902018-02-16 16:01:13 +05308562 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
8563 sizeof(uint32_t) + NLA_HDRLEN + NLMSG_HDRLEN);
8564 if (!reply_skb) {
8565 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
8566 return -ENOMEM;
8567 }
8568
8569 hddLog(LOG1, FL("Supported logger features: 0x%0x"), features);
8570 if (nla_put_u32(reply_skb, QCA_WLAN_VENDOR_ATTR_LOGGER_SUPPORTED,
8571 features)) {
8572 hddLog(LOGE, FL("nla put fail"));
8573 kfree_skb(reply_skb);
8574 return -EINVAL;
8575 }
8576
8577 return cfg80211_vendor_cmd_reply(reply_skb);
8578}
8579
8580/**
8581 * wlan_hdd_cfg80211_get_logger_supp_feature() - Get the wifi logger features
8582 * @wiphy: pointer to wireless wiphy structure.
8583 * @wdev: pointer to wireless_dev structure.
8584 * @data: Pointer to the data to be passed via vendor interface
8585 * @data_len:Length of the data to be passed
8586 *
8587 * This is called by userspace to know the supported logger features
8588 *
8589 * Return: Return the Success or Failure code.
8590 */
8591static int
8592wlan_hdd_cfg80211_get_logger_supp_feature(struct wiphy *wiphy,
8593 struct wireless_dev *wdev,
8594 const void *data, int data_len)
8595{
8596 int ret;
8597
8598 vos_ssr_protect(__func__);
8599 ret = __wlan_hdd_cfg80211_get_logger_supp_feature(wiphy, wdev,
8600 data, data_len);
8601 vos_ssr_unprotect(__func__);
8602
8603 return ret;
8604}
8605
Sunil Duttc69bccb2014-05-26 21:30:20 +05308606const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
8607{
Mukul Sharma2a271632014-10-13 14:59:01 +05308608 {
8609 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8610 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
8611 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8612 WIPHY_VENDOR_CMD_NEED_NETDEV |
8613 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308614 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05308615 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05308616
8617 {
8618 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8619 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
8620 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8621 WIPHY_VENDOR_CMD_NEED_NETDEV |
8622 WIPHY_VENDOR_CMD_NEED_RUNNING,
8623 .doit = wlan_hdd_cfg80211_nan_request
8624 },
8625
Sunil Duttc69bccb2014-05-26 21:30:20 +05308626#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8627 {
8628 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8629 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
8630 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8631 WIPHY_VENDOR_CMD_NEED_NETDEV |
8632 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308633 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05308634 },
8635
8636 {
8637 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8638 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
8639 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8640 WIPHY_VENDOR_CMD_NEED_NETDEV |
8641 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308642 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05308643 },
8644
8645 {
8646 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8647 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
8648 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8649 WIPHY_VENDOR_CMD_NEED_NETDEV |
8650 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308651 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05308652 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308653#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05308654#ifdef WLAN_FEATURE_EXTSCAN
8655 {
8656 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8657 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
8658 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8659 WIPHY_VENDOR_CMD_NEED_NETDEV |
8660 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308661 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05308662 },
8663 {
8664 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8665 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
8666 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8667 WIPHY_VENDOR_CMD_NEED_NETDEV |
8668 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308669 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05308670 },
8671 {
8672 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8673 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
8674 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8675 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308676 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05308677 },
8678 {
8679 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8680 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
8681 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8682 WIPHY_VENDOR_CMD_NEED_NETDEV |
8683 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308684 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05308685 },
8686 {
8687 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8688 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
8689 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8690 WIPHY_VENDOR_CMD_NEED_NETDEV |
8691 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308692 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05308693 },
8694 {
8695 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8696 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
8697 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8698 WIPHY_VENDOR_CMD_NEED_NETDEV |
8699 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308700 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05308701 },
8702 {
8703 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8704 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
8705 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8706 WIPHY_VENDOR_CMD_NEED_NETDEV |
8707 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308708 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05308709 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05308710#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05308711/*EXT TDLS*/
8712 {
8713 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8714 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
8715 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8716 WIPHY_VENDOR_CMD_NEED_NETDEV |
8717 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308718 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05308719 },
8720 {
8721 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8722 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
8723 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8724 WIPHY_VENDOR_CMD_NEED_NETDEV |
8725 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308726 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05308727 },
8728 {
8729 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8730 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
8731 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8732 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308733 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05308734 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05308735 {
8736 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8737 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
8738 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8739 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308740 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05308741 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05308742 {
8743 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8744 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
8745 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8746 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308747 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05308748 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05308749 {
8750 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8751 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
8752 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8753 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308754 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05308755 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05308756 {
8757 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8758 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
8759 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8760 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308761 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05308762 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05308763 {
8764 .info.vendor_id = QCA_NL80211_VENDOR_ID,
c_manjeecfd1efb2015-09-25 19:32:34 +05308765 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP,
8766 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8767 WIPHY_VENDOR_CMD_NEED_NETDEV |
8768 WIPHY_VENDOR_CMD_NEED_RUNNING,
8769 .doit = wlan_hdd_cfg80211_get_fw_mem_dump
8770 },
8771 {
8772 .info.vendor_id = QCA_NL80211_VENDOR_ID,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05308773 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
8774 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8775 WIPHY_VENDOR_CMD_NEED_NETDEV |
8776 WIPHY_VENDOR_CMD_NEED_RUNNING,
8777 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05308778 },
8779 {
8780 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8781 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
8782 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8783 WIPHY_VENDOR_CMD_NEED_NETDEV,
8784 .doit = wlan_hdd_cfg80211_wifi_logger_start
8785 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05308786 {
8787 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8788 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
8789 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8790 WIPHY_VENDOR_CMD_NEED_NETDEV|
8791 WIPHY_VENDOR_CMD_NEED_RUNNING,
8792 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05308793 },
8794 {
8795 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8796 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
8797 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8798 WIPHY_VENDOR_CMD_NEED_NETDEV |
8799 WIPHY_VENDOR_CMD_NEED_RUNNING,
8800 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05308801 },
8802 {
8803 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8804 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
8805 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8806 WIPHY_VENDOR_CMD_NEED_NETDEV |
8807 WIPHY_VENDOR_CMD_NEED_RUNNING,
8808 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05308809 },
8810#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
8811 {
8812 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8813 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
8814 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8815 WIPHY_VENDOR_CMD_NEED_NETDEV |
8816 WIPHY_VENDOR_CMD_NEED_RUNNING,
8817 .doit = wlan_hdd_cfg80211_offloaded_packets
Deepthi Gowriae6a1662015-10-12 12:59:37 +05308818 },
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05308819#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05308820 {
8821 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8822 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
8823 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8824 WIPHY_VENDOR_CMD_NEED_NETDEV |
8825 WIPHY_VENDOR_CMD_NEED_RUNNING,
8826 .doit = wlan_hdd_cfg80211_get_link_properties
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05308827 },
8828 {
8829 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8830 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION,
8831 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8832 WIPHY_VENDOR_CMD_NEED_NETDEV |
8833 WIPHY_VENDOR_CMD_NEED_RUNNING,
8834 .doit = wlan_hdd_cfg80211_wifi_configuration_set
Kapil Guptaee33bf12016-12-20 18:27:37 +05308835 },
8836#ifdef WLAN_FEATURE_APFIND
8837 {
8838 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8839 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_APFIND,
8840 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8841 WIPHY_VENDOR_CMD_NEED_NETDEV,
8842 .doit = wlan_hdd_cfg80211_apfind_cmd
8843 },
8844#endif /* WLAN_FEATURE_APFIND */
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308845 {
8846 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8847 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_SET,
8848 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8849 WIPHY_VENDOR_CMD_NEED_NETDEV |
8850 WIPHY_VENDOR_CMD_NEED_RUNNING,
8851 .doit = wlan_hdd_cfg80211_set_nud_stats
8852 },
8853 {
8854 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8855 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
8856 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8857 WIPHY_VENDOR_CMD_NEED_NETDEV |
8858 WIPHY_VENDOR_CMD_NEED_RUNNING,
8859 .doit = wlan_hdd_cfg80211_get_nud_stats
8860 },
Anurag Chouhanfcd20172017-07-19 17:25:19 +05308861 {
8862 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8863 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_STATION,
8864 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8865 WIPHY_VENDOR_CMD_NEED_NETDEV |
8866 WIPHY_VENDOR_CMD_NEED_RUNNING,
8867 .doit = hdd_cfg80211_get_station_cmd
8868 },
Hanumanth Reddy Pothula49c3f902018-02-16 16:01:13 +05308869 {
8870 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8871 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_LOGGER_FEATURE_SET,
8872 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
Hanumanth Reddy Pothula07c95582018-05-23 12:41:22 +05308873 WIPHY_VENDOR_CMD_NEED_NETDEV,
Hanumanth Reddy Pothula49c3f902018-02-16 16:01:13 +05308874 .doit = wlan_hdd_cfg80211_get_logger_supp_feature
8875 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308876};
8877
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008878/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05308879static const
8880struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008881{
8882#ifdef FEATURE_WLAN_CH_AVOID
8883 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05308884 .vendor_id = QCA_NL80211_VENDOR_ID,
8885 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008886 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308887#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
8888#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8889 {
8890 /* Index = 1*/
8891 .vendor_id = QCA_NL80211_VENDOR_ID,
8892 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
8893 },
8894 {
8895 /* Index = 2*/
8896 .vendor_id = QCA_NL80211_VENDOR_ID,
8897 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
8898 },
8899 {
8900 /* Index = 3*/
8901 .vendor_id = QCA_NL80211_VENDOR_ID,
8902 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
8903 },
8904 {
8905 /* Index = 4*/
8906 .vendor_id = QCA_NL80211_VENDOR_ID,
8907 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
8908 },
8909 {
8910 /* Index = 5*/
8911 .vendor_id = QCA_NL80211_VENDOR_ID,
8912 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
8913 },
8914 {
8915 /* Index = 6*/
8916 .vendor_id = QCA_NL80211_VENDOR_ID,
8917 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
8918 },
8919#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05308920#ifdef WLAN_FEATURE_EXTSCAN
8921 {
8922 .vendor_id = QCA_NL80211_VENDOR_ID,
8923 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
8924 },
8925 {
8926 .vendor_id = QCA_NL80211_VENDOR_ID,
8927 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
8928 },
8929 {
8930 .vendor_id = QCA_NL80211_VENDOR_ID,
8931 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
8932 },
8933 {
8934 .vendor_id = QCA_NL80211_VENDOR_ID,
8935 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
8936 },
8937 {
8938 .vendor_id = QCA_NL80211_VENDOR_ID,
8939 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
8940 },
8941 {
8942 .vendor_id = QCA_NL80211_VENDOR_ID,
8943 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
8944 },
8945 {
8946 .vendor_id = QCA_NL80211_VENDOR_ID,
8947 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
8948 },
8949 {
8950 .vendor_id = QCA_NL80211_VENDOR_ID,
8951 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
8952 },
8953 {
8954 .vendor_id = QCA_NL80211_VENDOR_ID,
8955 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
8956 },
8957 {
8958 .vendor_id = QCA_NL80211_VENDOR_ID,
8959 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
8960 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05308961#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05308962/*EXT TDLS*/
8963 {
8964 .vendor_id = QCA_NL80211_VENDOR_ID,
8965 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
8966 },
c_manjeecfd1efb2015-09-25 19:32:34 +05308967 [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = {
8968 .vendor_id = QCA_NL80211_VENDOR_ID,
8969 .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP
8970 },
8971
Srinivas Dasari030bad32015-02-18 23:23:54 +05308972
Srinivas Dasaribd1cf642017-01-23 14:54:41 +05308973 [QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX] = {
Srinivas Dasari030bad32015-02-18 23:23:54 +05308974 .vendor_id = QCA_NL80211_VENDOR_ID,
8975 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
8976 },
8977
Sushant Kaushik084f6592015-09-10 13:11:56 +05308978 {
8979 .vendor_id = QCA_NL80211_VENDOR_ID,
8980 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05308981 },
8982 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
8983 .vendor_id = QCA_NL80211_VENDOR_ID,
8984 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
8985 },
Padma, Santhosh Kumar7bbc7d92015-12-08 20:23:19 +05308986 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = {
8987 .vendor_id = QCA_NL80211_VENDOR_ID,
8988 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST
8989 },
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308990 [QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET_INDEX] = {
8991 .vendor_id = QCA_NL80211_VENDOR_ID,
8992 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
8993 },
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +05308994 [QCA_NL80211_VENDOR_SUBCMD_HANG_REASON_INDEX] = {
8995 .vendor_id = QCA_NL80211_VENDOR_ID,
8996 .subcmd = QCA_NL80211_VENDOR_SUBCMD_HANG,
8997 },
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +05308998 [QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES_INDEX] = {
8999 .vendor_id = QCA_NL80211_VENDOR_ID,
9000 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
9001 },
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08009002};
9003
Jeff Johnson295189b2012-06-20 16:38:30 -07009004/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309005 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309006 * This function is called by hdd_wlan_startup()
9007 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309008 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07009009 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309010struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07009011{
9012 struct wiphy *wiphy;
9013 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309014 /*
9015 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07009016 */
9017 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
9018
9019 if (!wiphy)
9020 {
9021 /* Print error and jump into err label and free the memory */
9022 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
9023 return NULL;
9024 }
9025
Sunil Duttc69bccb2014-05-26 21:30:20 +05309026
Jeff Johnson295189b2012-06-20 16:38:30 -07009027 return wiphy;
9028}
9029
Anurag Chouhan343af7e2016-12-16 13:11:19 +05309030#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,4,0)) || \
9031 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
9032/**
9033 * hdd_config_sched_scan_plans_to_wiphy() - configure sched scan plans to wiphy
9034 * @wiphy: pointer to wiphy
9035 * @config: pointer to config
9036 *
9037 * Return: None
9038 */
9039static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
9040 hdd_config_t *config)
9041{
9042 wiphy->max_sched_scan_plans = MAX_SCHED_SCAN_PLANS;
9043 if (config->max_sched_scan_plan_interval)
9044 wiphy->max_sched_scan_plan_interval =
9045 config->max_sched_scan_plan_interval;
9046 if (config->max_sched_scan_plan_iterations)
9047 wiphy->max_sched_scan_plan_iterations =
9048 config->max_sched_scan_plan_iterations;
9049}
9050#else
9051static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
9052 hdd_config_t *config)
9053{
9054}
9055#endif
9056
Jeff Johnson295189b2012-06-20 16:38:30 -07009057/*
9058 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309059 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07009060 * private ioctl to change the band value
9061 */
9062int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
9063{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309064 int i, j;
9065 eNVChannelEnabledType channelEnabledState;
9066
Jeff Johnsone7245742012-09-05 17:12:55 -07009067 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309068
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309069 for (i = 0; i < HDD_NUM_NL80211_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07009070 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309071
9072 if (NULL == wiphy->bands[i])
9073 {
9074 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
9075 __func__, i);
9076 continue;
9077 }
9078
9079 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9080 {
9081 struct ieee80211_supported_band *band = wiphy->bands[i];
9082
9083 channelEnabledState = vos_nv_getChannelEnabledState(
9084 band->channels[j].hw_value);
9085
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309086 if (HDD_NL80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309087 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309088 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309089 continue;
9090 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309091 else if (HDD_NL80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309092 {
9093 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
9094 continue;
9095 }
9096
9097 if (NV_CHANNEL_DISABLE == channelEnabledState ||
9098 NV_CHANNEL_INVALID == channelEnabledState)
9099 {
9100 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
9101 }
9102 else if (NV_CHANNEL_DFS == channelEnabledState)
9103 {
9104 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
9105 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
9106 }
9107 else
9108 {
9109 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
9110 |IEEE80211_CHAN_RADAR);
9111 }
9112 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 }
9114 return 0;
9115}
Abhishek Singh2f3c4752018-04-11 14:58:53 +05309116
9117/**
9118 * hdd_add_channel_switch_support()- Adds Channel Switch flag if supported
9119 * @wiphy: Pointer to the wiphy.
9120 *
9121 * This Function adds Channel Switch support flag, if channel switch is
9122 * supported by kernel.
9123 * Return: void.
9124 */
9125#ifdef CHANNEL_SWITCH_SUPPORTED
9126static inline
9127void hdd_add_channel_switch_support(struct wiphy *wiphy)
9128{
9129 wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
9130 wiphy->max_num_csa_counters = WLAN_HDD_MAX_NUM_CSA_COUNTERS;
9131}
9132#else
9133static inline
9134void hdd_add_channel_switch_support(struct wiphy *wiphy)
9135{
9136}
9137#endif
9138
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05309139#if defined(CFG80211_SCAN_RANDOM_MAC_ADDR) || \
9140 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
9141void wlan_hdd_cfg80211_scan_randomization_init(struct wiphy *wiphy)
9142{
9143 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
9144 hdd_config_t *config = hdd_ctx->cfg_ini;
9145
9146 if (config->enableMacSpoofing != MAC_ADDR_SPOOFING_FW_HOST_ENABLE)
9147 return;
9148
9149 wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
9150}
9151#endif
9152
Abhinav Kumar118efd02019-08-07 16:41:07 +05309153#if defined(WLAN_FEATURE_SAE) && \
9154 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
Abhinav Kumar97821072019-08-02 14:29:48 +05309155/**
9156 * wlan_hdd_cfg80211_set_wiphy_sae_feature() - Indicates support of SAE feature
9157 * @wiphy: Pointer to wiphy
9158 * @config: pointer to config
9159 *
9160 * This function is used to indicate the support of SAE
9161 *
9162 * Return: None
9163 */
9164static
9165void wlan_hdd_cfg80211_set_wiphy_sae_feature(struct wiphy *wiphy,
9166 hdd_config_t *config)
9167{
9168 if (config->is_sae_enabled)
9169 wiphy->features |= NL80211_FEATURE_SAE;
9170}
9171#else
9172static
9173void wlan_hdd_cfg80211_set_wiphy_sae_feature(struct wiphy *wiphy,
9174 hdd_config_t *config)
9175{
9176}
9177#endif
9178
Jeff Johnson295189b2012-06-20 16:38:30 -07009179/*
9180 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309181 * This function is called by hdd_wlan_startup()
9182 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 * This function is used to initialize and register wiphy structure.
9184 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309185int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009186 struct wiphy *wiphy,
9187 hdd_config_t *pCfg
9188 )
9189{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309190 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05309191 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9192
Jeff Johnsone7245742012-09-05 17:12:55 -07009193 ENTER();
9194
Jeff Johnson295189b2012-06-20 16:38:30 -07009195 /* Now bind the underlying wlan device with wiphy */
9196 set_wiphy_dev(wiphy, dev);
9197
9198 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07009199
Kiet Lam6c583332013-10-14 05:37:09 +05309200#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07009201 /* the flag for the other case would be initialzed in
9202 vos_init_wiphy_from_nv_bin */
Manjeet Singh9e19de62016-08-18 18:26:41 +05309203#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
9204 wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
9205#else
Amar Singhal0a402232013-10-11 20:57:16 -07009206 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05309207#endif
Manjeet Singh9e19de62016-08-18 18:26:41 +05309208#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07009209
Amar Singhalfddc28c2013-09-05 13:03:40 -07009210 /* This will disable updating of NL channels from passive to
9211 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05309212#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
9213 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
9214#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07009215 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05309216#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07009217
Nachiket Kukade5b2e7332018-04-06 14:40:22 +05309218#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) || defined(WITH_BACKPORTS)
9219 wiphy->wowlan = &wowlan_support_cfg80211_init;
9220#else
Nachiket Kukade1e1b90e2018-05-10 15:26:13 +05309221 wiphy->wowlan.flags = WIPHY_WOWLAN_ANY |
9222 WIPHY_WOWLAN_MAGIC_PKT;
Nachiket Kukade5b2e7332018-04-06 14:40:22 +05309223 wiphy->wowlan.n_patterns = WOWL_MAX_PTRNS_ALLOWED;
9224 wiphy->wowlan.pattern_min_len = 1;
9225 wiphy->wowlan.pattern_max_len = WOWL_PTRN_MAX_SIZE;
9226#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07009227
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009228#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07009229 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
9230 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
9231 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07009232 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05309233#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Rajeev Kumar Sirasanagandla0d6dd752016-08-17 15:01:39 +05309234 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05309235#else
9236 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
9237#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009238#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07009239
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009240#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07009241 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08009242#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07009243 || pCfg->isFastRoamIniFeatureEnabled
9244#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009245#ifdef FEATURE_WLAN_ESE
9246 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07009247#endif
9248 )
9249 {
9250 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
9251 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08009252#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009253#ifdef FEATURE_WLAN_TDLS
9254 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
9255 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
9256#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309257#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05309258 if (pCfg->configPNOScanSupport)
9259 {
9260 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
9261 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
9262 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
9263 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
9264 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309265#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009266
Abhishek Singh10d85972015-04-17 10:27:23 +05309267#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
9268 wiphy->features |= NL80211_FEATURE_HT_IBSS;
9269#endif
9270
Amar Singhalfddc28c2013-09-05 13:03:40 -07009271#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07009272 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
9273 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07009274 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07009275 driver need to determine what to do with both
9276 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07009277
9278 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07009279#else
9280 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07009281#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009282
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309283 wiphy->max_scan_ssids = MAX_SCAN_SSID;
9284
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05309285 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07009286
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309287 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
9288
Jeff Johnson295189b2012-06-20 16:38:30 -07009289 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05309290 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
9291 | BIT(NL80211_IFTYPE_ADHOC)
9292 | BIT(NL80211_IFTYPE_P2P_CLIENT)
9293 | BIT(NL80211_IFTYPE_P2P_GO)
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05309294 | BIT(NL80211_IFTYPE_AP)
9295 | BIT(NL80211_IFTYPE_MONITOR);
Jeff Johnson295189b2012-06-20 16:38:30 -07009296
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309297 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009298 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309299#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
9300 if( pCfg->enableMCC )
9301 {
9302 /* Currently, supports up to two channels */
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05309303 wlan_hdd_iface_combination[0].num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009304
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309305 if( !pCfg->allowMCCGODiffBI )
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05309306 wlan_hdd_iface_combination[0].beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009307
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309308 }
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05309309 wiphy->iface_combinations = wlan_hdd_iface_combination;
9310 wiphy->n_iface_combinations = ARRAY_SIZE(wlan_hdd_iface_combination);
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009311#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309312 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009313
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 /* Before registering we need to update the ht capabilitied based
9315 * on ini values*/
9316 if( !pCfg->ShortGI20MhzEnable )
9317 {
9318 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
9319 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
Jeff Johnson295189b2012-06-20 16:38:30 -07009320 }
9321
9322 if( !pCfg->ShortGI40MhzEnable )
9323 {
9324 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
9325 }
9326
9327 if( !pCfg->nChannelBondingMode5GHz )
9328 {
9329 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
9330 }
Agrawal Ashish97dec502015-11-26 20:20:58 +05309331 /*
9332 * In case of static linked driver at the time of driver unload,
9333 * module exit doesn't happens. Module cleanup helps in cleaning
9334 * of static memory.
9335 * If driver load happens statically, at the time of driver unload,
9336 * wiphy flags don't get reset because of static memory.
9337 * It's better not to store channel in static memory.
9338 */
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309339 wiphy->bands[HDD_NL80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
9340 wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels =
Agrawal Ashish97dec502015-11-26 20:20:58 +05309341 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_2_4_GHZ));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309342 if (wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels == NULL)
Agrawal Ashish97dec502015-11-26 20:20:58 +05309343 {
9344 hddLog(VOS_TRACE_LEVEL_ERROR,
9345 FL("Not enough memory to allocate channels"));
9346 return -ENOMEM;
9347 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309348 vos_mem_copy(wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels,
Agrawal Ashish97dec502015-11-26 20:20:58 +05309349 &hdd_channels_2_4_GHZ[0],
9350 sizeof(hdd_channels_2_4_GHZ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009351
Agrawal Ashish97dec502015-11-26 20:20:58 +05309352 if (true == hdd_is_5g_supported(pHddCtx))
9353 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309354 wiphy->bands[HDD_NL80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
9355 wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels =
Agrawal Ashish97dec502015-11-26 20:20:58 +05309356 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_5_GHZ));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309357 if (wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels == NULL)
Agrawal Ashish97dec502015-11-26 20:20:58 +05309358 {
9359 hddLog(VOS_TRACE_LEVEL_ERROR,
9360 FL("Not enough memory to allocate channels"));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309361 vos_mem_free(wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels);
9362 wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels = NULL;
Agrawal Ashish97dec502015-11-26 20:20:58 +05309363 return -ENOMEM;
9364 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309365 vos_mem_copy(wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels,
Agrawal Ashish97dec502015-11-26 20:20:58 +05309366 &hdd_channels_5_GHZ[0],
9367 sizeof(hdd_channels_5_GHZ));
9368 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309369
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309370 for (i = 0; i < HDD_NUM_NL80211_BANDS; i++)
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309371 {
9372
9373 if (NULL == wiphy->bands[i])
9374 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05309375 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309376 __func__, i);
9377 continue;
9378 }
9379
9380 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9381 {
9382 struct ieee80211_supported_band *band = wiphy->bands[i];
9383
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309384 if (HDD_NL80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309385 {
9386 // Enable social channels for P2P
9387 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
9388 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
9389 else
9390 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
9391 continue;
9392 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309393 else if (HDD_NL80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309394 {
9395 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
9396 continue;
9397 }
9398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009399 }
9400 /*Initialise the supported cipher suite details*/
9401 wiphy->cipher_suites = hdd_cipher_suites;
9402 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
9403
9404 /*signal strength in mBm (100*dBm) */
9405 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
9406
9407#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05309408 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07009409#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009410
Abhishek Singh2f3c4752018-04-11 14:58:53 +05309411 hdd_add_channel_switch_support(wiphy);
Sunil Duttc69bccb2014-05-26 21:30:20 +05309412 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
9413 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08009414 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
9415 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
9416
Anurag Chouhan343af7e2016-12-16 13:11:19 +05309417 hdd_config_sched_scan_plans_to_wiphy(wiphy, pCfg);
Abhinav Kumar97821072019-08-02 14:29:48 +05309418 wlan_hdd_cfg80211_set_wiphy_sae_feature(wiphy, pCfg);
Anurag Chouhan343af7e2016-12-16 13:11:19 +05309419
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309420 EXIT();
9421 return 0;
9422}
9423
9424/* In this function we are registering wiphy. */
9425int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
9426{
9427 ENTER();
9428 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009429 if (0 > wiphy_register(wiphy))
9430 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309431 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
9433 return -EIO;
9434 }
9435
9436 EXIT();
9437 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309438}
Jeff Johnson295189b2012-06-20 16:38:30 -07009439
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309440/* In this function we are updating channel list when,
9441 regulatory domain is FCC and country code is US.
9442 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
9443 As per FCC smart phone is not a indoor device.
9444 GO should not opeate on indoor channels */
9445void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
9446{
9447 int j;
9448 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9449 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
9450 //Default counrtycode from NV at the time of wiphy initialization.
9451 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
9452 &defaultCountryCode[0]))
9453 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009454 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309455 }
9456 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
9457 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309458 if (NULL == wiphy->bands[HDD_NL80211_BAND_5GHZ])
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309459 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309460 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[HDD_NL80211_BAND_5GHZ] is NULL",__func__ );
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309461 return;
9462 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309463 for (j = 0; j < wiphy->bands[HDD_NL80211_BAND_5GHZ]->n_channels; j++)
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309464 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309465 struct ieee80211_supported_band *band = wiphy->bands[HDD_NL80211_BAND_5GHZ];
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309466 // Mark UNII -1 band channel as passive
9467 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
9468 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
9469 }
9470 }
9471}
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05309472/* This function registers for all frame which supplicant is interested in */
9473void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009474{
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9476 /* Register for all P2P action, public action etc frames */
9477 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
Jeff Johnsone7245742012-09-05 17:12:55 -07009478 ENTER();
Abhishek Singh16e05762015-11-30 14:29:27 +05309479 /* Register frame indication call back */
9480 sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame);
Jeff Johnson295189b2012-06-20 16:38:30 -07009481 /* Right now we are registering these frame when driver is getting
9482 initialized. Once we will move to 2.6.37 kernel, in which we have
9483 frame register ops, we will move this code as a part of that */
9484 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309485 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07009486 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
9487
9488 /* GAS Initial Response */
9489 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9490 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309491
Jeff Johnson295189b2012-06-20 16:38:30 -07009492 /* GAS Comeback Request */
9493 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9494 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
9495
9496 /* GAS Comeback Response */
9497 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9498 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
9499
9500 /* P2P Public Action */
9501 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309502 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07009503 P2P_PUBLIC_ACTION_FRAME_SIZE );
9504
9505 /* P2P Action */
9506 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9507 (v_U8_t*)P2P_ACTION_FRAME,
9508 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07009509
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05309510 /* WNM BSS Transition Request frame */
9511 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9512 (v_U8_t*)WNM_BSS_ACTION_FRAME,
9513 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07009514
9515 /* WNM-Notification */
9516 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9517 (v_U8_t*)WNM_NOTIFICATION_FRAME,
9518 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07009519}
9520
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05309521void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009522{
Jeff Johnson295189b2012-06-20 16:38:30 -07009523 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9524 /* Register for all P2P action, public action etc frames */
9525 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
9526
Jeff Johnsone7245742012-09-05 17:12:55 -07009527 ENTER();
9528
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 /* Right now we are registering these frame when driver is getting
9530 initialized. Once we will move to 2.6.37 kernel, in which we have
9531 frame register ops, we will move this code as a part of that */
9532 /* GAS Initial Request */
9533
9534 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9535 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
9536
9537 /* GAS Initial Response */
9538 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9539 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309540
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 /* GAS Comeback Request */
9542 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9543 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
9544
9545 /* GAS Comeback Response */
9546 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9547 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
9548
9549 /* P2P Public Action */
9550 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309551 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 P2P_PUBLIC_ACTION_FRAME_SIZE );
9553
9554 /* P2P Action */
9555 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9556 (v_U8_t*)P2P_ACTION_FRAME,
9557 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07009558 /* WNM-Notification */
9559 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9560 (v_U8_t*)WNM_NOTIFICATION_FRAME,
9561 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07009562}
9563
9564#ifdef FEATURE_WLAN_WAPI
9565void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05309566 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07009567{
9568 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9569 tCsrRoamSetKey setKey;
9570 v_BOOL_t isConnected = TRUE;
9571 int status = 0;
9572 v_U32_t roamId= 0xFF;
9573 tANI_U8 *pKeyPtr = NULL;
9574 int n = 0;
9575
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309576 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
9577 __func__, hdd_device_modetoString(pAdapter->device_mode),
9578 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009579
Gopichand Nakkalae7480202013-02-11 15:24:22 +05309580 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07009581 setKey.keyId = key_index; // Store Key ID
9582 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
9583 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
9584 setKey.paeRole = 0 ; // the PAE role
9585 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9586 {
9587 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
9588 }
9589 else
9590 {
9591 isConnected = hdd_connIsConnected(pHddStaCtx);
9592 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
9593 }
9594 setKey.keyLength = key_Len;
9595 pKeyPtr = setKey.Key;
9596 memcpy( pKeyPtr, key, key_Len);
9597
Arif Hussain6d2a3322013-11-17 19:50:10 -08009598 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07009599 __func__, key_Len);
9600 for (n = 0 ; n < key_Len; n++)
9601 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
9602 __func__,n,setKey.Key[n]);
9603
9604 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9605 if ( isConnected )
9606 {
9607 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9608 pAdapter->sessionId, &setKey, &roamId );
9609 }
9610 if ( status != 0 )
9611 {
9612 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9613 "[%4d] sme_RoamSetKey returned ERROR status= %d",
9614 __LINE__, status );
9615 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9616 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309617 /* Need to clear any trace of key value in the memory.
9618 * Thus zero out the memory even though it is local
9619 * variable.
9620 */
9621 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07009622}
9623#endif /* FEATURE_WLAN_WAPI*/
9624
9625#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309626int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009627 beacon_data_t **ppBeacon,
9628 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009629#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309630int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009631 beacon_data_t **ppBeacon,
9632 struct cfg80211_beacon_data *params,
9633 int dtim_period)
9634#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309635{
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 int size;
9637 beacon_data_t *beacon = NULL;
9638 beacon_data_t *old = NULL;
Kapil Gupta137ef892016-12-13 19:38:00 +05309639 int head_len, tail_len, proberesp_ies_len, assocresp_ies_len;
9640 const u8 *head, *tail, *proberesp_ies, *assocresp_ies;
Jeff Johnson295189b2012-06-20 16:38:30 -07009641
Jeff Johnsone7245742012-09-05 17:12:55 -07009642 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309644 {
9645 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9646 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009647 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009649
9650 old = pAdapter->sessionCtx.ap.beacon;
9651
9652 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309653 {
9654 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9655 FL("session(%d) old and new heads points to NULL"),
9656 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009657 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309658 }
9659
9660 if (params->tail && !params->tail_len)
9661 {
9662 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9663 FL("tail_len is zero but tail is not NULL"));
9664 return -EINVAL;
9665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009666
Jeff Johnson295189b2012-06-20 16:38:30 -07009667#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
9668 /* Kernel 3.0 is not updating dtim_period for set beacon */
9669 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309670 {
9671 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9672 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309674 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009675#endif
9676
Kapil Gupta137ef892016-12-13 19:38:00 +05309677 if (params->head)
9678 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009679 head_len = params->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309680 head = params->head;
9681 } else
9682 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 head_len = old->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309684 head = old->head;
9685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009686
Kapil Gupta137ef892016-12-13 19:38:00 +05309687 if (params->tail || !old)
9688 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009689 tail_len = params->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309690 tail = params->tail;
9691 } else
9692 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 tail_len = old->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309694 tail = old->tail;
9695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009696
Kapil Gupta137ef892016-12-13 19:38:00 +05309697 if (params->proberesp_ies || !old)
9698 {
9699 proberesp_ies_len = params->proberesp_ies_len;
9700 proberesp_ies = params->proberesp_ies;
9701 } else
9702 {
9703 proberesp_ies_len = old->proberesp_ies_len;
9704 proberesp_ies = old->proberesp_ies;
9705 }
9706
9707 if (params->assocresp_ies || !old)
9708 {
9709 assocresp_ies_len = params->assocresp_ies_len;
9710 assocresp_ies = params->assocresp_ies;
9711 } else
9712 {
9713 assocresp_ies_len = old->assocresp_ies_len;
9714 assocresp_ies = old->assocresp_ies;
9715 }
9716
9717 size = sizeof(beacon_data_t) + head_len + tail_len +
9718 proberesp_ies_len + assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07009719
9720 beacon = kzalloc(size, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309722 {
9723 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9724 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309726 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009727
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009728#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Kapil Gupta137ef892016-12-13 19:38:00 +05309729 if (params->dtim_period)
Jeff Johnson295189b2012-06-20 16:38:30 -07009730 beacon->dtim_period = params->dtim_period;
9731 else
9732 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009733#else
Kapil Gupta137ef892016-12-13 19:38:00 +05309734 if (dtim_period)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009735 beacon->dtim_period = dtim_period;
9736 else
9737 beacon->dtim_period = old->dtim_period;
9738#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309739
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
9741 beacon->tail = beacon->head + head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309742 beacon->proberesp_ies = beacon->tail + tail_len;
9743 beacon->assocresp_ies = beacon->proberesp_ies + proberesp_ies_len;
9744
Jeff Johnson295189b2012-06-20 16:38:30 -07009745 beacon->head_len = head_len;
9746 beacon->tail_len = tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309747 beacon->proberesp_ies_len = proberesp_ies_len;
9748 beacon->assocresp_ies_len= assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07009749
c_manjee527ecac2017-01-25 12:25:27 +05309750 if (head && head_len)
9751 memcpy(beacon->head, head, head_len);
9752 if (tail && tail_len)
9753 memcpy(beacon->tail, tail, tail_len);
9754 if (proberesp_ies && proberesp_ies_len)
9755 memcpy(beacon->proberesp_ies, proberesp_ies, proberesp_ies_len);
9756 if (assocresp_ies && assocresp_ies_len)
9757 memcpy(beacon->assocresp_ies, assocresp_ies, assocresp_ies_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009758
9759 *ppBeacon = beacon;
9760
9761 kfree(old);
9762
9763 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009764}
Jeff Johnson295189b2012-06-20 16:38:30 -07009765
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309766v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
9767#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
9768 const v_U8_t *pIes,
9769#else
9770 v_U8_t *pIes,
9771#endif
9772 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009773{
9774 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309775 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07009776 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309777
Jeff Johnson295189b2012-06-20 16:38:30 -07009778 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309779 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009780 elem_id = ptr[0];
9781 elem_len = ptr[1];
9782 left -= 2;
9783 if(elem_len > left)
9784 {
9785 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009786 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 eid,elem_len,left);
9788 return NULL;
9789 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309790 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 {
9792 return ptr;
9793 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309794
Jeff Johnson295189b2012-06-20 16:38:30 -07009795 left -= elem_len;
9796 ptr += (elem_len + 2);
9797 }
9798 return NULL;
9799}
9800
Jeff Johnson295189b2012-06-20 16:38:30 -07009801/* Check if rate is 11g rate or not */
9802static int wlan_hdd_rate_is_11g(u8 rate)
9803{
Sanjay Devnani28322e22013-06-21 16:13:40 -07009804 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009805 u8 i;
9806 for (i = 0; i < 8; i++)
9807 {
9808 if(rate == gRateArray[i])
9809 return TRUE;
9810 }
9811 return FALSE;
9812}
9813
9814/* Check for 11g rate and set proper 11g only mode */
9815static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
9816 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
9817{
9818 u8 i, num_rates = pIe[0];
9819
9820 pIe += 1;
9821 for ( i = 0; i < num_rates; i++)
9822 {
9823 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
9824 {
9825 /* If rate set have 11g rate than change the mode to 11G */
9826 *pSapHw_mode = eSAP_DOT11_MODE_11g;
9827 if (pIe[i] & BASIC_RATE_MASK)
9828 {
9829 /* If we have 11g rate as basic rate, it means mode
9830 is 11g only mode.
9831 */
9832 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
9833 *pCheckRatesfor11g = FALSE;
9834 }
9835 }
9836 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
9837 {
9838 *require_ht = TRUE;
9839 }
9840 }
9841 return;
9842}
9843
9844static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
9845{
9846 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9847 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9848 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9849 u8 checkRatesfor11g = TRUE;
9850 u8 require_ht = FALSE;
9851 u8 *pIe=NULL;
9852
9853 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
9854
9855 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
9856 pBeacon->head_len, WLAN_EID_SUPP_RATES);
9857 if (pIe != NULL)
9858 {
9859 pIe += 1;
9860 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
9861 &pConfig->SapHw_mode);
9862 }
9863
9864 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
9865 WLAN_EID_EXT_SUPP_RATES);
9866 if (pIe != NULL)
9867 {
9868
9869 pIe += 1;
9870 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
9871 &pConfig->SapHw_mode);
9872 }
9873
9874 if( pConfig->channel > 14 )
9875 {
9876 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
9877 }
9878
9879 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
9880 WLAN_EID_HT_CAPABILITY);
9881
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309882 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009883 {
9884 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
9885 if(require_ht)
9886 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
9887 }
9888}
9889
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309890static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
9891 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
9892{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009893 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309894 v_U8_t *pIe = NULL;
9895 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9896
9897 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
9898 pBeacon->tail, pBeacon->tail_len);
9899
9900 if (pIe)
9901 {
9902 ielen = pIe[1] + 2;
9903 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
9904 {
9905 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
9906 }
9907 else
9908 {
9909 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
9910 return -EINVAL;
9911 }
9912 *total_ielen += ielen;
9913 }
9914 return 0;
9915}
9916
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009917static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
9918 v_U8_t *genie, v_U8_t *total_ielen)
9919{
9920 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9921 int left = pBeacon->tail_len;
9922 v_U8_t *ptr = pBeacon->tail;
9923 v_U8_t elem_id, elem_len;
9924 v_U16_t ielen = 0;
9925
9926 if ( NULL == ptr || 0 == left )
9927 return;
9928
9929 while (left >= 2)
9930 {
9931 elem_id = ptr[0];
9932 elem_len = ptr[1];
9933 left -= 2;
9934 if (elem_len > left)
9935 {
9936 hddLog( VOS_TRACE_LEVEL_ERROR,
9937 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
9938 elem_id, elem_len, left);
9939 return;
9940 }
Ashish Kumar Dhanotiya6af276b2017-08-22 16:53:48 +05309941 if ((IE_EID_VENDOR == elem_id) && (elem_len >= WPS_OUI_TYPE_SIZE))
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009942 {
9943 /* skipping the VSIE's which we don't want to include or
9944 * it will be included by existing code
9945 */
9946 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
9947#ifdef WLAN_FEATURE_WFD
9948 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
9949#endif
9950 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9951 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9952 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
9953 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9954 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
9955 {
9956 ielen = ptr[1] + 2;
9957 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
9958 {
9959 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
9960 *total_ielen += ielen;
9961 }
9962 else
9963 {
9964 hddLog( VOS_TRACE_LEVEL_ERROR,
9965 "IE Length is too big "
9966 "IEs eid=%d elem_len=%d total_ie_lent=%d",
9967 elem_id, elem_len, *total_ielen);
9968 }
9969 }
9970 }
9971
9972 left -= elem_len;
9973 ptr += (elem_len + 2);
9974 }
9975 return;
9976}
9977
Kapil Gupta137ef892016-12-13 19:38:00 +05309978int wlan_hdd_cfg80211_update_apies(hdd_adapter_t *pHostapdAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009979{
9980 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309981 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009982 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07009983 int ret = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +05309984 beacon_data_t *pBeacon = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009985
9986 genie = vos_mem_malloc(MAX_GENIE_LEN);
9987
9988 if(genie == NULL) {
9989
9990 return -ENOMEM;
9991 }
9992
Kapil Gupta137ef892016-12-13 19:38:00 +05309993 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309994 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9995 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07009996 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309997 hddLog(LOGE,
9998 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309999 ret = -EINVAL;
10000 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010001 }
10002
10003#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +053010004 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
10005 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
10006 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010007 hddLog(LOGE,
10008 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +053010009 ret = -EINVAL;
10010 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010011 }
10012#endif
10013
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +053010014 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
10015 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070010016 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010017 hddLog(LOGE,
10018 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +053010019 ret = -EINVAL;
10020 goto done;
10021 }
10022
10023 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
10024 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -070010025 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -070010026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010027
10028 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10029 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
10030 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
10031 {
10032 hddLog(LOGE,
10033 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010034 ret = -EINVAL;
10035 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010036 }
10037
10038 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10039 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
10040 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
10041 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
10042 ==eHAL_STATUS_FAILURE)
10043 {
10044 hddLog(LOGE,
10045 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010046 ret = -EINVAL;
10047 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010048 }
10049
10050 // Added for ProResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +053010051 if ((pBeacon->proberesp_ies != NULL) && (pBeacon->proberesp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010052 {
Kapil Gupta137ef892016-12-13 19:38:00 +053010053 u16 rem_probe_resp_ie_len = pBeacon->proberesp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -070010054 u8 probe_rsp_ie_len[3] = {0};
10055 u8 counter = 0;
10056 /* Check Probe Resp Length if it is greater then 255 then Store
10057 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
10058 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
10059 Store More then 255 bytes into One Variable.
10060 */
10061 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
10062 {
10063 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
10064 {
10065 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
10066 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
10067 }
10068 else
10069 {
10070 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
10071 rem_probe_resp_ie_len = 0;
10072 }
10073 }
10074
10075 rem_probe_resp_ie_len = 0;
10076
10077 if (probe_rsp_ie_len[0] > 0)
10078 {
10079 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10080 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
Kapil Gupta137ef892016-12-13 19:38:00 +053010081 (tANI_U8*)&pBeacon->
10082 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -070010083 probe_rsp_ie_len[0], NULL,
10084 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10085 {
10086 hddLog(LOGE,
10087 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010088 ret = -EINVAL;
10089 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010090 }
10091 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
10092 }
10093
10094 if (probe_rsp_ie_len[1] > 0)
10095 {
10096 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10097 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
Kapil Gupta137ef892016-12-13 19:38:00 +053010098 (tANI_U8*)&pBeacon->
10099 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 probe_rsp_ie_len[1], NULL,
10101 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10102 {
10103 hddLog(LOGE,
10104 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010105 ret = -EINVAL;
10106 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010107 }
10108 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
10109 }
10110
10111 if (probe_rsp_ie_len[2] > 0)
10112 {
10113 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10114 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
Kapil Gupta137ef892016-12-13 19:38:00 +053010115 (tANI_U8*)&pBeacon->
10116 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -070010117 probe_rsp_ie_len[2], NULL,
10118 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10119 {
10120 hddLog(LOGE,
10121 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010122 ret = -EINVAL;
10123 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010124 }
10125 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
10126 }
10127
10128 if (probe_rsp_ie_len[1] == 0 )
10129 {
10130 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10131 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
10132 eANI_BOOLEAN_FALSE) )
10133 {
10134 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010135 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010136 }
10137 }
10138
10139 if (probe_rsp_ie_len[2] == 0 )
10140 {
10141 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10142 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
10143 eANI_BOOLEAN_FALSE) )
10144 {
10145 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010146 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010147 }
10148 }
10149
10150 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10151 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
10152 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
10153 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
10154 == eHAL_STATUS_FAILURE)
10155 {
10156 hddLog(LOGE,
10157 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010158 ret = -EINVAL;
10159 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010160 }
10161 }
10162 else
10163 {
10164 // Reset WNI_CFG_PROBE_RSP Flags
10165 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
10166
10167 hddLog(VOS_TRACE_LEVEL_INFO,
10168 "%s: No Probe Response IE received in set beacon",
10169 __func__);
10170 }
10171
10172 // Added for AssocResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +053010173 if ((pBeacon->assocresp_ies != NULL) && (pBeacon->assocresp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010174 {
10175 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
Kapil Gupta137ef892016-12-13 19:38:00 +053010176 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)pBeacon->assocresp_ies,
10177 pBeacon->assocresp_ies_len, NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -070010178 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10179 {
10180 hddLog(LOGE,
10181 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010182 ret = -EINVAL;
10183 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010184 }
10185
10186 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10187 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
10188 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
10189 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
10190 == eHAL_STATUS_FAILURE)
10191 {
10192 hddLog(LOGE,
10193 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010194 ret = -EINVAL;
10195 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010196 }
10197 }
10198 else
10199 {
10200 hddLog(VOS_TRACE_LEVEL_INFO,
10201 "%s: No Assoc Response IE received in set beacon",
10202 __func__);
10203
10204 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10205 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
10206 eANI_BOOLEAN_FALSE) )
10207 {
10208 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010209 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010210 }
10211 }
10212
Jeff Johnsone7245742012-09-05 17:12:55 -070010213done:
Jeff Johnson295189b2012-06-20 16:38:30 -070010214 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +053010215 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010216}
Jeff Johnson295189b2012-06-20 16:38:30 -070010217
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010218/*
Jeff Johnson295189b2012-06-20 16:38:30 -070010219 * FUNCTION: wlan_hdd_validate_operation_channel
10220 * called by wlan_hdd_cfg80211_start_bss() and
10221 * wlan_hdd_cfg80211_set_channel()
10222 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010223 * channel list.
10224 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010225VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -070010226{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010227
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 v_U32_t num_ch = 0;
10229 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
10230 u32 indx = 0;
10231 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010232 v_U8_t fValidChannel = FALSE, count = 0;
10233 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010234
Jeff Johnson295189b2012-06-20 16:38:30 -070010235 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
10236
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010237 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070010238 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010239 /* Validate the channel */
10240 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -070010241 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010242 if ( channel == rfChannels[count].channelNum )
10243 {
10244 fValidChannel = TRUE;
10245 break;
10246 }
10247 }
10248 if (fValidChannel != TRUE)
10249 {
10250 hddLog(VOS_TRACE_LEVEL_ERROR,
10251 "%s: Invalid Channel [%d]", __func__, channel);
10252 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010253 }
10254 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010255 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010256 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010257 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
10258 valid_ch, &num_ch))
10259 {
10260 hddLog(VOS_TRACE_LEVEL_ERROR,
10261 "%s: failed to get valid channel list", __func__);
10262 return VOS_STATUS_E_FAILURE;
10263 }
10264 for (indx = 0; indx < num_ch; indx++)
10265 {
10266 if (channel == valid_ch[indx])
10267 {
10268 break;
10269 }
10270 }
10271
Rashmi Ramanna3b59e122014-04-10 14:45:13 +053010272 if (indx >= num_ch)
10273 {
10274 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
10275 {
10276 eCsrBand band;
10277 unsigned int freq;
10278
10279 sme_GetFreqBand(hHal, &band);
10280
10281 if (eCSR_BAND_5G == band)
10282 {
10283#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
10284 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
10285 {
10286 freq = ieee80211_channel_to_frequency(channel,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053010287 HDD_NL80211_BAND_2GHZ);
Rashmi Ramanna3b59e122014-04-10 14:45:13 +053010288 }
10289 else
10290 {
10291 freq = ieee80211_channel_to_frequency(channel,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053010292 HDD_NL80211_BAND_5GHZ);
Rashmi Ramanna3b59e122014-04-10 14:45:13 +053010293 }
10294#else
10295 freq = ieee80211_channel_to_frequency(channel);
10296#endif
10297 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
10298 return VOS_STATUS_SUCCESS;
10299 }
10300 }
10301
10302 hddLog(VOS_TRACE_LEVEL_ERROR,
10303 "%s: Invalid Channel [%d]", __func__, channel);
10304 return VOS_STATUS_E_FAILURE;
10305 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010306 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +053010307
Jeff Johnson295189b2012-06-20 16:38:30 -070010308 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010309
Jeff Johnson295189b2012-06-20 16:38:30 -070010310}
10311
Viral Modi3a32cc52013-02-08 11:14:52 -080010312/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010313 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -080010314 * This function is used to set the channel number
10315 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010316static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -080010317 struct ieee80211_channel *chan,
10318 enum nl80211_channel_type channel_type
10319 )
10320{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010321 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -080010322 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -070010323 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -080010324 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010325 hdd_context_t *pHddCtx;
10326 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -080010327
10328 ENTER();
10329
10330 if( NULL == dev )
10331 {
10332 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010333 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -080010334 return -ENODEV;
10335 }
10336 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010337
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010338 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10339 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
10340 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -080010341 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010342 "%s: device_mode = %s (%d) freq = %d", __func__,
10343 hdd_device_modetoString(pAdapter->device_mode),
10344 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010345
10346 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10347 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010348 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -080010349 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010350 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -080010351 }
10352
10353 /*
10354 * Do freq to chan conversion
10355 * TODO: for 11a
10356 */
10357
10358 channel = ieee80211_frequency_to_channel(freq);
10359
10360 /* Check freq range */
10361 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
10362 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
10363 {
10364 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010365 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -080010366 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
10367 WNI_CFG_CURRENT_CHANNEL_STAMAX);
10368 return -EINVAL;
10369 }
10370
10371 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
10372
Gopichand Nakkala6ab19562013-03-07 13:59:42 +053010373 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
10374 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -080010375 {
10376 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
10377 {
10378 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010379 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -080010380 return -EINVAL;
10381 }
10382 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10383 "%s: set channel to [%d] for device mode =%d",
10384 __func__, channel,pAdapter->device_mode);
10385 }
10386 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -080010387 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -080010388 )
10389 {
10390 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10391 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
10392 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10393
10394 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
10395 {
10396 /* Link is up then return cant set channel*/
10397 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010398 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -080010399 return -EINVAL;
10400 }
10401
10402 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
10403 pHddStaCtx->conn_info.operationChannel = channel;
10404 pRoamProfile->ChannelInfo.ChannelList =
10405 &pHddStaCtx->conn_info.operationChannel;
10406 }
10407 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -080010408 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -080010409 )
10410 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010411 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
10412 {
10413 if(VOS_STATUS_SUCCESS !=
10414 wlan_hdd_validate_operation_channel(pAdapter,channel))
10415 {
10416 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010417 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010418 return -EINVAL;
10419 }
10420 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
10421 }
10422 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -080010423 {
10424 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
10425
10426 /* If auto channel selection is configured as enable/ 1 then ignore
10427 channel set by supplicant
10428 */
10429 if ( cfg_param->apAutoChannelSelection )
10430 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010431 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
10432 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -080010433 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010434 "%s: set channel to auto channel (0) for device mode =%s (%d)",
10435 __func__, hdd_device_modetoString(pAdapter->device_mode),
10436 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -080010437 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010438 else
10439 {
10440 if(VOS_STATUS_SUCCESS !=
10441 wlan_hdd_validate_operation_channel(pAdapter,channel))
10442 {
10443 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010444 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010445 return -EINVAL;
10446 }
10447 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
10448 }
Viral Modi3a32cc52013-02-08 11:14:52 -080010449 }
10450 }
10451 else
10452 {
10453 hddLog(VOS_TRACE_LEVEL_FATAL,
10454 "%s: Invalid device mode failed to set valid channel", __func__);
10455 return -EINVAL;
10456 }
10457 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010458 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -080010459}
10460
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010461static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
10462 struct net_device *dev,
10463 struct ieee80211_channel *chan,
10464 enum nl80211_channel_type channel_type
10465 )
10466{
10467 int ret;
10468
10469 vos_ssr_protect(__func__);
10470 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
10471 vos_ssr_unprotect(__func__);
10472
10473 return ret;
10474}
10475
Anurag Chouhan83026002016-12-13 22:46:21 +053010476#ifdef DHCP_SERVER_OFFLOAD
10477void hdd_dhcp_server_offload_done(void *fw_dhcp_srv_offload_cb_context,
10478 VOS_STATUS status)
10479{
10480 hdd_adapter_t* adapter = (hdd_adapter_t*)fw_dhcp_srv_offload_cb_context;
10481
10482 ENTER();
10483
10484 if (NULL == adapter)
10485 {
10486 hddLog(VOS_TRACE_LEVEL_ERROR,
10487 "%s: adapter is NULL",__func__);
10488 return;
10489 }
10490
10491 adapter->dhcp_status.dhcp_offload_status = status;
10492 vos_event_set(&adapter->dhcp_status.vos_event);
10493 return;
10494}
10495
10496/**
10497 * wlan_hdd_set_dhcp_server_offload() - set dhcp server offload
10498 * @hostapd_adapter: pointer to hostapd adapter.
Anurag Chouhan638f5e22017-03-06 12:28:43 +053010499 * @re_init: flag set if api called post ssr
Anurag Chouhan83026002016-12-13 22:46:21 +053010500 *
10501 * Return: None
10502 */
Anurag Chouhan638f5e22017-03-06 12:28:43 +053010503VOS_STATUS wlan_hdd_set_dhcp_server_offload(hdd_adapter_t *hostapd_adapter,
10504 bool re_init)
Anurag Chouhan83026002016-12-13 22:46:21 +053010505{
10506 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(hostapd_adapter);
10507 sir_dhcp_srv_offload_info dhcp_srv_info;
10508 tANI_U8 num_entries = 0;
10509 tANI_U8 srv_ip[IPADDR_NUM_ENTRIES];
10510 tANI_U8 num;
10511 tANI_U32 temp;
10512 VOS_STATUS ret;
10513
10514 ENTER();
10515
Anurag Chouhan638f5e22017-03-06 12:28:43 +053010516 if (!re_init) {
10517 ret = wlan_hdd_validate_context(hdd_ctx);
10518 if (0 != ret)
10519 return VOS_STATUS_E_INVAL;
10520 }
Anurag Chouhan83026002016-12-13 22:46:21 +053010521
10522 /* Prepare the request to send to SME */
10523 dhcp_srv_info = vos_mem_malloc(sizeof(*dhcp_srv_info));
10524 if (NULL == dhcp_srv_info) {
10525 hddLog(VOS_TRACE_LEVEL_ERROR,
10526 "%s: could not allocate tDhcpSrvOffloadInfo!", __func__);
10527 return VOS_STATUS_E_NOMEM;
10528 }
10529
10530 vos_mem_zero(dhcp_srv_info, sizeof(*dhcp_srv_info));
10531
10532 dhcp_srv_info->bssidx = hostapd_adapter->sessionId;
10533 dhcp_srv_info->dhcp_srv_offload_enabled = TRUE;
10534 dhcp_srv_info->dhcp_client_num = hdd_ctx->cfg_ini->dhcp_max_num_clients;
10535 dhcp_srv_info->start_lsb = hdd_ctx->cfg_ini->dhcp_start_lsb;
10536 dhcp_srv_info->dhcp_offload_callback = hdd_dhcp_server_offload_done;
10537 dhcp_srv_info->dhcp_server_offload_cb_context = hostapd_adapter;
10538
10539 hdd_string_to_u8_array(hdd_ctx->cfg_ini->dhcp_srv_ip,
10540 srv_ip,
10541 &num_entries,
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +053010542 IPADDR_NUM_ENTRIES, ".", false);
Anurag Chouhan83026002016-12-13 22:46:21 +053010543 if (num_entries != IPADDR_NUM_ENTRIES) {
10544 hddLog(VOS_TRACE_LEVEL_ERROR,
10545 "%s: incorrect IP address (%s) assigned for DHCP server!",
10546 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
10547 vos_mem_free(dhcp_srv_info);
10548 return VOS_STATUS_E_FAILURE;
10549 }
10550
10551 if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) {
10552 hddLog(VOS_TRACE_LEVEL_ERROR,
10553 "%s: invalid IP address (%s)! It could NOT be multicast IP address!",
10554 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
10555 vos_mem_free(dhcp_srv_info);
10556 return VOS_STATUS_E_FAILURE;
10557 }
10558
10559 if (srv_ip[IPADDR_NUM_ENTRIES-1] >= DHCP_START_POOL_ADDRESS) {
10560 hddLog(VOS_TRACE_LEVEL_ERROR,
10561 "%s: invalid IP address (%s)! The last field must be less than 100!",
10562 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
10563 vos_mem_free(dhcp_srv_info);
10564 return VOS_STATUS_E_FAILURE;
10565 }
10566
10567 for (num = 0; num < num_entries; num++) {
10568 temp = srv_ip[num];
10569 dhcp_srv_info->dhcp_srv_ip |= (temp << (8 * num));
10570 }
10571
10572 if (eHAL_STATUS_SUCCESS !=
10573 sme_set_dhcp_srv_offload(hdd_ctx->hHal, dhcp_srv_info)) {
10574 hddLog(VOS_TRACE_LEVEL_ERROR,
10575 "%s: sme_set_dhcp_srv_offload fail!", __func__);
10576 vos_mem_free(dhcp_srv_info);
10577 return VOS_STATUS_E_FAILURE;
10578 }
10579
10580 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10581 "%s: enable DHCP Server offload successfully!", __func__);
10582
10583 vos_mem_free(dhcp_srv_info);
10584 return 0;
10585}
10586#endif /* DHCP_SERVER_OFFLOAD */
10587
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010588/*
10589 * hdd_modify_indoor_channel_state_flags() - modify wiphy flags and cds state
10590 * @wiphy_chan: wiphy channel number
10591 * @rfChannel: channel hw value
10592 * @disable: Disable/enable the flags
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010593 * @hdd_ctx: The HDD context handler
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010594 *
10595 * Modify wiphy flags and cds state if channel is indoor.
10596 *
10597 * Return: void
10598 */
10599void hdd_modify_indoor_channel_state_flags(struct ieee80211_channel *wiphy_chan,
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010600 v_U32_t rfChannel, bool disable, hdd_context_t *hdd_ctx)
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010601{
10602 v_U32_t channelLoop;
10603 eRfChannels channelEnum = INVALID_RF_CHANNEL;
10604
10605 for (channelLoop = 0; channelLoop <= RF_CHAN_165; channelLoop++) {
10606
10607 if (rfChannels[channelLoop].channelNum == rfChannel) {
10608 channelEnum = (eRfChannels)channelLoop;
10609 break;
10610 }
10611 }
10612
10613 if (INVALID_RF_CHANNEL == channelEnum)
10614 return;
10615
10616 if (disable) {
10617 if (wiphy_chan->flags & IEEE80211_CHAN_INDOOR_ONLY) {
10618 wiphy_chan->flags |=
10619 IEEE80211_CHAN_DISABLED;
10620 regChannels[channelEnum].enabled =
10621 NV_CHANNEL_DISABLE;
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010622 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %d marked as DISABLE",
10623 channelEnum);
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010624 }
10625 } else {
10626 if (wiphy_chan->flags & IEEE80211_CHAN_INDOOR_ONLY) {
10627 wiphy_chan->flags &=
10628 ~IEEE80211_CHAN_DISABLED;
10629 /*
10630 * Indoor channels are marked as DFS
10631 * during regulatory processing
10632 */
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010633 if ((wiphy_chan->flags & (IEEE80211_CHAN_RADAR |
10634 IEEE80211_CHAN_PASSIVE_SCAN)) ||
10635 ((hdd_ctx->cfg_ini->indoor_channel_support == false)
10636 && (wiphy_chan->flags &
10637 IEEE80211_CHAN_INDOOR_ONLY))) {
10638 regChannels[channelEnum].enabled = NV_CHANNEL_DFS;
10639 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %d marked as DFS",
10640 channelEnum);
10641 } else {
10642 regChannels[channelEnum].enabled =
10643 NV_CHANNEL_ENABLE;
10644 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %d marked as ENABLE",
10645 channelEnum);
10646 }
10647 }
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010648
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010649 }
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010650}
10651
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010652void hdd_update_indoor_channel(hdd_context_t *hdd_ctx, bool disable)
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010653{
10654 int band_num;
10655 int chan_num;
10656 v_U32_t rfChannel;
10657 struct ieee80211_channel *wiphy_chan;
10658 struct wiphy *wiphy;
10659
10660 ENTER();
10661 hddLog(VOS_TRACE_LEVEL_INFO, "disable: %d", disable);
10662
10663 wiphy = hdd_ctx->wiphy;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053010664 for (band_num = 0; band_num < HDD_NUM_NL80211_BANDS; band_num++) {
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010665
10666 if (wiphy->bands[band_num] == NULL)
10667 continue;
10668
10669 for (chan_num = 0;
10670 chan_num < wiphy->bands[band_num]->n_channels;
10671 chan_num++) {
10672
10673 wiphy_chan =
10674 &(wiphy->bands[band_num]->channels[chan_num]);
10675 rfChannel = wiphy->bands[band_num]->channels[chan_num].hw_value;
10676
10677 hdd_modify_indoor_channel_state_flags(wiphy_chan, rfChannel,
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010678 disable, hdd_ctx);
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010679 }
10680 }
10681 EXIT();
10682}
10683
Ganesh Kondabattini19813af2018-01-25 17:32:44 +053010684int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
10685{
Dundi Raviteja49de66b2018-07-27 12:22:57 +053010686 eHalStatus status;
10687 int result = 0;
Ganesh Kondabattini19813af2018-01-25 17:32:44 +053010688 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10689 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10690 long ret;
10691 eConnectionState prev_conn_state;
10692 uint32_t wait_time = WLAN_WAIT_TIME_DISCONNECT;
10693
10694 ENTER();
10695
Ganesh Kondabattini19813af2018-01-25 17:32:44 +053010696 /* Indicate sme of disconnect so that in progress connection or preauth
10697 * can be aborted
10698 */
10699 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
10700 pAdapter->sessionId);
10701 pHddCtx->isAmpAllowed = VOS_TRUE;
10702
10703 /* Need to apply spin lock before decreasing active sessions
10704 * as there can be chance for double decrement if context switch
10705 * Calls hdd_DisConnectHandler.
10706 */
10707
10708 prev_conn_state = pHddStaCtx->conn_info.connState;
10709
10710 spin_lock_bh(&pAdapter->lock_for_active_session);
10711 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
10712 {
10713 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
10714 }
10715 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
10716 spin_unlock_bh(&pAdapter->lock_for_active_session);
10717 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
10718
10719 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10720 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
10721
10722 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10723
10724 /*
10725 * stop tx queues before deleting STA/BSS context from the firmware.
10726 * tx has to be disabled because the firmware can get busy dropping
10727 * the tx frames after BSS/STA has been deleted and will not send
10728 * back a response resulting in WDI timeout
10729 */
10730 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
10731 netif_tx_disable(pAdapter->dev);
10732 netif_carrier_off(pAdapter->dev);
10733
10734 wlan_hdd_check_and_stop_mon(pAdapter, true);
10735
10736 /*issue disconnect*/
10737 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10738 pAdapter->sessionId, reason);
10739 if((eHAL_STATUS_CMD_NOT_QUEUED == status) &&
10740 prev_conn_state != eConnectionState_Connecting)
10741 {
10742 hddLog(LOG1,
10743 FL("status = %d, already disconnected"), status);
10744 result = 0;
10745 /*
10746 * Wait here instead of returning directly. This will block the
10747 * next connect command and allow processing of the disconnect
10748 * in SME else we might hit some race conditions leading to SME
10749 * and HDD out of sync. As disconnect is already in progress,
10750 * wait here for 1 sec instead of 5 sec.
10751 */
10752 wait_time = WLAN_WAIT_DISCONNECT_ALREADY_IN_PROGRESS;
10753 goto wait_for_disconnect;
10754 }
10755 /*
10756 * Wait here instead of returning directly, this will block the next
10757 * connect command and allow processing of the scan for ssid and
10758 * the previous connect command in CSR. Else we might hit some
10759 * race conditions leading to SME and HDD out of sync.
10760 */
10761 else if(eHAL_STATUS_CMD_NOT_QUEUED == status)
10762 {
10763 hddLog(LOG1,
10764 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
10765 }
10766 else if ( 0 != status )
10767 {
10768 hddLog(LOGE,
10769 FL("csrRoamDisconnect failure, returned %d"),
10770 (int)status);
10771 result = -EINVAL;
10772 goto disconnected;
10773 }
10774wait_for_disconnect:
10775 ret = wait_for_completion_timeout(&pAdapter->disconnect_comp_var,
10776 msecs_to_jiffies(wait_time));
10777 if (!ret && (eHAL_STATUS_CMD_NOT_QUEUED != status))
10778 {
10779 hddLog(LOGE,
10780 "%s: Failed to disconnect, timed out", __func__);
10781 result = -ETIMEDOUT;
10782 }
10783disconnected:
10784 hddLog(LOG1,
10785 FL("Set HDD connState to eConnectionState_NotConnected"));
10786 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
10787#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
10788 /* Sending disconnect event to userspace for kernel version < 3.11
10789 * is handled by __cfg80211_disconnect call to __cfg80211_disconnected
10790 */
10791 hddLog(LOG1, FL("Send disconnected event to userspace"));
10792
10793 wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true,
10794 WLAN_REASON_UNSPECIFIED);
10795#endif
10796
10797 EXIT();
10798 return result;
10799}
10800
Ganesh Kondabattini19813af2018-01-25 17:32:44 +053010801void hdd_check_and_disconnect_sta_on_invalid_channel(hdd_context_t *hdd_ctx)
10802{
10803
10804 hdd_adapter_t *sta_adapter;
10805 tANI_U8 sta_chan;
10806
10807 sta_chan = hdd_get_operating_channel(hdd_ctx, WLAN_HDD_INFRA_STATION);
10808
10809 if (!sta_chan) {
10810 hddLog(LOG1, FL("STA not connected"));
10811 return;
10812 }
10813
10814 hddLog(LOG1, FL("STA connected on chan %hu"), sta_chan);
10815
10816 if (sme_IsChannelValid(hdd_ctx->hHal, sta_chan)) {
10817 hddLog(LOG1, FL("STA connected on chan %hu and it is valid"),
10818 sta_chan);
10819 return;
10820 }
10821
10822 sta_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION);
10823
10824 if (!sta_adapter) {
10825 hddLog(LOG1, FL("STA adapter doesn't exist"));
10826 return;
10827 }
10828
10829 hddLog(LOG1, FL("chan %hu not valid, issue disconnect"), sta_chan);
10830 /* Issue Disconnect request */
10831 wlan_hdd_disconnect(sta_adapter, eCSR_DISCONNECT_REASON_DEAUTH);
10832}
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010833
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010834int wlan_hdd_restore_channels(hdd_context_t *hdd_ctx)
10835{
10836 struct hdd_cache_channels *cache_chann;
10837 struct wiphy *wiphy;
10838 int freq, status, rfChannel;
10839 int i, band_num, channel_num;
10840 struct ieee80211_channel *wiphy_channel;
10841
10842 ENTER();
10843
10844 if (!hdd_ctx) {
10845 hddLog(VOS_TRACE_LEVEL_FATAL, "HDD Context is NULL");
10846 return -EINVAL;
10847 }
10848
10849 wiphy = hdd_ctx->wiphy;
10850
10851 mutex_lock(&hdd_ctx->cache_channel_lock);
10852
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +053010853 cache_chann = hdd_ctx->original_channels;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010854
10855 if (!cache_chann || !cache_chann->num_channels) {
10856 hddLog(VOS_TRACE_LEVEL_INFO,
10857 "%s channel list is NULL or num channels are zero",
10858 __func__);
10859 mutex_unlock(&hdd_ctx->cache_channel_lock);
10860 return -EINVAL;
10861 }
10862
10863 for (i = 0; i < cache_chann->num_channels; i++) {
10864 status = hdd_wlan_get_freq(
10865 cache_chann->channel_info[i].channel_num,
10866 &freq);
10867
Rajeev Kumar Sirasanagandla17b649a2018-03-19 16:58:30 +053010868 for (band_num = 0; band_num < HDD_NUM_NL80211_BANDS;
10869 band_num++) {
Dundi Raviteja1d019fd2018-09-23 18:18:22 +053010870 if (!wiphy->bands[band_num])
10871 continue;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010872 for (channel_num = 0; channel_num <
10873 wiphy->bands[band_num]->n_channels;
10874 channel_num++) {
10875 wiphy_channel = &(wiphy->bands[band_num]->
10876 channels[channel_num]);
10877 if (wiphy_channel->center_freq == freq) {
10878 rfChannel = wiphy_channel->hw_value;
10879 /*
10880 *Restore the orginal states
10881 *of the channels
10882 */
10883 vos_nv_set_channel_state(
10884 rfChannel,
10885 cache_chann->
10886 channel_info[i].reg_status);
10887 wiphy_channel->flags =
10888 cache_chann->
10889 channel_info[i].wiphy_status;
Ashish Kumar Dhanotiya1cf97dd2019-03-11 16:59:25 +053010890 hddLog(VOS_TRACE_LEVEL_DEBUG,
10891 "Restore channel %d reg_stat %d wiphy_stat 0x%x",
10892 cache_chann->
10893 channel_info[i].channel_num,
10894 cache_chann->
10895 channel_info[i].reg_status,
10896 wiphy_channel->flags);
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010897 break;
10898 }
10899 }
10900 if (channel_num < wiphy->bands[band_num]->n_channels)
10901 break;
10902 }
10903 }
10904
10905 mutex_unlock(&hdd_ctx->cache_channel_lock);
10906
10907 status = sme_update_channel_list((tpAniSirGlobal)hdd_ctx->hHal);
10908 if (status)
10909 hddLog(VOS_TRACE_LEVEL_ERROR, "Can't Restore channel list");
10910 EXIT();
10911
10912 return 0;
10913}
10914
Ashish Kumar Dhanotiya1cf97dd2019-03-11 16:59:25 +053010915int wlan_hdd_disable_channels(hdd_context_t *hdd_ctx)
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010916{
10917 struct hdd_cache_channels *cache_chann;
10918 struct wiphy *wiphy;
10919 int freq, status, rfChannel;
10920 int i, band_num, band_ch_num;
10921 struct ieee80211_channel *wiphy_channel;
10922
10923 if (!hdd_ctx) {
10924 hddLog(VOS_TRACE_LEVEL_FATAL, "HDD Context is NULL");
10925 return -EINVAL;
10926 }
10927
10928 wiphy = hdd_ctx->wiphy;
10929
10930 mutex_lock(&hdd_ctx->cache_channel_lock);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +053010931 cache_chann = hdd_ctx->original_channels;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010932
10933 if (!cache_chann || !cache_chann->num_channels) {
10934 hddLog(VOS_TRACE_LEVEL_INFO,
10935 "%s channel list is NULL or num channels are zero",
10936 __func__);
10937 mutex_unlock(&hdd_ctx->cache_channel_lock);
10938 return -EINVAL;
10939 }
10940
10941 for (i = 0; i < cache_chann->num_channels; i++) {
10942 status = hdd_wlan_get_freq(
10943 cache_chann->channel_info[i].channel_num,
10944 &freq);
10945
Rajeev Kumar Sirasanagandla17b649a2018-03-19 16:58:30 +053010946 for (band_num = 0; band_num < HDD_NUM_NL80211_BANDS;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010947 band_num++) {
Dundi Raviteja1d019fd2018-09-23 18:18:22 +053010948 if (!wiphy->bands[band_num])
10949 continue;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010950 for (band_ch_num = 0; band_ch_num <
10951 wiphy->bands[band_num]->n_channels;
10952 band_ch_num++) {
10953 wiphy_channel = &(wiphy->bands[band_num]->
10954 channels[band_ch_num]);
10955 if (wiphy_channel->center_freq == freq) {
10956 rfChannel = wiphy_channel->hw_value;
10957 /*
10958 * Cache the current states of
10959 * the channels
10960 */
10961 cache_chann->
10962 channel_info[i].reg_status =
10963 vos_nv_getChannelEnabledState(
10964 rfChannel);
10965
10966 cache_chann->
10967 channel_info[i].wiphy_status =
10968 wiphy_channel->flags;
10969 hddLog(VOS_TRACE_LEVEL_INFO,
10970 "Disable channel %d reg_stat %d wiphy_stat 0x%x",
10971 cache_chann->
10972 channel_info[i].channel_num,
10973 cache_chann->
10974 channel_info[i].reg_status,
10975 wiphy_channel->flags);
10976
10977 vos_nv_set_channel_state(
10978 rfChannel,
10979 NV_CHANNEL_DISABLE);
10980 wiphy_channel->flags |=
10981 IEEE80211_CHAN_DISABLED;
10982 break;
10983 }
10984 }
10985 if (band_ch_num < wiphy->bands[band_num]->n_channels)
10986 break;
10987 }
10988 }
10989
10990 mutex_unlock(&hdd_ctx->cache_channel_lock);
10991 sme_update_channel_list((tpAniSirGlobal)hdd_ctx->hHal);
10992 return 0;
10993}
10994
Jeff Johnson295189b2012-06-20 16:38:30 -070010995#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10996static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
10997 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010998#else
10999static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
11000 struct cfg80211_beacon_data *params,
11001 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053011002 enum nl80211_hidden_ssid hidden_ssid,
11003 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011004#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011005{
11006 tsap_Config_t *pConfig;
11007 beacon_data_t *pBeacon = NULL;
11008 struct ieee80211_mgmt *pMgmt_frame;
11009 v_U8_t *pIe=NULL;
11010 v_U16_t capab_info;
11011 eCsrAuthType RSNAuthType;
11012 eCsrEncryptionType RSNEncryptType;
11013 eCsrEncryptionType mcRSNEncryptType;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011014 int status = VOS_STATUS_SUCCESS, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011015 tpWLAN_SAPEventCB pSapEventCallback;
11016 hdd_hostapd_state_t *pHostapdState;
Jeff Johnson295189b2012-06-20 16:38:30 -070011017 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011018 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011019 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053011020 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -070011021 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -080011022 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Vignesh Viswanathan36575f82018-06-14 16:52:21 +053011023 hdd_adapter_t *sta_adapter;
Peng Xu2446a892014-09-05 17:21:18 +053011024 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -070011025 v_BOOL_t MFPCapable = VOS_FALSE;
11026 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +053011027 v_BOOL_t sapEnable11AC =
11028 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Kapil Gupta137ef892016-12-13 19:38:00 +053011029 u_int16_t prev_rsn_length = 0;
11030
Jeff Johnson295189b2012-06-20 16:38:30 -070011031 ENTER();
11032
Nitesh Shah9b066282017-06-06 18:05:52 +053011033 wlan_hdd_tdls_disable_offchan_and_teardown_links(pHddCtx);
Vignesh Viswanathan36575f82018-06-14 16:52:21 +053011034
11035 /*
11036 * For STA+SAP concurrency support from GUI, first STA connection gets
11037 * triggered and while it is in progress, SAP start also comes up.
11038 * Once STA association is successful, STA connect event is sent to
11039 * kernel which gets queued in kernel workqueue and supplicant won't
11040 * process M1 received from AP and send M2 until this NL80211_CONNECT
11041 * event is received. Workqueue is not scheduled as RTNL lock is already
11042 * taken by hostapd thread which has issued start_bss command to driver.
11043 * Driver cannot complete start_bss as the pending command at the head
11044 * of the SME command pending list is hw_mode_update for STA session
11045 * which cannot be processed as SME is in WAITforKey state for STA
11046 * interface. The start_bss command for SAP interface is queued behind
11047 * the hw_mode_update command and so it cannot be processed until
11048 * hw_mode_update command is processed. This is causing a deadlock so
11049 * disconnect the STA interface first if connection or key exchange is
11050 * in progress and then start SAP interface.
11051 */
11052 sta_adapter = hdd_get_sta_connection_in_progress(pHddCtx);
11053 if (sta_adapter) {
11054 hddLog(LOG1, FL("Disconnecting STA with session id: %d"),
11055 sta_adapter->sessionId);
11056 wlan_hdd_disconnect(sta_adapter, eCSR_DISCONNECT_REASON_DEAUTH);
11057 }
11058
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053011059 iniConfig = pHddCtx->cfg_ini;
11060
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011061 /* Mark the indoor channel (passive) to disable */
Sourav Mohapatra8b149332018-03-06 14:28:18 +053011062 if (iniConfig->disable_indoor_channel &&
11063 pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) {
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011064 hdd_update_indoor_channel(pHddCtx, true);
11065
11066 if (!VOS_IS_STATUS_SUCCESS(
11067 sme_update_channel_list((tpAniSirGlobal)pHddCtx->hHal))) {
11068 hdd_update_indoor_channel(pHddCtx, false);
11069 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
11070 FL("Can't start BSS: update channel list failed"));
Bala Venkatesh5c06a252018-07-12 16:08:04 +053011071 ret = eHAL_STATUS_FAILURE;
11072 goto tdls_enable;
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011073 }
Ganesh Kondabattini19813af2018-01-25 17:32:44 +053011074
11075 /* check if STA is on indoor channel */
11076 if (hdd_is_sta_sap_scc_allowed_on_dfs_chan(pHddCtx))
11077 hdd_check_and_disconnect_sta_on_invalid_channel(pHddCtx);
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011078 }
11079
Jeff Johnson295189b2012-06-20 16:38:30 -070011080 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
11081
11082 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
11083
11084 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
11085
11086 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
11087
11088 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
11089
11090 //channel is already set in the set_channel Call back
11091 //pConfig->channel = pCommitConfig->channel;
11092
11093 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011094 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -070011095 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
11096
11097 pConfig->dtim_period = pBeacon->dtim_period;
11098
Arif Hussain6d2a3322013-11-17 19:50:10 -080011099 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -070011100 pConfig->dtim_period);
11101
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -080011102 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -070011103 {
11104 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -070011105 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +053011106 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
11107 {
11108 tANI_BOOLEAN restartNeeded;
11109 pConfig->ieee80211d = 1;
11110 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
11111 sme_setRegInfo(hHal, pConfig->countryCode);
11112 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
11113 }
11114 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -070011115 {
Jeff Johnson32d95a32012-09-10 13:15:23 -070011116 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011117 pConfig->ieee80211d = 1;
11118 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
11119 sme_setRegInfo(hHal, pConfig->countryCode);
11120 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -070011121 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070011122 else
11123 {
11124 pConfig->ieee80211d = 0;
11125 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011126 /*
11127 * If auto channel is configured i.e. channel is 0,
11128 * so skip channel validation.
11129 */
11130 if( AUTO_CHANNEL_SELECT != pConfig->channel )
11131 {
11132 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
11133 {
11134 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011135 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011136 ret = -EINVAL;
11137 goto error;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011138 }
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +053011139 pConfig->user_config_channel = pConfig->channel;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011140 }
11141 else
11142 {
11143 if(1 != pHddCtx->is_dynamic_channel_range_set)
11144 {
11145 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
11146 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
11147 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
11148 }
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +053011149 pHddCtx->is_dynamic_channel_range_set = 0;
11150 pConfig->user_config_channel = SAP_DEFAULT_24GHZ_CHANNEL;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011151 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011152 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070011153 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011154 {
11155 pConfig->ieee80211d = 0;
11156 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053011157
11158#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
11159 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
11160 pConfig->authType = eSAP_OPEN_SYSTEM;
11161 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
11162 pConfig->authType = eSAP_SHARED_KEY;
11163 else
11164 pConfig->authType = eSAP_AUTO_SWITCH;
11165#else
11166 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
11167 pConfig->authType = eSAP_OPEN_SYSTEM;
11168 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
11169 pConfig->authType = eSAP_SHARED_KEY;
11170 else
11171 pConfig->authType = eSAP_AUTO_SWITCH;
11172#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011173
11174 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011175
11176 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -070011177 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053011178#ifdef SAP_AUTH_OFFLOAD
11179 /* In case of sap offload, hostapd.conf is configuted with open mode and
11180 * security is configured from ini file. Due to open mode in hostapd.conf
11181 * privacy bit is set to false which will result in not sending,
11182 * data packets as encrypted.
11183 * If enable_sap_auth_offload is enabled in ini and
11184 * sap_auth_offload_sec_type is type of WPA2-PSK,
11185 * driver will set privacy bit to 1.
11186 */
11187 if (pHddCtx->cfg_ini->enable_sap_auth_offload &&
11188 pHddCtx->cfg_ini->sap_auth_offload_sec_type)
11189 pConfig->privacy = VOS_TRUE;
11190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011191
11192 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
11193
11194 /*Set wps station to configured*/
11195 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
11196
11197 if(pIe)
11198 {
11199 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
11200 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011201 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011202 ret = -EINVAL;
11203 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070011204 }
11205 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
11206 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070011207 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -070011208 /* Check 15 bit of WPS IE as it contain information for wps state
11209 * WPS state
11210 */
11211 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
11212 {
11213 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
11214 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
11215 {
11216 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
11217 }
11218 }
11219 }
11220 else
11221 {
11222 pConfig->wps_state = SAP_WPS_DISABLED;
11223 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011224 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -070011225
c_hpothufe599e92014-06-16 11:38:55 +053011226 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
11227 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
11228 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
11229 eCSR_ENCRYPT_TYPE_NONE;
11230
Jeff Johnson295189b2012-06-20 16:38:30 -070011231 pConfig->RSNWPAReqIELength = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +053011232 memset(&pConfig->RSNWPAReqIE[0], 0, sizeof(pConfig->RSNWPAReqIE));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011233 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -070011234 WLAN_EID_RSN);
11235 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011236 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011237 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053011238 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
11239 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
11240 pConfig->RSNWPAReqIELength);
11241 else
11242 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
11243 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011244 /* The actual processing may eventually be more extensive than
11245 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -070011246 * by the app.
11247 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011248 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -070011249 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
11250 &RSNEncryptType,
11251 &mcRSNEncryptType,
11252 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -080011253 &MFPCapable,
11254 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +053011255 pConfig->RSNWPAReqIE[1]+2,
11256 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011257
11258 if( VOS_STATUS_SUCCESS == status )
11259 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011260 /* Now copy over all the security attributes you have
11261 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -070011262 * */
11263 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
11264 pConfig->mcRSNEncryptType = mcRSNEncryptType;
11265 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
11266 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011267 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -080011268 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011269 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
11270 }
11271 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011272
Jeff Johnson295189b2012-06-20 16:38:30 -070011273 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
11274 pBeacon->tail, pBeacon->tail_len);
11275
11276 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
11277 {
Kapil Gupta137ef892016-12-13 19:38:00 +053011278 if (pConfig->RSNWPAReqIE[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070011279 {
11280 /*Mixed mode WPA/WPA2*/
Kapil Gupta137ef892016-12-13 19:38:00 +053011281 prev_rsn_length = pConfig->RSNWPAReqIELength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011282 pConfig->RSNWPAReqIELength += pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053011283 if (pConfig->RSNWPAReqIELength <=
11284 (sizeof(pConfig->RSNWPAReqIE) - prev_rsn_length))
11285 memcpy(&pConfig->RSNWPAReqIE[0] + prev_rsn_length, pIe,
11286 pIe[1] + 2);
11287 else
11288 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
11289 pConfig->RSNWPAReqIELength);
11290
Jeff Johnson295189b2012-06-20 16:38:30 -070011291 }
11292 else
11293 {
11294 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053011295 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
11296 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
11297 pConfig->RSNWPAReqIELength);
11298 else
11299 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
11300 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011301 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -070011302 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
11303 &RSNEncryptType,
11304 &mcRSNEncryptType,
11305 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -080011306 &MFPCapable,
11307 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +053011308 pConfig->RSNWPAReqIE[1]+2,
11309 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011310
11311 if( VOS_STATUS_SUCCESS == status )
11312 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011313 /* Now copy over all the security attributes you have
11314 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -070011315 * */
11316 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
11317 pConfig->mcRSNEncryptType = mcRSNEncryptType;
11318 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
11319 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011320 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -080011321 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011322 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
11323 }
11324 }
11325 }
11326
Kapil Gupta137ef892016-12-13 19:38:00 +053011327 if (pConfig->RSNWPAReqIELength > sizeof(pConfig->RSNWPAReqIE)) {
Jeff Johnson4416a782013-03-25 14:17:50 -070011328 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011329 ret = -EINVAL;
11330 goto error;
Jeff Johnson4416a782013-03-25 14:17:50 -070011331 }
11332
Jeff Johnson295189b2012-06-20 16:38:30 -070011333 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
11334
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011335#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070011336 if (params->ssid != NULL)
11337 {
11338 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
11339 pConfig->SSIDinfo.ssid.length = params->ssid_len;
11340 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
11341 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
11342 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011343#else
11344 if (ssid != NULL)
11345 {
11346 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
11347 pConfig->SSIDinfo.ssid.length = ssid_len;
11348 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
11349 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
11350 }
11351#endif
11352
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011353 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -070011354 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011355
Jeff Johnson295189b2012-06-20 16:38:30 -070011356 /* default value */
11357 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
11358 pConfig->num_accept_mac = 0;
11359 pConfig->num_deny_mac = 0;
11360
11361 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
11362 pBeacon->tail, pBeacon->tail_len);
11363
11364 /* pIe for black list is following form:
11365 type : 1 byte
11366 length : 1 byte
11367 OUI : 4 bytes
11368 acl type : 1 byte
11369 no of mac addr in black list: 1 byte
11370 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011371 */
11372 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070011373 {
11374 pConfig->SapMacaddr_acl = pIe[6];
11375 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -080011376 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011377 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011378 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
11379 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011380 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
11381 for (i = 0; i < pConfig->num_deny_mac; i++)
11382 {
11383 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
11384 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011386 }
11387 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
11388 pBeacon->tail, pBeacon->tail_len);
11389
11390 /* pIe for white list is following form:
11391 type : 1 byte
11392 length : 1 byte
11393 OUI : 4 bytes
11394 acl type : 1 byte
11395 no of mac addr in white list: 1 byte
11396 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011397 */
11398 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070011399 {
11400 pConfig->SapMacaddr_acl = pIe[6];
11401 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -080011402 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011403 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011404 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
11405 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011406 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
11407 for (i = 0; i < pConfig->num_accept_mac; i++)
11408 {
11409 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
11410 acl_entry++;
11411 }
11412 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011413
Jeff Johnson295189b2012-06-20 16:38:30 -070011414 wlan_hdd_set_sapHwmode(pHostapdAdapter);
11415
Jeff Johnsone7245742012-09-05 17:12:55 -070011416#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -080011417 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +053011418 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
11419 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +053011420 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
11421 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -080011422 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
11423 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +053011424 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
11425 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011426 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +053011427 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -070011428 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +053011429 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011430
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053011431 /* If ACS disable and selected channel <= 14
11432 * OR
11433 * ACS enabled and ACS operating band is choosen as 2.4
11434 * AND
11435 * VHT in 2.4G Disabled
11436 * THEN
11437 * Fallback to 11N mode
11438 */
11439 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
11440 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +053011441 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053011442 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011443 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +053011444 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
11445 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011446 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
11447 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011448 }
11449#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011450
Jeff Johnson295189b2012-06-20 16:38:30 -070011451 // ht_capab is not what the name conveys,this is used for protection bitmap
11452 pConfig->ht_capab =
11453 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
11454
Kapil Gupta137ef892016-12-13 19:38:00 +053011455 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -070011456 {
11457 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011458 ret = -EINVAL;
11459 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070011460 }
11461
11462 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011463 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -070011464 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
11465 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011466 pConfig->obssProtEnabled =
11467 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -070011468
Chet Lanctot8cecea22014-02-11 19:09:36 -080011469#ifdef WLAN_FEATURE_11W
11470 pConfig->mfpCapable = MFPCapable;
11471 pConfig->mfpRequired = MFPRequired;
11472 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
11473 pConfig->mfpCapable, pConfig->mfpRequired);
11474#endif
11475
Arif Hussain6d2a3322013-11-17 19:50:10 -080011476 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -070011477 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -080011478 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
11479 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
11480 (int)pConfig->channel);
11481 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
11482 pConfig->SapHw_mode, pConfig->privacy,
11483 pConfig->authType);
11484 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
11485 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
11486 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
11487 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011488
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011489 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -070011490 {
11491 //Bss already started. just return.
11492 //TODO Probably it should update some beacon params.
11493 hddLog( LOGE, "Bss Already started...Ignore the request");
11494 EXIT();
11495 return 0;
11496 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011497
Agarwal Ashish51325b52014-06-16 16:50:49 +053011498 if (vos_max_concurrent_connections_reached()) {
11499 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011500 ret = -EINVAL;
11501 goto error;
Agarwal Ashish51325b52014-06-16 16:50:49 +053011502 }
11503
Jeff Johnson295189b2012-06-20 16:38:30 -070011504 pConfig->persona = pHostapdAdapter->device_mode;
11505
Peng Xu2446a892014-09-05 17:21:18 +053011506 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
11507 if ( NULL != psmeConfig)
11508 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011509 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +053011510 sme_GetConfigParam(hHal, psmeConfig);
11511 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011512#ifdef WLAN_FEATURE_AP_HT40_24G
11513 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
11514 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
11515 && pHddCtx->cfg_ini->apHT40_24GEnabled)
11516 {
11517 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
11518 sme_UpdateConfig (hHal, psmeConfig);
11519 }
11520#endif
Peng Xu2446a892014-09-05 17:21:18 +053011521 vos_mem_free(psmeConfig);
11522 }
Peng Xuafc34e32014-09-25 13:23:55 +053011523 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +053011524
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011525 set_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
Jeff Johnson295189b2012-06-20 16:38:30 -070011526 pSapEventCallback = hdd_hostapd_SAPEventCB;
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +053011527
11528 vos_event_reset(&pHostapdState->vosEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
11530 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
11531 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011532 hddLog(LOGE,FL("SAP Start Bss fail"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011533 ret = -EINVAL;
11534 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070011535 }
11536
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011537 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011538 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
11539
11540 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011541
Jeff Johnson295189b2012-06-20 16:38:30 -070011542 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011543 {
11544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011545 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -070011546 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070011547 VOS_ASSERT(0);
11548 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011549
Jeff Johnson295189b2012-06-20 16:38:30 -070011550 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053011551 if (WLANSAP_get_sessionId(pVosContext, &pHostapdAdapter->sessionId) !=
11552 VOS_STATUS_SUCCESS)
11553 {
11554 hddLog(LOGE,FL("Fail to get Softap sessionID"));
11555 VOS_ASSERT(0);
11556 }
Kaushik, Sushantf6070802014-10-15 15:09:23 +053011557 /* Initialize WMM configuation */
11558 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +053011559 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011560
Anurag Chouhan83026002016-12-13 22:46:21 +053011561#ifdef DHCP_SERVER_OFFLOAD
11562 /* set dhcp server offload */
11563 if (iniConfig->enable_dhcp_srv_offload &&
11564 sme_IsFeatureSupportedByFW(SAP_OFFLOADS)) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011565 vos_event_reset(&pHostapdAdapter->dhcp_status.vos_event);
Anurag Chouhan638f5e22017-03-06 12:28:43 +053011566 status = wlan_hdd_set_dhcp_server_offload(pHostapdAdapter, false);
Anurag Chouhan83026002016-12-13 22:46:21 +053011567 if (!VOS_IS_STATUS_SUCCESS(status))
11568 {
11569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11570 ("HDD DHCP Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011571 vos_event_reset(&pHostapdState->vosEvent);
11572 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
11573 status = vos_wait_single_event(&pHostapdState->vosEvent,
11574 10000);
11575 if (!VOS_IS_STATUS_SUCCESS(status)) {
11576 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011577 ret = -EINVAL;
11578 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011579 }
11580 }
Anurag Chouhan83026002016-12-13 22:46:21 +053011581 }
Anurag Chouhan83026002016-12-13 22:46:21 +053011582 status = vos_wait_single_event(&pHostapdAdapter->dhcp_status.vos_event, 2000);
11583 if (!VOS_IS_STATUS_SUCCESS(status) || pHostapdAdapter->dhcp_status.dhcp_offload_status)
11584 {
11585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11586 ("ERROR: DHCP HDD vos wait for single_event failed!! %d"),
11587 pHostapdAdapter->dhcp_status.dhcp_offload_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011588 vos_event_reset(&pHostapdState->vosEvent);
11589 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
11590 status = vos_wait_single_event(&pHostapdState->vosEvent,
11591 10000);
11592 if (!VOS_IS_STATUS_SUCCESS(status)) {
11593 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011594 ret = -EINVAL;
11595 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011596 }
11597 }
Anurag Chouhan83026002016-12-13 22:46:21 +053011598 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011599#ifdef MDNS_OFFLOAD
11600 if (iniConfig->enable_mdns_offload) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011601 vos_event_reset(&pHostapdAdapter->mdns_status.vos_event);
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011602 status = wlan_hdd_set_mdns_offload(pHostapdAdapter);
11603 if (VOS_IS_STATUS_SUCCESS(status))
11604 {
11605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11606 ("HDD MDNS Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011607 vos_event_reset(&pHostapdState->vosEvent);
11608 if (VOS_STATUS_SUCCESS ==
11609 WLANSAP_StopBss(pHddCtx->pvosContext)) {
11610 status = vos_wait_single_event(&pHostapdState->vosEvent,
11611 10000);
11612 if (!VOS_IS_STATUS_SUCCESS(status)) {
11613 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011614 ret = -EINVAL;
11615 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011616 }
11617 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011618 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011619 status = vos_wait_single_event(&pHostapdAdapter->
11620 mdns_status.vos_event, 2000);
11621 if (!VOS_IS_STATUS_SUCCESS(status) ||
11622 pHostapdAdapter->mdns_status.mdns_enable_status ||
11623 pHostapdAdapter->mdns_status.mdns_fqdn_status ||
11624 pHostapdAdapter->mdns_status.mdns_resp_status)
11625 {
11626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11627 ("MDNS HDD vos wait for single_event failed!! enable %d fqdn %d resp %d"),
11628 pHostapdAdapter->mdns_status.mdns_enable_status,
11629 pHostapdAdapter->mdns_status.mdns_fqdn_status,
11630 pHostapdAdapter->mdns_status.mdns_resp_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011631 vos_event_reset(&pHostapdState->vosEvent);
11632 if (VOS_STATUS_SUCCESS ==
11633 WLANSAP_StopBss(pHddCtx->pvosContext)) {
11634 status = vos_wait_single_event(&pHostapdState->vosEvent,
11635 10000);
11636 if (!VOS_IS_STATUS_SUCCESS(status)) {
11637 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011638 ret = -EINVAL;
11639 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011640 }
11641 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011642 }
11643 }
11644#endif /* MDNS_OFFLOAD */
11645 } else {
11646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11647 ("DHCP Disabled ini %d, FW %d"),
11648 iniConfig->enable_dhcp_srv_offload,
11649 sme_IsFeatureSupportedByFW(SAP_OFFLOADS));
Anurag Chouhan83026002016-12-13 22:46:21 +053011650 }
11651#endif /* DHCP_SERVER_OFFLOAD */
11652
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011653#ifdef WLAN_FEATURE_P2P_DEBUG
11654 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
11655 {
11656 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
11657 {
11658 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
11659 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -080011660 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011661 }
11662 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
11663 {
11664 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
11665 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -080011666 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011667 }
11668 }
11669#endif
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +053011670 /* Check and restart SAP if it is on Unsafe channel */
11671 hdd_check_for_unsafe_ch(pHostapdAdapter, pHddCtx);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011672
Jeff Johnson295189b2012-06-20 16:38:30 -070011673 pHostapdState->bCommit = TRUE;
11674 EXIT();
11675
11676 return 0;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011677error:
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011678 /* Revert the indoor to passive marking if START BSS fails */
Sourav Mohapatra8b149332018-03-06 14:28:18 +053011679 if (iniConfig->disable_indoor_channel &&
11680 pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) {
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011681 hdd_update_indoor_channel(pHddCtx, false);
11682 sme_update_channel_list((tpAniSirGlobal)pHddCtx->hHal);
11683 }
11684
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011685 clear_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
Bala Venkatesh5c06a252018-07-12 16:08:04 +053011686
11687tdls_enable:
11688 if (ret != eHAL_STATUS_SUCCESS)
11689 wlan_hdd_tdls_reenable(pHddCtx);
11690
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011691 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070011692}
11693
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011694#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011695static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011696 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 struct beacon_parameters *params)
11698{
11699 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011700 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011701 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011702
11703 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011704
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011705 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11706 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
11707 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011708 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
11709 hdd_device_modetoString(pAdapter->device_mode),
11710 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011711
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011712 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11713 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011714 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011715 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011716 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011717 }
11718
Agarwal Ashish51325b52014-06-16 16:50:49 +053011719 if (vos_max_concurrent_connections_reached()) {
11720 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
11721 return -EINVAL;
11722 }
11723
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011724 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011725 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070011726 )
11727 {
11728 beacon_data_t *old,*new;
11729
11730 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011731
Jeff Johnson295189b2012-06-20 16:38:30 -070011732 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011733 {
11734 hddLog(VOS_TRACE_LEVEL_WARN,
11735 FL("already beacon info added to session(%d)"),
11736 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070011737 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011739
11740 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
11741
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011742 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -070011743 {
11744 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011745 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011746 return -EINVAL;
11747 }
11748
11749 pAdapter->sessionCtx.ap.beacon = new;
11750
11751 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
11752 }
11753
11754 EXIT();
11755 return status;
11756}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011757
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011758static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
11759 struct net_device *dev,
11760 struct beacon_parameters *params)
11761{
11762 int ret;
11763
11764 vos_ssr_protect(__func__);
11765 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
11766 vos_ssr_unprotect(__func__);
11767
11768 return ret;
11769}
11770
11771static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011772 struct net_device *dev,
11773 struct beacon_parameters *params)
11774{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011775 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011776 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11777 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011778 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011779
11780 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011781
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011782 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11783 TRACE_CODE_HDD_CFG80211_SET_BEACON,
11784 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
11785 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11786 __func__, hdd_device_modetoString(pAdapter->device_mode),
11787 pAdapter->device_mode);
11788
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011789 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11790 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011791 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011792 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011793 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011794 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011795
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011796 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011797 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011798 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 {
11800 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011801
Jeff Johnson295189b2012-06-20 16:38:30 -070011802 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011803
Jeff Johnson295189b2012-06-20 16:38:30 -070011804 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011805 {
11806 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11807 FL("session(%d) old and new heads points to NULL"),
11808 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070011809 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011810 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011811
11812 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
11813
11814 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011815 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011816 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011817 return -EINVAL;
11818 }
11819
11820 pAdapter->sessionCtx.ap.beacon = new;
11821
11822 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
11823 }
11824
11825 EXIT();
11826 return status;
11827}
11828
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011829static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
11830 struct net_device *dev,
11831 struct beacon_parameters *params)
11832{
11833 int ret;
11834
11835 vos_ssr_protect(__func__);
11836 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
11837 vos_ssr_unprotect(__func__);
11838
11839 return ret;
11840}
11841
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011842#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
11843
11844#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011845static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011846 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011847#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011848static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011849 struct net_device *dev)
11850#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011851{
11852 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Vignesh Viswanathan5caacc22018-06-14 17:14:20 +053011853 hdd_adapter_t *staAdapter = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070011854 hdd_context_t *pHddCtx = NULL;
11855 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011856 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011857 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070011858
11859 ENTER();
11860
11861 if (NULL == pAdapter)
11862 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011863 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011864 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 return -ENODEV;
11866 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011867
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011868 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11869 TRACE_CODE_HDD_CFG80211_STOP_AP,
11870 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011871 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11872 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011873 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011874 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011875 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -070011876 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011877
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011878 pScanInfo = &pHddCtx->scan_info;
11879
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011880 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11881 __func__, hdd_device_modetoString(pAdapter->device_mode),
11882 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011883
Vignesh Viswanathan5caacc22018-06-14 17:14:20 +053011884 /*
11885 * if a sta connection is in progress in another adapter, disconnect
11886 * the sta and complete the sap operation. sta will reconnect
11887 * after sap stop is done.
11888 */
11889 staAdapter = hdd_get_sta_connection_in_progress(pHddCtx);
11890 if (staAdapter) {
11891 hddLog(LOG1, FL("disconnecting sta with session id: %d"),
11892 staAdapter->sessionId);
11893 wlan_hdd_disconnect(staAdapter, eCSR_DISCONNECT_REASON_DEAUTH);
11894 }
11895
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011896 ret = wlan_hdd_scan_abort(pAdapter);
11897
Girish Gowli4bf7a632014-06-12 13:42:11 +053011898 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -070011899 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011900 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11901 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011902
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011903 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -070011904 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11906 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -080011907
Jeff Johnsone7245742012-09-05 17:12:55 -070011908 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011909 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -070011910 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011911 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070011912 }
11913
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053011914 /* Delete all associated STAs before stopping AP/P2P GO */
11915 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +053011916 hdd_hostapd_stop(dev);
11917
Jeff Johnson295189b2012-06-20 16:38:30 -070011918 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070011920 )
11921 {
11922 beacon_data_t *old;
11923
11924 old = pAdapter->sessionCtx.ap.beacon;
11925
11926 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011927 {
11928 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11929 FL("session(%d) beacon data points to NULL"),
11930 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070011931 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011933
Jeff Johnson295189b2012-06-20 16:38:30 -070011934 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011935
11936 mutex_lock(&pHddCtx->sap_lock);
11937 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
11938 {
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +053011939 hdd_hostapd_state_t *pHostapdState =
11940 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
11941
Abhishek Singh10e17cf2018-03-12 14:34:22 +053011942 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
11943 hdd_wait_for_ecsa_complete(pHddCtx);
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +053011944 vos_event_reset(&pHostapdState->vosEvent);
11945
Jeff Johnson4416a782013-03-25 14:17:50 -070011946 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011947 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
11949
11950 if (!VOS_IS_STATUS_SUCCESS(status))
11951 {
11952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011953 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011954 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011955 }
11956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011957 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +053011958 /* BSS stopped, clear the active sessions for this device mode */
11959 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011960 }
11961 mutex_unlock(&pHddCtx->sap_lock);
11962
11963 if(status != VOS_STATUS_SUCCESS)
11964 {
11965 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011966 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011967 return -EINVAL;
11968 }
11969
Jeff Johnson4416a782013-03-25 14:17:50 -070011970 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070011971 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
11972 ==eHAL_STATUS_FAILURE)
11973 {
11974 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011975 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070011976 }
11977
Jeff Johnson4416a782013-03-25 14:17:50 -070011978 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070011979 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
11980 eANI_BOOLEAN_FALSE) )
11981 {
11982 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011983 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070011984 }
11985
11986 // Reset WNI_CFG_PROBE_RSP Flags
11987 wlan_hdd_reset_prob_rspies(pAdapter);
11988
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011989 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
11990
Jeff Johnson295189b2012-06-20 16:38:30 -070011991 pAdapter->sessionCtx.ap.beacon = NULL;
11992 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011993#ifdef WLAN_FEATURE_P2P_DEBUG
11994 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
11995 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
11996 {
11997 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
11998 "GO got removed");
11999 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
12000 }
12001#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012002 }
12003 EXIT();
12004 return status;
12005}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012006
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012007#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
12008static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
12009 struct net_device *dev)
12010{
12011 int ret;
12012
12013 vos_ssr_protect(__func__);
12014 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
12015 vos_ssr_unprotect(__func__);
12016
12017 return ret;
12018}
12019#else
12020static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
12021 struct net_device *dev)
12022{
12023 int ret;
12024
12025 vos_ssr_protect(__func__);
12026 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
12027 vos_ssr_unprotect(__func__);
12028
12029 return ret;
12030}
12031#endif
12032
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012033#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
12034
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012035static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012036 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012037 struct cfg80211_ap_settings *params)
12038{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012039 hdd_adapter_t *pAdapter;
12040 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012041 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012042
12043 ENTER();
12044
Girish Gowlib143d7a2015-02-18 19:39:55 +053012045 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070012046 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012047 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +053012048 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012049 return -ENODEV;
12050 }
12051
12052 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12053 if (NULL == pAdapter)
12054 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012055 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012056 "%s: HDD adapter is Null", __func__);
12057 return -ENODEV;
12058 }
12059
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012060 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12061 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
12062 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012063 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
12064 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012066 "%s: HDD adapter magic is invalid", __func__);
12067 return -ENODEV;
12068 }
12069
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053012070 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
12071
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012072 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012073 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012074 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012075 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012076 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012077 }
12078
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012079 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
12080 __func__, hdd_device_modetoString(pAdapter->device_mode),
12081 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012082
12083 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012084 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012085 )
12086 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012087 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012088
12089 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012090
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012091 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012092 {
12093 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
12094 FL("already beacon info added to session(%d)"),
12095 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012096 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012097 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012098
Girish Gowlib143d7a2015-02-18 19:39:55 +053012099#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
12100 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
12101 &new,
12102 &params->beacon);
12103#else
12104 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
12105 &new,
12106 &params->beacon,
12107 params->dtim_period);
12108#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012109
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012110 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012111 {
12112 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012113 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012114 return -EINVAL;
12115 }
12116 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -080012117#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -070012118 wlan_hdd_cfg80211_set_channel(wiphy, dev,
12119#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
12120 params->channel, params->channel_type);
12121#else
12122 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
12123#endif
Viral Modi3a32cc52013-02-08 11:14:52 -080012124#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012125 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053012126 params->ssid_len, params->hidden_ssid,
12127 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012128 }
12129
12130 EXIT();
12131 return status;
12132}
12133
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012134static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
12135 struct net_device *dev,
12136 struct cfg80211_ap_settings *params)
12137{
12138 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012139
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012140 vos_ssr_protect(__func__);
12141 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
12142 vos_ssr_unprotect(__func__);
12143
12144 return ret;
12145}
12146
12147static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012148 struct net_device *dev,
12149 struct cfg80211_beacon_data *params)
12150{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012151 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012152 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012153 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012154
12155 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012156
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012157 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12158 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
12159 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -080012160 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012161 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012162
12163 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12164 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012165 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070012166 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012167 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070012168 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012169
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012170 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012171 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012172 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012173 {
12174 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012175
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012176 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012177
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012178 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012179 {
12180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12181 FL("session(%d) beacon data points to NULL"),
12182 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012183 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012184 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012185
12186 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
12187
12188 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012189 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012190 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012191 return -EINVAL;
12192 }
12193
12194 pAdapter->sessionCtx.ap.beacon = new;
12195
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053012196 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
12197 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012198 }
12199
12200 EXIT();
12201 return status;
12202}
12203
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012204static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
12205 struct net_device *dev,
12206 struct cfg80211_beacon_data *params)
12207{
12208 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012209
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012210 vos_ssr_protect(__func__);
12211 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
12212 vos_ssr_unprotect(__func__);
12213
12214 return ret;
12215}
12216
12217#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070012218
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012219static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 struct net_device *dev,
12221 struct bss_parameters *params)
12222{
12223 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012224 hdd_context_t *pHddCtx;
12225 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012226
12227 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012228
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012229 if (NULL == pAdapter)
12230 {
12231 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12232 "%s: HDD adapter is Null", __func__);
12233 return -ENODEV;
12234 }
12235 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012236 ret = wlan_hdd_validate_context(pHddCtx);
12237 if (0 != ret)
12238 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012239 return ret;
12240 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012241 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12242 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
12243 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012244 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12245 __func__, hdd_device_modetoString(pAdapter->device_mode),
12246 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012247
12248 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012249 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012250 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012251 {
12252 /* ap_isolate == -1 means that in change bss, upper layer doesn't
12253 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012254 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -070012255 {
12256 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012257 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012258 }
12259
12260 EXIT();
12261 return 0;
12262}
12263
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012264static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
12265 struct net_device *dev,
12266 struct bss_parameters *params)
12267{
12268 int ret;
12269
12270 vos_ssr_protect(__func__);
12271 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
12272 vos_ssr_unprotect(__func__);
12273
12274 return ret;
12275}
Kiet Lam10841362013-11-01 11:36:50 +053012276/* FUNCTION: wlan_hdd_change_country_code_cd
12277* to wait for contry code completion
12278*/
12279void* wlan_hdd_change_country_code_cb(void *pAdapter)
12280{
12281 hdd_adapter_t *call_back_pAdapter = pAdapter;
12282 complete(&call_back_pAdapter->change_country_code);
12283 return NULL;
12284}
12285
Jeff Johnson295189b2012-06-20 16:38:30 -070012286/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053012287 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -070012288 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
12289 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053012290int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 struct net_device *ndev,
12292 enum nl80211_iftype type,
12293 u32 *flags,
12294 struct vif_params *params
12295 )
12296{
12297 struct wireless_dev *wdev;
12298 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012299 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 tCsrRoamProfile *pRoamProfile = NULL;
Sourav Mohapatra85ef5062018-11-13 14:02:20 +053012301 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012302 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012303 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012304 eMib_dot11DesiredBssType connectedBssType;
12305 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012306 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012307
12308 ENTER();
12309
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012310 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012311 {
12312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12313 "%s: Adapter context is null", __func__);
12314 return VOS_STATUS_E_FAILURE;
12315 }
12316
12317 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12318 if (!pHddCtx)
12319 {
12320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12321 "%s: HDD context is null", __func__);
12322 return VOS_STATUS_E_FAILURE;
12323 }
12324
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012325 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12326 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
12327 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012328 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012329 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012330 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012331 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 }
12333
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012334 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12335 __func__, hdd_device_modetoString(pAdapter->device_mode),
12336 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012337
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053012338 if (pHddCtx->concurrency_mode == VOS_STA_MON) {
12339 hddLog(VOS_TRACE_LEVEL_FATAL,
12340 "%s: STA + MON is in progress, cannot change interface",
12341 __func__);
12342 }
12343
Agarwal Ashish51325b52014-06-16 16:50:49 +053012344 if (vos_max_concurrent_connections_reached()) {
12345 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12346 return -EINVAL;
12347 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012348 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070012349 wdev = ndev->ieee80211_ptr;
12350
12351#ifdef WLAN_BTAMP_FEATURE
12352 if((NL80211_IFTYPE_P2P_CLIENT == type)||
12353 (NL80211_IFTYPE_ADHOC == type)||
12354 (NL80211_IFTYPE_AP == type)||
12355 (NL80211_IFTYPE_P2P_GO == type))
12356 {
12357 pHddCtx->isAmpAllowed = VOS_FALSE;
12358 // stop AMP traffic
12359 status = WLANBAP_StopAmp();
12360 if(VOS_STATUS_SUCCESS != status )
12361 {
12362 pHddCtx->isAmpAllowed = VOS_TRUE;
12363 hddLog(VOS_TRACE_LEVEL_FATAL,
12364 "%s: Failed to stop AMP", __func__);
12365 return -EINVAL;
12366 }
12367 }
12368#endif //WLAN_BTAMP_FEATURE
12369 /* Reset the current device mode bit mask*/
12370 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
12371
Bala Venkatesh5c06a252018-07-12 16:08:04 +053012372 if (((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
12373 (type == NL80211_IFTYPE_P2P_CLIENT || type == NL80211_IFTYPE_P2P_GO)) ||
12374 type == NL80211_IFTYPE_AP)
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053012375 {
12376 /* Notify Mode change in case of concurrency.
12377 * Below function invokes TDLS teardown Functionality Since TDLS is
12378 * not Supported in case of concurrency i.e Once P2P session
12379 * is detected disable offchannel and teardown TDLS links
12380 */
12381 hddLog(LOG1,
12382 FL("Device mode = %d Interface type = %d"),
12383 pAdapter->device_mode, type);
12384 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
12385 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053012386
Jeff Johnson295189b2012-06-20 16:38:30 -070012387 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070012388 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070012389 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070012390 )
12391 {
12392 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012393 if (!pWextState)
12394 {
12395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12396 "%s: pWextState is null", __func__);
12397 return VOS_STATUS_E_FAILURE;
12398 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012399 pRoamProfile = &pWextState->roamProfile;
12400 LastBSSType = pRoamProfile->BSSType;
12401
12402 switch (type)
12403 {
12404 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070012405 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070012406 hddLog(VOS_TRACE_LEVEL_INFO,
12407 "%s: setting interface Type to INFRASTRUCTURE", __func__);
12408 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070012409#ifdef WLAN_FEATURE_11AC
12410 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
12411 {
12412 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
12413 }
12414#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012415 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070012416 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012417 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080012418 //Check for sub-string p2p to confirm its a p2p interface
12419 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012420 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053012421#ifdef FEATURE_WLAN_TDLS
12422 mutex_lock(&pHddCtx->tdls_lock);
12423 wlan_hdd_tdls_exit(pAdapter, TRUE);
12424 mutex_unlock(&pHddCtx->tdls_lock);
12425#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080012426 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
12427 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
12428 }
12429 else
12430 {
12431 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070012432 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080012433 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012434 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053012435
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 case NL80211_IFTYPE_ADHOC:
12437 hddLog(VOS_TRACE_LEVEL_INFO,
12438 "%s: setting interface Type to ADHOC", __func__);
12439 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
12440 pRoamProfile->phyMode =
12441 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070012442 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012443 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053012444 hdd_set_ibss_ops( pAdapter );
12445 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053012446
12447 status = hdd_sta_id_hash_attach(pAdapter);
12448 if (VOS_STATUS_SUCCESS != status) {
12449 hddLog(VOS_TRACE_LEVEL_ERROR,
12450 FL("Failed to initialize hash for IBSS"));
12451 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012452 break;
12453
12454 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070012455 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070012456 {
12457 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
12458 "%s: setting interface Type to %s", __func__,
12459 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
12460
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080012461 //Cancel any remain on channel for GO mode
12462 if (NL80211_IFTYPE_P2P_GO == type)
12463 {
12464 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
12465 }
Sourav Mohapatra85ef5062018-11-13 14:02:20 +053012466 if (NL80211_IFTYPE_AP == type)
12467 {
12468 /*
12469 * As Loading WLAN Driver one interface being created
12470 * for p2p device address. This will take one HW STA and
12471 * the max number of clients that can connect to softAP
12472 * will be reduced by one. so while changing the interface
12473 * type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 interface
12474 * as it is not required in SoftAP mode.
12475 */
12476
12477 // Get P2P Adapter
12478 pP2pAdapter = hdd_get_adapter(pHddCtx,
12479 WLAN_HDD_P2P_DEVICE);
12480 if (pP2pAdapter)
12481 {
Min Liuf3481952018-12-10 16:01:14 +080012482 wlan_hdd_release_intf_addr(pHddCtx,
12483 pP2pAdapter->macAddressCurrent.bytes);
Sourav Mohapatra85ef5062018-11-13 14:02:20 +053012484 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
12485 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
12486 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
12487 }
12488 }
12489
Swaroop Goltia2e32212014-04-09 23:37:33 +053012490 //Disable IMPS & BMPS for SAP/GO
12491 if(VOS_STATUS_E_FAILURE ==
12492 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
12493 {
12494 //Fail to Exit BMPS
12495 VOS_ASSERT(0);
12496 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053012497
12498 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
12499
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012500#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070012501
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012502 /* A Mutex Lock is introduced while changing the mode to
12503 * protect the concurrent access for the Adapters by TDLS
12504 * module.
12505 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012506 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012507#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012508 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053012509 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012510 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070012511 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
12512 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012513#ifdef FEATURE_WLAN_TDLS
12514 mutex_unlock(&pHddCtx->tdls_lock);
12515#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070012516 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
12517 (pConfig->apRandomBssidEnabled))
12518 {
12519 /* To meet Android requirements create a randomized
12520 MAC address of the form 02:1A:11:Fx:xx:xx */
12521 get_random_bytes(&ndev->dev_addr[3], 3);
12522 ndev->dev_addr[0] = 0x02;
12523 ndev->dev_addr[1] = 0x1A;
12524 ndev->dev_addr[2] = 0x11;
12525 ndev->dev_addr[3] |= 0xF0;
12526 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
12527 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080012528 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
12529 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070012530 }
12531
Jeff Johnson295189b2012-06-20 16:38:30 -070012532 hdd_set_ap_ops( pAdapter->dev );
12533
Kiet Lam10841362013-11-01 11:36:50 +053012534 /* This is for only SAP mode where users can
12535 * control country through ini.
12536 * P2P GO follows station country code
12537 * acquired during the STA scanning. */
12538 if((NL80211_IFTYPE_AP == type) &&
12539 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
12540 {
12541 int status = 0;
12542 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
12543 "%s: setting country code from INI ", __func__);
12544 init_completion(&pAdapter->change_country_code);
12545 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
12546 (void *)(tSmeChangeCountryCallback)
12547 wlan_hdd_change_country_code_cb,
12548 pConfig->apCntryCode, pAdapter,
12549 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053012550 eSIR_FALSE,
12551 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053012552 if (eHAL_STATUS_SUCCESS == status)
12553 {
12554 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012555 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053012556 &pAdapter->change_country_code,
12557 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012558 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053012559 {
12560 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012561 FL("SME Timed out while setting country code %ld"),
12562 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080012563
12564 if (pHddCtx->isLogpInProgress)
12565 {
12566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12567 "%s: LOGP in Progress. Ignore!!!", __func__);
12568 return -EAGAIN;
12569 }
Kiet Lam10841362013-11-01 11:36:50 +053012570 }
12571 }
12572 else
12573 {
12574 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012575 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053012576 return -EINVAL;
12577 }
12578 }
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +053012579 status = hdd_init_ap_mode(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -070012580 if(status != VOS_STATUS_SUCCESS)
12581 {
12582 hddLog(VOS_TRACE_LEVEL_FATAL,
12583 "%s: Error initializing the ap mode", __func__);
12584 return -EINVAL;
12585 }
12586 hdd_set_conparam(1);
12587
Nirav Shah7e3c8132015-06-22 23:51:42 +053012588 status = hdd_sta_id_hash_attach(pAdapter);
12589 if (VOS_STATUS_SUCCESS != status)
12590 {
12591 hddLog(VOS_TRACE_LEVEL_ERROR,
12592 FL("Failed to initialize hash for AP"));
12593 return -EINVAL;
12594 }
12595
Jeff Johnson295189b2012-06-20 16:38:30 -070012596 /*interface type changed update in wiphy structure*/
12597 if(wdev)
12598 {
12599 wdev->iftype = type;
12600 pHddCtx->change_iface = type;
12601 }
12602 else
12603 {
12604 hddLog(VOS_TRACE_LEVEL_ERROR,
12605 "%s: ERROR !!!! Wireless dev is NULL", __func__);
12606 return -EINVAL;
12607 }
12608 goto done;
12609 }
12610
12611 default:
12612 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
12613 __func__);
12614 return -EOPNOTSUPP;
12615 }
12616 }
12617 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012618 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070012619 )
12620 {
12621 switch(type)
12622 {
12623 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053012626
Sourav Mohapatra85ef5062018-11-13 14:02:20 +053012627 if (pAdapter->device_mode == WLAN_HDD_SOFTAP
12628 && !hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE)) {
12629 /*
12630 * The p2p interface was deleted while SoftAP mode was init,
12631 * create that interface now that the SoftAP is going down.
12632 */
12633 pP2pAdapter = hdd_open_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE,
12634 "p2p%d", wlan_hdd_get_intf_addr(pHddCtx),
12635 VOS_TRUE);
12636 }
12637
Deepthi Gowri500fc472014-08-11 19:53:10 +053012638 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Sourav Mohapatra85ef5062018-11-13 14:02:20 +053012639
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012640#ifdef FEATURE_WLAN_TDLS
12641
12642 /* A Mutex Lock is introduced while changing the mode to
12643 * protect the concurrent access for the Adapters by TDLS
12644 * module.
12645 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012646 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012647#endif
c_hpothu002231a2015-02-05 14:58:51 +053012648 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080012650 //Check for sub-string p2p to confirm its a p2p interface
12651 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080012652 {
12653 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
12654 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
12655 }
12656 else
12657 {
12658 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070012659 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080012660 }
Agrawal Ashishcfe83282016-09-29 13:03:45 +053012661
12662 /* set con_mode to STA only when no SAP concurrency mode */
12663 if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO)))
12664 hdd_set_conparam(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012665 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070012666 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
12667 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012668#ifdef FEATURE_WLAN_TDLS
12669 mutex_unlock(&pHddCtx->tdls_lock);
12670#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053012671 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070012672 if( VOS_STATUS_SUCCESS != status )
12673 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070012674 /* In case of JB, for P2P-GO, only change interface will be called,
12675 * This is the right place to enable back bmps_imps()
12676 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012677 if (pHddCtx->hdd_wlan_suspended)
12678 {
12679 hdd_set_pwrparams(pHddCtx);
12680 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012681 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070012682 goto done;
12683 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070012684 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070012685 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070012686 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
12687 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012688 goto done;
12689 default:
12690 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
12691 __func__);
12692 return -EOPNOTSUPP;
12693
12694 }
12695
12696 }
12697 else
12698 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012699 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
12700 __func__, hdd_device_modetoString(pAdapter->device_mode),
12701 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012702 return -EOPNOTSUPP;
12703 }
12704
12705
12706 if(pRoamProfile)
12707 {
12708 if ( LastBSSType != pRoamProfile->BSSType )
12709 {
12710 /*interface type changed update in wiphy structure*/
12711 wdev->iftype = type;
12712
12713 /*the BSS mode changed, We need to issue disconnect
12714 if connected or in IBSS disconnect state*/
12715 if ( hdd_connGetConnectedBssType(
12716 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
12717 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
12718 {
12719 /*need to issue a disconnect to CSR.*/
12720 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12721 if( eHAL_STATUS_SUCCESS ==
12722 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12723 pAdapter->sessionId,
12724 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12725 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012726 ret = wait_for_completion_interruptible_timeout(
12727 &pAdapter->disconnect_comp_var,
12728 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12729 if (ret <= 0)
12730 {
12731 hddLog(VOS_TRACE_LEVEL_ERROR,
12732 FL("wait on disconnect_comp_var failed %ld"), ret);
12733 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 }
12735 }
12736 }
12737 }
12738
12739done:
12740 /*set bitmask based on updated value*/
12741 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070012742
12743 /* Only STA mode support TM now
12744 * all other mode, TM feature should be disabled */
12745 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
12746 (~VOS_STA & pHddCtx->concurrency_mode) )
12747 {
12748 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
12749 }
12750
Jeff Johnson295189b2012-06-20 16:38:30 -070012751#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012752 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012753 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070012754 {
12755 //we are ok to do AMP
12756 pHddCtx->isAmpAllowed = VOS_TRUE;
12757 }
12758#endif //WLAN_BTAMP_FEATURE
12759 EXIT();
12760 return 0;
12761}
12762
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053012763/*
12764 * FUNCTION: wlan_hdd_cfg80211_change_iface
12765 * wrapper function to protect the actual implementation from SSR.
12766 */
12767int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
12768 struct net_device *ndev,
12769 enum nl80211_iftype type,
12770 u32 *flags,
12771 struct vif_params *params
12772 )
12773{
12774 int ret;
12775
12776 vos_ssr_protect(__func__);
12777 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
12778 vos_ssr_unprotect(__func__);
12779
12780 return ret;
12781}
12782
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012783#ifdef FEATURE_WLAN_TDLS
12784static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012785 struct net_device *dev,
12786#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12787 const u8 *mac,
12788#else
12789 u8 *mac,
12790#endif
12791 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012792{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012793 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012794 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012795 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012796 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012797 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053012798 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012799
12800 ENTER();
12801
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012802 if (!dev) {
12803 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
12804 return -EINVAL;
12805 }
12806
12807 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12808 if (!pAdapter) {
12809 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
12810 return -EINVAL;
12811 }
12812
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053012813 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012814 {
12815 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12816 "Invalid arguments");
12817 return -EINVAL;
12818 }
Hoonki Lee27511902013-03-14 18:19:06 -070012819
12820 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
12821 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
12822 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012823 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070012824 "%s: TDLS mode is disabled OR not enabled in FW."
12825 MAC_ADDRESS_STR " Request declined.",
12826 __func__, MAC_ADDR_ARRAY(mac));
12827 return -ENOTSUPP;
12828 }
12829
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012830 if (pHddCtx->isLogpInProgress)
12831 {
12832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12833 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053012834 wlan_hdd_tdls_set_link_status(pAdapter,
12835 mac,
12836 eTDLS_LINK_IDLE,
12837 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012838 return -EBUSY;
12839 }
12840
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053012841 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053012842 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012843
12844 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012845 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012846 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
12847 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053012848 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012849 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070012850 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012851
12852 /* in add station, we accept existing valid staId if there is */
12853 if ((0 == update) &&
12854 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
12855 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012856 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012857 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012858 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012859 " link_status %d. staId %d. add station ignored.",
12860 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012861 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012862 return 0;
12863 }
12864 /* in change station, we accept only when staId is valid */
12865 if ((1 == update) &&
12866 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
12867 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
12868 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012869 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012870 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012871 "%s: " MAC_ADDRESS_STR
12872 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012873 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
12874 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
12875 mutex_unlock(&pHddCtx->tdls_lock);
12876 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012877 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012878 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070012879
12880 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053012881 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012882 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012883 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12884 "%s: " MAC_ADDRESS_STR
12885 " TDLS setup is ongoing. Request declined.",
12886 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070012887 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012888 }
12889
12890 /* first to check if we reached to maximum supported TDLS peer.
12891 TODO: for now, return -EPERM looks working fine,
12892 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012893 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
12894 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012895 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012896 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12897 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012898 " TDLS Max peer already connected. Request declined."
12899 " Num of peers (%d), Max allowed (%d).",
12900 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
12901 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070012902 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012903 }
12904 else
12905 {
12906 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012907 mutex_lock(&pHddCtx->tdls_lock);
12908 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012909 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012910 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012911 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012912 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12913 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
12914 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012915 return -EPERM;
12916 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012917 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012918 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012919 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053012920 wlan_hdd_tdls_set_link_status(pAdapter,
12921 mac,
12922 eTDLS_LINK_CONNECTING,
12923 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012924
Jeff Johnsond75fe012013-04-06 10:53:06 -070012925 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053012926 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012927 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012929 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070012930 if(StaParams->htcap_present)
12931 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070012933 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070012935 "ht_capa->extended_capabilities: %0x",
12936 StaParams->HTCap.extendedHtCapInfo);
12937 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012939 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012941 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070012942 if(StaParams->vhtcap_present)
12943 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070012945 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
12946 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
12947 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
12948 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012949 {
12950 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012951 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012952 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012954 "[%d]: %x ", i, StaParams->supported_rates[i]);
12955 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070012956 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053012957 else if ((1 == update) && (NULL == StaParams))
12958 {
12959 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12960 "%s : update is true, but staParams is NULL. Error!", __func__);
12961 return -EPERM;
12962 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012963
12964 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
12965
12966 if (!update)
12967 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053012968 /*Before adding sta make sure that device exited from BMPS*/
12969 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
12970 {
12971 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12972 "%s: Adding tdls peer sta. Disable BMPS", __func__);
12973 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
12974 if (status != VOS_STATUS_SUCCESS) {
12975 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
12976 }
12977 }
12978
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012979 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012980 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012981 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053012982 hddLog(VOS_TRACE_LEVEL_ERROR,
12983 FL("Failed to add TDLS peer STA. Enable Bmps"));
12984 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012985 return -EPERM;
12986 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012987 }
12988 else
12989 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012990 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012991 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012992 if (ret != eHAL_STATUS_SUCCESS) {
12993 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
12994 return -EPERM;
12995 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012996 }
12997
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012998 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012999 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
13000
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053013001 mutex_lock(&pHddCtx->tdls_lock);
13002 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
13003
Masti, Narayanraddi07262462016-01-19 12:40:06 +053013004 if ((pTdlsPeer != NULL) &&
13005 (pTdlsPeer->link_status == eTDLS_LINK_TEARING))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013006 {
Masti, Narayanraddi07262462016-01-19 12:40:06 +053013007 hddLog(VOS_TRACE_LEVEL_ERROR,
13008 FL("peer link status %u"), pTdlsPeer->link_status);
13009 mutex_unlock(&pHddCtx->tdls_lock);
13010 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013011 }
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053013012 mutex_unlock(&pHddCtx->tdls_lock);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013013
Masti, Narayanraddi07262462016-01-19 12:40:06 +053013014 if (ret <= 0)
13015 {
13016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13017 "%s: timeout waiting for tdls add station indication %ld",
13018 __func__, ret);
13019 goto error;
13020 }
13021
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013022 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
13023 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013025 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013026 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013027 }
13028
13029 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070013030
13031error:
Atul Mittal115287b2014-07-08 13:26:33 +053013032 wlan_hdd_tdls_set_link_status(pAdapter,
13033 mac,
13034 eTDLS_LINK_IDLE,
13035 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070013036 return -EPERM;
13037
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013038}
13039#endif
13040
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013041VOS_STATUS wlan_hdd_send_sta_authorized_event(
13042 hdd_adapter_t *adapter,
13043 hdd_context_t *hdd_ctx,
13044 const v_MACADDR_t *mac_addr)
13045{
13046 struct sk_buff *vendor_event;
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013047 VOS_STATUS status;
Sourav Mohapatra55dfabe2019-04-03 15:09:21 +053013048 struct nl80211_sta_flag_update sta_flags;
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013049
13050 ENTER();
13051
13052 if (!hdd_ctx) {
13053 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is null"));
13054 return -EINVAL;
13055 }
13056
13057 vendor_event =
13058 cfg80211_vendor_event_alloc(
Ashish Kumar Dhanotiyac99fbef2018-04-11 12:23:32 +053013059 hdd_ctx->wiphy,
13060#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
13061 &adapter->wdev,
13062#endif
13063 sizeof(sta_flags) +
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013064 VOS_MAC_ADDR_SIZE + NLMSG_HDRLEN,
13065 QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES_INDEX,
13066 GFP_KERNEL);
13067 if (!vendor_event) {
13068 hddLog(VOS_TRACE_LEVEL_ERROR,
13069 FL("cfg80211_vendor_event_alloc failed"));
13070 return -EINVAL;
13071 }
13072
Sourav Mohapatra55dfabe2019-04-03 15:09:21 +053013073 sta_flags.mask |= BIT(NL80211_STA_FLAG_AUTHORIZED);
13074 sta_flags.set = true;
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013075
Sourav Mohapatra55dfabe2019-04-03 15:09:21 +053013076 status = nla_put(vendor_event,
13077 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_STA_FLAGS,
13078 sizeof(struct nl80211_sta_flag_update),
13079 &sta_flags);
13080
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013081 if (status) {
13082 hddLog(VOS_TRACE_LEVEL_ERROR, FL("STA flag put fails"));
13083 kfree_skb(vendor_event);
13084 return VOS_STATUS_E_FAILURE;
13085 }
Sourav Mohapatra55dfabe2019-04-03 15:09:21 +053013086
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013087 status = nla_put(vendor_event,
Sourav Mohapatra55dfabe2019-04-03 15:09:21 +053013088 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_MAC_ADDR,
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013089 VOS_MAC_ADDR_SIZE, mac_addr->bytes);
13090 if (status) {
13091 hddLog(VOS_TRACE_LEVEL_ERROR, FL("STA MAC put fails"));
13092 kfree_skb(vendor_event);
13093 return VOS_STATUS_E_FAILURE;
13094 }
13095
13096 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
13097
13098 EXIT();
13099 return 0;
13100}
13101
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013102static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013103 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013104#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13105 const u8 *mac,
13106#else
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013108#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013109 struct station_parameters *params)
13110{
13111 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013112 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053013113 hdd_context_t *pHddCtx;
13114 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013115 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013116 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070013117#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013118 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013119 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013120 tANI_U8 isOffChannelSupported = 0;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013121 tANI_U8 isQosWmmSta = FALSE;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070013122#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070013123
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013124 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013125
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013126 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053013127 if ((NULL == pAdapter))
13128 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053013130 "invalid adapter ");
13131 return -EINVAL;
13132 }
13133
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013134 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13135 TRACE_CODE_HDD_CHANGE_STATION,
13136 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053013137 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053013138
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013139 ret = wlan_hdd_validate_context(pHddCtx);
13140 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053013141 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013142 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053013143 }
13144
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013145 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13146
13147 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013148 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13150 "invalid HDD station context");
13151 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013152 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013153 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
13154
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013155 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
13156 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070013157 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013158 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070013159 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013160 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070013161 WLANTL_STA_AUTHENTICATED);
13162
Gopichand Nakkala29149562013-05-10 21:43:41 +053013163 if (status != VOS_STATUS_SUCCESS)
13164 {
13165 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13166 "%s: Not able to change TL state to AUTHENTICATED", __func__);
13167 return -EINVAL;
13168 }
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013169 status = wlan_hdd_send_sta_authorized_event(pAdapter, pHddCtx,
13170 &STAMacAddress);
13171 if (status != VOS_STATUS_SUCCESS)
13172 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 }
13174 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070013175 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
13176 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053013177#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013178 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
13179 StaParams.capability = params->capability;
13180 StaParams.uapsd_queues = params->uapsd_queues;
13181 StaParams.max_sp = params->max_sp;
13182
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013183 /* Convert (first channel , number of channels) tuple to
13184 * the total list of channels. This goes with the assumption
13185 * that if the first channel is < 14, then the next channels
13186 * are an incremental of 1 else an incremental of 4 till the number
13187 * of channels.
13188 */
13189 if (0 != params->supported_channels_len) {
13190 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
Ashish Kumar Dhanotiyaf01ec752018-04-25 15:50:15 +053013191 for ( i = 0 ; i < params->supported_channels_len
13192 && j < SIR_MAC_MAX_SUPP_CHANNELS; i+=2)
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013193 {
13194 int wifi_chan_index;
13195 StaParams.supported_channels[j] = params->supported_channels[i];
13196 wifi_chan_index =
13197 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
13198 no_of_channels = params->supported_channels[i+1];
Ashish Kumar Dhanotiyaf01ec752018-04-25 15:50:15 +053013199 for(k=1; k <= no_of_channels
13200 && j < SIR_MAC_MAX_SUPP_CHANNELS - 1; k++)
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013201 {
13202 StaParams.supported_channels[j+1] =
13203 StaParams.supported_channels[j] + wifi_chan_index;
13204 j+=1;
13205 }
13206 }
13207 StaParams.supported_channels_len = j;
13208 }
SaidiReddy Yenuga0f1a1592017-04-05 13:18:26 +053013209 if (params->supported_oper_classes_len >
13210 SIR_MAC_MAX_SUPP_OPER_CLASSES) {
13211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13212 "received oper classes:%d, resetting it to max supported %d",
13213 params->supported_oper_classes_len,
13214 SIR_MAC_MAX_SUPP_OPER_CLASSES);
13215 params->supported_oper_classes_len =
13216 SIR_MAC_MAX_SUPP_OPER_CLASSES;
13217 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013218 vos_mem_copy(StaParams.supported_oper_classes,
13219 params->supported_oper_classes,
13220 params->supported_oper_classes_len);
13221 StaParams.supported_oper_classes_len =
13222 params->supported_oper_classes_len;
13223
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053013224 if (params->ext_capab_len > sizeof(StaParams.extn_capability)) {
13225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13226 "received extn capabilities:%d, resetting it to max supported",
13227 params->ext_capab_len);
13228 params->ext_capab_len = sizeof(StaParams.extn_capability);
13229 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013230 if (0 != params->ext_capab_len)
13231 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053013232 params->ext_capab_len);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013233
13234 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070013235 {
13236 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013237 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070013238 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013239
13240 StaParams.supported_rates_len = params->supported_rates_len;
13241
13242 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
13243 * The supported_rates array , for all the structures propogating till Add Sta
13244 * to the firmware has to be modified , if the supplicant (ieee80211) is
13245 * modified to send more rates.
13246 */
13247
13248 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
13249 */
13250 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
13251 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
13252
13253 if (0 != StaParams.supported_rates_len) {
13254 int i = 0;
13255 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
13256 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013257 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013258 "Supported Rates with Length %d", StaParams.supported_rates_len);
13259 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013260 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013261 "[%d]: %0x", i, StaParams.supported_rates[i]);
13262 }
13263
13264 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070013265 {
13266 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013267 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070013268 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013269
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013270 if (0 != params->ext_capab_len ) {
13271 /*Define A Macro : TODO Sunil*/
13272 if ((1<<4) & StaParams.extn_capability[3]) {
13273 isBufSta = 1;
13274 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013275 /* TDLS Channel Switching Support */
13276 if ((1<<6) & StaParams.extn_capability[3]) {
13277 isOffChannelSupported = 1;
13278 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013279 }
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013280
13281 if (pHddCtx->cfg_ini->fEnableTDLSWmmMode &&
Nitesh Shah48df4c02016-08-12 16:27:33 +053013282 (params->ht_capa || params->vht_capa ||
13283 (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME))))
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013284 /* TDLS Peer is WME/QoS capable */
13285 isQosWmmSta = TRUE;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013286
13287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13288 "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d",
13289 __func__, isQosWmmSta, StaParams.htcap_present);
13290
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013291 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
13292 &StaParams, isBufSta,
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013293 isOffChannelSupported,
13294 isQosWmmSta);
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013295
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013296 if (VOS_STATUS_SUCCESS != status) {
13297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13298 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
13299 return -EINVAL;
13300 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013301 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
13302
13303 if (VOS_STATUS_SUCCESS != status) {
13304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13305 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
13306 return -EINVAL;
13307 }
13308 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070013309#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053013310 }
Jeff Johnsone7245742012-09-05 17:12:55 -070013311 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013312 return status;
13313}
13314
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013315#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
13316static int wlan_hdd_change_station(struct wiphy *wiphy,
13317 struct net_device *dev,
13318 const u8 *mac,
13319 struct station_parameters *params)
13320#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013321static int wlan_hdd_change_station(struct wiphy *wiphy,
13322 struct net_device *dev,
13323 u8 *mac,
13324 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013325#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013326{
13327 int ret;
13328
13329 vos_ssr_protect(__func__);
13330 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
13331 vos_ssr_unprotect(__func__);
13332
13333 return ret;
13334}
13335
Jeff Johnson295189b2012-06-20 16:38:30 -070013336/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013337 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 * This function is used to initialize the key information
13339 */
13340#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013341static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013342 struct net_device *ndev,
13343 u8 key_index, bool pairwise,
13344 const u8 *mac_addr,
13345 struct key_params *params
13346 )
13347#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013348static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013349 struct net_device *ndev,
13350 u8 key_index, const u8 *mac_addr,
13351 struct key_params *params
13352 )
13353#endif
13354{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013355 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070013356 tCsrRoamSetKey setKey;
13357 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013358 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013359 v_U32_t roamId= 0xFF;
13360 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013361 hdd_hostapd_state_t *pHostapdState;
13362 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013363 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013364 hdd_context_t *pHddCtx;
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013365 uint8_t i;
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013366 v_MACADDR_t *peerMacAddr;
13367 u64 rsc_counter = 0;
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013368 uint8_t staid = HDD_MAX_STA_COUNT;
13369 bool pairwise_set_key = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070013370
13371 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013372
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013373 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13374 TRACE_CODE_HDD_CFG80211_ADD_KEY,
13375 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013376 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13377 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013378 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013379 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013380 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013381 }
13382
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013383 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13384 __func__, hdd_device_modetoString(pAdapter->device_mode),
13385 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013386
13387 if (CSR_MAX_NUM_KEY <= key_index)
13388 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013389 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013390 key_index);
13391
13392 return -EINVAL;
13393 }
13394
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013395 if (CSR_MAX_KEY_LEN < params->key_len)
13396 {
13397 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
13398 params->key_len);
13399
13400 return -EINVAL;
13401 }
13402
Jingxiang Gec438aea2017-10-26 16:44:00 +080013403 if (CSR_MAX_RSC_LEN < params->seq_len)
13404 {
13405 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Invalid seq length %d", __func__,
13406 params->seq_len);
Ashish Kumar Dhanotiya9783b182017-12-08 14:50:46 +053013407
13408 return -EINVAL;
Jingxiang Gec438aea2017-10-26 16:44:00 +080013409 }
13410
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013411 hddLog(VOS_TRACE_LEVEL_INFO,
Jingxiang Gec438aea2017-10-26 16:44:00 +080013412 "%s: called with key index = %d & key length %d & seq length %d",
13413 __func__, key_index, params->key_len, params->seq_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013414
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013415 peerMacAddr = (v_MACADDR_t *)mac_addr;
13416
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 /*extract key idx, key len and key*/
13418 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
13419 setKey.keyId = key_index;
13420 setKey.keyLength = params->key_len;
13421 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
Jingxiang Gec438aea2017-10-26 16:44:00 +080013422 vos_mem_copy(&setKey.keyRsc[0], params->seq, params->seq_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013423
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013424 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013425 {
13426 case WLAN_CIPHER_SUITE_WEP40:
13427 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
13428 break;
13429
13430 case WLAN_CIPHER_SUITE_WEP104:
13431 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
13432 break;
13433
13434 case WLAN_CIPHER_SUITE_TKIP:
13435 {
13436 u8 *pKey = &setKey.Key[0];
13437 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
13438
13439 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
13440
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013441 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070013442
13443 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013444 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 |--------------|----------|----------|
13446 <---16bytes---><--8bytes--><--8bytes-->
13447
13448 */
13449 /*Sme expects the 32 bytes key to be in the below order
13450
13451 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013452 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070013453 |--------------|----------|----------|
13454 <---16bytes---><--8bytes--><--8bytes-->
13455 */
13456 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013457 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013458
13459 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013460 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013461
13462 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013463 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013464
13465
13466 break;
13467 }
13468
13469 case WLAN_CIPHER_SUITE_CCMP:
13470 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
13471 break;
13472
13473#ifdef FEATURE_WLAN_WAPI
13474 case WLAN_CIPHER_SUITE_SMS4:
13475 {
13476 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
13477 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
13478 params->key, params->key_len);
13479 return 0;
13480 }
13481#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070013482
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013483#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 case WLAN_CIPHER_SUITE_KRK:
13485 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
13486 break;
13487#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070013488
13489#ifdef WLAN_FEATURE_11W
13490 case WLAN_CIPHER_SUITE_AES_CMAC:
13491 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070013492 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070013493#endif
13494
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070013496 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070013497 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013498 status = -EOPNOTSUPP;
13499 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 }
13501
13502 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
13503 __func__, setKey.encType);
13504
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013505 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070013506#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13507 (!pairwise)
13508#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013509 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013510#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013511 )
13512 {
13513 /* set group key*/
13514 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13515 "%s- %d: setting Broadcast key",
13516 __func__, __LINE__);
13517 setKey.keyDirection = eSIR_RX_ONLY;
13518 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
13519 }
13520 else
13521 {
13522 /* set pairwise key*/
13523 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13524 "%s- %d: setting pairwise key",
13525 __func__, __LINE__);
13526 setKey.keyDirection = eSIR_TX_RX;
13527 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013528 pairwise_set_key = true;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013529 }
13530 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
13531 {
13532 setKey.keyDirection = eSIR_TX_RX;
13533 /*Set the group key*/
13534 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
13535 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013536
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013537 if ( 0 != status )
13538 {
13539 hddLog(VOS_TRACE_LEVEL_ERROR,
13540 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013541 status = -EINVAL;
13542 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013543 }
13544 /*Save the keys here and call sme_RoamSetKey for setting
13545 the PTK after peer joins the IBSS network*/
13546 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
13547 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013548 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013549 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053013550 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
13551 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
13552 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013553 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013554 if( pHostapdState->bssState == BSS_START )
13555 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013556 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13557 vos_status = wlan_hdd_check_ula_done(pAdapter);
13558
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013559 if (peerMacAddr && (pairwise_set_key == true))
13560 staid = hdd_sta_id_find_from_mac_addr(pAdapter, peerMacAddr);
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013561
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013562 if ( vos_status != VOS_STATUS_SUCCESS )
13563 {
13564 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13565 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
13566 __LINE__, vos_status );
13567
13568 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
13569
13570 status = -EINVAL;
13571 goto end;
13572 }
13573
Jeff Johnson295189b2012-06-20 16:38:30 -070013574 status = WLANSAP_SetKeySta( pVosContext, &setKey);
13575
13576 if ( status != eHAL_STATUS_SUCCESS )
13577 {
13578 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13579 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
13580 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013581 status = -EINVAL;
13582 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013583 }
13584 }
13585
13586 /* Saving WEP keys */
13587 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
13588 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
13589 {
13590 //Save the wep key in ap context. Issue setkey after the BSS is started.
13591 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
13592 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
13593 }
13594 else
13595 {
13596 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013597 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
13599 }
13600 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013601 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
13602 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013603 {
13604 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13605 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13606
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013607#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13608 if (!pairwise)
13609#else
13610 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
13611#endif
13612 {
13613 /* set group key*/
13614 if (pHddStaCtx->roam_info.deferKeyComplete)
13615 {
13616 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13617 "%s- %d: Perform Set key Complete",
13618 __func__, __LINE__);
13619 hdd_PerformRoamSetKeyComplete(pAdapter);
13620 }
13621 }
13622
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013623 if (pairwise_set_key == true)
13624 staid = pHddStaCtx->conn_info.staId[0];
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013625
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
13627
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080013628 pWextState->roamProfile.Keys.defaultIndex = key_index;
13629
13630
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013631 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 params->key, params->key_len);
13633
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013634
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
13636
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013637 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070013638 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013639 __func__, setKey.peerMac[0], setKey.peerMac[1],
13640 setKey.peerMac[2], setKey.peerMac[3],
13641 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 setKey.keyDirection);
13643
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013644 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053013645
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013646 if ( vos_status != VOS_STATUS_SUCCESS )
13647 {
13648 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013649 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
13650 __LINE__, vos_status );
13651
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013652 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013653
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013654 status = -EINVAL;
13655 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013656
13657 }
13658
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013659#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013660 /* The supplicant may attempt to set the PTK once pre-authentication
13661 is done. Save the key in the UMAC and include it in the ADD BSS
13662 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013663 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013664 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013665 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013666 hddLog(VOS_TRACE_LEVEL_INFO_MED,
13667 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013668 status = 0;
13669 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013670 }
13671 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
13672 {
13673 hddLog(VOS_TRACE_LEVEL_ERROR,
13674 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013675 status = -EINVAL;
13676 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013677 }
13678#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070013679
13680 /* issue set key request to SME*/
13681 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
13682 pAdapter->sessionId, &setKey, &roamId );
13683
13684 if ( 0 != status )
13685 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013686 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
13688 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013689 status = -EINVAL;
13690 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 }
13692
13693
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013694 /* in case of IBSS as there was no information available about WEP keys during
13695 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070013696 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013697 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
13698 !( ( IW_AUTH_KEY_MGMT_802_1X
13699 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070013700 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
13701 )
13702 &&
13703 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
13704 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
13705 )
13706 )
13707 {
13708 setKey.keyDirection = eSIR_RX_ONLY;
13709 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
13710
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013711 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013713 __func__, setKey.peerMac[0], setKey.peerMac[1],
13714 setKey.peerMac[2], setKey.peerMac[3],
13715 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070013716 setKey.keyDirection);
13717
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013718 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 pAdapter->sessionId, &setKey, &roamId );
13720
13721 if ( 0 != status )
13722 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013723 hddLog(VOS_TRACE_LEVEL_ERROR,
13724 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013725 __func__, status);
13726 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013727 status = -EINVAL;
13728 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 }
13730 }
13731 }
13732
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013733 if (pairwise_set_key == true) {
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013734 for (i = 0; i < params->seq_len; i++) {
13735 rsc_counter |= (params->seq[i] << i*8);
13736 }
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013737 WLANTL_SetKeySeqCounter(pVosContext, rsc_counter, staid);
13738 }
13739
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013740end:
13741 /* Need to clear any trace of key value in the memory.
13742 * Thus zero out the memory even though it is local
13743 * variable.
13744 */
13745 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013746 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013747 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013748}
13749
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013750#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13751static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
13752 struct net_device *ndev,
13753 u8 key_index, bool pairwise,
13754 const u8 *mac_addr,
13755 struct key_params *params
13756 )
13757#else
13758static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
13759 struct net_device *ndev,
13760 u8 key_index, const u8 *mac_addr,
13761 struct key_params *params
13762 )
13763#endif
13764{
13765 int ret;
13766 vos_ssr_protect(__func__);
13767#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13768 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
13769 mac_addr, params);
13770#else
13771 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
13772 params);
13773#endif
13774 vos_ssr_unprotect(__func__);
13775
13776 return ret;
13777}
13778
Jeff Johnson295189b2012-06-20 16:38:30 -070013779/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013780 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070013781 * This function is used to get the key information
13782 */
13783#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013784static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013785 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013786 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013787 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070013788 const u8 *mac_addr, void *cookie,
13789 void (*callback)(void *cookie, struct key_params*)
13790 )
13791#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013792static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013793 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 struct net_device *ndev,
13795 u8 key_index, const u8 *mac_addr, void *cookie,
13796 void (*callback)(void *cookie, struct key_params*)
13797 )
13798#endif
13799{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013800 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013801 hdd_wext_state_t *pWextState = NULL;
13802 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013803 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013804 hdd_context_t *pHddCtx;
13805 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013806
13807 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013808
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013809 if (NULL == pAdapter)
13810 {
13811 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13812 "%s: HDD adapter is Null", __func__);
13813 return -ENODEV;
13814 }
13815
13816 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13817 ret = wlan_hdd_validate_context(pHddCtx);
13818 if (0 != ret)
13819 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013820 return ret;
13821 }
13822
13823 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13824 pRoamProfile = &(pWextState->roamProfile);
13825
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013826 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13827 __func__, hdd_device_modetoString(pAdapter->device_mode),
13828 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013829
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 memset(&params, 0, sizeof(params));
13831
13832 if (CSR_MAX_NUM_KEY <= key_index)
13833 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013834 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013836 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013837
13838 switch(pRoamProfile->EncryptionType.encryptionType[0])
13839 {
13840 case eCSR_ENCRYPT_TYPE_NONE:
13841 params.cipher = IW_AUTH_CIPHER_NONE;
13842 break;
13843
13844 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
13845 case eCSR_ENCRYPT_TYPE_WEP40:
13846 params.cipher = WLAN_CIPHER_SUITE_WEP40;
13847 break;
13848
13849 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
13850 case eCSR_ENCRYPT_TYPE_WEP104:
13851 params.cipher = WLAN_CIPHER_SUITE_WEP104;
13852 break;
13853
13854 case eCSR_ENCRYPT_TYPE_TKIP:
13855 params.cipher = WLAN_CIPHER_SUITE_TKIP;
13856 break;
13857
13858 case eCSR_ENCRYPT_TYPE_AES:
13859 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
13860 break;
13861
13862 default:
13863 params.cipher = IW_AUTH_CIPHER_NONE;
13864 break;
13865 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013866
c_hpothuaaf19692014-05-17 17:01:48 +053013867 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13868 TRACE_CODE_HDD_CFG80211_GET_KEY,
13869 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013870
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
13872 params.seq_len = 0;
13873 params.seq = NULL;
13874 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
13875 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013876 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 return 0;
13878}
13879
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013880#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13881static int wlan_hdd_cfg80211_get_key(
13882 struct wiphy *wiphy,
13883 struct net_device *ndev,
13884 u8 key_index, bool pairwise,
13885 const u8 *mac_addr, void *cookie,
13886 void (*callback)(void *cookie, struct key_params*)
13887 )
13888#else
13889static int wlan_hdd_cfg80211_get_key(
13890 struct wiphy *wiphy,
13891 struct net_device *ndev,
13892 u8 key_index, const u8 *mac_addr, void *cookie,
13893 void (*callback)(void *cookie, struct key_params*)
13894 )
13895#endif
13896{
13897 int ret;
13898
13899 vos_ssr_protect(__func__);
13900#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13901 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
13902 mac_addr, cookie, callback);
13903#else
13904 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
13905 callback);
13906#endif
13907 vos_ssr_unprotect(__func__);
13908
13909 return ret;
13910}
13911
Jeff Johnson295189b2012-06-20 16:38:30 -070013912/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013913 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070013914 * This function is used to delete the key information
13915 */
13916#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013917static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013919 u8 key_index,
13920 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070013921 const u8 *mac_addr
13922 )
13923#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013924static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013925 struct net_device *ndev,
13926 u8 key_index,
13927 const u8 *mac_addr
13928 )
13929#endif
13930{
13931 int status = 0;
13932
13933 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013934 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070013935 //it is observed that this is invalidating peer
13936 //key index whenever re-key is done. This is affecting data link.
13937 //It should be ok to ignore del_key.
13938#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013939 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
13940 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013941 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13942 tCsrRoamSetKey setKey;
13943 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013944
Jeff Johnson295189b2012-06-20 16:38:30 -070013945 ENTER();
13946
13947 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
13948 __func__,pAdapter->device_mode);
13949
13950 if (CSR_MAX_NUM_KEY <= key_index)
13951 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013952 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 key_index);
13954
13955 return -EINVAL;
13956 }
13957
13958 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
13959 setKey.keyId = key_index;
13960
13961 if (mac_addr)
13962 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
13963 else
13964 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
13965
13966 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
13967
13968 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013969 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013970 )
13971 {
13972
13973 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
13975 if( pHostapdState->bssState == BSS_START)
13976 {
13977 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013978
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 if ( status != eHAL_STATUS_SUCCESS )
13980 {
13981 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13982 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
13983 __LINE__, status );
13984 }
13985 }
13986 }
13987 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013988 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070013989 )
13990 {
13991 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13992
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013993 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
13994
13995 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013997 __func__, setKey.peerMac[0], setKey.peerMac[1],
13998 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014000 if(pAdapter->sessionCtx.station.conn_info.connState ==
14001 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070014002 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014003 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070014004 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014005
Jeff Johnson295189b2012-06-20 16:38:30 -070014006 if ( 0 != status )
14007 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014008 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 "%s: sme_RoamSetKey failure, returned %d",
14010 __func__, status);
14011 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
14012 return -EINVAL;
14013 }
14014 }
14015 }
14016#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070014017 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014018 return status;
14019}
14020
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014021#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14022static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
14023 struct net_device *ndev,
14024 u8 key_index,
14025 bool pairwise,
14026 const u8 *mac_addr
14027 )
14028#else
14029static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
14030 struct net_device *ndev,
14031 u8 key_index,
14032 const u8 *mac_addr
14033 )
14034#endif
14035{
14036 int ret;
14037
14038 vos_ssr_protect(__func__);
14039#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14040 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
14041 mac_addr);
14042#else
14043 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
14044#endif
14045 vos_ssr_unprotect(__func__);
14046
14047 return ret;
14048}
14049
Jeff Johnson295189b2012-06-20 16:38:30 -070014050/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053014051 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070014052 * This function is used to set the default tx key index
14053 */
14054#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053014055static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014056 struct net_device *ndev,
14057 u8 key_index,
14058 bool unicast, bool multicast)
14059#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053014060static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014061 struct net_device *ndev,
14062 u8 key_index)
14063#endif
14064{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014065 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014066 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053014067 hdd_wext_state_t *pWextState;
14068 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014069 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070014070
14071 ENTER();
14072
Gopichand Nakkala29149562013-05-10 21:43:41 +053014073 if ((NULL == pAdapter))
14074 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053014076 "invalid adapter");
14077 return -EINVAL;
14078 }
14079
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014080 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14081 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
14082 pAdapter->sessionId, key_index));
14083
Gopichand Nakkala29149562013-05-10 21:43:41 +053014084 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14085 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14086
14087 if ((NULL == pWextState) || (NULL == pHddStaCtx))
14088 {
14089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14090 "invalid Wext state or HDD context");
14091 return -EINVAL;
14092 }
14093
Arif Hussain6d2a3322013-11-17 19:50:10 -080014094 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014095 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014096
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 if (CSR_MAX_NUM_KEY <= key_index)
14098 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014099 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 key_index);
14101
14102 return -EINVAL;
14103 }
14104
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014105 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14106 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014107 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014108 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014109 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014110 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014111
Jeff Johnson295189b2012-06-20 16:38:30 -070014112 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070014113 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014114 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014115 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053014116 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080014117 pHddStaCtx->conn_info.ucEncryptionType) &&
Hu Wangb1f68cb2017-08-23 20:01:49 +080014118#ifdef FEATURE_WLAN_WAPI
14119 (eCSR_ENCRYPT_TYPE_WPI !=
14120 pHddStaCtx->conn_info.ucEncryptionType) &&
14121#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014122 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080014123 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070014124 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014125 {
14126 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014128
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 tCsrRoamSetKey setKey;
14130 v_U32_t roamId= 0xFF;
14131 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014132
14133 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014135
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 Keys->defaultIndex = (u8)key_index;
14137 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
14138 setKey.keyId = key_index;
14139 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014140
14141 vos_mem_copy(&setKey.Key[0],
14142 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014144
Gopichand Nakkala29149562013-05-10 21:43:41 +053014145 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014146
14147 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070014148 &pHddStaCtx->conn_info.bssId[0],
14149 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014150
Gopichand Nakkala29149562013-05-10 21:43:41 +053014151 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
14152 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
14153 eCSR_ENCRYPT_TYPE_WEP104)
14154 {
14155 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
14156 even though ap is configured for WEP-40 encryption. In this canse the key length
14157 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
14158 type(104) and switching encryption type to 40*/
14159 pWextState->roamProfile.EncryptionType.encryptionType[0] =
14160 eCSR_ENCRYPT_TYPE_WEP40;
14161 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
14162 eCSR_ENCRYPT_TYPE_WEP40;
14163 }
14164
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014165 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070014166 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014167
Jeff Johnson295189b2012-06-20 16:38:30 -070014168 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014169 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014171
Jeff Johnson295189b2012-06-20 16:38:30 -070014172 if ( 0 != status )
14173 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014174 hddLog(VOS_TRACE_LEVEL_ERROR,
14175 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014176 status);
14177 return -EINVAL;
14178 }
14179 }
14180 }
14181
14182 /* In SoftAp mode setting key direction for default mode */
14183 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
14184 {
14185 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
14186 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
14187 (eCSR_ENCRYPT_TYPE_AES !=
14188 pWextState->roamProfile.EncryptionType.encryptionType[0])
14189 )
14190 {
14191 /* Saving key direction for default key index to TX default */
14192 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
14193 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
14194 }
14195 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014196 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014197 return status;
14198}
14199
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053014200#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14201static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
14202 struct net_device *ndev,
14203 u8 key_index,
14204 bool unicast, bool multicast)
14205#else
14206static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
14207 struct net_device *ndev,
14208 u8 key_index)
14209#endif
14210{
14211 int ret;
14212 vos_ssr_protect(__func__);
14213#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14214 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
14215 multicast);
14216#else
14217 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
14218#endif
14219 vos_ssr_unprotect(__func__);
14220
14221 return ret;
14222}
14223
Jeff Johnson295189b2012-06-20 16:38:30 -070014224/*
14225 * FUNCTION: wlan_hdd_cfg80211_inform_bss
14226 * This function is used to inform the BSS details to nl80211 interface.
14227 */
14228static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
14229 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
14230{
14231 struct net_device *dev = pAdapter->dev;
14232 struct wireless_dev *wdev = dev->ieee80211_ptr;
14233 struct wiphy *wiphy = wdev->wiphy;
14234 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
14235 int chan_no;
14236 int ie_length;
14237 const char *ie;
14238 unsigned int freq;
14239 struct ieee80211_channel *chan;
14240 int rssi = 0;
14241 struct cfg80211_bss *bss = NULL;
14242
Jeff Johnson295189b2012-06-20 16:38:30 -070014243 if( NULL == pBssDesc )
14244 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014245 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014246 return bss;
14247 }
14248
14249 chan_no = pBssDesc->channelId;
14250 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
14251 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
14252
14253 if( NULL == ie )
14254 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014255 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014256 return bss;
14257 }
14258
14259#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
14260 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
14261 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014262 freq = ieee80211_channel_to_frequency(chan_no, HDD_NL80211_BAND_2GHZ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014263 }
14264 else
14265 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014266 freq = ieee80211_channel_to_frequency(chan_no, HDD_NL80211_BAND_5GHZ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014267 }
14268#else
14269 freq = ieee80211_channel_to_frequency(chan_no);
14270#endif
14271
14272 chan = __ieee80211_get_channel(wiphy, freq);
14273
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053014274 if (!chan) {
14275 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
14276 return NULL;
14277 }
14278
Abhishek Singhaee43942014-06-16 18:55:47 +053014279 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070014280
Anand N Sunkad9f80b742015-07-30 20:05:51 +053014281 return cfg80211_inform_bss(wiphy, chan,
14282#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14283 CFG80211_BSS_FTYPE_UNKNOWN,
14284#endif
14285 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014286 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070014287 pBssDesc->capabilityInfo,
14288 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053014289 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070014290}
14291
Abhishek Singhe6137b82019-03-22 20:06:09 +053014292void wlan_hdd_cfg80211_unlink_bss(hdd_adapter_t *pAdapter, tSirMacAddr bssid)
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053014293{
14294 struct net_device *dev = pAdapter->dev;
14295 struct wireless_dev *wdev = dev->ieee80211_ptr;
14296 struct wiphy *wiphy = wdev->wiphy;
14297 struct cfg80211_bss *bss = NULL;
14298
Abhishek Singh5a597e62016-12-05 15:16:30 +053014299 bss = hdd_get_bss_entry(wiphy,
14300 NULL, bssid,
14301 NULL, 0);
Abhishek Singhe6137b82019-03-22 20:06:09 +053014302 if (!bss) {
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053014303 hddLog(LOGE, FL("BSS not present"));
14304 } else {
14305 hddLog(LOG1, FL("cfg80211_unlink_bss called for BSSID "
14306 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(bssid));
14307 cfg80211_unlink_bss(wiphy, bss);
Abhishek Singhe6137b82019-03-22 20:06:09 +053014308 /* cfg80211_get_bss get bss with ref count so release it */
14309 cfg80211_put_bss(wiphy, bss);
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053014310 }
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053014311}
Jeff Johnson295189b2012-06-20 16:38:30 -070014312
14313
14314/*
14315 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
14316 * This function is used to inform the BSS details to nl80211 interface.
14317 */
14318struct cfg80211_bss*
14319wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
14320 tSirBssDescription *bss_desc
14321 )
14322{
14323 /*
14324 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
14325 already exists in bss data base of cfg80211 for that particular BSS ID.
14326 Using cfg80211_inform_bss_frame to update the bss entry instead of
14327 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
14328 now there is no possibility to get the mgmt(probe response) frame from PE,
14329 converting bss_desc to ieee80211_mgmt(probe response) and passing to
14330 cfg80211_inform_bss_frame.
14331 */
14332 struct net_device *dev = pAdapter->dev;
14333 struct wireless_dev *wdev = dev->ieee80211_ptr;
14334 struct wiphy *wiphy = wdev->wiphy;
14335 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080014336#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
14337 qcom_ie_age *qie_age = NULL;
14338 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
14339#else
Jeff Johnson295189b2012-06-20 16:38:30 -070014340 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080014341#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014342 const char *ie =
14343 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
14344 unsigned int freq;
14345 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053014346 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014347 struct cfg80211_bss *bss_status = NULL;
Hanumanth Reddy Pothulae04e06c2018-05-31 14:41:36 +053014348 size_t frame_len = ie_length + offsetof(struct ieee80211_mgmt,
14349 u.probe_resp.variable);
Jeff Johnson295189b2012-06-20 16:38:30 -070014350 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070014351 hdd_context_t *pHddCtx;
14352 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070014353#ifdef WLAN_OPEN_SOURCE
14354 struct timespec ts;
14355#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014356
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014357
Wilson Yangf80a0542013-10-07 13:02:37 -070014358 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14359 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070014360 if (0 != status)
14361 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070014362 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070014363 }
14364
Hanumanth Reddy Pothula33548e22018-05-31 13:28:51 +053014365 mgmt = kzalloc(frame_len, GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070014366 if (!mgmt)
14367 {
14368 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14369 "%s: memory allocation failed ", __func__);
14370 return NULL;
14371 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070014372
Jeff Johnson295189b2012-06-20 16:38:30 -070014373 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070014374
14375#ifdef WLAN_OPEN_SOURCE
14376 /* Android does not want the timestamp from the frame.
14377 Instead it wants a monotonic increasing value */
14378 get_monotonic_boottime(&ts);
14379 mgmt->u.probe_resp.timestamp =
14380 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
14381#else
14382 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070014383 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
14384 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070014385
14386#endif
14387
Jeff Johnson295189b2012-06-20 16:38:30 -070014388 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
14389 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080014390
14391#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
14392 /* GPS Requirement: need age ie per entry. Using vendor specific. */
14393 /* Assuming this is the last IE, copy at the end */
14394 ie_length -=sizeof(qcom_ie_age);
14395 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
14396 qie_age->element_id = QCOM_VENDOR_IE_ID;
14397 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
14398 qie_age->oui_1 = QCOM_OUI1;
14399 qie_age->oui_2 = QCOM_OUI2;
14400 qie_age->oui_3 = QCOM_OUI3;
14401 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
Selvaraj, Sridhar4b3a8362016-10-12 12:34:08 +053014402 /* Lowi expects the timestamp of bss in units of 1/10 ms. In driver all
14403 * bss related timestamp is in units of ms. Due to this when scan results
14404 * are sent to lowi the scan age is high.To address this, send age in units
14405 * of 1/10 ms.
14406 */
14407 qie_age->age = (vos_timer_get_system_time() -
14408 bss_desc->nReceivedTime)/10;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080014409#endif
14410
Jeff Johnson295189b2012-06-20 16:38:30 -070014411 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053014412 if (bss_desc->fProbeRsp)
14413 {
14414 mgmt->frame_control |=
14415 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
14416 }
14417 else
14418 {
14419 mgmt->frame_control |=
14420 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
14421 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014422
14423#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014424 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014425 (wiphy->bands[HDD_NL80211_BAND_2GHZ] != NULL))
Jeff Johnson295189b2012-06-20 16:38:30 -070014426 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014427 freq = ieee80211_channel_to_frequency(chan_no, HDD_NL80211_BAND_2GHZ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014428 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014429 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014430 (wiphy->bands[HDD_NL80211_BAND_5GHZ] != NULL))
Jeff Johnson295189b2012-06-20 16:38:30 -070014431
14432 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014433 freq = ieee80211_channel_to_frequency(chan_no, HDD_NL80211_BAND_5GHZ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014434 }
14435 else
14436 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053014437 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
14438 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070014439 kfree(mgmt);
14440 return NULL;
14441 }
14442#else
14443 freq = ieee80211_channel_to_frequency(chan_no);
14444#endif
14445 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080014446 /*when the band is changed on the fly using the GUI, three things are done
14447 * 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)
14448 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
14449 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
14450 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
14451 * and discards the channels correponding to previous band and calls back with zero bss results.
14452 * 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
14453 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
14454 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
14455 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
14456 * So drop the bss and continue to next bss.
14457 */
14458 if(chan == NULL)
14459 {
Deepthi Gowri306657b2016-04-28 17:10:41 +053014460 hddLog(VOS_TRACE_LEVEL_ERROR,
14461 FL("chan pointer is NULL, chan_no: %d freq: %d"),
14462 chan_no, freq);
Chilam Ngc4244af2013-04-01 15:37:32 -070014463 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080014464 return NULL;
14465 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053014466 /*To keep the rssi icon of the connected AP in the scan window
14467 *and the rssi icon of the wireless networks in sync
14468 * */
14469 if (( eConnectionState_Associated ==
14470 pAdapter->sessionCtx.station.conn_info.connState ) &&
14471 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
14472 pAdapter->sessionCtx.station.conn_info.bssId,
14473 WNI_CFG_BSSID_LEN)) &&
14474 (pHddCtx->hdd_wlan_suspended == FALSE))
14475 {
14476 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
14477 rssi = (pAdapter->rssi * 100);
14478 }
14479 else
14480 {
14481 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
14482 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014483
Nirav Shah20ac06f2013-12-12 18:14:06 +053014484 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053014485 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
14486 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053014487
Jeff Johnson295189b2012-06-20 16:38:30 -070014488 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
14489 frame_len, rssi, GFP_KERNEL);
14490 kfree(mgmt);
14491 return bss_status;
14492}
14493
14494/*
14495 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
14496 * This function is used to update the BSS data base of CFG8011
14497 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014498struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014499 tCsrRoamInfo *pRoamInfo
14500 )
14501{
14502 tCsrRoamConnectedProfile roamProfile;
14503 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14504 struct cfg80211_bss *bss = NULL;
14505
14506 ENTER();
14507
14508 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
14509 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
14510
14511 if (NULL != roamProfile.pBssDesc)
14512 {
Girish Gowlif4b68022014-08-28 23:18:57 +053014513 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
14514 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014515
14516 if (NULL == bss)
14517 {
14518 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
14519 __func__);
14520 }
14521
14522 sme_RoamFreeConnectProfile(hHal, &roamProfile);
14523 }
14524 else
14525 {
14526 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
14527 __func__);
14528 }
14529 return bss;
14530}
14531
14532/*
14533 * FUNCTION: wlan_hdd_cfg80211_update_bss
14534 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014535static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
14536 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014538{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014539 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014540 tCsrScanResultInfo *pScanResult;
14541 eHalStatus status = 0;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014542 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070014543 tScanResultHandle pResult;
14544 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070014545 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014546 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070014547 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014548
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014549 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14550 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
14551 NO_SESSION, pAdapter->sessionId));
14552
Wilson Yangf80a0542013-10-07 13:02:37 -070014553 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014554 ret = wlan_hdd_validate_context(pHddCtx);
14555 if (0 != ret)
Jeff Johnson295189b2012-06-20 16:38:30 -070014556 {
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014557 return ret;
Wilson Yangf80a0542013-10-07 13:02:37 -070014558 }
14559
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014560 if (pAdapter->request != NULL)
14561 {
14562 if ((pAdapter->request->n_ssids == 1)
14563 && (pAdapter->request->ssids != NULL)
14564 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
14565 is_p2p_scan = true;
14566 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014567 /*
14568 * start getting scan results and populate cgf80211 BSS database
14569 */
14570 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
14571
14572 /* no scan results */
14573 if (NULL == pResult)
14574 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053014575 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
14576 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053014577 wlan_hdd_get_frame_logs(pAdapter,
14578 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070014579 return status;
14580 }
14581
14582 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
14583
14584 while (pScanResult)
14585 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014586 /*
14587 * cfg80211_inform_bss() is not updating ie field of bss entry, if
14588 * entry already exists in bss data base of cfg80211 for that
14589 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
14590 * bss entry instead of cfg80211_inform_bss, But this call expects
14591 * mgmt packet as input. As of now there is no possibility to get
14592 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070014593 * ieee80211_mgmt(probe response) and passing to c
14594 * fg80211_inform_bss_frame.
14595 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014596 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
14597 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
14598 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014599 pScanResult = sme_ScanResultGetNext(hHal, pResult);
14600 continue; //Skip the non p2p bss entries
14601 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014602 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
14603 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014604
Jeff Johnson295189b2012-06-20 16:38:30 -070014605
14606 if (NULL == bss_status)
14607 {
14608 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014609 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014610 }
14611 else
14612 {
Yue Maf49ba872013-08-19 12:04:25 -070014613 cfg80211_put_bss(
14614#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
14615 wiphy,
14616#endif
14617 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070014618 }
14619
14620 pScanResult = sme_ScanResultGetNext(hHal, pResult);
14621 }
14622
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014623 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014624 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014625 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014626}
14627
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014628void
14629hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
14630{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014631 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080014632 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014633} /****** end hddPrintMacAddr() ******/
14634
14635void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070014636hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014637{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014638 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014639 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070014640 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
14641 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
14642 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014643} /****** end hddPrintPmkId() ******/
14644
14645//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
14646//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
14647
14648//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
14649//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
14650
14651#define dump_bssid(bssid) \
14652 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070014653 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
14654 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014655 }
14656
14657#define dump_pmkid(pMac, pmkid) \
14658 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070014659 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
14660 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014661 }
14662
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070014663#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014664/*
14665 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
14666 * This function is used to notify the supplicant of a new PMKSA candidate.
14667 */
14668int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014669 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014670 int index, bool preauth )
14671{
Jeff Johnsone7245742012-09-05 17:12:55 -070014672#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014673 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070014674 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014675
14676 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070014677 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014678
14679 if( NULL == pRoamInfo )
14680 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014681 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014682 return -EINVAL;
14683 }
14684
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070014685 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
14686 {
14687 dump_bssid(pRoamInfo->bssid);
14688 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014689 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070014690 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014691#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014692 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014693}
14694#endif //FEATURE_WLAN_LFR
14695
Yue Maef608272013-04-08 23:09:17 -070014696#ifdef FEATURE_WLAN_LFR_METRICS
14697/*
14698 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
14699 * 802.11r/LFR metrics reporting function to report preauth initiation
14700 *
14701 */
14702#define MAX_LFR_METRICS_EVENT_LENGTH 100
14703VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
14704 tCsrRoamInfo *pRoamInfo)
14705{
14706 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
14707 union iwreq_data wrqu;
14708
14709 ENTER();
14710
14711 if (NULL == pAdapter)
14712 {
14713 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
14714 return VOS_STATUS_E_FAILURE;
14715 }
14716
14717 /* create the event */
14718 memset(&wrqu, 0, sizeof(wrqu));
14719 memset(metrics_notification, 0, sizeof(metrics_notification));
14720
14721 wrqu.data.pointer = metrics_notification;
14722 wrqu.data.length = scnprintf(metrics_notification,
14723 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
14724 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
14725
14726 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
14727
14728 EXIT();
14729
14730 return VOS_STATUS_SUCCESS;
14731}
14732
14733/*
14734 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
14735 * 802.11r/LFR metrics reporting function to report preauth completion
14736 * or failure
14737 */
14738VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
14739 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
14740{
14741 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
14742 union iwreq_data wrqu;
14743
14744 ENTER();
14745
14746 if (NULL == pAdapter)
14747 {
14748 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
14749 return VOS_STATUS_E_FAILURE;
14750 }
14751
14752 /* create the event */
14753 memset(&wrqu, 0, sizeof(wrqu));
14754 memset(metrics_notification, 0, sizeof(metrics_notification));
14755
14756 scnprintf(metrics_notification, sizeof(metrics_notification),
14757 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
14758 MAC_ADDR_ARRAY(pRoamInfo->bssid));
14759
14760 if (1 == preauth_status)
14761 strncat(metrics_notification, " TRUE", 5);
14762 else
14763 strncat(metrics_notification, " FALSE", 6);
14764
14765 wrqu.data.pointer = metrics_notification;
14766 wrqu.data.length = strlen(metrics_notification);
14767
14768 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
14769
14770 EXIT();
14771
14772 return VOS_STATUS_SUCCESS;
14773}
14774
14775/*
14776 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
14777 * 802.11r/LFR metrics reporting function to report handover initiation
14778 *
14779 */
14780VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
14781 tCsrRoamInfo *pRoamInfo)
14782{
14783 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
14784 union iwreq_data wrqu;
14785
14786 ENTER();
14787
14788 if (NULL == pAdapter)
14789 {
14790 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
14791 return VOS_STATUS_E_FAILURE;
14792 }
14793
14794 /* create the event */
14795 memset(&wrqu, 0, sizeof(wrqu));
14796 memset(metrics_notification, 0, sizeof(metrics_notification));
14797
14798 wrqu.data.pointer = metrics_notification;
14799 wrqu.data.length = scnprintf(metrics_notification,
14800 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
14801 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
14802
14803 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
14804
14805 EXIT();
14806
14807 return VOS_STATUS_SUCCESS;
14808}
14809#endif
14810
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014811
14812/**
14813 * wlan_hdd_cfg80211_validate_scan_req - validate scan request
14814 * @scan_req: scan request to be checked
14815 *
14816 * Return: true or false
14817 */
14818#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
14819static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
14820 cfg80211_scan_request
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014821 *scan_req, hdd_context_t
14822 *hdd_ctx)
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014823{
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014824 if (!scan_req || !scan_req->wiphy ||
14825 scan_req->wiphy != hdd_ctx->wiphy) {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014826 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
14827 return false;
14828 }
14829 if (vos_is_load_unload_in_progress(VOS_MODULE_ID_HDD, NULL)) {
14830 hddLog(VOS_TRACE_LEVEL_ERROR, "Load/Unload in progress");
14831 return false;
14832 }
14833 return true;
14834}
14835#else
14836static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
14837 cfg80211_scan_request
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014838 *scan_req, hdd_context_t
14839 *hdd_ctx)
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014840{
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014841 if (!scan_req || !scan_req->wiphy ||
14842 scan_req->wiphy != hdd_ctx->wiphy) {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014843 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
14844 return false;
14845 }
14846 return true;
14847}
14848#endif
14849
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014850#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))
14851/**
14852 * hdd_cfg80211_scan_done() - Scan completed callback to cfg80211
14853 * @adapter: Pointer to the adapter
14854 * @req : Scan request
14855 * @aborted : true scan aborted false scan success
14856 *
14857 * This function notifies scan done to cfg80211
14858 *
14859 * Return: none
14860 */
14861static void hdd_cfg80211_scan_done(hdd_adapter_t *adapter,
14862 struct cfg80211_scan_request *req,
14863 bool aborted)
14864{
14865 struct cfg80211_scan_info info = {
14866 .aborted = aborted
14867 };
14868
14869 if (adapter->dev->flags & IFF_UP)
14870 cfg80211_scan_done(req, &info);
14871 else
14872 hddLog(LOGW,
14873 FL("IFF_UP flag reset for %s"), adapter->dev->name);
14874}
14875#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
14876/**
14877 * hdd_cfg80211_scan_done() - Scan completed callback to cfg80211
14878 * @adapter: Pointer to the adapter
14879 * @req : Scan request
14880 * @aborted : true scan aborted false scan success
14881 *
14882 * This function notifies scan done to cfg80211
14883 *
14884 * Return: none
14885 */
14886static void hdd_cfg80211_scan_done(hdd_adapter_t *adapter,
14887 struct cfg80211_scan_request *req,
14888 bool aborted)
14889{
14890 if (adapter->dev->flags & IFF_UP)
14891 cfg80211_scan_done(req, aborted);
14892 else
14893 hddLog(LOGW,
14894 FL("IFF_UP flag reset for %s"), adapter->dev->name);
14895}
14896#else
14897/**
14898 * hdd_cfg80211_scan_done() - Scan completed callback to cfg80211
14899 * @adapter: Pointer to the adapter
14900 * @req : Scan request
14901 * @aborted : true scan aborted false scan success
14902 *
14903 * This function notifies scan done to cfg80211
14904 *
14905 * Return: none
14906 */
14907static void hdd_cfg80211_scan_done(hdd_adapter_t *adapter,
14908 struct cfg80211_scan_request *req,
14909 bool aborted)
14910{
14911 cfg80211_scan_done(req, aborted);
14912}
14913#endif
14914
Mukul Sharmab392b642017-08-17 17:45:29 +053014915#define NET_DEV_IS_IFF_UP(pAdapter) (pAdapter->dev->flags & IFF_UP)
Jeff Johnson295189b2012-06-20 16:38:30 -070014916/*
14917 * FUNCTION: hdd_cfg80211_scan_done_callback
14918 * scanning callback function, called after finishing scan
14919 *
14920 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014921static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070014922 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
14923{
14924 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014925 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014927 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070014928 struct cfg80211_scan_request *req = NULL;
14929 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014930 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014931 long waitRet = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014932 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070014933
14934 ENTER();
14935
c_manjee1b4ab9a2016-10-26 11:36:55 +053014936 if (!pAdapter || pAdapter->magic != WLAN_HDD_ADAPTER_MAGIC ||
14937 !pAdapter->dev) {
14938 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Adapter is not valid"));
14939 return 0;
14940 }
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014941 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053014942 if (NULL == pHddCtx) {
14943 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014944 return 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014945 }
14946
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053014947#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mukul Sharmab392b642017-08-17 17:45:29 +053014948 if (!NET_DEV_IS_IFF_UP(pAdapter))
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053014949 {
14950 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down"));
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053014951 }
14952#endif
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014953 pScanInfo = &pHddCtx->scan_info;
14954
Jeff Johnson295189b2012-06-20 16:38:30 -070014955 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070014956 "%s called with halHandle = %pK, pContext = %pK,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080014957 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014958 __func__, halHandle, pContext, (int) scanId, (int) status);
14959
Kiet Lamac06e2c2013-10-23 16:25:07 +053014960 pScanInfo->mScanPendingCounter = 0;
14961
Jeff Johnson295189b2012-06-20 16:38:30 -070014962 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014963 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070014964 &pScanInfo->scan_req_completion_event,
14965 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014966 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014968 hddLog(VOS_TRACE_LEVEL_ERROR,
14969 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070014971 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 }
14973
Yue Maef608272013-04-08 23:09:17 -070014974 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 {
14976 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070014977 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070014978 }
14979
14980 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014981 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014982 {
14983 hddLog(VOS_TRACE_LEVEL_INFO,
14984 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080014985 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070014986 (int) scanId);
14987 }
14988
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053014989#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mukul Sharmab392b642017-08-17 17:45:29 +053014990 if (NET_DEV_IS_IFF_UP(pAdapter))
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053014991#endif
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014992 {
14993 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
14994 pAdapter);
14995 if (0 > ret)
14996 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053014997 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014998
Jeff Johnson295189b2012-06-20 16:38:30 -070014999 /* If any client wait scan result through WEXT
15000 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070015001 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070015002 {
15003 /* The other scan request waiting for current scan finish
15004 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070015005 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070015006 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070015007 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070015008 }
15009 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070015010 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070015011 {
15012 struct net_device *dev = pAdapter->dev;
15013 union iwreq_data wrqu;
15014 int we_event;
15015 char *msg;
15016
15017 memset(&wrqu, '\0', sizeof(wrqu));
15018 we_event = SIOCGIWSCAN;
15019 msg = NULL;
15020 wireless_send_event(dev, we_event, &wrqu, msg);
15021 }
15022 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070015023 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015024
15025 /* Get the Scan Req */
15026 req = pAdapter->request;
mukul sharmae7041822015-12-03 15:09:21 +053015027 pAdapter->request = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015028
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015029 /* Scan is no longer pending */
15030 pScanInfo->mScanPending = VOS_FALSE;
15031
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053015032 if (!wlan_hdd_cfg80211_validate_scan_req(req, pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -070015033 {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053015034#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
15035 hddLog(VOS_TRACE_LEVEL_ERROR, FL("interface state %s"),
Mukul Sharmab392b642017-08-17 17:45:29 +053015036 NET_DEV_IS_IFF_UP(pAdapter) ? "up" : "down");
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053015037#endif
15038
15039 if (pAdapter->dev) {
15040 hddLog(VOS_TRACE_LEVEL_ERROR, FL("device name %s"),
15041 pAdapter->dev->name);
15042 }
mukul sharmae7041822015-12-03 15:09:21 +053015043 complete(&pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -070015044 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070015045 }
15046
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015047 /* last_scan_timestamp is used to decide if new scan
15048 * is needed or not on station interface. If last station
15049 * scan time and new station scan time is less then
15050 * last_scan_timestamp ; driver will return cached scan.
Hanumanth Reddy Pothulaf31f65c2018-01-30 19:51:27 +053015051 * Also only last_scan_timestamp is updated here last_scan_channellist
15052 * is updated on receiving scan request itself to make sure kernel
15053 * allocated scan request(scan_req) object is not dereferenced here,
15054 * because interface down, where kernel frees scan_req, may happen any
15055 * time while driver is processing scan_done_callback. So it's better
15056 * not to access scan_req in this routine.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015057 */
Hanumanth Reddy Pothulaf31f65c2018-01-30 19:51:27 +053015058 if (pScanInfo->no_cck == FALSE) { // no_cck will be set during p2p find
15059 if (status == eCSR_SCAN_SUCCESS)
15060 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
15061 else {
15062 vos_mem_zero(pHddCtx->scan_info.last_scan_channelList,
15063 sizeof(pHddCtx->scan_info.last_scan_channelList));
15064 pHddCtx->scan_info.last_scan_numChannels = 0;
15065 pScanInfo->last_scan_timestamp = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015066 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015067 }
15068
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070015069 /*
15070 * cfg80211_scan_done informing NL80211 about completion
15071 * of scanning
15072 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053015073 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
15074 {
15075 aborted = true;
15076 }
mukul sharmae7041822015-12-03 15:09:21 +053015077
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015078#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mukul Sharmab392b642017-08-17 17:45:29 +053015079 if (NET_DEV_IS_IFF_UP(pAdapter) &&
15080 wlan_hdd_cfg80211_validate_scan_req(req, pHddCtx))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015081#endif
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053015082 hdd_cfg80211_scan_done(pAdapter, req, aborted);
mukul sharmae7041822015-12-03 15:09:21 +053015083
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080015084 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070015085
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015086allow_suspend:
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053015087 if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
15088 ) && (pHddCtx->spoofMacAddr.isEnabled
15089 || pHddCtx->spoofMacAddr.isReqDeferred)) {
Siddharth Bhal76972212014-10-15 16:22:51 +053015090 /* Generate new random mac addr for next scan */
15091 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +053015092
15093 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
15094 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhal76972212014-10-15 16:22:51 +053015095 }
15096
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070015097 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015098 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070015099
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070015100 /* Acquire wakelock to handle the case where APP's tries to suspend
15101 * immediatly after the driver gets connect request(i.e after scan)
15102 * from supplicant, this result in app's is suspending and not able
15103 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015104 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070015105
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015106#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mukul Sharmab392b642017-08-17 17:45:29 +053015107 if (NET_DEV_IS_IFF_UP(pAdapter))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015108#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070015109#ifdef FEATURE_WLAN_TDLS
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015110 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070015111#endif
15112
Jeff Johnson295189b2012-06-20 16:38:30 -070015113 EXIT();
15114 return 0;
15115}
15116
15117/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053015118 * FUNCTION: hdd_isConnectionInProgress
15119 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015120 *
15121 */
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015122v_BOOL_t hdd_isConnectionInProgress(hdd_context_t *pHddCtx, v_U8_t *session_id,
15123 scan_reject_states *reason)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015124{
15125 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
15126 hdd_station_ctx_t *pHddStaCtx = NULL;
15127 hdd_adapter_t *pAdapter = NULL;
15128 VOS_STATUS status = 0;
15129 v_U8_t staId = 0;
15130 v_U8_t *staMac = NULL;
15131
15132 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
15133
15134 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
15135 {
15136 pAdapter = pAdapterNode->pAdapter;
15137
15138 if( pAdapter )
15139 {
15140 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015141 "%s: Adapter with device mode %s (%d) exists",
15142 __func__, hdd_device_modetoString(pAdapter->device_mode),
15143 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015144 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053015145 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
15146 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
15147 (eConnectionState_Connecting ==
15148 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
15149 {
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015150 hddLog(LOG1,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070015151 "%s: %pK(%d) Connection is in progress", __func__,
Rashmi Ramannab1429032014-04-26 14:59:09 +053015152 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015153 if (session_id && reason)
15154 {
15155 *session_id = pAdapter->sessionId;
15156 *reason = eHDD_CONNECTION_IN_PROGRESS;
15157 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053015158 return VOS_TRUE;
15159 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015160 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053015161 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015162 {
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015163 hddLog(LOG1,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070015164 "%s: %pK(%d) Reassociation is in progress", __func__,
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015165 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015166 if (session_id && reason)
15167 {
15168 *session_id = pAdapter->sessionId;
15169 *reason = eHDD_REASSOC_IN_PROGRESS;
15170 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015171 return VOS_TRUE;
15172 }
15173 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015174 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
15175 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015176 {
15177 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15178 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Vignesh Viswanathan0ac8e562018-06-14 17:24:10 +053015179 sme_is_sta_key_exchange_in_progress(pHddCtx->hHal,
15180 pAdapter->sessionId))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015181 {
15182 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015183 hddLog(LOG1,
Arif Hussain24bafea2013-11-15 15:10:03 -080015184 "%s: client " MAC_ADDRESS_STR
15185 " is in the middle of WPS/EAPOL exchange.", __func__,
15186 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015187 if (session_id && reason)
15188 {
15189 *session_id = pAdapter->sessionId;
15190 *reason = eHDD_EAPOL_IN_PROGRESS;
15191 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053015192 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015193 }
15194 }
15195 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
15196 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
15197 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015198 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
15199 ptSapContext pSapCtx = NULL;
15200 pSapCtx = VOS_GET_SAP_CB(pVosContext);
15201 if(pSapCtx == NULL){
15202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15203 FL("psapCtx is NULL"));
15204 return VOS_FALSE;
15205 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015206 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
15207 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015208 if ((pSapCtx->aStaInfo[staId].isUsed) &&
15209 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015210 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015211 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015212
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015213 hddLog(LOG1,
Arif Hussain24bafea2013-11-15 15:10:03 -080015214 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
15215 "middle of WPS/EAPOL exchange.", __func__,
15216 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015217 if (session_id && reason)
15218 {
15219 *session_id = pAdapter->sessionId;
15220 *reason = eHDD_SAP_EAPOL_IN_PROGRESS;
15221 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053015222 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015223 }
15224 }
15225 }
15226 }
15227 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
15228 pAdapterNode = pNext;
15229 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053015230 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015231}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015232
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053015233/**
15234 * csr_scan_request_assign_bssid() - Set the BSSID received from Supplicant
15235 * to the Scan request
15236 * @scanRequest: Pointer to the csr scan request
15237 * @request: Pointer to the scan request from supplicant
15238 *
15239 * Return: None
15240 */
15241#ifdef CFG80211_SCAN_BSSID
15242static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
15243 struct cfg80211_scan_request *request)
15244{
15245 vos_mem_copy(scanRequest->bssid, request->bssid, VOS_MAC_ADDR_SIZE);
15246}
15247#else
15248static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
15249 struct cfg80211_scan_request *request)
15250{
15251}
15252#endif
15253
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +053015254#if defined(CFG80211_SCAN_RANDOM_MAC_ADDR) || \
15255 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
15256/**
15257 * hdd_is_wiphy_scan_random_support() - Check NL80211 scan randomization support
15258 * @wiphy: Pointer to wiphy structure
15259 *
15260 * This function is used to check whether @wiphy supports
15261 * NL80211 scan randomization feature.
15262 *
15263 * Return: If randomization is supported then return true else false.
15264 */
15265static bool
15266hdd_is_wiphy_scan_random_support(struct wiphy *wiphy)
15267{
15268 if (wiphy->features & NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR)
15269 return true;
15270
15271 return false;
15272}
15273
15274/**
15275 * hdd_is_nl_scan_random() - Check for randomization flag in cfg80211 scan
15276 * @nl_scan: cfg80211 scan request
15277 *
15278 * This function is used to check whether scan randomization flag is set for
15279 * current cfg80211 scan request identified by @nl_scan.
15280 *
15281 * Return: If randomization flag is set then return true else false.
15282 */
15283static bool
15284hdd_is_nl_scan_random(struct cfg80211_scan_request *nl_scan)
15285{
15286 if (nl_scan->flags & NL80211_SCAN_FLAG_RANDOM_ADDR)
15287 return true;
15288
15289 return false;
15290}
15291#else
15292static bool
15293hdd_is_wiphy_scan_random_support(struct wiphy *wiphy)
15294{
15295 return false;
15296}
15297
15298static bool
15299hdd_is_nl_scan_random(struct cfg80211_scan_request *nl_scan)
15300{
15301 return false;
15302}
15303#endif
15304
15305/**
15306 * hdd_generate_scan_random_mac() - Generate Random mac addr for cfg80211 scan
15307 * @mac_addr: Input mac-addr from which random-mac address is to be generated
15308 * @mac_mask: Bits of mac_addr which should not be randomized
15309 * @random_mac: Output pointer to hold generated random mac address
15310 *
15311 * This function is used generate random mac address using @mac_addr and
15312 * @mac_mask with following logic:
15313 * Bit value 0 in the mask means that we should randomize that bit.
15314 * Bit value 1 in the mask means that we should take specific bit value
15315 * from mac address provided.
15316 *
15317 * Return: None
15318 */
15319static void
15320hdd_generate_scan_random_mac(uint8_t *mac_addr, uint8_t *mac_mask,
15321 uint8_t *random_mac)
15322{
15323 uint32_t i;
15324 uint8_t random_byte;
15325
15326 for (i = 0; i < VOS_MAC_ADDRESS_LEN; i++) {
15327 random_byte = 0;
15328 get_random_bytes(&random_byte, 1);
15329 random_mac[i] = (mac_addr[i] & mac_mask[i]) |
15330 (random_byte & (~(mac_mask[i])));
15331 }
15332
15333 /*
15334 * Make sure locally administered bit is set if that
15335 * particular bit in the mask is 0
15336 */
15337 if (!(mac_mask[0] & 0x2))
15338 random_mac[0] |= 0x2;
15339
15340 /*
15341 * Make sure multicast/group address bit is NOT set if that
15342 * particular bit in the mask is 0
15343 */
15344 if (!(mac_mask[0] & 0x1))
15345 random_mac[0] &= ~0x1;
15346}
15347
15348/**
15349 * hdd_spoof_scan() - Spoof cfg80211 scan
15350 * @wiphy: Pointer to wiphy
15351 * @adapter: Pointer to adapter for which scan is requested
15352 * @nl_scan: Cfg80211 scan request
15353 * @is_p2p_scan: Check for p2p scan
15354 * @csr_scan: Pointer to internal (csr) scan request
15355 *
15356 * This function is used for following purposes:
15357 * (a) If cfg80211 supports scan randomization then this function invokes helper
15358 * functions to generate random-mac address.
15359 * (b) If the cfg80211 doesn't support scan randomization then randomize scans
15360 * using spoof mac received with VENDOR_SUBCMD_MAC_OUI.
15361 * (c) Configure the random-mac in transport layer.
15362 *
15363 * Return: For success return 0 else return negative value.
15364 */
15365static int
15366hdd_spoof_scan(struct wiphy *wiphy, hdd_adapter_t *adapter,
15367 struct cfg80211_scan_request *nl_scan,
15368 bool is_p2p_scan, tCsrScanRequest *csr_scan)
15369{
15370 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
15371 hdd_config_t *config = hdd_ctx->cfg_ini;
15372 uint8_t random_mac[VOS_MAC_ADDRESS_LEN];
15373 VOS_STATUS vos_status;
15374 eHalStatus hal_status;
15375
15376 csr_scan->nl_scan = true;
15377 csr_scan->scan_randomize = false;
15378
15379 if (config->enableMacSpoofing != MAC_ADDR_SPOOFING_FW_HOST_ENABLE ||
15380 !sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN))
15381 return 0;
15382
15383 vos_flush_delayed_work(&hdd_ctx->spoof_mac_addr_work);
15384
15385 if (hdd_is_wiphy_scan_random_support(wiphy)) {
15386 if (!hdd_is_nl_scan_random(nl_scan) || is_p2p_scan)
15387 return 0;
15388
15389 hdd_generate_scan_random_mac(nl_scan->mac_addr,
15390 nl_scan->mac_addr_mask,
15391 random_mac);
15392
15393 hddLog(VOS_TRACE_LEVEL_INFO,
15394 FL("cfg80211 scan random attributes:"));
15395 hddLog(VOS_TRACE_LEVEL_INFO, "mac-addr: "MAC_ADDRESS_STR
15396 " mac-mask: "MAC_ADDRESS_STR
15397 " random-mac: "MAC_ADDRESS_STR,
15398 MAC_ADDR_ARRAY(nl_scan->mac_addr),
15399 MAC_ADDR_ARRAY(nl_scan->mac_addr_mask),
15400 MAC_ADDR_ARRAY(random_mac));
15401
15402 hal_status = sme_SpoofMacAddrReq(hdd_ctx->hHal,
15403 (v_MACADDR_t *)random_mac,
15404 false);
15405 if (hal_status != eHAL_STATUS_SUCCESS) {
15406 hddLog(LOGE,
15407 FL("Send of Spoof request failed"));
15408 hddLog(LOGE,
15409 FL("Disable spoofing and use self-mac"));
15410 return 0;
15411 }
15412
15413 vos_status = WLANTL_updateSpoofMacAddr(hdd_ctx->pvosContext,
15414 (v_MACADDR_t*)random_mac,
15415 &adapter->macAddressCurrent);
15416 if(vos_status != VOS_STATUS_SUCCESS) {
15417 hddLog(VOS_TRACE_LEVEL_ERROR,
15418 FL("Failed to update spoof mac in TL"));
15419 return -EINVAL;
15420 }
15421
15422 csr_scan->scan_randomize = true;
15423
15424 return 0;
15425 }
15426
15427 /*
15428 * If wiphy does not support cfg80211 scan randomization then scan
15429 * will be randomized using the vendor MAC OUI.
15430 */
15431 if (!hdd_ctx->spoofMacAddr.isEnabled)
15432 return 0;
15433
15434 hddLog(VOS_TRACE_LEVEL_INFO,
15435 FL("MAC Spoofing enabled for current scan and spoof addr is:"
15436 MAC_ADDRESS_STR),
15437 MAC_ADDR_ARRAY(hdd_ctx->spoofMacAddr.randomMacAddr.bytes));
15438
15439 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
15440 * to fill TxBds for probe request during current scan
15441 */
15442 vos_status = WLANTL_updateSpoofMacAddr(hdd_ctx->pvosContext,
15443 &hdd_ctx->spoofMacAddr.randomMacAddr, &adapter->macAddressCurrent);
15444 if(vos_status != VOS_STATUS_SUCCESS) {
15445 hddLog(VOS_TRACE_LEVEL_ERROR,
15446 FL("Failed to update spoof mac in TL"));
15447 return -EINVAL;
15448 }
15449
15450 csr_scan->scan_randomize = true;
15451
15452 return 0;
15453}
15454
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015455/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015456 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070015457 * this scan respond to scan trigger and update cfg80211 scan database
15458 * later, scan dump command can be used to recieve scan results
15459 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015460int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080015461#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
15462 struct net_device *dev,
15463#endif
15464 struct cfg80211_scan_request *request)
15465{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053015466 hdd_adapter_t *pAdapter = NULL;
15467 hdd_context_t *pHddCtx = NULL;
15468 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015469 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015470 tCsrScanRequest scanRequest;
15471 tANI_U8 *channelList = NULL, i;
15472 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015473 int status;
15474 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015475 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015476 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053015477 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053015478 bool is_p2p_scan = false;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015479 v_U8_t curr_session_id;
15480 scan_reject_states curr_reason;
Jeff Johnson295189b2012-06-20 16:38:30 -070015481
Siddharth Bhal0c162d02014-05-06 19:50:42 +053015482#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
15483 struct net_device *dev = NULL;
15484 if (NULL == request)
15485 {
15486 hddLog(VOS_TRACE_LEVEL_ERROR,
15487 "%s: scan req param null", __func__);
15488 return -EINVAL;
15489 }
15490 dev = request->wdev->netdev;
15491#endif
15492
15493 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
15494 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
15495 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15496
Jeff Johnson295189b2012-06-20 16:38:30 -070015497 ENTER();
15498
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015499 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
15500 __func__, hdd_device_modetoString(pAdapter->device_mode),
15501 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015502
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015503 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015504 if (0 != status)
15505 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015506 return status;
15507 }
15508
Siddharth Bhal0c162d02014-05-06 19:50:42 +053015509 if (NULL == pwextBuf)
15510 {
15511 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
15512 __func__);
15513 return -EIO;
15514 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015515 cfg_param = pHddCtx->cfg_ini;
15516 pScanInfo = &pHddCtx->scan_info;
15517
Jeff Johnson295189b2012-06-20 16:38:30 -070015518#ifdef WLAN_BTAMP_FEATURE
15519 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015520 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070015521 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080015522 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015523 "%s: No scanning when AMP is on", __func__);
15524 return -EOPNOTSUPP;
15525 }
15526#endif
15527 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015528 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070015529 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015530 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015531 "%s: Not scanning on device_mode = %s (%d)",
15532 __func__, hdd_device_modetoString(pAdapter->device_mode),
15533 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015534 return -EOPNOTSUPP;
15535 }
15536
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053015537 if (pAdapter->device_mode == WLAN_HDD_MONITOR) {
15538 hddLog(LOGE, FL("Scan is not supported for monitor adapter"));
15539 return -EOPNOTSUPP;
15540 }
15541
Jeff Johnson295189b2012-06-20 16:38:30 -070015542 if (TRUE == pScanInfo->mScanPending)
15543 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053015544 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
15545 {
15546 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
15547 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015548 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070015549 }
15550
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053015551 // Don't allow scan if PNO scan is going on.
15552 if (pHddCtx->isPnoEnable)
15553 {
15554 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15555 FL("pno scan in progress"));
15556 return -EBUSY;
15557 }
15558
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015559 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070015560 //Channel and action frame is pending
15561 //Otherwise Cancel Remain On Channel and allow Scan
15562 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015563 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070015564 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053015565 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070015566 return -EBUSY;
15567 }
15568
Jeff Johnson295189b2012-06-20 16:38:30 -070015569 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
15570 {
15571 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080015572 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015573 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015574 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015575 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
15576 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053015577 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015578 "%s: MAX TM Level Scan not allowed", __func__);
15579 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015580 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070015581 }
15582 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
15583
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015584 /* Check if scan is allowed at this point of time.
15585 */
Hanumanth Reddy Pothulaec960842016-09-14 19:04:26 +053015586 if (TRUE == pHddCtx->btCoexModeSet)
15587 {
15588 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15589 FL("BTCoex Mode operation in progress"));
15590 return -EBUSY;
15591 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015592 if (hdd_isConnectionInProgress(pHddCtx, &curr_session_id, &curr_reason))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015593 {
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015594
15595 if (!(pHddCtx->scan_reject_cnt % HDD_SCAN_REJECT_RATE_LIMIT))
15596 hddLog(LOGE, FL("Scan not allowed Session %d reason %d"),
15597 curr_session_id, curr_reason);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015598 if (pHddCtx->last_scan_reject_session_id != curr_session_id ||
15599 pHddCtx->last_scan_reject_reason != curr_reason ||
15600 !pHddCtx->last_scan_reject_timestamp)
15601 {
15602 pHddCtx->last_scan_reject_session_id = curr_session_id;
15603 pHddCtx->last_scan_reject_reason = curr_reason;
Abhishek Singh3e500772017-07-17 10:13:43 +053015604 pHddCtx->last_scan_reject_timestamp =
Abhinav Kumar61d1bfe2018-07-26 00:30:22 +053015605 jiffies + msecs_to_jiffies(SCAN_REJECT_THRESHOLD_TIME);
Abhishek Singhe4b12562017-06-20 16:53:39 +053015606 pHddCtx->scan_reject_cnt = 0;
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053015607 }
Abhishek Singhe4b12562017-06-20 16:53:39 +053015608 else
15609 {
15610 pHddCtx->scan_reject_cnt++;
15611
Abhishek Singhe4b12562017-06-20 16:53:39 +053015612 if ((pHddCtx->scan_reject_cnt >=
15613 SCAN_REJECT_THRESHOLD) &&
Abhinav Kumar61d1bfe2018-07-26 00:30:22 +053015614 vos_system_time_after(jiffies,
Abhishek Singh3e500772017-07-17 10:13:43 +053015615 pHddCtx->last_scan_reject_timestamp))
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015616 {
Abhinav Kumar61d1bfe2018-07-26 00:30:22 +053015617 hddLog(LOGE, FL("Session %d reason %d reject cnt %d reject timestamp %lu jiffies %lu"),
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015618 curr_session_id, curr_reason, pHddCtx->scan_reject_cnt,
Abhinav Kumar61d1bfe2018-07-26 00:30:22 +053015619 pHddCtx->last_scan_reject_timestamp, jiffies);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015620 pHddCtx->last_scan_reject_timestamp = 0;
Abhishek Singhe4b12562017-06-20 16:53:39 +053015621 pHddCtx->scan_reject_cnt = 0;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015622 if (pHddCtx->cfg_ini->enableFatalEvent)
15623 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
15624 WLAN_LOG_INDICATOR_HOST_DRIVER,
15625 WLAN_LOG_REASON_SCAN_NOT_ALLOWED,
15626 FALSE, FALSE);
15627 else
15628 {
15629 hddLog(LOGE, FL("Triggering SSR"));
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +053015630 vos_wlanRestart(VOS_SCAN_REQ_EXPIRED);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015631 }
15632 }
15633 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015634 return -EBUSY;
15635 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015636 pHddCtx->last_scan_reject_timestamp = 0;
15637 pHddCtx->last_scan_reject_session_id = 0xFF;
15638 pHddCtx->last_scan_reject_reason = 0;
Abhishek Singhe4b12562017-06-20 16:53:39 +053015639 pHddCtx->scan_reject_cnt = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015640
Jeff Johnson295189b2012-06-20 16:38:30 -070015641 vos_mem_zero( &scanRequest, sizeof(scanRequest));
15642
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015643 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
15644 * Becasue of this, driver is assuming that this is not wildcard scan and so
15645 * is not aging out the scan results.
15646 */
Hanumanth Reddy Pothula998efeb2017-10-31 15:43:19 +053015647 if ((request->ssids) && (request->n_ssids == 1) &&
15648 ('\0' == request->ssids->ssid[0])) {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015649 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015650 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015651
15652 if ((request->ssids) && (0 < request->n_ssids))
15653 {
15654 tCsrSSIDInfo *SsidInfo;
15655 int j;
15656 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
15657 /* Allocate num_ssid tCsrSSIDInfo structure */
15658 SsidInfo = scanRequest.SSIDs.SSIDList =
15659 ( tCsrSSIDInfo *)vos_mem_malloc(
15660 request->n_ssids*sizeof(tCsrSSIDInfo));
15661
15662 if(NULL == scanRequest.SSIDs.SSIDList)
15663 {
15664 hddLog(VOS_TRACE_LEVEL_ERROR,
15665 "%s: memory alloc failed SSIDInfo buffer", __func__);
15666 return -ENOMEM;
15667 }
15668
15669 /* copy all the ssid's and their length */
15670 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
15671 {
15672 /* get the ssid length */
15673 SsidInfo->SSID.length = request->ssids[j].ssid_len;
15674 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
15675 SsidInfo->SSID.length);
15676 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
15677 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
15678 j, SsidInfo->SSID.ssId);
15679 }
15680 /* set the scan type to active */
15681 scanRequest.scanType = eSIR_ACTIVE_SCAN;
15682 }
15683 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070015684 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053015685 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15686 TRACE_CODE_HDD_CFG80211_SCAN,
15687 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070015688 /* set the scan type to active */
15689 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070015690 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015691 else
15692 {
15693 /*Set the scan type to default type, in this case it is ACTIVE*/
15694 scanRequest.scanType = pScanInfo->scan_mode;
15695 }
15696 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
15697 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070015698
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053015699 csr_scan_request_assign_bssid(&scanRequest, request);
15700
Jeff Johnson295189b2012-06-20 16:38:30 -070015701 /* set BSSType to default type */
15702 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
15703
15704 /*TODO: scan the requested channels only*/
15705
15706 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015707 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070015708 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015709 hddLog(VOS_TRACE_LEVEL_WARN,
15710 "No of Scan Channels exceeded limit: %d", request->n_channels);
15711 request->n_channels = MAX_CHANNEL;
15712 }
15713
15714 hddLog(VOS_TRACE_LEVEL_INFO,
15715 "No of Scan Channels: %d", request->n_channels);
15716
15717
15718 if( request->n_channels )
15719 {
15720 char chList [(request->n_channels*5)+1];
15721 int len;
15722 channelList = vos_mem_malloc( request->n_channels );
15723 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053015724 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015725 hddLog(VOS_TRACE_LEVEL_ERROR,
15726 "%s: memory alloc failed channelList", __func__);
15727 status = -ENOMEM;
15728 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053015729 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015730
15731 for( i = 0, len = 0; i < request->n_channels ; i++ )
15732 {
15733 channelList[i] = request->channels[i]->hw_value;
15734 len += snprintf(chList+len, 5, "%d ", channelList[i]);
15735 }
15736
Nirav Shah20ac06f2013-12-12 18:14:06 +053015737 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015738 "Channel-List: %s ", chList);
15739 }
c_hpothu53512302014-04-15 18:49:53 +053015740
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015741 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
15742 scanRequest.ChannelInfo.ChannelList = channelList;
15743
15744 /* set requestType to full scan */
15745 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
15746
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015747 /* if there is back to back scan happening in driver with in
15748 * nDeferScanTimeInterval interval driver should defer new scan request
15749 * and should provide last cached scan results instead of new channel list.
15750 * This rule is not applicable if scan is p2p scan.
15751 * This condition will work only in case when last request no of channels
15752 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053015753 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053015754 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015755 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015756
Sushant Kaushik86592172015-04-27 16:35:03 +053015757 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
15758 /* if wps ie is NULL , then only defer scan */
15759 if ( pWpsIe == NULL &&
15760 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053015761 {
15762 if ( pScanInfo->last_scan_timestamp !=0 &&
15763 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
15764 {
15765 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
15766 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
15767 vos_mem_compare(pScanInfo->last_scan_channelList,
15768 channelList, pScanInfo->last_scan_numChannels))
15769 {
15770 hddLog(VOS_TRACE_LEVEL_WARN,
15771 " New and old station scan time differ is less then %u",
15772 pHddCtx->cfg_ini->nDeferScanTimeInterval);
15773
15774 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015775 pAdapter);
15776
Agarwal Ashish57e84372014-12-05 18:26:53 +053015777 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053015778 "Return old cached scan as all channels and no of channels are same");
15779
Agarwal Ashish57e84372014-12-05 18:26:53 +053015780 if (0 > ret)
15781 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015782
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053015783 hdd_cfg80211_scan_done(pAdapter, request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053015784
15785 status = eHAL_STATUS_SUCCESS;
15786 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053015787 }
15788 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015789 }
15790
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015791 /* Flush the scan results(only p2p beacons) for STA scan and P2P
15792 * search (Flush on both full scan and social scan but not on single
15793 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
15794 */
15795
15796 /* Supplicant does single channel scan after 8-way handshake
15797 * and in that case driver shoudnt flush scan results. If
15798 * driver flushes the scan results here and unfortunately if
15799 * the AP doesnt respond to our probe req then association
15800 * fails which is not desired
15801 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053015802 if ((request->n_ssids == 1)
15803 && (request->ssids != NULL)
15804 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
15805 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015806
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053015807 if( is_p2p_scan ||
15808 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015809 {
15810 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
15811 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
15812 pAdapter->sessionId );
15813 }
15814
15815 if( request->ie_len )
15816 {
15817 /* save this for future association (join requires this) */
15818 /*TODO: Array needs to be converted to dynamic allocation,
15819 * as multiple ie.s can be sent in cfg80211_scan_request structure
15820 * CR 597966
15821 */
15822 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
15823 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
15824 pScanInfo->scanAddIE.length = request->ie_len;
15825
15826 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
15827 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
15828 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070015829 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015830 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070015831 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015832 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
15833 memcpy( pwextBuf->roamProfile.addIEScan,
15834 request->ie, request->ie_len);
15835 }
15836 else
15837 {
15838 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
15839 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015840 }
15841
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015842 }
15843 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
15844 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
15845
15846 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
15847 request->ie_len);
15848 if (pP2pIe != NULL)
15849 {
15850#ifdef WLAN_FEATURE_P2P_DEBUG
15851 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
15852 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
15853 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053015854 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015855 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
15856 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
15857 "Go nego completed to Connection is started");
15858 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
15859 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053015860 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015861 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
15862 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070015863 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015864 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
15865 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
15866 "Disconnected state to Connection is started");
15867 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
15868 "for 4way Handshake");
15869 }
15870#endif
15871
15872 /* no_cck will be set during p2p find to disable 11b rates */
15873 if(TRUE == request->no_cck)
15874 {
15875 hddLog(VOS_TRACE_LEVEL_INFO,
15876 "%s: This is a P2P Search", __func__);
15877 scanRequest.p2pSearch = 1;
15878
15879 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053015880 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015881 /* set requestType to P2P Discovery */
15882 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
15883 }
15884
15885 /*
15886 Skip Dfs Channel in case of P2P Search
15887 if it is set in ini file
15888 */
15889 if(cfg_param->skipDfsChnlInP2pSearch)
15890 {
15891 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053015892 }
15893 else
15894 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015895 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053015896 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015897
Agarwal Ashish4f616132013-12-30 23:32:50 +053015898 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015899 }
15900 }
15901
15902 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
15903
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015904#ifdef FEATURE_WLAN_TDLS
15905 /* if tdls disagree scan right now, return immediately.
15906 tdls will schedule the scan when scan is allowed. (return SUCCESS)
15907 or will reject the scan if any TDLS is in progress. (return -EBUSY)
15908 */
15909 status = wlan_hdd_tdls_scan_callback (pAdapter,
15910 wiphy,
15911#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
15912 dev,
15913#endif
15914 request);
Abhishek Singhe2b63952016-01-05 18:27:29 +053015915 if (status <= 0)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015916 {
Abhishek Singhe2b63952016-01-05 18:27:29 +053015917 if (!status)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015918 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
15919 "scan rejected %d", __func__, status);
15920 else
15921 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
15922 __func__, status);
Abhishek Singhe2b63952016-01-05 18:27:29 +053015923 hdd_wlan_block_scan_by_tdls();
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053015924 goto free_mem;
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015925 }
15926#endif
15927
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070015928 /* acquire the wakelock to avoid the apps suspend during the scan. To
15929 * address the following issues.
15930 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
15931 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
15932 * for long time, this result in apps running at full power for long time.
15933 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
15934 * be stuck in full power because of resume BMPS
15935 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015936 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070015937
Nirav Shah20ac06f2013-12-12 18:14:06 +053015938 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
15939 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015940 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
15941 scanRequest.requestType, scanRequest.scanType,
15942 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053015943 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
15944
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +053015945 ret = hdd_spoof_scan(wiphy, pAdapter, request, is_p2p_scan, &scanRequest);
15946 if(ret) {
15947 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
15948 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053015949#ifdef FEATURE_WLAN_TDLS
15950 wlan_hdd_tdls_scan_done_callback(pAdapter);
15951#endif
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +053015952 goto free_mem;
Siddharth Bhal76972212014-10-15 16:22:51 +053015953 }
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +053015954
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053015955 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070015956 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070015957 pAdapter->sessionId, &scanRequest, &scanId,
15958 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070015959
Jeff Johnson295189b2012-06-20 16:38:30 -070015960 if (eHAL_STATUS_SUCCESS != status)
15961 {
15962 hddLog(VOS_TRACE_LEVEL_ERROR,
15963 "%s: sme_ScanRequest returned error %d", __func__, status);
15964 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070015965 if(eHAL_STATUS_RESOURCES == status)
15966 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053015967 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
15968 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070015969 status = -EBUSY;
15970 } else {
15971 status = -EIO;
15972 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015973 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015974
15975#ifdef FEATURE_WLAN_TDLS
15976 wlan_hdd_tdls_scan_done_callback(pAdapter);
15977#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015978 goto free_mem;
15979 }
15980
15981 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053015982 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015983 pAdapter->request = request;
15984 pScanInfo->scanId = scanId;
Hanumanth Reddy Pothulaf31f65c2018-01-30 19:51:27 +053015985 pScanInfo->no_cck = request->no_cck;
15986 pHddCtx->scan_info.last_scan_numChannels = request->n_channels;
15987 for (i = 0; i < pHddCtx->scan_info.last_scan_numChannels; i++) {
15988 pHddCtx->scan_info.last_scan_channelList[i] =
15989 request->channels[i]->hw_value;
15990 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015991
15992 complete(&pScanInfo->scan_req_completion_event);
15993
15994free_mem:
15995 if( scanRequest.SSIDs.SSIDList )
15996 {
15997 vos_mem_free(scanRequest.SSIDs.SSIDList);
15998 }
15999
16000 if( channelList )
16001 vos_mem_free( channelList );
16002
16003 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016004 return status;
16005}
16006
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053016007int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
16008#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
16009 struct net_device *dev,
16010#endif
16011 struct cfg80211_scan_request *request)
16012{
16013 int ret;
16014
16015 vos_ssr_protect(__func__);
16016 ret = __wlan_hdd_cfg80211_scan(wiphy,
16017#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
16018 dev,
16019#endif
16020 request);
16021 vos_ssr_unprotect(__func__);
16022
16023 return ret;
16024}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016025
16026void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
16027{
16028 v_U8_t iniDot11Mode =
16029 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
16030 eHddDot11Mode hddDot11Mode = iniDot11Mode;
16031
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053016032 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
16033 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016034 switch ( iniDot11Mode )
16035 {
16036 case eHDD_DOT11_MODE_AUTO:
16037 case eHDD_DOT11_MODE_11ac:
16038 case eHDD_DOT11_MODE_11ac_ONLY:
16039#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053016040 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
16041 sme_IsFeatureSupportedByFW(DOT11AC) )
16042 hddDot11Mode = eHDD_DOT11_MODE_11ac;
16043 else
16044 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016045#else
16046 hddDot11Mode = eHDD_DOT11_MODE_11n;
16047#endif
16048 break;
16049 case eHDD_DOT11_MODE_11n:
16050 case eHDD_DOT11_MODE_11n_ONLY:
16051 hddDot11Mode = eHDD_DOT11_MODE_11n;
16052 break;
16053 default:
16054 hddDot11Mode = iniDot11Mode;
16055 break;
16056 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053016057#ifdef WLAN_FEATURE_AP_HT40_24G
16058 if (operationChannel > SIR_11B_CHANNEL_END)
16059#endif
16060 {
16061 /* This call decides required channel bonding mode */
16062 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016063 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
Abhishek Singh02b823e2017-10-30 17:53:20 +053016064 operationChannel, eHT_MAX_CHANNEL_WIDTH);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053016065 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016066}
16067
Jeff Johnson295189b2012-06-20 16:38:30 -070016068/*
16069 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016070 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070016071 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016072int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053016073 const u8 *ssid, size_t ssid_len, const u8 *bssid,
16074 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070016075{
16076 int status = 0;
16077 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080016078 hdd_context_t *pHddCtx;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053016079 hdd_station_ctx_t *hdd_sta_ctx;
Jeff Johnson295189b2012-06-20 16:38:30 -070016080 v_U32_t roamId;
16081 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070016082 eCsrAuthType RSNAuthType;
16083
16084 ENTER();
16085
16086 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080016087 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053016088 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080016089
16090 status = wlan_hdd_validate_context(pHddCtx);
16091 if (status)
16092 {
Yue Mae36e3552014-03-05 17:06:20 -080016093 return status;
16094 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016095
Jeff Johnson295189b2012-06-20 16:38:30 -070016096 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
16097 {
16098 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
16099 return -EINVAL;
16100 }
16101
Nitesh Shah9b066282017-06-06 18:05:52 +053016102
Jeff Johnson295189b2012-06-20 16:38:30 -070016103 pRoamProfile = &pWextState->roamProfile;
16104
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016105 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070016106 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016107 hdd_station_ctx_t *pHddStaCtx;
16108 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Abhishek Singh6782c9e2017-06-06 13:37:45 +053016109 pHddStaCtx->get_mgmt_log_sent = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016110
Siddharth Bhalda0d1622015-04-24 15:47:49 +053016111 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
16112
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016113 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070016114 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
16115 {
16116 /*QoS not enabled in cfg file*/
16117 pRoamProfile->uapsd_mask = 0;
16118 }
16119 else
16120 {
16121 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016122 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070016123 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
16124 }
16125
16126 pRoamProfile->SSIDs.numOfSSIDs = 1;
16127 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
16128 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016129 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070016130 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
16131 ssid, ssid_len);
16132
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016133 vos_mem_zero(pRoamProfile->BSSIDs.bssid, WNI_CFG_BSSID_LEN);
16134 vos_mem_zero(pRoamProfile->bssid_hint, WNI_CFG_BSSID_LEN);
16135
Jeff Johnson295189b2012-06-20 16:38:30 -070016136 if (bssid)
16137 {
16138 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016139 vos_mem_copy(pRoamProfile->BSSIDs.bssid, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070016140 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016141 /* Save BSSID in seperate variable as well, as RoamProfile
16142 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070016143 case of join failure we should send valid BSSID to supplicant
16144 */
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016145 vos_mem_copy(pWextState->req_bssId, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070016146 WNI_CFG_BSSID_LEN);
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016147
Jeff Johnson295189b2012-06-20 16:38:30 -070016148 }
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016149 else if (bssid_hint)
Dhanashri Atre51981c62013-06-13 11:47:57 -070016150 {
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016151 /* Store bssid_hint to use in the scan filter. */
16152 vos_mem_copy(pRoamProfile->bssid_hint, bssid_hint,
16153 WNI_CFG_BSSID_LEN);
16154 /*
16155 * Save BSSID in seperate variable as well, as RoamProfile
16156 * BSSID is getting zeroed out in the association process. And in
16157 * case of join failure we should send valid BSSID to supplicant
16158 */
16159 vos_mem_copy(pWextState->req_bssId, bssid_hint,
16160 WNI_CFG_BSSID_LEN);
16161 hddLog(LOG1, FL(" bssid_hint: "MAC_ADDRESS_STR),
16162 MAC_ADDR_ARRAY(pRoamProfile->bssid_hint));
Dhanashri Atre51981c62013-06-13 11:47:57 -070016163 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016164
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016165
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053016166 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
16167 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070016168 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
16169 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016170 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016171 /*set gen ie*/
16172 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
16173 /*set auth*/
16174 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
16175 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016176#ifdef FEATURE_WLAN_WAPI
16177 if (pAdapter->wapi_info.nWapiMode)
16178 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016179 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016180 switch (pAdapter->wapi_info.wapiAuthMode)
16181 {
16182 case WAPI_AUTH_MODE_PSK:
16183 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016184 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016185 pAdapter->wapi_info.wapiAuthMode);
16186 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
16187 break;
16188 }
16189 case WAPI_AUTH_MODE_CERT:
16190 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016191 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016192 pAdapter->wapi_info.wapiAuthMode);
16193 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
16194 break;
16195 }
16196 } // End of switch
16197 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
16198 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
16199 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016200 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016201 pRoamProfile->AuthType.numEntries = 1;
16202 pRoamProfile->EncryptionType.numEntries = 1;
16203 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
16204 pRoamProfile->mcEncryptionType.numEntries = 1;
16205 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
16206 }
16207 }
16208#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016209#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016210 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016211 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
16212 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
16213 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016214 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
16215 sizeof (tSirGtkOffloadParams));
16216 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016217 }
16218#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016219 pRoamProfile->csrPersona = pAdapter->device_mode;
16220
Jeff Johnson32d95a32012-09-10 13:15:23 -070016221 if( operatingChannel )
16222 {
16223 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
16224 pRoamProfile->ChannelInfo.numOfChannels = 1;
16225 }
Chet Lanctot186b5732013-03-18 10:26:30 -070016226 else
16227 {
16228 pRoamProfile->ChannelInfo.ChannelList = NULL;
16229 pRoamProfile->ChannelInfo.numOfChannels = 0;
16230 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016231 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
16232 {
16233 hdd_select_cbmode(pAdapter,operatingChannel);
16234 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053016235
Agarwal Ashish40f9b872015-09-01 16:17:35 +053016236 /*
16237 * Change conn_state to connecting before sme_RoamConnect(),
16238 * because sme_RoamConnect() has a direct path to call
16239 * hdd_smeRoamCallback(), which will change the conn_state
16240 * If direct path, conn_state will be accordingly changed
16241 * to NotConnected or Associated by either
16242 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
16243 * in sme_RoamCallback()
16244 * if sme_RomConnect is to be queued,
16245 * Connecting state will remain until it is completed.
16246 * If connection state is not changed,
16247 * connection state will remain in eConnectionState_NotConnected state.
16248 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
16249 * if conn state is eConnectionState_NotConnected.
16250 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
16251 * informed of connect result indication which is an issue.
16252 */
16253
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053016254 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
16255 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053016256 {
16257 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053016258 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080016259 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
16260 eConnectionState_Connecting);
Abhishek Singh10e17cf2018-03-12 14:34:22 +053016261 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
16262 hdd_wait_for_ecsa_complete(pHddCtx);
Abhishek Singhf4669da2014-05-26 15:07:49 +053016263 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +053016264
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016265 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070016266 pAdapter->sessionId, pRoamProfile, &roamId);
16267
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053016268 if ((eHAL_STATUS_SUCCESS != status) &&
16269 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
16270 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053016271
16272 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053016273 hddLog(VOS_TRACE_LEVEL_ERROR,
16274 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
16275 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080016276 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053016277 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080016278 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053016279 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080016280
16281 pRoamProfile->ChannelInfo.ChannelList = NULL;
16282 pRoamProfile->ChannelInfo.numOfChannels = 0;
16283
Jeff Johnson295189b2012-06-20 16:38:30 -070016284 }
16285 else
16286 {
16287 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
16288 return -EINVAL;
16289 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080016290 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016291 return status;
16292}
16293
16294/*
16295 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
16296 * This function is used to set the authentication type (OPEN/SHARED).
16297 *
16298 */
16299static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
16300 enum nl80211_auth_type auth_type)
16301{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016302 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016303 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16304
16305 ENTER();
16306
16307 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016308 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070016309 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016310 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053016311 hddLog(VOS_TRACE_LEVEL_INFO,
16312 "%s: set authentication type to AUTOSWITCH", __func__);
16313 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
16314 break;
16315
16316 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016317#ifdef WLAN_FEATURE_VOWIFI_11R
16318 case NL80211_AUTHTYPE_FT:
16319#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016320 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070016321 "%s: set authentication type to OPEN", __func__);
16322 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
16323 break;
16324
16325 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016326 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070016327 "%s: set authentication type to SHARED", __func__);
16328 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
16329 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016330#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070016331 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016332 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070016333 "%s: set authentication type to CCKM WPA", __func__);
16334 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
16335 break;
16336#endif
Abhinav Kumar4d44f632019-08-02 13:55:54 +053016337 case NL80211_AUTHTYPE_SAE:
16338 hddLog(LOG1, "set authentication type to SAE");
16339 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SAE;
16340 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016341
16342 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016343 hddLog(VOS_TRACE_LEVEL_ERROR,
16344 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016345 auth_type);
16346 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
16347 return -EINVAL;
16348 }
16349
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016350 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070016351 pHddStaCtx->conn_info.authType;
16352 return 0;
16353}
16354
16355/*
16356 * FUNCTION: wlan_hdd_set_akm_suite
16357 * This function is used to set the key mgmt type(PSK/8021x).
16358 *
16359 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016360static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070016361 u32 key_mgmt
16362 )
16363{
16364 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
16365 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053016366 /* Should be in ieee802_11_defs.h */
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053016367#ifndef WLAN_AKM_SUITE_8021X_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053016368#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053016369#endif
16370#ifndef WLAN_AKM_SUITE_PSK_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053016371#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053016372#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016373 /*set key mgmt type*/
16374 switch(key_mgmt)
16375 {
16376 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053016377 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053016378#ifdef WLAN_FEATURE_VOWIFI_11R
16379 case WLAN_AKM_SUITE_FT_PSK:
16380#endif
16381 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070016382 __func__);
16383 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
16384 break;
16385
16386 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053016387 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053016388#ifdef WLAN_FEATURE_VOWIFI_11R
16389 case WLAN_AKM_SUITE_FT_8021X:
16390#endif
16391 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070016392 __func__);
16393 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
16394 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016395#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070016396#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
16397#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
16398 case WLAN_AKM_SUITE_CCKM:
16399 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
16400 __func__);
16401 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
16402 break;
16403#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070016404#ifndef WLAN_AKM_SUITE_OSEN
16405#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
16406 case WLAN_AKM_SUITE_OSEN:
16407 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
16408 __func__);
16409 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
16410 break;
16411#endif
Abhinav Kumar4d44f632019-08-02 13:55:54 +053016412 case WLAN_AKM_SUITE_SAE:
16413 hddLog(LOG1, "setting key mgmt type to SAE");
16414 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
16415 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016416
Abhinav Kumar487e49e2019-07-22 14:46:18 +053016417 case WLAN_AKM_SUITE_OWE_1:
16418 hddLog(LOG1, "setting key mgmt type to OWE");
16419 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
16420 break;
16421
Jeff Johnson295189b2012-06-20 16:38:30 -070016422 default:
Abhinav Kumar487e49e2019-07-22 14:46:18 +053016423 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %x",
Jeff Johnson295189b2012-06-20 16:38:30 -070016424 __func__, key_mgmt);
16425 return -EINVAL;
16426
16427 }
16428 return 0;
16429}
16430
16431/*
16432 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016433 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070016434 * (NONE/WEP40/WEP104/TKIP/CCMP).
16435 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016436static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
16437 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070016438 bool ucast
16439 )
16440{
16441 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016442 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016443 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16444
16445 ENTER();
16446
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016447 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070016448 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053016449 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070016450 __func__, cipher);
16451 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
16452 }
16453 else
16454 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016455
Jeff Johnson295189b2012-06-20 16:38:30 -070016456 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016457 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070016458 {
16459 case IW_AUTH_CIPHER_NONE:
16460 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
16461 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016462
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053016464 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070016465 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016466
Jeff Johnson295189b2012-06-20 16:38:30 -070016467 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053016468 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070016469 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016470
Jeff Johnson295189b2012-06-20 16:38:30 -070016471 case WLAN_CIPHER_SUITE_TKIP:
16472 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
16473 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016474
Jeff Johnson295189b2012-06-20 16:38:30 -070016475 case WLAN_CIPHER_SUITE_CCMP:
16476 encryptionType = eCSR_ENCRYPT_TYPE_AES;
16477 break;
16478#ifdef FEATURE_WLAN_WAPI
16479 case WLAN_CIPHER_SUITE_SMS4:
16480 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
16481 break;
16482#endif
16483
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016484#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070016485 case WLAN_CIPHER_SUITE_KRK:
16486 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
16487 break;
16488#endif
16489 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016490 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016491 __func__, cipher);
16492 return -EOPNOTSUPP;
16493 }
16494 }
16495
16496 if (ucast)
16497 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016498 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016499 __func__, encryptionType);
16500 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
16501 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016502 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070016503 encryptionType;
16504 }
16505 else
16506 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016507 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016508 __func__, encryptionType);
16509 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
16510 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
16511 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
16512 }
16513
16514 return 0;
16515}
16516
16517
16518/*
16519 * FUNCTION: wlan_hdd_cfg80211_set_ie
16520 * This function is used to parse WPA/RSN IE's.
16521 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016522int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016523#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16524 const u8 *ie,
16525#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016526 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016527#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016528 size_t ie_len
16529 )
16530{
16531 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016532#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16533 const u8 *genie = ie;
16534#else
Jeff Johnson295189b2012-06-20 16:38:30 -070016535 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016536#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016537 v_U16_t remLen = ie_len;
16538#ifdef FEATURE_WLAN_WAPI
16539 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
16540 u16 *tmp;
16541 v_U16_t akmsuiteCount;
16542 int *akmlist;
16543#endif
16544 ENTER();
16545
16546 /* clear previous assocAddIE */
16547 pWextState->assocAddIE.length = 0;
16548 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070016549 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016550
16551 while (remLen >= 2)
16552 {
16553 v_U16_t eLen = 0;
16554 v_U8_t elementId;
16555 elementId = *genie++;
16556 eLen = *genie++;
16557 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016558
Nachiket Kukade4aba5f02017-06-09 15:43:48 +053016559 /* Sanity check on eLen */
16560 if (eLen > remLen) {
16561 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid IE length[%d] for IE[0x%X]",
16562 __func__, eLen, elementId);
16563 VOS_ASSERT(0);
16564 return -EINVAL;
16565 }
16566
Arif Hussain6d2a3322013-11-17 19:50:10 -080016567 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070016568 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016569
16570 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070016571 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016572 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016573 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 -070016574 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016575 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016576 "%s: Invalid WPA IE", __func__);
16577 return -EINVAL;
16578 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016579 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070016580 {
16581 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016582 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070016583 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016584
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016585 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070016586 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016587 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
16588 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070016589 VOS_ASSERT(0);
16590 return -ENOMEM;
16591 }
16592 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
16593 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16594 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016595
Jeff Johnson295189b2012-06-20 16:38:30 -070016596 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
16597 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16598 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16599 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016600 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
16601 {
Nachiket Kukade3d72b7e2017-06-09 16:58:24 +053016602 if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) {
16603 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid WPA RSN IE length[%d]",
16604 __func__, eLen);
16605 VOS_ASSERT(0);
16606 return -EINVAL;
16607 }
16608
Jeff Johnson295189b2012-06-20 16:38:30 -070016609 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
16610 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
16611 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
16612 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
16613 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
16614 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016615 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053016616 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070016617 {
16618 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016619 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070016620 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016621
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016622 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070016623 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016624 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16625 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070016626 VOS_ASSERT(0);
16627 return -ENOMEM;
16628 }
16629 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
16630 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16631 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016632
Jeff Johnson295189b2012-06-20 16:38:30 -070016633 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16634 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16635 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016636#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016637 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
16638 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016639 /*Consider WFD IE, only for P2P Client */
16640 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
16641 {
16642 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016643 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070016644 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016645
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016646 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070016647 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016648 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16649 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070016650 VOS_ASSERT(0);
16651 return -ENOMEM;
16652 }
16653 // WFD IE is saved to Additional IE ; it should be accumulated to handle
16654 // WPS IE + P2P IE + WFD IE
16655 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16656 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016657
Jeff Johnson295189b2012-06-20 16:38:30 -070016658 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16659 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16660 }
16661#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016662 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016663 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016664 HS20_OUI_TYPE_SIZE)) )
16665 {
16666 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016667 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016668 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016669
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016670 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016671 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016672 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16673 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016674 VOS_ASSERT(0);
16675 return -ENOMEM;
16676 }
16677 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16678 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016679
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016680 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16681 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16682 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070016683 /* Appending OSEN Information Element in Assiciation Request */
16684 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
16685 OSEN_OUI_TYPE_SIZE)) )
16686 {
16687 v_U16_t curAddIELen = pWextState->assocAddIE.length;
16688 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
16689 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016690
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016691 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070016692 {
16693 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16694 "Need bigger buffer space");
16695 VOS_ASSERT(0);
16696 return -ENOMEM;
16697 }
16698 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16699 pWextState->assocAddIE.length += eLen + 2;
16700
16701 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
16702 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16703 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16704 }
16705
Abhishek Singh4322e622015-06-10 15:42:54 +053016706 /* Update only for WPA IE */
16707 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
16708 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070016709
16710 /* populating as ADDIE in beacon frames */
16711 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016712 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070016713 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
16714 {
16715 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
16716 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
16717 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
16718 {
16719 hddLog(LOGE,
16720 "Coldn't pass "
16721 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
16722 }
16723 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
16724 else
16725 hddLog(LOGE,
16726 "Could not pass on "
16727 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
16728
16729 /* IBSS mode doesn't contain params->proberesp_ies still
16730 beaconIE's need to be populated in probe response frames */
16731 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
16732 {
16733 u16 rem_probe_resp_ie_len = eLen + 2;
16734 u8 probe_rsp_ie_len[3] = {0};
16735 u8 counter = 0;
16736
16737 /* Check Probe Resp Length if it is greater then 255 then
16738 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
16739 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
16740 not able Store More then 255 bytes into One Variable */
16741
16742 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
16743 {
16744 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
16745 {
16746 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
16747 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
16748 }
16749 else
16750 {
16751 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
16752 rem_probe_resp_ie_len = 0;
16753 }
16754 }
16755
16756 rem_probe_resp_ie_len = 0;
16757
16758 if (probe_rsp_ie_len[0] > 0)
16759 {
16760 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
16761 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
16762 (tANI_U8*)(genie - 2),
16763 probe_rsp_ie_len[0], NULL,
16764 eANI_BOOLEAN_FALSE)
16765 == eHAL_STATUS_FAILURE)
16766 {
16767 hddLog(LOGE,
16768 "Could not pass"
16769 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
16770 }
16771 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
16772 }
16773
16774 if (probe_rsp_ie_len[1] > 0)
16775 {
16776 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
16777 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
16778 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
16779 probe_rsp_ie_len[1], NULL,
16780 eANI_BOOLEAN_FALSE)
16781 == eHAL_STATUS_FAILURE)
16782 {
16783 hddLog(LOGE,
16784 "Could not pass"
16785 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
16786 }
16787 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
16788 }
16789
16790 if (probe_rsp_ie_len[2] > 0)
16791 {
16792 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
16793 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
16794 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
16795 probe_rsp_ie_len[2], NULL,
16796 eANI_BOOLEAN_FALSE)
16797 == eHAL_STATUS_FAILURE)
16798 {
16799 hddLog(LOGE,
16800 "Could not pass"
16801 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
16802 }
16803 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
16804 }
16805
16806 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
16807 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
16808 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
16809 {
16810 hddLog(LOGE,
16811 "Could not pass"
16812 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
16813 }
16814 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070016815 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070016816 break;
16817 case DOT11F_EID_RSN:
Nachiket Kukade307d4892018-01-23 23:36:25 +053016818 if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) {
16819 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid WPA RSN IE length[%d], exceeds %d bytes",
16820 __func__, eLen, MAX_WPA_RSN_IE_LEN - 2);
16821 VOS_ASSERT(0);
16822 return -EINVAL;
16823 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016824 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
16825 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
16826 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
16827 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
16828 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
16829 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053016830
Abhishek Singhb16f3562016-01-20 11:08:32 +053016831 /* Appending extended capabilities with Interworking or
16832 * bsstransition bit set in Assoc Req.
Abhishek Singh15d95602015-03-24 15:52:57 +053016833 *
16834 * In assoc req this EXT Cap will only be taken into account if
Abhishek Singhb16f3562016-01-20 11:08:32 +053016835 * interworkingService or bsstransition bit is set to 1.
16836 * Driver is only interested in interworkingService and
16837 * bsstransition capability from supplicant.
16838 * If in future any other EXT Cap info is
Abhishek Singh15d95602015-03-24 15:52:57 +053016839 * required from supplicat, it needs to be handled while
16840 * sending Assoc Req in LIM.
16841 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016842 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016843 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016844 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016845 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016846 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016847
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016848 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016849 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016850 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16851 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016852 VOS_ASSERT(0);
16853 return -ENOMEM;
16854 }
16855 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16856 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016857
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016858 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16859 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16860 break;
16861 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016862#ifdef FEATURE_WLAN_WAPI
16863 case WLAN_EID_WAPI:
16864 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070016865 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070016866 pAdapter->wapi_info.nWapiMode);
16867 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016868 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070016869 akmsuiteCount = WPA_GET_LE16(tmp);
16870 tmp = tmp + 1;
16871 akmlist = (int *)(tmp);
16872 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
16873 {
16874 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
16875 }
16876 else
16877 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016878 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070016879 VOS_ASSERT(0);
16880 return -EINVAL;
16881 }
16882
16883 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
16884 {
16885 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016886 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016887 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016888 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016889 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016890 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016891 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016892 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016893 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
16894 }
16895 break;
16896#endif
Abhinav Kumar487e49e2019-07-22 14:46:18 +053016897 case SIR_MAC_REQUEST_EID_MAX:
16898 if (genie[0] == SIR_DH_PARAMETER_ELEMENT_EXT_EID)
16899 {
16900 v_U16_t curAddIELen = pWextState->assocAddIE.length;
16901 if (SIR_MAC_MAX_ADD_IE_LENGTH <
16902 (pWextState->assocAddIE.length + eLen))
16903 {
16904 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16905 "Need bigger buffer space");
16906 VOS_ASSERT(0);
16907 return -ENOMEM;
16908 }
16909 hddLog(VOS_TRACE_LEVEL_INFO, "Set DH EXT IE(len %d)",
16910 eLen + 2);
16911 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen,
16912 genie - 2, eLen + 2);
16913 pWextState->assocAddIE.length += eLen + 2;
16914 pWextState->roamProfile.pAddIEAssoc =
16915 pWextState->assocAddIE.addIEdata;
16916 pWextState->roamProfile.nAddIEAssocLength =
16917 pWextState->assocAddIE.length;
16918 }else {
16919 hddLog(VOS_TRACE_LEVEL_FATAL, "UNKNOWN EID: %X", genie[0]);
16920 }
16921 break;
16922
Jeff Johnson295189b2012-06-20 16:38:30 -070016923 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016924 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016925 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016926 /* when Unknown IE is received we should break and continue
16927 * to the next IE in the buffer instead we were returning
16928 * so changing this to break */
16929 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016930 }
16931 genie += eLen;
16932 remLen -= eLen;
16933 }
16934 EXIT();
16935 return 0;
16936}
16937
16938/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053016939 * FUNCTION: hdd_isWPAIEPresent
16940 * Parse the received IE to find the WPA IE
16941 *
16942 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016943static bool hdd_isWPAIEPresent(
16944#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
16945 const u8 *ie,
16946#else
16947 u8 *ie,
16948#endif
16949 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053016950{
16951 v_U8_t eLen = 0;
16952 v_U16_t remLen = ie_len;
16953 v_U8_t elementId = 0;
16954
16955 while (remLen >= 2)
16956 {
16957 elementId = *ie++;
16958 eLen = *ie++;
16959 remLen -= 2;
16960 if (eLen > remLen)
16961 {
16962 hddLog(VOS_TRACE_LEVEL_ERROR,
16963 "%s: IE length is wrong %d", __func__, eLen);
16964 return FALSE;
16965 }
16966 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
16967 {
16968 /* OUI - 0x00 0X50 0XF2
16969 WPA Information Element - 0x01
16970 WPA version - 0x01*/
16971 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
16972 return TRUE;
16973 }
16974 ie += eLen;
16975 remLen -= eLen;
16976 }
16977 return FALSE;
16978}
16979
16980/*
Jeff Johnson295189b2012-06-20 16:38:30 -070016981 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016982 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070016983 * parameters during connect operation.
16984 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016985int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070016986 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016987 )
Jeff Johnson295189b2012-06-20 16:38:30 -070016988{
16989 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016990 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016991 ENTER();
16992
16993 /*set wpa version*/
16994 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
16995
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016996 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070016997 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053016998 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070016999 {
17000 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
17001 }
17002 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
17003 {
17004 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
17005 }
17006 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017007
17008 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070017009 pWextState->wpaVersion);
17010
17011 /*set authentication type*/
17012 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
17013
17014 if (0 > status)
17015 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017016 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070017017 "%s: failed to set authentication type ", __func__);
17018 return status;
17019 }
17020
17021 /*set key mgmt type*/
17022 if (req->crypto.n_akm_suites)
17023 {
17024 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
17025 if (0 > status)
17026 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017027 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070017028 __func__);
17029 return status;
17030 }
17031 }
17032
17033 /*set pairwise cipher type*/
17034 if (req->crypto.n_ciphers_pairwise)
17035 {
17036 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
17037 req->crypto.ciphers_pairwise[0], true);
17038 if (0 > status)
17039 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017040 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070017041 "%s: failed to set unicast cipher type", __func__);
17042 return status;
17043 }
17044 }
17045 else
17046 {
17047 /*Reset previous cipher suite to none*/
17048 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
17049 if (0 > status)
17050 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017051 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070017052 "%s: failed to set unicast cipher type", __func__);
17053 return status;
17054 }
17055 }
17056
17057 /*set group cipher type*/
17058 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
17059 false);
17060
17061 if (0 > status)
17062 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017063 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070017064 __func__);
17065 return status;
17066 }
17067
Chet Lanctot186b5732013-03-18 10:26:30 -070017068#ifdef WLAN_FEATURE_11W
17069 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
17070#endif
17071
Jeff Johnson295189b2012-06-20 16:38:30 -070017072 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
17073 if (req->ie_len)
17074 {
17075 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
17076 if ( 0 > status)
17077 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017078 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070017079 __func__);
17080 return status;
17081 }
17082 }
17083
17084 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017085 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070017086 {
17087 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
17088 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
17089 )
17090 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017091 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070017092 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
17093 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017094 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070017095 __func__);
17096 return -EOPNOTSUPP;
17097 }
17098 else
17099 {
17100 u8 key_len = req->key_len;
17101 u8 key_idx = req->key_idx;
17102
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017103 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070017104 && (CSR_MAX_NUM_KEY > key_idx)
17105 )
17106 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017107 hddLog(VOS_TRACE_LEVEL_INFO,
17108 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070017109 __func__, key_idx, key_len);
17110 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017111 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070017112 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017113 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070017114 (u8)key_len;
17115 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
17116 }
17117 }
17118 }
17119 }
17120
17121 return status;
17122}
17123
17124/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017125 * FUNCTION: wlan_hdd_try_disconnect
17126 * This function is used to disconnect from previous
17127 * connection
17128 */
Agrawal Ashishc407f192017-01-23 17:18:35 +053017129int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017130{
17131 long ret = 0;
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017132 int status, result = 0;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017133 hdd_station_ctx_t *pHddStaCtx;
17134 eMib_dot11DesiredBssType connectedBssType;
Abhishek Singh19a7dd92015-12-30 16:31:51 +053017135 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017136
Abhishek Singh19a7dd92015-12-30 16:31:51 +053017137 ret = wlan_hdd_validate_context(pHddCtx);
17138 if (0 != ret)
17139 {
17140 return ret;
17141 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017142 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17143
17144 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
17145
17146 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
17147 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
Abhishek Singh630ff592016-01-07 18:15:53 +053017148 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) ||
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017149 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
17150 {
Abhishek Singh9f4df782017-03-15 17:29:10 +053017151 /* Indicate disconnect to SME so that in-progress connection or preauth
17152 * can be aborted
17153 */
17154 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
17155 pAdapter->sessionId);
Abhishek Singh19a7dd92015-12-30 16:31:51 +053017156 spin_lock_bh(&pAdapter->lock_for_active_session);
17157 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
17158 {
17159 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
17160 }
17161 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singhf7962582015-10-23 10:54:06 +053017162 hdd_connSetConnectionState(pHddStaCtx,
17163 eConnectionState_Disconnecting);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017164 /* Issue disconnect to CSR */
17165 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017166 status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017167 pAdapter->sessionId,
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017168 eCSR_DISCONNECT_REASON_UNSPECIFIED);
17169 if(eHAL_STATUS_CMD_NOT_QUEUED == status) {
17170 hddLog(LOG1,
17171 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
17172 } else if ( 0 != status ) {
17173 hddLog(LOGE,
17174 FL("csrRoamDisconnect failure, returned %d"),
17175 (int)status );
17176 result = -EINVAL;
17177 goto disconnected;
17178 }
17179 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017180 &pAdapter->disconnect_comp_var,
17181 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017182 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status)) {
17183 hddLog(LOGE,
17184 "%s: Failed to disconnect, timed out", __func__);
17185 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017186 }
17187 }
17188 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
17189 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017190 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017191 &pAdapter->disconnect_comp_var,
17192 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017193 if (!ret)
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017194 {
17195 hddLog(LOGE, FL("Failed to receive disconnect event"));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017196 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017197 }
17198 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017199disconnected:
17200 hddLog(LOG1,
17201 FL("Set HDD connState to eConnectionState_NotConnected"));
17202 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
17203 return result;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017204}
17205
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053017206/**
17207 * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present
17208 * @adapter: Pointer to the HDD adapter
17209 * @req: Pointer to the structure cfg_connect_params receieved from user space
17210 *
Abhinav Kumar42c34902018-09-27 19:00:35 +053017211 * This function will start reassociation if prev_bssid is set and bssid/
17212 * bssid_hint, channel/channel_hint parameters are present in connect request.
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053017213 *
17214 * Return: success if reassociation is happening
17215 * Error code if reassociation is not permitted or not happening
17216 */
17217#ifdef CFG80211_CONNECT_PREV_BSSID
17218static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
17219 struct cfg80211_connect_params *req)
17220{
17221 int status = -EPERM;
Abhinav Kumar42c34902018-09-27 19:00:35 +053017222 const uint8_t *bssid = NULL;
17223 uint16_t channel = 0;
17224
17225 if (req->bssid)
17226 bssid = req->bssid;
17227 else if (req->bssid_hint)
17228 bssid = req->bssid_hint;
17229
17230 if (req->channel)
17231 channel = req->channel->hw_value;
17232 else if (req->channel_hint)
17233 channel = req->channel_hint->hw_value;
17234
17235 if (bssid && channel && req->prev_bssid) {
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053017236 hddLog(VOS_TRACE_LEVEL_INFO,
17237 FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR),
Abhinav Kumar42c34902018-09-27 19:00:35 +053017238 channel, MAC_ADDR_ARRAY(bssid));
17239 status = hdd_reassoc(adapter, bssid, channel,
17240 CONNECT_CMD_USERSPACE);
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053017241 }
17242 return status;
17243}
17244#else
17245static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
17246 struct cfg80211_connect_params *req)
17247{
17248 return -EPERM;
17249}
17250#endif
17251
Abhishek Singhe3beee22017-07-31 15:35:40 +053017252/**
17253 * wlan_hdd_check_ht20_ht40_ind() - check if Supplicant has indicated to
17254 * connect in HT20 mode
17255 * @hdd_ctx: hdd context
17256 * @adapter: Pointer to the HDD adapter
17257 * @req: Pointer to the structure cfg_connect_params receieved from user space
17258 *
17259 * This function will check if supplicant has indicated to to connect in HT20
17260 * mode. this is currently applicable only for 2.4Ghz mode only.
17261 * if feature is enabled and supplicant indicate HT20 set
17262 * force_24ghz_in_ht20 to true to force 2.4Ghz in HT20 else set it to false.
17263 *
17264 * Return: void
17265 */
17266#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
17267static void wlan_hdd_check_ht20_ht40_ind(hdd_context_t *hdd_ctx,
17268 hdd_adapter_t *adapter,
17269 struct cfg80211_connect_params *req)
17270{
17271 hdd_wext_state_t *wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
17272 tCsrRoamProfile *roam_profile;
17273
17274 roam_profile = &wext_state->roamProfile;
17275 roam_profile->force_24ghz_in_ht20 = false;
17276 if (hdd_ctx->cfg_ini->override_ht20_40_24g &&
17277 !(req->ht_capa.cap_info &
17278 IEEE80211_HT_CAP_SUP_WIDTH_20_40))
17279 roam_profile->force_24ghz_in_ht20 = true;
17280
17281 hddLog(LOG1, FL("req->ht_capa.cap_info %x override_ht20_40_24g %d"),
17282 req->ht_capa.cap_info, hdd_ctx->cfg_ini->override_ht20_40_24g);
17283}
17284#else
17285static inline void wlan_hdd_check_ht20_ht40_ind(hdd_context_t *hdd_ctx,
17286 hdd_adapter_t *adapter,
17287 struct cfg80211_connect_params *req)
17288{
17289 hdd_wext_state_t *wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
17290 tCsrRoamProfile *roam_profile;
17291
17292 roam_profile = &wext_state->roamProfile;
17293 roam_profile->force_24ghz_in_ht20 = false;
17294}
17295#endif
17296
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017297/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053017298 * FUNCTION: __wlan_hdd_cfg80211_connect
17299 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070017300 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017301static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017302 struct net_device *ndev,
17303 struct cfg80211_connect_params *req
17304 )
17305{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017306 int status;
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017307 u16 channel;
Edhar, Mahesh Kumar496c7f72016-03-18 12:47:44 +053017308#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
17309 defined(CFG80211_BSSID_HINT_BACKPORT)
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017310 const u8 *bssid_hint = req->bssid_hint;
17311#else
17312 const u8 *bssid_hint = NULL;
17313#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017314 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070017315 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053017316 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017317
17318 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017319
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017320 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17321 TRACE_CODE_HDD_CFG80211_CONNECT,
17322 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017323 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053017324 "%s: device_mode = %s (%d)", __func__,
17325 hdd_device_modetoString(pAdapter->device_mode),
17326 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070017327
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017328 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080017329 if (!pHddCtx)
17330 {
17331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17332 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053017333 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080017334 }
17335
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017336 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017337 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070017338 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017339 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017340 }
17341
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053017342 if (wlan_hdd_check_and_stop_mon(pAdapter, true))
17343 return -EINVAL;
17344
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053017345 status = wlan_hdd_reassoc_bssid_hint(pAdapter, req);
17346 if (0 == status)
17347 return status;
17348
Agarwal Ashish51325b52014-06-16 16:50:49 +053017349
Jeff Johnson295189b2012-06-20 16:38:30 -070017350#ifdef WLAN_BTAMP_FEATURE
17351 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017352 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070017353 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017354 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070017355 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080017356 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070017357 }
17358#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017359
17360 //If Device Mode is Station Concurrent Sessions Exit BMps
17361 //P2P Mode will be taken care in Open/close adapter
17362 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053017363 (vos_concurrent_open_sessions_running())) {
17364 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
17365 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017366 }
17367
17368 /*Try disconnecting if already in connected state*/
17369 status = wlan_hdd_try_disconnect(pAdapter);
17370 if ( 0 > status)
17371 {
17372 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
17373 " connection"));
17374 return -EALREADY;
17375 }
Agrawal Ashish559530c2015-12-01 18:04:20 +053017376 /* Check for max concurrent connections after doing disconnect if any*/
17377 if (vos_max_concurrent_connections_reached()) {
17378 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
17379 return -ECONNREFUSED;
17380 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017381
Jeff Johnson295189b2012-06-20 16:38:30 -070017382 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017383 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070017384
17385 if ( 0 > status)
17386 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017387 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070017388 __func__);
17389 return status;
17390 }
Sravan Kumar Kairam589c5722016-01-27 20:28:53 +053017391
17392 if (pHddCtx->spoofMacAddr.isEnabled)
17393 {
17394 hddLog(VOS_TRACE_LEVEL_INFO,
17395 "%s: MAC Spoofing enabled ", __func__);
17396 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
17397 * to fill TxBds for probe request during SSID scan which may happen
17398 * as part of connect command
17399 */
17400 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
17401 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
17402 if (status != VOS_STATUS_SUCCESS)
17403 return -ECONNREFUSED;
17404 }
17405
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017406 if (req->channel)
17407 channel = req->channel->hw_value;
Mohit Khanna765234a2012-09-11 15:08:35 -070017408 else
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017409 channel = 0;
Kapil Gupta312028a2016-10-25 14:15:20 +053017410
17411 /* Abort if any scan is going on */
17412 status = wlan_hdd_scan_abort(pAdapter);
17413 if (0 != status)
17414 hddLog(VOS_TRACE_LEVEL_ERROR, FL("scan abort failed"));
17415
Abhishek Singhe3beee22017-07-31 15:35:40 +053017416 wlan_hdd_check_ht20_ht40_ind(pHddCtx, pAdapter, req);
17417
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017418 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
17419 req->ssid_len, req->bssid,
17420 bssid_hint, channel);
Jeff Johnson295189b2012-06-20 16:38:30 -070017421
Sushant Kaushikd7083982015-03-18 14:33:24 +053017422 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070017423 {
17424 //ReEnable BMPS if disabled
17425 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
17426 (NULL != pHddCtx))
17427 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053017428 if (pHddCtx->hdd_wlan_suspended)
17429 {
17430 hdd_set_pwrparams(pHddCtx);
17431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017432 //ReEnable Bmps and Imps back
17433 hdd_enable_bmps_imps(pHddCtx);
17434 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053017435 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017436 return status;
17437 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017438 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017439 EXIT();
17440 return status;
17441}
17442
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017443static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
17444 struct net_device *ndev,
17445 struct cfg80211_connect_params *req)
17446{
17447 int ret;
17448 vos_ssr_protect(__func__);
17449 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
17450 vos_ssr_unprotect(__func__);
17451
17452 return ret;
17453}
Jeff Johnson295189b2012-06-20 16:38:30 -070017454
17455/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017456 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070017457 * This function is used to issue a disconnect request to SME
17458 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017459static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017460 struct net_device *dev,
17461 u16 reason
17462 )
17463{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017464 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017465 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017466 tCsrRoamProfile *pRoamProfile;
17467 hdd_station_ctx_t *pHddStaCtx;
17468 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017469#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017470 tANI_U8 staIdx;
17471#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017472
Jeff Johnson295189b2012-06-20 16:38:30 -070017473 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017474
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017475 if (!pAdapter) {
17476 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
17477 return -EINVAL;
17478 }
17479
17480 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17481 if (!pHddStaCtx) {
17482 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
17483 return -EINVAL;
17484 }
17485
17486 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17487 status = wlan_hdd_validate_context(pHddCtx);
17488 if (0 != status)
17489 {
17490 return status;
17491 }
17492
17493 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
17494
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017495 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17496 TRACE_CODE_HDD_CFG80211_DISCONNECT,
17497 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053017498 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
17499 __func__, hdd_device_modetoString(pAdapter->device_mode),
17500 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070017501
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017502 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
17503 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070017504
Jeff Johnson295189b2012-06-20 16:38:30 -070017505 if (NULL != pRoamProfile)
17506 {
17507 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053017508 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
17509 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070017510 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017511 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070017512 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017513 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070017514 switch(reason)
17515 {
17516 case WLAN_REASON_MIC_FAILURE:
17517 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
17518 break;
17519
17520 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
17521 case WLAN_REASON_DISASSOC_AP_BUSY:
17522 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
17523 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
17524 break;
17525
17526 case WLAN_REASON_PREV_AUTH_NOT_VALID:
17527 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053017528 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070017529 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
17530 break;
17531
Jeff Johnson295189b2012-06-20 16:38:30 -070017532 default:
17533 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
17534 break;
17535 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017536 pScanInfo = &pHddCtx->scan_info;
17537 if (pScanInfo->mScanPending)
17538 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053017539 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017540 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053017541 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053017542 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017543 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053017544 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017545#ifdef FEATURE_WLAN_TDLS
17546 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080017547 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017548 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080017549 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
17550 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017551 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017552 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080017553 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017555 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080017556 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017557 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017558 status = sme_DeleteTdlsPeerSta(
17559 WLAN_HDD_GET_HAL_CTX(pAdapter),
17560 pAdapter->sessionId,
17561 mac);
17562 if (status != eHAL_STATUS_SUCCESS) {
17563 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
17564 return -EPERM;
17565 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017566 }
17567 }
17568#endif
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053017569
17570 hddLog(LOG1, FL("Disconnecting with reasoncode:%u connState %d"),
17571 reasonCode,
17572 pHddStaCtx->conn_info.connState);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053017573 status = wlan_hdd_disconnect(pAdapter, reasonCode);
17574 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070017575 {
17576 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017577 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070017578 __func__, (int)status );
17579 return -EINVAL;
17580 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017581 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053017582 else
17583 {
17584 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
17585 "called while in %d state", __func__,
17586 pHddStaCtx->conn_info.connState);
17587 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017588 }
17589 else
17590 {
17591 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
17592 }
17593
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017594 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070017595 return status;
17596}
17597
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017598static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
17599 struct net_device *dev,
17600 u16 reason
17601 )
17602{
17603 int ret;
17604 vos_ssr_protect(__func__);
17605 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
17606 vos_ssr_unprotect(__func__);
17607
17608 return ret;
17609}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053017610
Jeff Johnson295189b2012-06-20 16:38:30 -070017611/*
17612 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017613 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070017614 * settings in IBSS mode.
17615 */
17616static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017617 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070017618 struct cfg80211_ibss_params *params
17619 )
17620{
17621 int status = 0;
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +053017622 tANI_U32 ret;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017623 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070017624 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
17625 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017626
Jeff Johnson295189b2012-06-20 16:38:30 -070017627 ENTER();
17628
17629 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070017630 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070017631
17632 if (params->ie_len && ( NULL != params->ie) )
17633 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017634 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
17635 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070017636 {
17637 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
17638 encryptionType = eCSR_ENCRYPT_TYPE_AES;
17639 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017640 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070017641 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070017642 tDot11fIEWPA dot11WPAIE;
17643 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017644 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070017645
Wilson Yang00256342013-10-10 23:13:38 -070017646 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017647 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
17648 params->ie_len, DOT11F_EID_WPA);
17649 if ( NULL != ie )
17650 {
17651 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
Hanumanth Reddy Pothulad6d2d2c2018-06-27 12:28:12 +053017652
17653 if (ie[1] < DOT11F_IE_WPA_MIN_LEN ||
17654 ie[1] > DOT11F_IE_WPA_MAX_LEN) {
17655 hddLog(LOGE, FL("invalid ie len:%d"), ie[1]);
17656 return -EINVAL;
17657 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017658 // Unpack the WPA IE
17659 //Skip past the EID byte and length byte - and four byte WiFi OUI
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +053017660 ret = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017661 &ie[2+4],
17662 ie[1] - 4,
17663 &dot11WPAIE);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +053017664 if (DOT11F_FAILED(ret))
17665 {
17666 hddLog(LOGE,
17667 FL("unpack failed status:(0x%08x)"),
17668 ret);
17669 return -EINVAL;
17670 }
17671
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017672 /*Extract the multicast cipher, the encType for unicast
17673 cipher for wpa-none is none*/
17674 encryptionType =
17675 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
17676 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017677 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017678
Jeff Johnson295189b2012-06-20 16:38:30 -070017679 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
17680
17681 if (0 > status)
17682 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017683 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070017684 __func__);
17685 return status;
17686 }
17687 }
17688
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017689 pWextState->roamProfile.AuthType.authType[0] =
17690 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070017691 eCSR_AUTH_TYPE_OPEN_SYSTEM;
Jeff Johnson295189b2012-06-20 16:38:30 -070017692 if (params->privacy)
17693 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017694 /* Security enabled IBSS, At this time there is no information available
17695 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070017696 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017697 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070017698 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017699 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070017700 *enable privacy bit in beacons */
17701
17702 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
17703 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070017704 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
17705 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070017706 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
17707 pWextState->roamProfile.EncryptionType.numEntries = 1;
17708 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070017709 return status;
17710}
17711
17712/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017713 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017714 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070017715 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017716static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017717 struct net_device *dev,
17718 struct cfg80211_ibss_params *params
17719 )
17720{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017721 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070017722 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
17723 tCsrRoamProfile *pRoamProfile;
17724 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017725 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17726 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017727 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070017728
17729 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017730
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017731 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17732 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
17733 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017734 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053017735 "%s: device_mode = %s (%d)", __func__,
17736 hdd_device_modetoString(pAdapter->device_mode),
17737 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070017738
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017739 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017740 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070017741 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017742 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017743 }
17744
17745 if (NULL == pWextState)
17746 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017747 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070017748 __func__);
17749 return -EIO;
17750 }
17751
Agarwal Ashish51325b52014-06-16 16:50:49 +053017752 if (vos_max_concurrent_connections_reached()) {
17753 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
17754 return -ECONNREFUSED;
17755 }
17756
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017757 /*Try disconnecting if already in connected state*/
17758 status = wlan_hdd_try_disconnect(pAdapter);
17759 if ( 0 > status)
17760 {
17761 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
17762 " IBSS connection"));
17763 return -EALREADY;
17764 }
17765
Jeff Johnson295189b2012-06-20 16:38:30 -070017766 pRoamProfile = &pWextState->roamProfile;
17767
17768 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
17769 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017770 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017771 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070017772 return -EINVAL;
17773 }
17774
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070017775 /* BSSID is provided by upper layers hence no need to AUTO generate */
17776 if (NULL != params->bssid) {
17777 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
17778 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
17779 hddLog (VOS_TRACE_LEVEL_ERROR,
17780 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
17781 return -EIO;
17782 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017783 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070017784 }
krunal sonie9002db2013-11-25 14:24:17 -080017785 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
17786 {
17787 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
17788 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
17789 {
17790 hddLog (VOS_TRACE_LEVEL_ERROR,
17791 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
17792 return -EIO;
17793 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017794
17795 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080017796 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017797 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080017798 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070017799
Jeff Johnson295189b2012-06-20 16:38:30 -070017800 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070017801 if (NULL !=
17802#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
17803 params->chandef.chan)
17804#else
17805 params->channel)
17806#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017807 {
17808 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017809 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
17810 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
17811 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17812 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070017813
17814 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017815 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070017816 ieee80211_frequency_to_channel(
17817#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
17818 params->chandef.chan->center_freq);
17819#else
17820 params->channel->center_freq);
17821#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017822
17823 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
17824 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070017825 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017826 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
17827 __func__);
17828 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070017829 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017830
17831 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070017832 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017833 if (channelNum == validChan[indx])
17834 {
17835 break;
17836 }
17837 }
17838 if (indx >= numChans)
17839 {
17840 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070017841 __func__, channelNum);
17842 return -EINVAL;
17843 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017844 /* Set the Operational Channel */
17845 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
17846 channelNum);
17847 pRoamProfile->ChannelInfo.numOfChannels = 1;
17848 pHddStaCtx->conn_info.operationChannel = channelNum;
17849 pRoamProfile->ChannelInfo.ChannelList =
17850 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070017851 }
17852
17853 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017854 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070017855 if (status < 0)
17856 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017857 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070017858 __func__);
17859 return status;
17860 }
17861
17862 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017863 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Abhishek Singh4d924682015-11-17 15:23:06 +053017864 params->ssid_len, (const u8 *)&bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017865 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070017866
17867 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070017868 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070017869
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017870 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017871 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017872}
17873
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017874static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
17875 struct net_device *dev,
17876 struct cfg80211_ibss_params *params
17877 )
17878{
17879 int ret = 0;
17880
17881 vos_ssr_protect(__func__);
17882 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
17883 vos_ssr_unprotect(__func__);
17884
17885 return ret;
17886}
17887
Jeff Johnson295189b2012-06-20 16:38:30 -070017888/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017889 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017890 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070017891 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017892static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017893 struct net_device *dev
17894 )
17895{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017896 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017897 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
17898 tCsrRoamProfile *pRoamProfile;
17899 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017900 int status;
Abhishek Singh69de3302016-11-11 16:44:32 +053017901 eHalStatus hal_status;
Abhishek Singh7cd040e2016-01-07 10:51:04 +053017902#ifdef WLAN_FEATURE_RMC
17903 tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN] = {0};
17904#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017905
17906 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017907
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017908 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17909 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
17910 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017911 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017912 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017913 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017914 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017915 }
17916
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053017917 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
17918 hdd_device_modetoString(pAdapter->device_mode),
17919 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070017920 if (NULL == pWextState)
17921 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017922 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070017923 __func__);
17924 return -EIO;
17925 }
17926
17927 pRoamProfile = &pWextState->roamProfile;
17928
17929 /* Issue disconnect only if interface type is set to IBSS */
17930 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
17931 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017932 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070017933 __func__);
17934 return -EINVAL;
17935 }
17936
Abhishek Singh7cd040e2016-01-07 10:51:04 +053017937#ifdef WLAN_FEATURE_RMC
17938 /* Clearing add IE of beacon */
17939 if (ccmCfgSetStr(pHddCtx->hHal,
17940 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0],
17941 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN,
17942 NULL, eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
17943 {
17944 hddLog (VOS_TRACE_LEVEL_ERROR,
17945 "%s: unable to clear PROBE_RSP_BCN_ADDNIE_DATA", __func__);
17946 return -EINVAL;
17947 }
17948 if (ccmCfgSetInt(pHddCtx->hHal,
17949 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0, NULL,
17950 eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
17951 {
17952 hddLog (VOS_TRACE_LEVEL_ERROR,
17953 "%s: unable to clear WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
17954 __func__);
17955 return -EINVAL;
17956 }
17957
17958 // Reset WNI_CFG_PROBE_RSP Flags
17959 wlan_hdd_reset_prob_rspies(pAdapter);
17960
17961 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
17962 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 0,NULL,
17963 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
17964 {
17965 hddLog (VOS_TRACE_LEVEL_ERROR,
17966 "%s: unable to clear WNI_CFG_PROBE_RSP_ADDNIE_FLAG",
17967 __func__);
17968 return -EINVAL;
17969 }
17970#endif
17971
Jeff Johnson295189b2012-06-20 16:38:30 -070017972 /* Issue Disconnect request */
17973 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singh69de3302016-11-11 16:44:32 +053017974 hal_status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
17975 pAdapter->sessionId,
17976 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
17977 if (!HAL_STATUS_SUCCESS(hal_status)) {
17978 hddLog(LOGE,
17979 FL("sme_RoamDisconnect failed hal_status(%d)"),
17980 hal_status);
17981 return -EAGAIN;
17982 }
17983 status = wait_for_completion_timeout(
17984 &pAdapter->disconnect_comp_var,
17985 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
17986 if (!status) {
17987 hddLog(LOGE,
17988 FL("wait on disconnect_comp_var failed"));
17989 return -ETIMEDOUT;
17990 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017991
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017992 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070017993 return 0;
17994}
17995
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017996static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
17997 struct net_device *dev
17998 )
17999{
18000 int ret = 0;
18001
18002 vos_ssr_protect(__func__);
18003 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
18004 vos_ssr_unprotect(__func__);
18005
18006 return ret;
18007}
18008
Jeff Johnson295189b2012-06-20 16:38:30 -070018009/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053018010 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070018011 * This function is used to set the phy parameters
18012 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
18013 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053018014static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070018015 u32 changed)
18016{
18017 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
18018 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018019 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070018020
18021 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018022
18023 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018024 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
18025 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018026
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018027 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018028 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018029 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018030 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018031 }
18032
Jeff Johnson295189b2012-06-20 16:38:30 -070018033 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
18034 {
18035 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
18036 WNI_CFG_RTS_THRESHOLD_STAMAX :
18037 wiphy->rts_threshold;
18038
18039 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018040 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070018041 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018042 hddLog(VOS_TRACE_LEVEL_ERROR,
18043 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018044 __func__, rts_threshold);
18045 return -EINVAL;
18046 }
18047
18048 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
18049 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018050 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070018051 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018052 hddLog(VOS_TRACE_LEVEL_ERROR,
18053 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018054 __func__, rts_threshold);
18055 return -EIO;
18056 }
18057
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018058 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070018059 rts_threshold);
18060 }
18061
18062 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
18063 {
18064 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
18065 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
18066 wiphy->frag_threshold;
18067
18068 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018069 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070018070 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018071 hddLog(VOS_TRACE_LEVEL_ERROR,
18072 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070018073 frag_threshold);
18074 return -EINVAL;
18075 }
18076
18077 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
18078 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018079 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070018080 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018081 hddLog(VOS_TRACE_LEVEL_ERROR,
18082 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018083 __func__, frag_threshold);
18084 return -EIO;
18085 }
18086
18087 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
18088 frag_threshold);
18089 }
18090
18091 if ((changed & WIPHY_PARAM_RETRY_SHORT)
18092 || (changed & WIPHY_PARAM_RETRY_LONG))
18093 {
18094 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
18095 wiphy->retry_short :
18096 wiphy->retry_long;
18097
18098 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
18099 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
18100 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018101 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018102 __func__, retry_value);
18103 return -EINVAL;
18104 }
18105
18106 if (changed & WIPHY_PARAM_RETRY_SHORT)
18107 {
18108 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
18109 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018110 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070018111 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018112 hddLog(VOS_TRACE_LEVEL_ERROR,
18113 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018114 __func__, retry_value);
18115 return -EIO;
18116 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018117 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018118 __func__, retry_value);
18119 }
18120 else if (changed & WIPHY_PARAM_RETRY_SHORT)
18121 {
18122 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
18123 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018124 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070018125 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018126 hddLog(VOS_TRACE_LEVEL_ERROR,
18127 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018128 __func__, retry_value);
18129 return -EIO;
18130 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018131 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018132 __func__, retry_value);
18133 }
18134 }
18135
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018136 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070018137 return 0;
18138}
18139
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053018140static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
18141 u32 changed)
18142{
18143 int ret;
18144
18145 vos_ssr_protect(__func__);
18146 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
18147 vos_ssr_unprotect(__func__);
18148
18149 return ret;
18150}
18151
Jeff Johnson295189b2012-06-20 16:38:30 -070018152/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053018153 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070018154 * This function is used to set the txpower
18155 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053018156static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070018157#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18158 struct wireless_dev *wdev,
18159#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018160#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018161 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070018162#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018163 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070018164#endif
18165 int dbm)
18166{
18167 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018168 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070018169 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
18170 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018171 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070018172
18173 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018174
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018175 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18176 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
18177 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018178 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018179 if (0 != status)
18180 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018181 return status;
18182 }
18183
18184 hHal = pHddCtx->hHal;
18185
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018186 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
18187 dbm, ccmCfgSetCallback,
18188 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070018189 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018190 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070018191 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
18192 return -EIO;
18193 }
18194
18195 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
18196 dbm);
18197
18198 switch(type)
18199 {
18200 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
18201 /* Fall through */
18202 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
18203 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
18204 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018205 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
18206 __func__);
18207 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070018208 }
18209 break;
18210 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018211 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070018212 __func__);
18213 return -EOPNOTSUPP;
18214 break;
18215 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018216 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
18217 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070018218 return -EIO;
18219 }
18220
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018221 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070018222 return 0;
18223}
18224
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053018225static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
18226#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18227 struct wireless_dev *wdev,
18228#endif
18229#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
18230 enum tx_power_setting type,
18231#else
18232 enum nl80211_tx_power_setting type,
18233#endif
18234 int dbm)
18235{
18236 int ret;
18237 vos_ssr_protect(__func__);
18238 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
18239#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18240 wdev,
18241#endif
18242#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
18243 type,
18244#else
18245 type,
18246#endif
18247 dbm);
18248 vos_ssr_unprotect(__func__);
18249
18250 return ret;
18251}
18252
Jeff Johnson295189b2012-06-20 16:38:30 -070018253/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018254 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070018255 * This function is used to read the txpower
18256 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018257static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070018258#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18259 struct wireless_dev *wdev,
18260#endif
18261 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070018262{
18263
18264 hdd_adapter_t *pAdapter;
18265 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018266 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070018267
Jeff Johnsone7245742012-09-05 17:12:55 -070018268 ENTER();
18269
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018270 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018271 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018272 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018273 *dbm = 0;
18274 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018275 }
18276
Jeff Johnson295189b2012-06-20 16:38:30 -070018277 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
18278 if (NULL == pAdapter)
18279 {
18280 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
18281 return -ENOENT;
18282 }
18283
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018284 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18285 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
18286 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070018287 wlan_hdd_get_classAstats(pAdapter);
18288 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
18289
Jeff Johnsone7245742012-09-05 17:12:55 -070018290 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070018291 return 0;
18292}
18293
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018294static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
18295#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18296 struct wireless_dev *wdev,
18297#endif
18298 int *dbm)
18299{
18300 int ret;
18301
18302 vos_ssr_protect(__func__);
18303 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
18304#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18305 wdev,
18306#endif
18307 dbm);
18308 vos_ssr_unprotect(__func__);
18309
18310 return ret;
18311}
18312
Dustin Brown8c1d4092017-07-28 18:08:01 +053018313/*
18314 * wlan_hdd_fill_summary_stats() - populate station_info summary stats
18315 * @stats: summary stats to use as a source
18316 * @info: kernel station_info struct to use as a destination
18317 *
18318 * Return: None
18319 */
18320static void wlan_hdd_fill_summary_stats(tCsrSummaryStatsInfo *stats,
18321 struct station_info *info)
18322{
18323 int i;
18324
18325 info->rx_packets = stats->rx_frm_cnt;
18326 info->tx_packets = 0;
18327 info->tx_retries = 0;
18328 info->tx_failed = 0;
18329
18330 for (i = 0; i < 4; ++i) {
18331 info->tx_packets += stats->tx_frm_cnt[i];
18332 info->tx_retries += stats->multiple_retry_cnt[i];
18333 info->tx_failed += stats->fail_cnt[i];
18334 }
18335
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018336#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
18337 !defined(WITH_BACKPORTS)
Dustin Brown8c1d4092017-07-28 18:08:01 +053018338 info->filled |= STATION_INFO_TX_PACKETS |
18339 STATION_INFO_TX_RETRIES |
18340 STATION_INFO_TX_FAILED |
18341 STATION_INFO_RX_PACKETS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018342#else
18343 info->filled |= BIT(NL80211_STA_INFO_TX_PACKETS) |
18344 BIT(NL80211_STA_INFO_TX_RETRIES) |
18345 BIT(NL80211_STA_INFO_TX_FAILED) |
18346 BIT(NL80211_STA_INFO_RX_PACKETS);
18347#endif
Dustin Brown8c1d4092017-07-28 18:08:01 +053018348}
18349
18350/**
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018351 * wlan_hdd_sap_get_sta_rssi() - get RSSI of the SAP client
18352 * @adapter: sap adapter pointer
18353 * @staid: station id of the client
18354 * @rssi: rssi value to fill
18355 *
18356 * Return: None
18357 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053018358void
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018359wlan_hdd_sap_get_sta_rssi(hdd_adapter_t *adapter, uint8_t staid, s8 *rssi)
18360{
18361 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
18362
18363 WLANTL_GetSAPStaRSSi(pVosContext, staid, rssi);
18364}
18365
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018366#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
18367 !defined(WITH_BACKPORTS)
18368static inline void wlan_hdd_fill_station_info_signal(struct station_info
18369 *sinfo)
18370{
18371 sinfo->filled |= STATION_INFO_SIGNAL;
18372}
18373#else
18374static inline void wlan_hdd_fill_station_info_signal(struct station_info
18375 *sinfo)
18376{
18377 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
18378}
18379#endif
18380
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018381/**
Dustin Brown8c1d4092017-07-28 18:08:01 +053018382 * wlan_hdd_get_sap_stats() - get aggregate SAP stats
18383 * @adapter: sap adapter to get stats for
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018384 * @mac: mac address of the station
Dustin Brown8c1d4092017-07-28 18:08:01 +053018385 * @info: kernel station_info struct to populate
18386 *
18387 * Fetch the vdev-level aggregate stats for the given SAP adapter. This is to
18388 * support "station dump" and "station get" for SAP vdevs, even though they
18389 * aren't technically stations.
18390 *
18391 * Return: errno
18392 */
18393static int
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018394wlan_hdd_get_sap_stats(hdd_adapter_t *adapter,
18395#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18396 const u8* mac,
18397#else
18398 u8* mac,
18399#endif
18400 struct station_info *info)
Dustin Brown8c1d4092017-07-28 18:08:01 +053018401{
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018402 v_MACADDR_t *peerMacAddr;
18403 uint8_t staid;
Dustin Brown8c1d4092017-07-28 18:08:01 +053018404 VOS_STATUS status;
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018405 bool bc_mac_addr;
Dustin Brown8c1d4092017-07-28 18:08:01 +053018406
18407 status = wlan_hdd_get_station_stats(adapter);
18408 if (!VOS_IS_STATUS_SUCCESS(status)) {
18409 hddLog(VOS_TRACE_LEVEL_ERROR,
18410 "Failed to get SAP stats; status:%d", status);
18411 return 0;
18412 }
18413
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018414 peerMacAddr = (v_MACADDR_t *)mac;
18415 bc_mac_addr = vos_is_macaddr_broadcast(peerMacAddr);
18416 staid = hdd_sta_id_find_from_mac_addr(adapter, peerMacAddr);
18417 hddLog(VOS_TRACE_LEVEL_INFO, "Get SAP stats for sta id:%d", staid);
18418
18419 if (staid < WLAN_MAX_STA_COUNT && !bc_mac_addr) {
18420 wlan_hdd_sap_get_sta_rssi(adapter, staid, &info->signal);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018421 wlan_hdd_fill_station_info_signal(info);
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018422 }
18423
Dustin Brown8c1d4092017-07-28 18:08:01 +053018424 wlan_hdd_fill_summary_stats(&adapter->hdd_stats.summary_stat, info);
18425
18426 return 0;
18427}
18428
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018429static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053018430#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18431 const u8* mac,
18432#else
18433 u8* mac,
18434#endif
18435 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070018436{
18437 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
18438 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
c_hpothu44ff4e02014-05-08 00:13:57 +053018439 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070018440
18441 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
18442 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070018443
18444 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
18445 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
18446 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
18447 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
18448 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
18449 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
18450 tANI_U16 maxRate = 0;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053018451 int8_t snr = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018452 tANI_U16 myRate;
18453 tANI_U16 currentRate = 0;
18454 tANI_U8 maxSpeedMCS = 0;
18455 tANI_U8 maxMCSIdx = 0;
18456 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053018457 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070018458 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018459 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070018460
Leo Chang6f8870f2013-03-26 18:11:36 -070018461#ifdef WLAN_FEATURE_11AC
18462 tANI_U32 vht_mcs_map;
18463 eDataRate11ACMaxMcs vhtMaxMcs;
18464#endif /* WLAN_FEATURE_11AC */
18465
Jeff Johnsone7245742012-09-05 17:12:55 -070018466 ENTER();
18467
Dustin Brown8c1d4092017-07-28 18:08:01 +053018468 status = wlan_hdd_validate_context(pHddCtx);
18469 if (0 != status)
18470 {
18471 return status;
18472 }
18473
18474 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018475 return wlan_hdd_get_sap_stats(pAdapter, mac, sinfo);
Dustin Brown8c1d4092017-07-28 18:08:01 +053018476
Abhinav Kumarf70293b2019-09-19 12:33:43 +053018477 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -070018478 {
Abhinav Kumarf70293b2019-09-19 12:33:43 +053018479 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070018480 /*To keep GUI happy*/
18481 return 0;
18482 }
18483
Mukul Sharma811205f2014-07-09 21:07:30 +053018484 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
18485 {
18486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18487 "%s: Roaming in progress, so unable to proceed this request", __func__);
Sachin Ahuja81ab1812016-08-19 21:35:58 +053018488 /* return a cached value */
18489 sinfo->signal = pAdapter->rssi;
Mukul Sharma811205f2014-07-09 21:07:30 +053018490 return 0;
18491 }
18492
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053018493 wlan_hdd_get_station_stats(pAdapter);
18494 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070018495
Kiet Lam3b17fc82013-09-27 05:24:08 +053018496 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053018497 wlan_hdd_get_snr(pAdapter, &snr);
18498 pHddStaCtx->conn_info.signal = sinfo->signal;
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +053018499 pHddStaCtx->cache_conn_info.signal = sinfo->signal;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053018500 pHddStaCtx->conn_info.noise = pHddStaCtx->conn_info.signal - snr;
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +053018501 pHddStaCtx->cache_conn_info.noise = pHddStaCtx->conn_info.noise;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018502 wlan_hdd_fill_station_info_signal(sinfo);
Kiet Lam3b17fc82013-09-27 05:24:08 +053018503
c_hpothu09f19542014-05-30 21:53:31 +053018504 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053018505 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
18506 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053018507 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053018508 {
18509 rate_flags = pAdapter->maxRateFlags;
18510 }
c_hpothu44ff4e02014-05-08 00:13:57 +053018511
Jeff Johnson295189b2012-06-20 16:38:30 -070018512 //convert to the UI units of 100kbps
18513 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
18514
18515#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070018516 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 -070018517 sinfo->signal,
18518 pCfg->reportMaxLinkSpeed,
18519 myRate,
18520 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070018521 (int) pCfg->linkSpeedRssiMid,
18522 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070018523 (int) rate_flags,
18524 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070018525#endif //LINKSPEED_DEBUG_ENABLED
18526
Hanumanth Reddy Pothula596b8b32018-05-01 20:17:38 +053018527#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || defined(WITH_BACKPORTS)
18528 /* assume basic BW. anything else will override this later */
18529 sinfo->txrate.bw = RATE_INFO_BW_20;
18530#endif
18531
Jeff Johnson295189b2012-06-20 16:38:30 -070018532 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
18533 {
18534 // we do not want to necessarily report the current speed
18535 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
18536 {
18537 // report the max possible speed
18538 rssidx = 0;
18539 }
18540 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
18541 {
18542 // report the max possible speed with RSSI scaling
18543 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
18544 {
18545 // report the max possible speed
18546 rssidx = 0;
18547 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070018548 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070018549 {
18550 // report middle speed
18551 rssidx = 1;
18552 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070018553 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
18554 {
18555 // report middle speed
18556 rssidx = 2;
18557 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018558 else
18559 {
18560 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070018561 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070018562 }
18563 }
18564 else
18565 {
18566 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
18567 hddLog(VOS_TRACE_LEVEL_ERROR,
18568 "%s: Invalid value for reportMaxLinkSpeed: %u",
18569 __func__, pCfg->reportMaxLinkSpeed);
18570 rssidx = 0;
18571 }
18572
18573 maxRate = 0;
18574
18575 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053018576 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
18577 OperationalRates, &ORLeng))
18578 {
18579 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
18580 /*To keep GUI happy*/
18581 return 0;
18582 }
18583
Jeff Johnson295189b2012-06-20 16:38:30 -070018584 for (i = 0; i < ORLeng; i++)
18585 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018586 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070018587 {
18588 /* Validate Rate Set */
18589 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
18590 {
18591 currentRate = supported_data_rate[j].supported_rate[rssidx];
18592 break;
18593 }
18594 }
18595 /* Update MAX rate */
18596 maxRate = (currentRate > maxRate)?currentRate:maxRate;
18597 }
18598
18599 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053018600 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
18601 ExtendedRates, &ERLeng))
18602 {
18603 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
18604 /*To keep GUI happy*/
18605 return 0;
18606 }
18607
Jeff Johnson295189b2012-06-20 16:38:30 -070018608 for (i = 0; i < ERLeng; i++)
18609 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018610 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070018611 {
18612 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
18613 {
18614 currentRate = supported_data_rate[j].supported_rate[rssidx];
18615 break;
18616 }
18617 }
18618 /* Update MAX rate */
18619 maxRate = (currentRate > maxRate)?currentRate:maxRate;
18620 }
c_hpothu79aab322014-07-14 21:11:01 +053018621
Kiet Lamb69f8dc2013-11-15 15:34:27 +053018622 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053018623 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053018624 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053018625 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070018626 {
c_hpothu79aab322014-07-14 21:11:01 +053018627 if (rate_flags & eHAL_TX_RATE_VHT80)
18628 mode = 2;
18629 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
18630 mode = 1;
18631 else
18632 mode = 0;
18633
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053018634 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
18635 MCSRates, &MCSLeng))
18636 {
18637 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
18638 /*To keep GUI happy*/
18639 return 0;
18640 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018641 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070018642#ifdef WLAN_FEATURE_11AC
18643 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018644 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070018645 {
Leo Chang6f8870f2013-03-26 18:11:36 -070018646 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018647 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070018648 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070018649 {
Leo Chang6f8870f2013-03-26 18:11:36 -070018650 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070018651 }
Leo Chang6f8870f2013-03-26 18:11:36 -070018652 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070018653 {
Leo Chang6f8870f2013-03-26 18:11:36 -070018654 maxMCSIdx = 7;
18655 }
18656 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
18657 {
18658 maxMCSIdx = 8;
18659 }
18660 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
18661 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018662 //VHT20 is supporting 0~8
18663 if (rate_flags & eHAL_TX_RATE_VHT20)
18664 maxMCSIdx = 8;
18665 else
18666 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070018667 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018668
c_hpothu79aab322014-07-14 21:11:01 +053018669 if (0 != rssidx)/*check for scaled */
18670 {
18671 //get middle rate MCS index if rssi=1/2
18672 for (i=0; i <= maxMCSIdx; i++)
18673 {
18674 if (sinfo->signal <= rssiMcsTbl[mode][i])
18675 {
18676 maxMCSIdx = i;
18677 break;
18678 }
18679 }
18680 }
18681
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018682 if (rate_flags & eHAL_TX_RATE_VHT80)
18683 {
18684 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
18685 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
18686 }
18687 else if (rate_flags & eHAL_TX_RATE_VHT40)
18688 {
18689 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
18690 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
18691 }
18692 else if (rate_flags & eHAL_TX_RATE_VHT20)
18693 {
18694 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
18695 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
18696 }
18697
Leo Chang6f8870f2013-03-26 18:11:36 -070018698 maxSpeedMCS = 1;
18699 if (currentRate > maxRate)
18700 {
18701 maxRate = currentRate;
18702 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018703
Leo Chang6f8870f2013-03-26 18:11:36 -070018704 }
18705 else
18706#endif /* WLAN_FEATURE_11AC */
18707 {
18708 if (rate_flags & eHAL_TX_RATE_HT40)
18709 {
18710 rateFlag |= 1;
18711 }
18712 if (rate_flags & eHAL_TX_RATE_SGI)
18713 {
18714 rateFlag |= 2;
18715 }
18716
Girish Gowli01abcee2014-07-31 20:18:55 +053018717 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053018718 if (rssidx == 1 || rssidx == 2)
18719 {
18720 //get middle rate MCS index if rssi=1/2
18721 for (i=0; i <= 7; i++)
18722 {
18723 if (sinfo->signal <= rssiMcsTbl[mode][i])
18724 {
18725 temp = i+1;
18726 break;
18727 }
18728 }
18729 }
c_hpothu79aab322014-07-14 21:11:01 +053018730
18731 for (i = 0; i < MCSLeng; i++)
18732 {
Leo Chang6f8870f2013-03-26 18:11:36 -070018733 for (j = 0; j < temp; j++)
18734 {
18735 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
18736 {
18737 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053018738 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070018739 break;
18740 }
18741 }
18742 if ((j < temp) && (currentRate > maxRate))
18743 {
18744 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070018745 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018746 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053018747 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070018748 }
18749 }
18750
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018751 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
18752 {
18753 maxRate = myRate;
18754 maxSpeedMCS = 1;
18755 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
18756 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018757 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053018758 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070018759 {
18760 maxRate = myRate;
18761 if (rate_flags & eHAL_TX_RATE_LEGACY)
18762 {
18763 maxSpeedMCS = 0;
18764 }
18765 else
18766 {
18767 maxSpeedMCS = 1;
18768 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
18769 }
18770 }
18771
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018772 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070018773 {
18774 sinfo->txrate.legacy = maxRate;
18775#ifdef LINKSPEED_DEBUG_ENABLED
18776 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
18777#endif //LINKSPEED_DEBUG_ENABLED
18778 }
18779 else
18780 {
18781 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070018782#ifdef WLAN_FEATURE_11AC
18783 sinfo->txrate.nss = 1;
18784 if (rate_flags & eHAL_TX_RATE_VHT80)
18785 {
18786 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018787#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18788 defined(WITH_BACKPORTS)
18789 sinfo->txrate.bw = RATE_INFO_BW_80;
18790#else
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018791 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018792#endif
Leo Chang6f8870f2013-03-26 18:11:36 -070018793 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018794 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070018795 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018796 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018797#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18798 defined(WITH_BACKPORTS)
18799 sinfo->txrate.bw = RATE_INFO_BW_40;
18800#else
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018801 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018802#endif
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018803 }
18804 else if (rate_flags & eHAL_TX_RATE_VHT20)
18805 {
18806 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
18807 }
18808#endif /* WLAN_FEATURE_11AC */
18809 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
18810 {
18811 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
18812 if (rate_flags & eHAL_TX_RATE_HT40)
18813 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018814#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18815 defined(WITH_BACKPORTS)
18816 sinfo->txrate.bw = RATE_INFO_BW_40;
18817#else
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018818 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018819#endif
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018820 }
Leo Chang6f8870f2013-03-26 18:11:36 -070018821 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018822 if (rate_flags & eHAL_TX_RATE_SGI)
18823 {
18824 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
18825 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018826
Jeff Johnson295189b2012-06-20 16:38:30 -070018827#ifdef LINKSPEED_DEBUG_ENABLED
18828 pr_info("Reporting MCS rate %d flags %x\n",
18829 sinfo->txrate.mcs,
18830 sinfo->txrate.flags );
18831#endif //LINKSPEED_DEBUG_ENABLED
18832 }
18833 }
18834 else
18835 {
18836 // report current rate instead of max rate
18837
18838 if (rate_flags & eHAL_TX_RATE_LEGACY)
18839 {
18840 //provide to the UI in units of 100kbps
18841 sinfo->txrate.legacy = myRate;
18842#ifdef LINKSPEED_DEBUG_ENABLED
18843 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
18844#endif //LINKSPEED_DEBUG_ENABLED
18845 }
18846 else
18847 {
18848 //must be MCS
18849 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070018850#ifdef WLAN_FEATURE_11AC
18851 sinfo->txrate.nss = 1;
18852 if (rate_flags & eHAL_TX_RATE_VHT80)
18853 {
18854 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
18855 }
18856 else
18857#endif /* WLAN_FEATURE_11AC */
18858 {
18859 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
18860 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018861 if (rate_flags & eHAL_TX_RATE_SGI)
18862 {
18863 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
18864 }
18865 if (rate_flags & eHAL_TX_RATE_HT40)
18866 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018867#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18868 defined(WITH_BACKPORTS)
18869 sinfo->txrate.bw = RATE_INFO_BW_40;
18870#else
Jeff Johnson295189b2012-06-20 16:38:30 -070018871 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018872#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018873 }
Leo Chang6f8870f2013-03-26 18:11:36 -070018874#ifdef WLAN_FEATURE_11AC
18875 else if (rate_flags & eHAL_TX_RATE_VHT80)
18876 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018877#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18878 defined(WITH_BACKPORTS)
18879 sinfo->txrate.bw = RATE_INFO_BW_80;
18880#else
Leo Chang6f8870f2013-03-26 18:11:36 -070018881 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018882#endif
Leo Chang6f8870f2013-03-26 18:11:36 -070018883 }
18884#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070018885#ifdef LINKSPEED_DEBUG_ENABLED
18886 pr_info("Reporting actual MCS rate %d flags %x\n",
18887 sinfo->txrate.mcs,
18888 sinfo->txrate.flags );
18889#endif //LINKSPEED_DEBUG_ENABLED
18890 }
18891 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018892
18893#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
18894 !defined(WITH_BACKPORTS)
Jeff Johnson295189b2012-06-20 16:38:30 -070018895 sinfo->filled |= STATION_INFO_TX_BITRATE;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018896#else
18897 sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE);
18898#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018899
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018900 sinfo->tx_packets =
18901 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
18902 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
18903 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
18904 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
18905
18906 sinfo->tx_retries =
18907 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
18908 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
18909 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
18910 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
18911
18912 sinfo->tx_failed =
18913 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
18914 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
18915 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
18916 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
18917
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018918#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
18919 !defined(WITH_BACKPORTS)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018920 sinfo->filled |=
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018921 STATION_INFO_RX_PACKETS |
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018922 STATION_INFO_TX_PACKETS |
18923 STATION_INFO_TX_RETRIES |
18924 STATION_INFO_TX_FAILED;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018925#else
18926 sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS) |
18927 BIT(NL80211_STA_INFO_TX_PACKETS) |
18928 BIT(NL80211_STA_INFO_TX_RETRIES) |
18929 BIT(NL80211_STA_INFO_TX_FAILED);
18930#endif
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018931
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053018932 sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt;
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053018933
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053018934 vos_mem_copy(&pHddStaCtx->conn_info.txrate,
18935 &sinfo->txrate, sizeof(sinfo->txrate));
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +053018936 vos_mem_copy(&pHddStaCtx->cache_conn_info.txrate,
18937 &sinfo->txrate, sizeof(sinfo->txrate));
18938
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053018939 if (rate_flags & eHAL_TX_RATE_LEGACY)
18940 hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"),
18941 sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets,
18942 sinfo->rx_packets);
18943 else
18944 hddLog(LOG1,
18945 FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"),
18946 sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags,
18947 sinfo->tx_packets, sinfo->rx_packets);
18948
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018949 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18950 TRACE_CODE_HDD_CFG80211_GET_STA,
18951 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018952 EXIT();
18953 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018954}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053018955#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
18956static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
18957 const u8* mac, struct station_info *sinfo)
18958#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018959static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
18960 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053018961#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018962{
18963 int ret;
18964
18965 vos_ssr_protect(__func__);
18966 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
18967 vos_ssr_unprotect(__func__);
18968
18969 return ret;
18970}
18971
18972static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070018973 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070018974{
18975 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018976 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070018977 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018978 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070018979
Jeff Johnsone7245742012-09-05 17:12:55 -070018980 ENTER();
18981
Jeff Johnson295189b2012-06-20 16:38:30 -070018982 if (NULL == pAdapter)
18983 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080018984 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070018985 return -ENODEV;
18986 }
18987
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018988 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18989 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
18990 pAdapter->sessionId, timeout));
18991
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018992 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018993 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018994 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018995 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018996 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018997 }
18998
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018999 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
19000 (TRUE == pHddCtx->hdd_wlan_suspended) &&
19001 (pHddCtx->cfg_ini->fhostArpOffload) &&
19002 (eConnectionState_Associated ==
19003 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
19004 {
Amar Singhald53568e2013-09-26 11:03:45 -070019005
19006 hddLog(VOS_TRACE_LEVEL_INFO,
19007 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053019008 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053019009 if (!VOS_IS_STATUS_SUCCESS(vos_status))
19010 {
19011 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080019012 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053019013 __func__, vos_status);
19014 }
19015 }
19016
Jeff Johnson295189b2012-06-20 16:38:30 -070019017 /**The get power cmd from the supplicant gets updated by the nl only
19018 *on successful execution of the function call
19019 *we are oppositely mapped w.r.t mode in the driver
19020 **/
19021 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
19022
19023 if (VOS_STATUS_E_FAILURE == vos_status)
19024 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019025 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19026 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070019027 return -EINVAL;
19028 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019029 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070019030 return 0;
19031}
19032
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019033static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
19034 struct net_device *dev, bool mode, int timeout)
19035{
19036 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070019037
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019038 vos_ssr_protect(__func__);
19039 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
19040 vos_ssr_unprotect(__func__);
19041
19042 return ret;
19043}
Sushant Kaushik084f6592015-09-10 13:11:56 +053019044
Jeff Johnson295189b2012-06-20 16:38:30 -070019045#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019046static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
19047 struct net_device *netdev,
19048 u8 key_index)
19049{
19050 ENTER();
19051 return 0;
19052}
19053
Jeff Johnson295189b2012-06-20 16:38:30 -070019054static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019055 struct net_device *netdev,
19056 u8 key_index)
19057{
19058 int ret;
19059 vos_ssr_protect(__func__);
19060 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
19061 vos_ssr_unprotect(__func__);
19062 return ret;
19063}
19064#endif //LINUX_VERSION_CODE
19065
19066#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
19067static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
19068 struct net_device *dev,
19069 struct ieee80211_txq_params *params)
19070{
19071 ENTER();
19072 return 0;
19073}
19074#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
19075static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
19076 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070019077{
Jeff Johnsone7245742012-09-05 17:12:55 -070019078 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070019079 return 0;
19080}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019081#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070019082
19083#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
19084static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019085 struct net_device *dev,
19086 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070019087{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019088 int ret;
19089
19090 vos_ssr_protect(__func__);
19091 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
19092 vos_ssr_unprotect(__func__);
19093 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070019094}
19095#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
19096static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
19097 struct ieee80211_txq_params *params)
19098{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019099 int ret;
19100
19101 vos_ssr_protect(__func__);
19102 ret = __wlan_hdd_set_txq_params(wiphy, params);
19103 vos_ssr_unprotect(__func__);
19104 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070019105}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019106#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019107
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019108static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019109 struct net_device *dev,
19110 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070019111{
19112 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019113 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019114 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019115 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019116 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019117 v_CONTEXT_t pVosContext = NULL;
19118 ptSapContext pSapCtx = NULL;
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019119 hdd_hostapd_state_t *hostap_state;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019120
Jeff Johnsone7245742012-09-05 17:12:55 -070019121 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019122
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019123 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070019124 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019125 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070019126 return -EINVAL;
19127 }
19128
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019129 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19130 TRACE_CODE_HDD_CFG80211_DEL_STA,
19131 pAdapter->sessionId, pAdapter->device_mode));
19132
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019133 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19134 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019135 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019136 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019137 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019138 }
19139
Jeff Johnson295189b2012-06-20 16:38:30 -070019140 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070019141 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070019142 )
19143 {
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019144 hostap_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019145 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
19146 pSapCtx = VOS_GET_SAP_CB(pVosContext);
19147 if(pSapCtx == NULL){
19148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19149 FL("psapCtx is NULL"));
19150 return -ENOENT;
19151 }
Agrawal Ashish306b75f2017-01-11 19:16:25 +053019152 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
19153 {
19154 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
19155 "Change reason code to eSIR_MAC_DISASSOC_LEAVING_BSS_REASON in sap auth offload");
19156 pDelStaParams->reason_code = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
19157 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019158 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070019159 {
19160 v_U16_t i;
19161 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
19162 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019163 if ((pSapCtx->aStaInfo[i].isUsed) &&
19164 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070019165 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019166 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019167 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019168 ETHER_ADDR_LEN);
19169
Jeff Johnson295189b2012-06-20 16:38:30 -070019170 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080019171 "%s: Delete STA with MAC::"
19172 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019173 __func__,
19174 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019175 vos_event_reset(&hostap_state->sta_discon_event);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019176 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070019177 if (VOS_IS_STATUS_SUCCESS(vos_status))
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019178 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019179 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019180 vos_status =
19181 vos_wait_single_event(
19182 &hostap_state->sta_discon_event,
19183 WLAN_WAIT_TIME_DISCONNECT);
19184 if (!VOS_IS_STATUS_SUCCESS(vos_status))
19185 hddLog(LOGE,"!!%s: ERROR: Deauth wait expired!!",
19186 __func__);
19187 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019188 }
19189 }
19190 }
19191 else
19192 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019193
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019194 vos_status = hdd_softap_GetStaId(pAdapter,
19195 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019196 if (!VOS_IS_STATUS_SUCCESS(vos_status))
19197 {
19198 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080019199 "%s: Skip this DEL STA as this is not used::"
19200 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019201 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019202 return -ENOENT;
19203 }
19204
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019205 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019206 {
19207 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080019208 "%s: Skip this DEL STA as deauth is in progress::"
19209 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019210 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019211 return -ENOENT;
19212 }
19213
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019214 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019215
Jeff Johnson295189b2012-06-20 16:38:30 -070019216 hddLog(VOS_TRACE_LEVEL_INFO,
19217 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080019218 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070019219 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019220 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019221
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019222 vos_event_reset(&hostap_state->sta_discon_event);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019223 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019224 if (!VOS_IS_STATUS_SUCCESS(vos_status))
19225 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019226 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019227 hddLog(VOS_TRACE_LEVEL_INFO,
19228 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080019229 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019230 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019231 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019232 return -ENOENT;
19233 }
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019234 vos_status =
19235 vos_wait_single_event(&hostap_state->sta_discon_event,
19236 WLAN_WAIT_TIME_DISCONNECT);
19237 if (!VOS_IS_STATUS_SUCCESS(vos_status))
19238 hddLog(LOGE,"!!%s: ERROR: Deauth wait expired!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070019239 }
19240 }
19241
19242 EXIT();
19243
19244 return 0;
19245}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019246
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053019247#ifdef USE_CFG80211_DEL_STA_V2
Kapil Gupta137ef892016-12-13 19:38:00 +053019248int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019249 struct net_device *dev,
19250 struct station_del_parameters *param)
19251#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019252#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
Kapil Gupta137ef892016-12-13 19:38:00 +053019253int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019254 struct net_device *dev, const u8 *mac)
19255#else
Kapil Gupta137ef892016-12-13 19:38:00 +053019256int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019257 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019258#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019259#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019260{
19261 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019262 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070019263
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019264 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019265
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053019266#ifdef USE_CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019267 if (NULL == param) {
19268 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019269 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019270 return -EINVAL;
19271 }
19272
19273 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
19274 param->subtype, &delStaParams);
19275
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019276#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053019277 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019278 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019279#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019280 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
19281
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019282 vos_ssr_unprotect(__func__);
19283
19284 return ret;
19285}
19286
19287static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019288 struct net_device *dev,
19289#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
19290 const u8 *mac,
19291#else
19292 u8 *mac,
19293#endif
19294 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080019295{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019296 hdd_adapter_t *pAdapter;
19297 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080019298 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080019299#ifdef FEATURE_WLAN_TDLS
19300 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019301
Hoonki Lee11f7dda2013-02-14 16:55:44 -080019302 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019303
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019304 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19305 if (NULL == pAdapter)
19306 {
19307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19308 "%s: Adapter is NULL",__func__);
19309 return -EINVAL;
19310 }
19311 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19312 status = wlan_hdd_validate_context(pHddCtx);
19313 if (0 != status)
19314 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019315 return status;
19316 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019317
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019318 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19319 TRACE_CODE_HDD_CFG80211_ADD_STA,
19320 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019321 mask = params->sta_flags_mask;
19322
19323 set = params->sta_flags_set;
19324
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053019325 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019326 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
19327 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019328
19329 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
19330 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080019331 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019332 }
19333 }
19334#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019335 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080019336 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070019337}
19338
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019339#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
19340static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
19341 struct net_device *dev, const u8 *mac,
19342 struct station_parameters *params)
19343#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019344static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
19345 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019346#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019347{
19348 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019349
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019350 vos_ssr_protect(__func__);
19351 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
19352 vos_ssr_unprotect(__func__);
19353
19354 return ret;
19355}
Abhinav Kumar8c122592019-08-07 15:43:20 +053019356
19357#if defined(WLAN_FEATURE_SAE) && \
19358 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
19359/*
19360 * wlan_hdd_is_pmksa_valid: API to validate pmksa
19361 * @pmksa: pointer to cfg80211_pmksa structure
19362 *
19363 * Return: True if valid else false
19364 */
19365static inline bool wlan_hdd_is_pmksa_valid(struct cfg80211_pmksa *pmksa)
19366{
19367 if (pmksa->bssid){
19368 return true;
19369 }
19370 else
19371 {
19372 hddLog(LOGE, FL(" Either of bssid (%p) is NULL"), pmksa->bssid);
19373 return false;
19374 }
19375}
19376
19377/*
19378 * hdd_update_pmksa_info: API to update tPmkidCacheInfo from cfg80211_pmksa
19379 * @pmk_cache: pmksa from supplicant
19380 * @pmk_cache: pmk needs to be updated
19381 *
19382 * Return: None
19383 */
19384static void hdd_update_pmksa_info(tPmkidCacheInfo *pmk_cache,
19385 struct cfg80211_pmksa *pmksa, bool is_delete)
19386{
19387 if (pmksa->bssid) {
19388 hddLog(VOS_TRACE_LEVEL_DEBUG,"set PMKSA for " MAC_ADDRESS_STR,
19389 MAC_ADDR_ARRAY(pmksa->bssid));
19390 vos_mem_copy(pmk_cache->BSSID,
19391 pmksa->bssid, VOS_MAC_ADDR_SIZE);
19392 }
19393
19394 if (is_delete)
19395 return;
19396
19397 vos_mem_copy(pmk_cache->PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
19398 if (pmksa->pmk_len && (pmksa->pmk_len <= CSR_RSN_MAX_PMK_LEN)) {
19399 vos_mem_copy(pmk_cache->pmk, pmksa->pmk, pmksa->pmk_len);
19400 pmk_cache->pmk_len = pmksa->pmk_len;
19401 } else
19402 hddLog(VOS_TRACE_LEVEL_INFO, "pmk len is %zu", pmksa->pmk_len);
19403}
19404#else
19405/*
19406 * wlan_hdd_is_pmksa_valid: API to validate pmksa
19407 * @pmksa: pointer to cfg80211_pmksa structure
19408 *
19409 * Return: True if valid else false
19410 */
19411static inline bool wlan_hdd_is_pmksa_valid(struct cfg80211_pmksa *pmksa)
19412{
19413 if (!pmksa->bssid) {
19414 hddLog(LOGE,FL("both bssid is NULL %p"), pmksa->bssid);
19415 return false;
19416 }
19417 return true;
19418}
19419
19420/*
19421 * hdd_update_pmksa_info: API to update tPmkidCacheInfo from cfg80211_pmksa
19422 * @pmk_cache: pmksa from supplicant
19423 * @pmk_cache: pmk needs to be updated
19424 *
19425 * Return: None
19426 */
19427static void hdd_update_pmksa_info(tPmkidCacheInfo *pmk_cache,
19428 struct cfg80211_pmksa *pmksa, bool is_delete)
19429{
19430 hddLog(VOS_TRACE_LEVEL_INFO,"set PMKSA for " MAC_ADDRESS_STR,
19431 MAC_ADDR_ARRAY(pmksa->bssid));
19432 vos_mem_copy(pmk_cache->BSSID,
19433 pmksa->bssid, VOS_MAC_ADDR_SIZE);
19434
19435 if (is_delete)
19436 return;
19437
19438 vos_mem_copy(pmk_cache->PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
19439}
19440#endif
19441
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019442#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070019443
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019444static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070019445 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019446{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019447 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19448 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019449 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019450 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019451 hdd_context_t *pHddCtx;
Abhinav Kumar8c122592019-08-07 15:43:20 +053019452 tPmkidCacheInfo pmk_cache;
Jeff Johnsone7245742012-09-05 17:12:55 -070019453
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019454 ENTER();
19455
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019456 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019457 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019458 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019459 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019460 return -EINVAL;
19461 }
19462
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019463 if (!pmksa) {
19464 hddLog(LOGE, FL("pmksa is NULL"));
19465 return -EINVAL;
19466 }
19467
Abhinav Kumar8c122592019-08-07 15:43:20 +053019468 if (!pmksa->pmkid) {
19469 hddLog(LOGE, FL("pmksa->pmkid(%p) is NULL"), pmksa->pmkid);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019470 return -EINVAL;
19471 }
19472
Abhinav Kumar8c122592019-08-07 15:43:20 +053019473 if (!wlan_hdd_is_pmksa_valid(pmksa))
19474 return -EINVAL;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019475
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019476 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19477 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019478 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019479 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019480 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019481 }
19482
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019483 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019484 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19485
Abhinav Kumar8c122592019-08-07 15:43:20 +053019486 vos_mem_zero(&pmk_cache, sizeof(pmk_cache));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019487
Abhinav Kumar8c122592019-08-07 15:43:20 +053019488 hdd_update_pmksa_info(&pmk_cache, pmksa, false);
19489
19490
19491 /* Add to the PMKSA ID Cache in CSR
19492 * PMKSA cache will be having following
19493 * 1. pmkid id
19494 * 2. pmk 15733
19495 * 3. bssid or cache identifier
19496 */
19497 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
19498 &pmk_cache, 1, FALSE);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019499
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019500 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19501 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
19502 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019503
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019504 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019505 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019506}
19507
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019508static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
19509 struct cfg80211_pmksa *pmksa)
19510{
19511 int ret;
19512
19513 vos_ssr_protect(__func__);
19514 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
19515 vos_ssr_unprotect(__func__);
19516
19517 return ret;
19518}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019519
Wilson Yang6507c4e2013-10-01 20:11:19 -070019520
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019521static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070019522 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019523{
Wilson Yang6507c4e2013-10-01 20:11:19 -070019524 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19525 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019526 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080019527 int status = 0;
Abhinav Kumar8c122592019-08-07 15:43:20 +053019528 tPmkidCacheInfo pmk_cache;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019529
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019530 ENTER();
19531
Wilson Yang6507c4e2013-10-01 20:11:19 -070019532 /* Validate pAdapter */
19533 if (NULL == pAdapter)
19534 {
19535 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
19536 return -EINVAL;
19537 }
19538
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019539 if (!pmksa) {
19540 hddLog(LOGE, FL("pmksa is NULL"));
19541 return -EINVAL;
19542 }
19543
Abhinav Kumar8c122592019-08-07 15:43:20 +053019544 if (!wlan_hdd_is_pmksa_valid(pmksa))
19545 return -EINVAL;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019546
Kiet Lam98c46a12014-10-31 15:34:57 -070019547
Wilson Yang6507c4e2013-10-01 20:11:19 -070019548 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19549 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070019550 if (0 != status)
19551 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070019552 return status;
19553 }
19554
19555 /*Retrieve halHandle*/
19556 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19557
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019558 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19559 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
19560 pAdapter->sessionId, 0));
Abhinav Kumar8c122592019-08-07 15:43:20 +053019561
19562 vos_mem_zero(&pmk_cache, sizeof(pmk_cache));
19563
19564 hdd_update_pmksa_info(&pmk_cache, pmksa, true);
19565
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019566 /* Delete the PMKID CSR cache */
19567 if (eHAL_STATUS_SUCCESS !=
19568 sme_RoamDelPMKIDfromCache(halHandle,
Abhinav Kumar8c122592019-08-07 15:43:20 +053019569 pAdapter->sessionId, &pmk_cache, FALSE)) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019570 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
19571 MAC_ADDR_ARRAY(pmksa->bssid));
19572 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019573 }
19574
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019575 EXIT();
19576 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019577}
19578
Wilson Yang6507c4e2013-10-01 20:11:19 -070019579
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019580static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
19581 struct cfg80211_pmksa *pmksa)
19582{
19583 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019584
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019585 vos_ssr_protect(__func__);
19586 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
19587 vos_ssr_unprotect(__func__);
19588
19589 return ret;
19590
19591}
19592
19593static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019594{
Wilson Yang6507c4e2013-10-01 20:11:19 -070019595 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19596 tHalHandle halHandle;
19597 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080019598 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019599
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019600 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070019601
19602 /* Validate pAdapter */
19603 if (NULL == pAdapter)
19604 {
19605 hddLog(VOS_TRACE_LEVEL_ERROR,
19606 "%s: Invalid Adapter" ,__func__);
19607 return -EINVAL;
19608 }
19609
19610 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19611 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070019612 if (0 != status)
19613 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070019614 return status;
19615 }
19616
19617 /*Retrieve halHandle*/
19618 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19619
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019620 /* Flush the PMKID cache in CSR */
19621 if (eHAL_STATUS_SUCCESS !=
19622 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
19623 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
19624 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019625 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019626 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080019627 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019628}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019629
19630static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
19631{
19632 int ret;
19633
19634 vos_ssr_protect(__func__);
19635 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
19636 vos_ssr_unprotect(__func__);
19637
19638 return ret;
19639}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019640#endif
19641
Abhinav Kumar118efd02019-08-07 16:41:07 +053019642#if defined(WLAN_FEATURE_SAE) && \
19643 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
19644/**
19645 * __wlan_hdd_cfg80211_external_auth() - Handle external auth
19646 * @wiphy: Pointer to wireless phy
19647 * @dev: net device
19648 * @params: Pointer to external auth params
19649 *
19650 * Return: 0 on success, negative errno on failure
19651 */
19652static int
19653__wlan_hdd_cfg80211_external_auth(struct wiphy *wiphy, struct net_device *dev,
19654 struct cfg80211_external_auth_params *params)
19655{
19656 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
19657 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
19658 int ret;
19659
19660 if (hdd_get_conparam() == VOS_FTM_MODE) {
19661 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Command not allowed in FTM mode"));
19662 return -EPERM;
19663 }
19664
19665 ret = wlan_hdd_validate_context(hdd_ctx);
19666 if (ret)
19667 return ret;
19668
19669 hddLog(VOS_TRACE_LEVEL_DEBUG, FL("external_auth status: %d"),
19670 params->status);
19671
19672 sme_handle_sae_msg(hdd_ctx->hHal, adapter->sessionId, params->status);
19673
19674 return ret;
19675}
19676
19677/**
19678 * wlan_hdd_cfg80211_external_auth() - Handle external auth
19679 * @wiphy: Pointer to wireless phy
19680 * @dev: net device
19681 * @params: Pointer to external auth params
19682 *
19683 * Return: 0 on success, negative errno on failure
19684 */
19685static int
19686wlan_hdd_cfg80211_external_auth(struct wiphy *wiphy,
19687 struct net_device *dev,
19688 struct cfg80211_external_auth_params *params)
19689{
19690 int ret;
19691
19692 vos_ssr_protect(__func__);
19693 ret = __wlan_hdd_cfg80211_external_auth(wiphy, dev, params);
19694 vos_ssr_unprotect(__func__);
19695
19696 return ret;
19697}
19698#endif
19699
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019700#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019701static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
19702 struct net_device *dev,
19703 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019704{
19705 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19706 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019707 hdd_context_t *pHddCtx;
19708 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019709
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019710 ENTER();
19711
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019712 if (NULL == pAdapter)
19713 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080019714 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019715 return -ENODEV;
19716 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019717 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19718 ret = wlan_hdd_validate_context(pHddCtx);
19719 if (0 != ret)
19720 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019721 return ret;
19722 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019723 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019724 if (NULL == pHddStaCtx)
19725 {
19726 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
19727 return -EINVAL;
19728 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019729
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019730 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19731 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
19732 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019733 // Added for debug on reception of Re-assoc Req.
19734 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
19735 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080019736 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019737 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080019738 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019739 }
19740
19741#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Abhinav Kumar36177e12018-10-30 11:55:48 +053019742 hddLog(LOG1, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019743 ftie->ie_len);
19744#endif
19745
19746 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053019747 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
19748 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019749 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019750
19751 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019752 return 0;
19753}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019754
19755static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
19756 struct net_device *dev,
19757 struct cfg80211_update_ft_ies_params *ftie)
19758{
19759 int ret;
19760
19761 vos_ssr_protect(__func__);
19762 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
19763 vos_ssr_unprotect(__func__);
19764
19765 return ret;
19766}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019767#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019768
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019769#ifdef FEATURE_WLAN_SCAN_PNO
19770
19771void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
19772 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
19773{
19774 int ret;
19775 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
19776 hdd_context_t *pHddCtx;
19777
Nirav Shah80830bf2013-12-31 16:35:12 +053019778 ENTER();
19779
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019780 if (NULL == pAdapter)
19781 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053019782 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019783 "%s: HDD adapter is Null", __func__);
19784 return ;
19785 }
19786
19787 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19788 if (NULL == pHddCtx)
19789 {
19790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19791 "%s: HDD context is Null!!!", __func__);
19792 return ;
19793 }
19794
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019795 spin_lock(&pHddCtx->schedScan_lock);
19796 if (TRUE == pHddCtx->isWiphySuspended)
19797 {
19798 pHddCtx->isSchedScanUpdatePending = TRUE;
19799 spin_unlock(&pHddCtx->schedScan_lock);
19800 hddLog(VOS_TRACE_LEVEL_INFO,
19801 "%s: Update cfg80211 scan database after it resume", __func__);
19802 return ;
19803 }
19804 spin_unlock(&pHddCtx->schedScan_lock);
19805
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019806 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
19807
19808 if (0 > ret)
19809 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053019810 else
19811 {
19812 /* Acquire wakelock to handle the case where APP's tries to suspend
19813 * immediatly after the driver gets connect request(i.e after pno)
19814 * from supplicant, this result in app's is suspending and not able
19815 * to process the connect request to AP */
19816 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
19817 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019818 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19820 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019821}
19822
19823/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019824 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053019825 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019826 */
19827static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
19828{
19829 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
19830 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019831 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019832 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19833 int status = 0;
Agrawal Ashishcff31692016-12-16 17:17:50 +053019834
19835 if (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
19836 {
19837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19838 "%s: PNO is allowed only in STA interface", __func__);
19839 return eHAL_STATUS_FAILURE;
19840 }
19841
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019842 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
19843
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053019844 /* The current firmware design does not allow PNO during any
Agrawal Ashishcff31692016-12-16 17:17:50 +053019845 * active sessions. PNO is allowed only in case when sap session
19846 * is present and sapo auth offload feature enabled in firmare.
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053019847 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019848 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
19849 {
19850 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019851 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019852
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019853 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
19854 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
19855 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
19856 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
Agrawal Ashishcff31692016-12-16 17:17:50 +053019857 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode &&
19858 !pHddCtx->cfg_ini->enable_sap_auth_offload)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053019859 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019860 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019861 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019862 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019863 }
19864 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
19865 pAdapterNode = pNext;
19866 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019867 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019868}
19869
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019870void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
19871{
19872 hdd_adapter_t *pAdapter = callbackContext;
19873 hdd_context_t *pHddCtx;
19874
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019875 ENTER();
19876
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019877 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
19878 {
19879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19880 FL("Invalid adapter or adapter has invalid magic"));
19881 return;
19882 }
19883
19884 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19885 if (0 != wlan_hdd_validate_context(pHddCtx))
19886 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019887 return;
19888 }
19889
c_hpothub53c45d2014-08-18 16:53:14 +053019890 if (VOS_STATUS_SUCCESS != status)
19891 {
19892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019893 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053019894 pHddCtx->isPnoEnable = FALSE;
19895 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019896
19897 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
19898 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019899 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019900}
19901
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019902#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) || \
19903 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
19904/**
19905 * hdd_config_sched_scan_plan() - configures the sched scan plans
19906 * from the framework.
19907 * @pno_req: pointer to PNO scan request
19908 * @request: pointer to scan request from framework
19909 *
19910 * Return: None
19911 */
19912static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
19913 struct cfg80211_sched_scan_request *request,
19914 hdd_context_t *hdd_ctx)
19915{
19916 v_U32_t i = 0;
19917
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019918 pno_req->scanTimers.ucScanTimersCount = request->n_scan_plans;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019919 for (i = 0; i < request->n_scan_plans; i++)
19920 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019921 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
19922 request->scan_plans[i].iterations;
19923 pno_req->scanTimers.aTimerValues[i].uTimerValue =
19924 request->scan_plans[i].interval;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019925 }
19926}
19927#else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019928static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019929 struct cfg80211_sched_scan_request *request,
19930 hdd_context_t *hdd_ctx)
19931{
19932 v_U32_t i, temp_int;
19933 /* Driver gets only one time interval which is hardcoded in
19934 * supplicant for 10000ms. Taking power consumption into account 6
19935 * timers will be used, Timervalue is increased exponentially
19936 * i.e 10,20,40, 80,160,320 secs. And number of scan cycle for each
19937 * timer is configurable through INI param gPNOScanTimerRepeatValue.
19938 * If it is set to 0 only one timer will be used and PNO scan cycle
19939 * will be repeated after each interval specified by supplicant
19940 * till PNO is disabled.
19941 */
19942 if (0 == hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue)
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019943 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019944 HDD_PNO_SCAN_TIMERS_SET_ONE;
19945 else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019946 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019947 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
19948
19949 temp_int = (request->interval)/1000;
19950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19951 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
19952 temp_int, hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue);
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019953 for ( i = 0; i < pno_req->scanTimers.ucScanTimersCount; i++)
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019954 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019955 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019956 hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue;
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019957 pno_req->scanTimers.aTimerValues[i].uTimerValue = temp_int;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019958 temp_int *= 2;
19959 }
19960 //Repeat last timer until pno disabled.
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019961 pno_req->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019962}
19963#endif
19964
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019965/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053019966 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
19967 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019968 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053019969static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019970 struct net_device *dev, struct cfg80211_sched_scan_request *request)
19971{
19972 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019973 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019974 hdd_context_t *pHddCtx;
19975 tHalHandle hHal;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019976 v_U32_t i, indx, num_ch, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053019977 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
19978 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019979 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
19980 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019981 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053019982 hdd_config_t *pConfig = NULL;
19983 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019984
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019985 ENTER();
19986
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019987 if (NULL == pAdapter)
19988 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019990 "%s: HDD adapter is Null", __func__);
19991 return -ENODEV;
19992 }
19993
19994 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019995 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019996
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019997 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019998 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019999 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020000 }
20001
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053020002 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020003 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
20004 if (NULL == hHal)
20005 {
20006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20007 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020008 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020009 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053020010 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20011 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
20012 pAdapter->sessionId, pAdapter->device_mode));
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053020013 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053020014 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053020015 {
20016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20017 "%s: aborting the existing scan is unsuccessfull", __func__);
20018 return -EBUSY;
20019 }
20020
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053020021 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053020022 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053020023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053020024 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053020025 return -EBUSY;
20026 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020027
c_hpothu37f21312014-04-09 21:49:54 +053020028 if (TRUE == pHddCtx->isPnoEnable)
20029 {
20030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
20031 FL("already PNO is enabled"));
20032 return -EBUSY;
20033 }
c_hpothu225aa7c2014-10-22 17:45:13 +053020034
20035 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
20036 {
20037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20038 "%s: abort ROC failed ", __func__);
20039 return -EBUSY;
20040 }
20041
c_hpothu37f21312014-04-09 21:49:54 +053020042 pHddCtx->isPnoEnable = TRUE;
20043
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020044 pnoRequest.enable = 1; /*Enable PNO */
20045 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020046
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020047 if (( !pnoRequest.ucNetworksCount ) ||
20048 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020049 {
20050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053020051 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020052 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053020053 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020054 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020055 goto error;
20056 }
20057
20058 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
20059 {
20060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053020061 "%s: Incorrect number of channels %d",
20062 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020063 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020064 goto error;
20065 }
20066
20067 /* Framework provides one set of channels(all)
20068 * common for all saved profile */
20069 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
20070 channels_allowed, &num_channels_allowed))
20071 {
20072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20073 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020074 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020075 goto error;
20076 }
20077 /* Checking each channel against allowed channel list */
20078 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053020079 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020080 {
Nirav Shah80830bf2013-12-31 16:35:12 +053020081 char chList [(request->n_channels*5)+1];
20082 int len;
20083 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020084 {
Nirav Shah80830bf2013-12-31 16:35:12 +053020085 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020086 {
Nirav Shah80830bf2013-12-31 16:35:12 +053020087 if (request->channels[i]->hw_value == channels_allowed[indx])
20088 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053020089 if ((!pConfig->enableDFSPnoChnlScan) &&
20090 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
20091 {
20092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20093 "%s : Dropping DFS channel : %d",
20094 __func__,channels_allowed[indx]);
20095 num_ignore_dfs_ch++;
20096 break;
20097 }
20098
Nirav Shah80830bf2013-12-31 16:35:12 +053020099 valid_ch[num_ch++] = request->channels[i]->hw_value;
20100 len += snprintf(chList+len, 5, "%d ",
20101 request->channels[i]->hw_value);
20102 break ;
20103 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020104 }
20105 }
Nirav Shah80830bf2013-12-31 16:35:12 +053020106 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020107
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053020108 /*If all channels are DFS and dropped, then ignore the PNO request*/
20109 if (num_ignore_dfs_ch == request->n_channels)
20110 {
20111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20112 "%s : All requested channels are DFS channels", __func__);
20113 ret = -EINVAL;
20114 goto error;
20115 }
20116 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020117
20118 pnoRequest.aNetworks =
20119 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
20120 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020121 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020122 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
20123 FL("failed to allocate memory aNetworks %u"),
20124 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
20125 goto error;
20126 }
20127 vos_mem_zero(pnoRequest.aNetworks,
20128 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
20129
20130 /* Filling per profile params */
20131 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
20132 {
20133 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020134 request->match_sets[i].ssid.ssid_len;
20135
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020136 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
20137 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020138 {
20139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053020140 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020141 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020142 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020143 goto error;
20144 }
20145
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020146 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020147 request->match_sets[i].ssid.ssid,
20148 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053020149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20150 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020151 i, pnoRequest.aNetworks[i].ssId.ssId);
20152 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
20153 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
20154 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020155
20156 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020157 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
20158 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020159
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020160 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020161 }
20162
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053020163 for (i = 0; i < request->n_ssids; i++)
20164 {
20165 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020166 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053020167 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020168 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053020169 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020170 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053020171 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020172 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053020173 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020174 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053020175 break;
20176 }
20177 j++;
20178 }
20179 }
20180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20181 "Number of hidden networks being Configured = %d",
20182 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053020183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080020184 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020185
20186 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
20187 if (pnoRequest.p24GProbeTemplate == NULL)
20188 {
20189 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
20190 FL("failed to allocate memory p24GProbeTemplate %u"),
20191 SIR_PNO_MAX_PB_REQ_SIZE);
20192 goto error;
20193 }
20194
20195 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
20196 if (pnoRequest.p5GProbeTemplate == NULL)
20197 {
20198 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
20199 FL("failed to allocate memory p5GProbeTemplate %u"),
20200 SIR_PNO_MAX_PB_REQ_SIZE);
20201 goto error;
20202 }
20203
20204 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
20205 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
20206
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053020207 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
20208 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053020209 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020210 pnoRequest.us24GProbeTemplateLen = request->ie_len;
20211 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
20212 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053020213
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020214 pnoRequest.us5GProbeTemplateLen = request->ie_len;
20215 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
20216 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053020217 }
20218
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053020219 hdd_config_sched_scan_plan(&pnoRequest, request, pHddCtx);
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053020220
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020221 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020222
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020223 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020224 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
20225 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020226 pAdapter->pno_req_status = 0;
20227
Nirav Shah80830bf2013-12-31 16:35:12 +053020228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20229 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020230 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
20231 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053020232
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020233 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020234 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020235 hdd_cfg80211_sched_scan_done_callback, pAdapter);
20236 if (eHAL_STATUS_SUCCESS != status)
20237 {
20238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053020239 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020240 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020241 goto error;
20242 }
20243
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020244 ret = wait_for_completion_timeout(
20245 &pAdapter->pno_comp_var,
20246 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
20247 if (0 >= ret)
20248 {
20249 // Did not receive the response for PNO enable in time.
20250 // Assuming the PNO enable was success.
20251 // Returning error from here, because we timeout, results
20252 // in side effect of Wifi (Wifi Setting) not to work.
20253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20254 FL("Timed out waiting for PNO to be Enabled"));
20255 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020256 }
20257
20258 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053020259 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020260
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020261error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20263 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053020264 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020265 if (pnoRequest.aNetworks)
20266 vos_mem_free(pnoRequest.aNetworks);
20267 if (pnoRequest.p24GProbeTemplate)
20268 vos_mem_free(pnoRequest.p24GProbeTemplate);
20269 if (pnoRequest.p5GProbeTemplate)
20270 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020271
20272 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020273 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020274}
20275
20276/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053020277 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
20278 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020279 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053020280static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
20281 struct net_device *dev, struct cfg80211_sched_scan_request *request)
20282{
20283 int ret;
20284
20285 vos_ssr_protect(__func__);
20286 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
20287 vos_ssr_unprotect(__func__);
20288
20289 return ret;
20290}
20291
20292/*
20293 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
20294 * Function to disable PNO
20295 */
20296static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020297 struct net_device *dev)
20298{
20299 eHalStatus status = eHAL_STATUS_FAILURE;
20300 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
20301 hdd_context_t *pHddCtx;
20302 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020303 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020304 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020305
20306 ENTER();
20307
20308 if (NULL == pAdapter)
20309 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053020310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020311 "%s: HDD adapter is Null", __func__);
20312 return -ENODEV;
20313 }
20314
20315 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020316
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020317 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020318 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020319 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020320 "%s: HDD context is Null", __func__);
20321 return -ENODEV;
20322 }
20323
20324 /* The return 0 is intentional when isLogpInProgress and
20325 * isLoadUnloadInProgress. We did observe a crash due to a return of
20326 * failure in sched_scan_stop , especially for a case where the unload
20327 * of the happens at the same time. The function __cfg80211_stop_sched_scan
20328 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
20329 * success. If it returns a failure , then its next invocation due to the
20330 * clean up of the second interface will have the dev pointer corresponding
20331 * to the first one leading to a crash.
20332 */
20333 if (pHddCtx->isLogpInProgress)
20334 {
20335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20336 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053020337 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020338 return ret;
20339 }
20340
Mihir Shete18156292014-03-11 15:38:30 +053020341 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020342 {
20343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20344 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
20345 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020346 }
20347
20348 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
20349 if (NULL == hHal)
20350 {
20351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20352 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020353 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020354 }
20355
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020356 pnoRequest.enable = 0; /* Disable PNO */
20357 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020358
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053020359 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20360 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
20361 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053020362
20363 INIT_COMPLETION(pAdapter->pno_comp_var);
20364 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
20365 pnoRequest.callbackContext = pAdapter;
20366 pAdapter->pno_req_status = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020367 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020368 pAdapter->sessionId,
20369 NULL, pAdapter);
20370 if (eHAL_STATUS_SUCCESS != status)
20371 {
20372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20373 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020374 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020375 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020376 }
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053020377 ret = wait_for_completion_timeout(
20378 &pAdapter->pno_comp_var,
20379 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
20380 if (0 >= ret)
20381 {
20382 // Did not receive the response for PNO disable in time.
20383 // Assuming the PNO disable was success.
20384 // Returning error from here, because we timeout, results
20385 // in side effect of Wifi (Wifi Setting) not to work.
Anurag Chouhan96b41cb2016-09-28 18:54:47 +053020386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053020387 FL("Timed out waiting for PNO to be disabled"));
20388 ret = 0;
20389 }
20390
20391 ret = pAdapter->pno_req_status;
20392 pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020393
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020394error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020395 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020396 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020397
20398 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020399 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020400}
20401
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053020402/*
20403 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
20404 * NL interface to disable PNO
20405 */
20406static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
20407 struct net_device *dev)
20408{
20409 int ret;
20410
20411 vos_ssr_protect(__func__);
20412 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
20413 vos_ssr_unprotect(__func__);
20414
20415 return ret;
20416}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020417#endif /*FEATURE_WLAN_SCAN_PNO*/
20418
20419
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020420#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053020421#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020422static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20423 struct net_device *dev,
20424 u8 *peer, u8 action_code,
20425 u8 dialog_token,
20426 u16 status_code, u32 peer_capability,
20427 const u8 *buf, size_t len)
20428#else /* TDLS_MGMT_VERSION2 */
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053020429#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || \
20430 defined(WITH_BACKPORTS)
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020431static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20432 struct net_device *dev,
20433 const u8 *peer, u8 action_code,
20434 u8 dialog_token, u16 status_code,
20435 u32 peer_capability, bool initiator,
20436 const u8 *buf, size_t len)
20437#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
20438static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20439 struct net_device *dev,
20440 const u8 *peer, u8 action_code,
20441 u8 dialog_token, u16 status_code,
20442 u32 peer_capability, const u8 *buf,
20443 size_t len)
20444#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
20445static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20446 struct net_device *dev,
20447 u8 *peer, u8 action_code,
20448 u8 dialog_token,
20449 u16 status_code, u32 peer_capability,
20450 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053020451#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020452static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20453 struct net_device *dev,
20454 u8 *peer, u8 action_code,
20455 u8 dialog_token,
20456 u16 status_code, const u8 *buf,
20457 size_t len)
20458#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053020459#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020460{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020461 hdd_adapter_t *pAdapter;
20462 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020463 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070020464 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080020465 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070020466 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020467 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053020468 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020469#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053020470 u32 peer_capability = 0;
20471#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053020472 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020473 hdd_station_ctx_t *pHddStaCtx = NULL;
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020474 tdlsCtx_t *pHddTdlsCtx;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053020475
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020476 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
20477 if (NULL == pAdapter)
20478 {
20479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20480 "%s: Adapter is NULL",__func__);
20481 return -EINVAL;
20482 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053020483 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20484 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
20485 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020486
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020487 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020488 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020489 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053020490 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020491 "Invalid arguments");
20492 return -EINVAL;
20493 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020494
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080020495 if (pHddCtx->isLogpInProgress)
20496 {
20497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20498 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053020499 wlan_hdd_tdls_set_link_status(pAdapter,
20500 peer,
20501 eTDLS_LINK_IDLE,
20502 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080020503 return -EBUSY;
20504 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020505
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020506 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
20507 {
20508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20509 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
20510 return -EAGAIN;
20511 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020512
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020513 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
20514 if (!pHddTdlsCtx) {
20515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20516 "%s: pHddTdlsCtx not valid.", __func__);
Hanumanth Reddy Pothula36dfa522018-03-12 16:42:08 +053020517 return -EINVAL;
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020518 }
20519
Hoonki Lee27511902013-03-14 18:19:06 -070020520 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020521 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053020522 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070020523 "%s: TDLS mode is disabled OR not enabled in FW."
20524 MAC_ADDRESS_STR " action %d declined.",
20525 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020526 return -ENOTSUPP;
20527 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080020528
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020529 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
20530
20531 if( NULL == pHddStaCtx )
20532 {
20533 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20534 "%s: HDD station context NULL ",__func__);
20535 return -EINVAL;
20536 }
20537
20538 /* STA should be connected and authenticated
20539 * before sending any TDLS frames
20540 */
20541 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
20542 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
20543 {
20544 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20545 "STA is not connected or unauthenticated. "
20546 "connState %u, uIsAuthenticated %u",
20547 pHddStaCtx->conn_info.connState,
20548 pHddStaCtx->conn_info.uIsAuthenticated);
20549 return -EAGAIN;
20550 }
20551
Hoonki Lee27511902013-03-14 18:19:06 -070020552 /* other than teardown frame, other mgmt frames are not sent if disabled */
20553 if (SIR_MAC_TDLS_TEARDOWN != action_code)
20554 {
20555 /* if tdls_mode is disabled to respond to peer's request */
20556 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
20557 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053020558 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070020559 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070020560 " TDLS mode is disabled. action %d declined.",
20561 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070020562
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020563 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070020564 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053020565
20566 if (vos_max_concurrent_connections_reached())
20567 {
20568 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
20569 return -EINVAL;
20570 }
Hoonki Lee27511902013-03-14 18:19:06 -070020571 }
20572
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020573 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
20574 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053020575 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020576 {
20577 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020578 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070020579 " TDLS setup is ongoing. action %d declined.",
20580 __func__, MAC_ADDR_ARRAY(peer), action_code);
20581 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020582 }
20583 }
20584
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020585 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
20586 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080020587 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053020588 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
20589 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080020590 {
20591 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
20592 we return error code at 'add_station()'. Hence we have this
20593 check again in addtion to add_station().
20594 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020595 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080020596 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020597 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20598 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053020599 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
20600 __func__, MAC_ADDR_ARRAY(peer), action_code,
20601 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053020602 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080020603 }
20604 else
20605 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020606 /* maximum reached. tweak to send error code to peer and return
20607 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080020608 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020609 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20610 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053020611 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
20612 __func__, MAC_ADDR_ARRAY(peer), status_code,
20613 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070020614 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020615 /* fall through to send setup resp with failure status
20616 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080020617 }
20618 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020619 else
20620 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020621 mutex_lock(&pHddCtx->tdls_lock);
20622 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070020623 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020624 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020625 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070020627 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
20628 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020629 return -EPERM;
20630 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020631 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020632 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080020633 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020634
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053020635 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053020636 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020637 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
20638 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020639
Hoonki Leea34dd892013-02-05 22:56:02 -080020640 /*Except teardown responder will not be used so just make 0*/
20641 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020642 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080020643 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070020644
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020645 mutex_lock(&pHddCtx->tdls_lock);
20646 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070020647
20648 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
20649 responder = pTdlsPeer->is_responder;
20650 else
Hoonki Leea34dd892013-02-05 22:56:02 -080020651 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070020652 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053020653 "%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 -070020654 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
20655 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020656 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070020657 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080020658 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020659 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020660 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020661
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053020662 /* Discard TDLS setup if peer is removed by user app */
20663 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
20664 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
20665 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
20666 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
20667
20668 mutex_lock(&pHddCtx->tdls_lock);
20669 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
20670 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
20671 mutex_unlock(&pHddCtx->tdls_lock);
20672 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
20673 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
20674 MAC_ADDR_ARRAY(peer), action_code);
20675 return -EINVAL;
20676 }
20677 mutex_unlock(&pHddCtx->tdls_lock);
20678 }
20679
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053020680 /* For explicit trigger of DIS_REQ come out of BMPS for
20681 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070020682 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Deepthi Gowrif78f1f72016-03-21 13:13:28 +053020683 (SIR_MAC_TDLS_SETUP_CNF== action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053020684 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
20685 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070020686 {
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020687 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053020688 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020689 "%s: Sending frame action_code %u.Disable BMPS", __func__,
20690 action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020691 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
20692 if (status != VOS_STATUS_SUCCESS) {
20693 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020694 } else {
20695 pHddTdlsCtx->is_tdls_disabled_bmps = true;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020696 }
Hoonki Lee14621352013-04-16 17:51:19 -070020697 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020698 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020699 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020700 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
20701 }
20702 }
Hoonki Lee14621352013-04-16 17:51:19 -070020703 }
20704
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020705 /* make sure doesn't call send_mgmt() while it is pending */
20706 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
20707 {
20708 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080020709 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020710 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020711 ret = -EBUSY;
20712 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020713 }
20714
20715 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020716 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
20717
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020718 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
20719 pAdapter->sessionId, peer, action_code, dialog_token,
20720 status_code, peer_capability, (tANI_U8 *)buf, len,
20721 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020722
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020723 if (VOS_STATUS_SUCCESS != status)
20724 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20726 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020727 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020728 ret = -EINVAL;
20729 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020730 }
20731
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20733 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
20734 WAIT_TIME_TDLS_MGMT);
20735
Hoonki Leed37cbb32013-04-20 00:31:14 -070020736 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
20737 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
20738
20739 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020740 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070020741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070020742 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070020743 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020744 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080020745
20746 if (pHddCtx->isLogpInProgress)
20747 {
20748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20749 "%s: LOGP in Progress. Ignore!!!", __func__);
20750 return -EAGAIN;
20751 }
Abhishek Singh837adf22015-10-01 17:37:37 +053020752 if (rc <= 0)
20753 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
20754 WLAN_LOG_INDICATOR_HOST_DRIVER,
20755 WLAN_LOG_REASON_HDD_TIME_OUT,
20756 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080020757
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020758 ret = -EINVAL;
20759 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020760 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020761 else
20762 {
20763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20764 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
20765 __func__, rc, pAdapter->mgmtTxCompletionStatus);
20766 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020767
Gopichand Nakkala05922802013-03-14 12:23:19 -070020768 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070020769 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020770 ret = max_sta_failed;
20771 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070020772 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020773
Hoonki Leea34dd892013-02-05 22:56:02 -080020774 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
20775 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020776 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020777 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
20778 }
Hoonki Leea34dd892013-02-05 22:56:02 -080020779 }
20780 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
20781 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020782 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020783 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
20784 }
Hoonki Leea34dd892013-02-05 22:56:02 -080020785 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020786
20787 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020788
20789tx_failed:
20790 /* add_station will be called before sending TDLS_SETUP_REQ and
20791 * TDLS_SETUP_RSP and as part of add_station driver will enable
20792 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
20793 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
20794 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
20795 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
20796 */
20797
20798 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
20799 (SIR_MAC_TDLS_SETUP_RSP == action_code))
20800 wlan_hdd_tdls_check_bmps(pAdapter);
20801 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020802}
20803
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020804#if TDLS_MGMT_VERSION2
20805static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
20806 u8 *peer, u8 action_code, u8 dialog_token,
20807 u16 status_code, u32 peer_capability,
20808 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020809#else /* TDLS_MGMT_VERSION2 */
20810#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
20811static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20812 struct net_device *dev,
20813 const u8 *peer, u8 action_code,
20814 u8 dialog_token, u16 status_code,
20815 u32 peer_capability, bool initiator,
20816 const u8 *buf, size_t len)
20817#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
20818static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20819 struct net_device *dev,
20820 const u8 *peer, u8 action_code,
20821 u8 dialog_token, u16 status_code,
20822 u32 peer_capability, const u8 *buf,
20823 size_t len)
20824#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
20825static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20826 struct net_device *dev,
20827 u8 *peer, u8 action_code,
20828 u8 dialog_token,
20829 u16 status_code, u32 peer_capability,
20830 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020831#else
20832static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
20833 u8 *peer, u8 action_code, u8 dialog_token,
20834 u16 status_code, const u8 *buf, size_t len)
20835#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020836#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020837{
20838 int ret;
20839
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020840 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020841#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020842 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20843 dialog_token, status_code,
20844 peer_capability, buf, len);
20845#else /* TDLS_MGMT_VERSION2 */
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053020846#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || \
20847 defined(WITH_BACKPORTS)
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020848 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20849 dialog_token, status_code,
20850 peer_capability, initiator,
20851 buf, len);
20852#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
20853 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20854 dialog_token, status_code,
20855 peer_capability, buf, len);
20856#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
20857 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20858 dialog_token, status_code,
20859 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020860#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020861 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20862 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020863#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020864#endif
20865 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020866
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020867 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020868}
Atul Mittal115287b2014-07-08 13:26:33 +053020869
20870int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020871#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
20872 const u8 *peer,
20873#else
Atul Mittal115287b2014-07-08 13:26:33 +053020874 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020875#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020876 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053020877 cfg80211_exttdls_callback callback)
20878{
20879
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020880 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053020881 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053020882 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053020883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20884 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
20885 __func__, MAC_ADDR_ARRAY(peer));
20886
20887 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
20888 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
20889
20890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020891 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
20892 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
20893 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053020894 return -ENOTSUPP;
20895 }
20896
20897 /* To cater the requirement of establishing the TDLS link
20898 * irrespective of the data traffic , get an entry of TDLS peer.
20899 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053020900 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020901 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
20902 if (pTdlsPeer == NULL) {
20903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20904 "%s: peer " MAC_ADDRESS_STR " not existing",
20905 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053020906 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020907 return -EINVAL;
20908 }
20909
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053020910 /* check FW TDLS Off Channel capability */
20911 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053020912 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053020913 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020914 {
20915 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
20916 pTdlsPeer->peerParams.global_operating_class =
20917 tdls_peer_params->global_operating_class;
20918 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
20919 pTdlsPeer->peerParams.min_bandwidth_kbps =
20920 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053020921 /* check configured channel is valid, non dfs and
20922 * not current operating channel */
20923 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
20924 tdls_peer_params->channel)) &&
20925 (pHddStaCtx) &&
20926 (tdls_peer_params->channel !=
20927 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020928 {
20929 pTdlsPeer->isOffChannelConfigured = TRUE;
20930 }
20931 else
20932 {
20933 pTdlsPeer->isOffChannelConfigured = FALSE;
20934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20935 "%s: Configured Tdls Off Channel is not valid", __func__);
20936
20937 }
20938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053020939 "%s: tdls_off_channel %d isOffChannelConfigured %d "
20940 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020941 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053020942 pTdlsPeer->isOffChannelConfigured,
20943 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020944 }
20945 else
20946 {
20947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053020948 "%s: TDLS off channel FW capability %d, "
20949 "host capab %d or Invalid TDLS Peer Params", __func__,
20950 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
20951 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020952 }
20953
Atul Mittal115287b2014-07-08 13:26:33 +053020954 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
20955
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020956 mutex_unlock(&pHddCtx->tdls_lock);
20957
Atul Mittal115287b2014-07-08 13:26:33 +053020958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20959 " %s TDLS Add Force Peer Failed",
20960 __func__);
20961 return -EINVAL;
20962 }
20963 /*EXT TDLS*/
20964
20965 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020966 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20968 " %s TDLS set callback Failed",
20969 __func__);
20970 return -EINVAL;
20971 }
20972
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020973 mutex_unlock(&pHddCtx->tdls_lock);
20974
Atul Mittal115287b2014-07-08 13:26:33 +053020975 return(0);
20976
20977}
20978
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020979int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
20980#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
20981 const u8 *peer
20982#else
20983 u8 *peer
20984#endif
20985)
Atul Mittal115287b2014-07-08 13:26:33 +053020986{
20987
20988 hddTdlsPeer_t *pTdlsPeer;
20989 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053020990
Atul Mittal115287b2014-07-08 13:26:33 +053020991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20992 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
20993 __func__, MAC_ADDR_ARRAY(peer));
20994
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053020995 if (0 != wlan_hdd_validate_context(pHddCtx)) {
20996 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
20997 return -EINVAL;
20998 }
20999
Atul Mittal115287b2014-07-08 13:26:33 +053021000 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
21001 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
21002
21003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021004 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
21005 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
21006 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053021007 return -ENOTSUPP;
21008 }
21009
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053021010 mutex_lock(&pHddCtx->tdls_lock);
21011 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053021012
21013 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053021014 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053021015 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021016 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053021017 __func__, MAC_ADDR_ARRAY(peer));
21018 return -EINVAL;
21019 }
21020 else {
21021 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
21022 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053021023 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL,
21024 pTdlsPeer->peerMac);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021025 /* if channel switch is configured, reset
21026 the channel for this peer */
21027 if (TRUE == pTdlsPeer->isOffChannelConfigured)
21028 {
21029 pTdlsPeer->peerParams.channel = 0;
21030 pTdlsPeer->isOffChannelConfigured = FALSE;
21031 }
Atul Mittal115287b2014-07-08 13:26:33 +053021032 }
21033
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021034 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053021035 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021036 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053021037 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021038 }
Atul Mittal115287b2014-07-08 13:26:33 +053021039
21040 /*EXT TDLS*/
21041
21042 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053021043 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053021044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21045 " %s TDLS set callback Failed",
21046 __func__);
21047 return -EINVAL;
21048 }
Atul Mittal115287b2014-07-08 13:26:33 +053021049
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053021050 mutex_unlock(&pHddCtx->tdls_lock);
21051
21052 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053021053}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021054static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053021055#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
21056 const u8 *peer,
21057#else
21058 u8 *peer,
21059#endif
21060 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021061{
21062 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
21063 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021064 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070021065 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053021066
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021067 ENTER();
21068
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053021069 if (!pAdapter) {
21070 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
21071 return -EINVAL;
21072 }
21073
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053021074 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
21075 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
21076 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021077 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021078 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080021079 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070021080 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021081 return -EINVAL;
21082 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080021083
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021084 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021085 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080021086 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021087 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080021088 }
21089
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021090
21091 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080021092 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021093 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080021094 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021095 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
21096 "Cannot process TDLS commands",
21097 pHddCtx->cfg_ini->fEnableTDLSSupport,
21098 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021099 return -ENOTSUPP;
21100 }
21101
21102 switch (oper) {
21103 case NL80211_TDLS_ENABLE_LINK:
21104 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021105 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053021106 long ret;
Hanumantha Reddy Pothulada389492016-02-11 17:29:27 +053021107 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams = { {0}, 0,
21108 0, 0, 0, 0, 0, 0, {0}, 0, {0} };
Agarwal Ashish16020c42014-12-29 22:01:11 +053021109 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021110 tANI_U16 numCurrTdlsPeers = 0;
21111 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053021112 tANI_U8 suppChannelLen = 0;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021113 tSirMacAddr peerMac;
21114 int channel;
21115 tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021116
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21118 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
21119 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053021120
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021121 mutex_lock(&pHddCtx->tdls_lock);
21122 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053021123 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053021124 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021125 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021126 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
21127 " (oper %d) not exsting. ignored",
21128 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
21129 return -EINVAL;
21130 }
21131
21132 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21133 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
21134 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
21135 "NL80211_TDLS_ENABLE_LINK");
21136
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070021137 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
21138 {
21139 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
21140 MAC_ADDRESS_STR " failed",
21141 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021142 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070021143 return -EINVAL;
21144 }
21145
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053021146 /* before starting tdls connection, set tdls
21147 * off channel established status to default value */
21148 pTdlsPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021149
21150 mutex_unlock(&pHddCtx->tdls_lock);
21151
Deepthi Gowri2d85bbf2016-07-25 15:43:31 +053021152 wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021153 /* TDLS Off Channel, Disable tdls channel switch,
21154 when there are more than one tdls link */
21155 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053021156 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021157 {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021158 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021159 /* get connected peer and send disable tdls off chan */
21160 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021161 if ((connPeer) &&
21162 (connPeer->isOffChannelSupported == TRUE) &&
21163 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021164 {
21165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21166 "%s: More then one peer connected, Disable "
21167 "TDLS channel switch", __func__);
21168
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053021169 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021170 vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr));
21171 channel = connPeer->peerParams.channel;
21172
21173 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053021174
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021175 ret = sme_SendTdlsChanSwitchReq(
21176 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021177 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021178 peerMac,
21179 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021180 TDLS_OFF_CHANNEL_BW_OFFSET,
21181 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021182 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021183 hddLog(VOS_TRACE_LEVEL_ERROR,
21184 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021185 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021186 }
21187 else
21188 {
21189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21190 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021191 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021192 "isOffChannelConfigured %d",
21193 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021194 (connPeer ? (connPeer->isOffChannelSupported)
21195 : -1),
21196 (connPeer ? (connPeer->isOffChannelConfigured)
21197 : -1));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021198 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021199 }
21200 }
21201
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021202 mutex_lock(&pHddCtx->tdls_lock);
21203 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
21204 if ( NULL == pTdlsPeer ) {
21205 mutex_unlock(&pHddCtx->tdls_lock);
21206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21207 "%s: " MAC_ADDRESS_STR
21208 " (oper %d) peer got freed in other context. ignored",
21209 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
21210 return -EINVAL;
21211 }
21212 peer_status = pTdlsPeer->link_status;
21213 mutex_unlock(&pHddCtx->tdls_lock);
21214
21215 if (eTDLS_LINK_CONNECTED != peer_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021216 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053021217 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053021218
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053021219 if (0 != wlan_hdd_tdls_get_link_establish_params(
21220 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021221 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053021222 return -EINVAL;
21223 }
21224 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021225
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021226 ret = sme_SendTdlsLinkEstablishParams(
21227 WLAN_HDD_GET_HAL_CTX(pAdapter),
21228 pAdapter->sessionId, peer,
21229 &tdlsLinkEstablishParams);
21230 if (ret != VOS_STATUS_SUCCESS) {
21231 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
21232 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053021233 /* Send TDLS peer UAPSD capabilities to the firmware and
21234 * register with the TL on after the response for this operation
21235 * is received .
21236 */
21237 ret = wait_for_completion_interruptible_timeout(
21238 &pAdapter->tdls_link_establish_req_comp,
21239 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Masti, Narayanraddie1892a52015-12-15 15:01:01 +053021240
21241 mutex_lock(&pHddCtx->tdls_lock);
21242 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
21243 if ( NULL == pTdlsPeer ) {
21244 mutex_unlock(&pHddCtx->tdls_lock);
21245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21246 "%s %d: " MAC_ADDRESS_STR
21247 " (oper %d) peer got freed in other context. ignored",
21248 __func__, __LINE__, MAC_ADDR_ARRAY(peer),
21249 (int)oper);
21250 return -EINVAL;
21251 }
21252 peer_status = pTdlsPeer->link_status;
21253 mutex_unlock(&pHddCtx->tdls_lock);
21254
21255 if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING))
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053021256 {
21257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021258 FL("Link Establish Request Failed Status %ld"),
21259 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053021260 return -EINVAL;
21261 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021262 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053021263
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021264 mutex_lock(&pHddCtx->tdls_lock);
21265 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
21266 if ( NULL == pTdlsPeer ) {
21267 mutex_unlock(&pHddCtx->tdls_lock);
21268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21269 "%s: " MAC_ADDRESS_STR
21270 " (oper %d) peer got freed in other context. ignored",
21271 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
21272 return -EINVAL;
21273 }
21274
Atul Mittal115287b2014-07-08 13:26:33 +053021275 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
21276 eTDLS_LINK_CONNECTED,
21277 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053021278 staDesc.ucSTAId = pTdlsPeer->staId;
21279 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053021280
21281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21282 "%s: tdlsLinkEstablishParams of peer "
21283 MAC_ADDRESS_STR "uapsdQueues: %d"
21284 "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d"
21285 "isResponder: %d peerstaId: %d",
21286 __func__,
21287 MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac),
21288 tdlsLinkEstablishParams.uapsdQueues,
21289 tdlsLinkEstablishParams.qos,
21290 tdlsLinkEstablishParams.maxSp,
21291 tdlsLinkEstablishParams.isBufSta,
21292 tdlsLinkEstablishParams.isOffChannelSupported,
21293 tdlsLinkEstablishParams.isResponder,
21294 pTdlsPeer->staId);
21295
21296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21297 "%s: StaDesc ucSTAId: %d ucQosEnabled: %d",
21298 __func__,
21299 staDesc.ucSTAId,
21300 staDesc.ucQosEnabled);
21301
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021302 ret = WLANTL_UpdateTdlsSTAClient(
21303 pHddCtx->pvosContext,
21304 &staDesc);
21305 if (ret != VOS_STATUS_SUCCESS) {
21306 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
21307 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053021308
Gopichand Nakkala471708b2013-06-04 20:03:01 +053021309 /* Mark TDLS client Authenticated .*/
21310 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
21311 pTdlsPeer->staId,
21312 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070021313 if (VOS_STATUS_SUCCESS == status)
21314 {
Hoonki Lee14621352013-04-16 17:51:19 -070021315 if (pTdlsPeer->is_responder == 0)
21316 {
21317 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053021318 tdlsConnInfo_t *tdlsInfo;
21319
21320 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
21321
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053021322 if (!vos_timer_is_initialized(
21323 &pTdlsPeer->initiatorWaitTimeoutTimer))
21324 {
21325 /* Initialize initiator wait callback */
21326 vos_timer_init(
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053021327 &pTdlsPeer->initiatorWaitTimeoutTimer,
21328 VOS_TIMER_TYPE_SW,
21329 wlan_hdd_tdls_initiator_wait_cb,
21330 tdlsInfo);
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053021331 }
Hoonki Lee14621352013-04-16 17:51:19 -070021332 wlan_hdd_tdls_timer_restart(pAdapter,
21333 &pTdlsPeer->initiatorWaitTimeoutTimer,
21334 WAIT_TIME_TDLS_INITIATOR);
21335 /* suspend initiator TX until it receives direct packet from the
21336 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021337 ret = WLANTL_SuspendDataTx(
21338 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
21339 &staId, NULL);
21340 if (ret != VOS_STATUS_SUCCESS) {
21341 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
21342 }
Hoonki Lee14621352013-04-16 17:51:19 -070021343 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021344
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053021345 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021346 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053021347 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021348 suppChannelLen =
21349 tdlsLinkEstablishParams.supportedChannelsLen;
21350
21351 if ((suppChannelLen > 0) &&
21352 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
21353 {
21354 tANI_U8 suppPeerChannel = 0;
21355 int i = 0;
21356 for (i = 0U; i < suppChannelLen; i++)
21357 {
21358 suppPeerChannel =
21359 tdlsLinkEstablishParams.supportedChannels[i];
21360
21361 pTdlsPeer->isOffChannelSupported = FALSE;
21362 if (suppPeerChannel ==
21363 pTdlsPeer->peerParams.channel)
21364 {
21365 pTdlsPeer->isOffChannelSupported = TRUE;
21366 break;
21367 }
21368 }
21369 }
21370 else
21371 {
21372 pTdlsPeer->isOffChannelSupported = FALSE;
21373 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053021374 }
21375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21376 "%s: TDLS channel switch request for channel "
21377 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021378 "%d isOffChannelSupported %d", __func__,
21379 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053021380 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021381 suppChannelLen,
21382 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053021383
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021384 /* TDLS Off Channel, Enable tdls channel switch,
21385 when their is only one tdls link and it supports */
21386 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
21387 if ((numCurrTdlsPeers == 1) &&
21388 (TRUE == pTdlsPeer->isOffChannelSupported) &&
21389 (TRUE == pTdlsPeer->isOffChannelConfigured))
21390 {
21391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21392 "%s: Send TDLS channel switch request for channel %d",
21393 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053021394
21395 pTdlsPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021396 vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr));
21397 channel = pTdlsPeer->peerParams.channel;
21398
21399 mutex_unlock(&pHddCtx->tdls_lock);
21400
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021401 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
21402 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021403 peerMac,
21404 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021405 TDLS_OFF_CHANNEL_BW_OFFSET,
21406 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021407 if (ret != VOS_STATUS_SUCCESS) {
21408 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
21409 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021410 }
21411 else
21412 {
21413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21414 "%s: TDLS channel switch request not sent"
21415 " numCurrTdlsPeers %d "
21416 "isOffChannelSupported %d "
21417 "isOffChannelConfigured %d",
21418 __func__, numCurrTdlsPeers,
21419 pTdlsPeer->isOffChannelSupported,
21420 pTdlsPeer->isOffChannelConfigured);
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021421 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021422 }
21423
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070021424 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021425 else
21426 mutex_unlock(&pHddCtx->tdls_lock);
21427
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021428 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021429
21430 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053021431 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
21432 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021433 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053021434 int ac;
21435 uint8 ucAc[4] = { WLANTL_AC_VO,
21436 WLANTL_AC_VI,
21437 WLANTL_AC_BK,
21438 WLANTL_AC_BE };
21439 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
21440 for(ac=0; ac < 4; ac++)
21441 {
21442 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
21443 pTdlsPeer->staId, ucAc[ac],
21444 tlTid[ac], tlTid[ac], 0, 0,
21445 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021446 if (status != VOS_STATUS_SUCCESS) {
21447 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
21448 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053021449 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021450 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021451 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021452
Bhargav Shah66896792015-10-01 18:17:37 +053021453 /* stop TCP delack timer if TDLS is enable */
21454 set_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
21455 hdd_manage_delack_timer(pHddCtx);
Abhishek Singh67fa6bc2016-01-05 15:57:19 +053021456 hdd_wlan_tdls_enable_link_event(peer,
21457 pTdlsPeer->isOffChannelSupported,
21458 pTdlsPeer->isOffChannelConfigured,
21459 pTdlsPeer->isOffChannelEstablished);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021460 }
21461 break;
21462 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080021463 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021464 tANI_U16 numCurrTdlsPeers = 0;
21465 hddTdlsPeer_t *connPeer = NULL;
21466
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21468 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
21469 __func__, MAC_ADDR_ARRAY(peer));
21470
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021471 mutex_lock(&pHddCtx->tdls_lock);
21472 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021473
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021474
Sunil Dutt41de4e22013-11-14 18:09:02 +053021475 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021476 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021477 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
21478 " (oper %d) not exsting. ignored",
21479 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
21480 return -EINVAL;
21481 }
21482
21483 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21484 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
21485 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
21486 "NL80211_TDLS_DISABLE_LINK");
21487
Hoonki Lee5305c3a2013-04-29 23:28:59 -070021488 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080021489 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021490 long status;
21491
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053021492 /* set tdls off channel status to false for this peer */
21493 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053021494 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
21495 eTDLS_LINK_TEARING,
21496 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
21497 eTDLS_LINK_UNSPECIFIED:
21498 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021499 mutex_unlock(&pHddCtx->tdls_lock);
21500
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021501 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
21502
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021503 status = sme_DeleteTdlsPeerSta(
21504 WLAN_HDD_GET_HAL_CTX(pAdapter),
21505 pAdapter->sessionId, peer );
21506 if (status != VOS_STATUS_SUCCESS) {
21507 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
21508 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021509
21510 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
21511 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021512
21513 mutex_lock(&pHddCtx->tdls_lock);
21514 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
21515 if ( NULL == pTdlsPeer ) {
21516 mutex_unlock(&pHddCtx->tdls_lock);
21517 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
21518 " peer was freed in other context",
21519 __func__, MAC_ADDR_ARRAY(peer));
21520 return -EINVAL;
21521 }
21522
Atul Mittal271a7652014-09-12 13:18:22 +053021523 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053021524 eTDLS_LINK_IDLE,
21525 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021526 mutex_unlock(&pHddCtx->tdls_lock);
21527
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021528 if (status <= 0)
21529 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21531 "%s: Del station failed status %ld",
21532 __func__, status);
21533 return -EPERM;
21534 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021535
21536 /* TDLS Off Channel, Enable tdls channel switch,
21537 when their is only one tdls link and it supports */
21538 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
21539 if (numCurrTdlsPeers == 1)
21540 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021541 tSirMacAddr peerMac;
21542 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053021543
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021544 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021545 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053021546
21547 if (connPeer == NULL) {
21548 mutex_unlock(&pHddCtx->tdls_lock);
21549 hddLog(VOS_TRACE_LEVEL_ERROR,
21550 "%s connPeer is NULL", __func__);
21551 return -EINVAL;
21552 }
21553
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021554 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
21555 channel = connPeer->peerParams.channel;
21556
21557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21558 "%s: TDLS channel switch "
21559 "isOffChannelSupported %d "
21560 "isOffChannelConfigured %d "
21561 "isOffChannelEstablished %d",
21562 __func__,
21563 (connPeer ? connPeer->isOffChannelSupported : -1),
21564 (connPeer ? connPeer->isOffChannelConfigured : -1),
21565 (connPeer ? connPeer->isOffChannelEstablished : -1));
21566
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021567 if ((connPeer) &&
21568 (connPeer->isOffChannelSupported == TRUE) &&
21569 (connPeer->isOffChannelConfigured == TRUE))
21570 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053021571 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021572 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021573 status = sme_SendTdlsChanSwitchReq(
21574 WLAN_HDD_GET_HAL_CTX(pAdapter),
21575 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021576 peerMac,
21577 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021578 TDLS_OFF_CHANNEL_BW_OFFSET,
21579 TDLS_CHANNEL_SWITCH_ENABLE);
21580 if (status != VOS_STATUS_SUCCESS) {
21581 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
21582 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021583 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021584 else
21585 mutex_unlock(&pHddCtx->tdls_lock);
21586 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021587 else
21588 {
21589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21590 "%s: TDLS channel switch request not sent "
21591 "numCurrTdlsPeers %d ",
21592 __func__, numCurrTdlsPeers);
21593 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080021594 }
21595 else
21596 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021597 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21599 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080021600 }
Bhargav Shah66896792015-10-01 18:17:37 +053021601 if (numCurrTdlsPeers == 0) {
21602 /* start TCP delack timer if TDLS is disable */
21603 clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
21604 hdd_manage_delack_timer(pHddCtx);
21605 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080021606 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021607 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021608 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053021609 {
Atul Mittal115287b2014-07-08 13:26:33 +053021610 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021611
Atul Mittal115287b2014-07-08 13:26:33 +053021612 if (0 != status)
21613 {
21614 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021615 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053021616 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053021617 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053021618 break;
21619 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021620 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053021621 {
Atul Mittal115287b2014-07-08 13:26:33 +053021622 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
21623 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021624 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053021625 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021626
Atul Mittal115287b2014-07-08 13:26:33 +053021627 if (0 != status)
21628 {
21629 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021630 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053021631 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053021632 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053021633 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053021634 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021635 case NL80211_TDLS_DISCOVERY_REQ:
21636 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053021637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021638 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053021639 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021640 return -ENOTSUPP;
21641 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053021642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21643 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021644 return -ENOTSUPP;
21645 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021646
21647 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021648 return 0;
21649}
Chilam NG571c65a2013-01-19 12:27:36 +053021650
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021651static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053021652#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
21653 const u8 *peer,
21654#else
21655 u8 *peer,
21656#endif
21657 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021658{
21659 int ret;
21660
21661 vos_ssr_protect(__func__);
21662 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
21663 vos_ssr_unprotect(__func__);
21664
21665 return ret;
21666}
21667
Chilam NG571c65a2013-01-19 12:27:36 +053021668int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
21669 struct net_device *dev, u8 *peer)
21670{
Arif Hussaina7c8e412013-11-20 11:06:42 -080021671 hddLog(VOS_TRACE_LEVEL_INFO,
21672 "tdls send discover req: "MAC_ADDRESS_STR,
21673 MAC_ADDR_ARRAY(peer));
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053021674#if TDLS_MGMT_VERSION2
21675 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21676 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
21677#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053021678#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
21679 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21680 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
21681#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
21682 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21683 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
21684#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
21685 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21686 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
21687#else
Chilam NG571c65a2013-01-19 12:27:36 +053021688 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21689 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053021690#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053021691#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053021692}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021693#endif
21694
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021695#ifdef WLAN_FEATURE_GTK_OFFLOAD
21696/*
21697 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
21698 * Callback rountine called upon receiving response for
21699 * get offload info
21700 */
21701void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
21702 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
21703{
21704
21705 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021706 tANI_U8 tempReplayCounter[8];
21707 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021708
21709 ENTER();
21710
21711 if (NULL == pAdapter)
21712 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053021713 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021714 "%s: HDD adapter is Null", __func__);
21715 return ;
21716 }
21717
21718 if (NULL == pGtkOffloadGetInfoRsp)
21719 {
21720 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21721 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
21722 return ;
21723 }
21724
21725 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
21726 {
21727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21728 "%s: wlan Failed to get replay counter value",
21729 __func__);
21730 return ;
21731 }
21732
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021733 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
21734 /* Update replay counter */
21735 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
21736 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
21737
21738 {
21739 /* changing from little to big endian since supplicant
21740 * works on big endian format
21741 */
21742 int i;
21743 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
21744
21745 for (i = 0; i < 8; i++)
21746 {
21747 tempReplayCounter[7-i] = (tANI_U8)p[i];
21748 }
21749 }
21750
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021751 /* Update replay counter to NL */
21752 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021753 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021754}
21755
21756/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021757 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021758 * This function is used to offload GTK rekeying job to the firmware.
21759 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021760int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021761 struct cfg80211_gtk_rekey_data *data)
21762{
21763 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
21764 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
21765 hdd_station_ctx_t *pHddStaCtx;
21766 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021767 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021768 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021769 eHalStatus status = eHAL_STATUS_FAILURE;
21770
21771 ENTER();
21772
21773 if (NULL == pAdapter)
21774 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053021775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021776 "%s: HDD adapter is Null", __func__);
21777 return -ENODEV;
21778 }
21779
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053021780 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
21781 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
21782 pAdapter->sessionId, pAdapter->device_mode));
21783
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021784 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021785 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021786 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021787 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021788 }
21789
21790 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
21791 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
21792 if (NULL == hHal)
21793 {
21794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21795 "%s: HAL context is Null!!!", __func__);
21796 return -EAGAIN;
21797 }
21798
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021799 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
21800 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
21801 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
21802 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021803 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021804 {
21805 /* changing from big to little endian since driver
21806 * works on little endian format
21807 */
21808 tANI_U8 *p =
21809 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
21810 int i;
21811
21812 for (i = 0; i < 8; i++)
21813 {
21814 p[7-i] = data->replay_ctr[i];
21815 }
21816 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021817
21818 if (TRUE == pHddCtx->hdd_wlan_suspended)
21819 {
21820 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021821 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
21822 sizeof (tSirGtkOffloadParams));
21823 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021824 pAdapter->sessionId);
21825
21826 if (eHAL_STATUS_SUCCESS != status)
21827 {
21828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21829 "%s: sme_SetGTKOffload failed, returned %d",
21830 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053021831
21832 /* Need to clear any trace of key value in the memory.
21833 * Thus zero out the memory even though it is local
21834 * variable.
21835 */
21836 vos_mem_zero(&hddGtkOffloadReqParams,
21837 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021838 return status;
21839 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21841 "%s: sme_SetGTKOffload successfull", __func__);
21842 }
21843 else
21844 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21846 "%s: wlan not suspended GTKOffload request is stored",
21847 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021848 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021849
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053021850 /* Need to clear any trace of key value in the memory.
21851 * Thus zero out the memory even though it is local
21852 * variable.
21853 */
21854 vos_mem_zero(&hddGtkOffloadReqParams,
21855 sizeof(hddGtkOffloadReqParams));
21856
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021857 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021858 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021859}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021860
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021861int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
21862 struct cfg80211_gtk_rekey_data *data)
21863{
21864 int ret;
21865
21866 vos_ssr_protect(__func__);
21867 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
21868 vos_ssr_unprotect(__func__);
21869
21870 return ret;
21871}
21872#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021873/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053021874 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021875 * This function is used to set access control policy
21876 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053021877static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
21878 struct net_device *dev,
21879 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021880{
21881 int i;
21882 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
21883 hdd_hostapd_state_t *pHostapdState;
21884 tsap_Config_t *pConfig;
21885 v_CONTEXT_t pVosContext = NULL;
21886 hdd_context_t *pHddCtx;
21887 int status;
21888
21889 ENTER();
21890
21891 if (NULL == pAdapter)
21892 {
21893 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
21894 "%s: HDD adapter is Null", __func__);
21895 return -ENODEV;
21896 }
21897
21898 if (NULL == params)
21899 {
21900 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
21901 "%s: params is Null", __func__);
21902 return -EINVAL;
21903 }
21904
21905 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
21906 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021907 if (0 != status)
21908 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021909 return status;
21910 }
21911
21912 pVosContext = pHddCtx->pvosContext;
21913 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
21914
21915 if (NULL == pHostapdState)
21916 {
21917 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
21918 "%s: pHostapdState is Null", __func__);
21919 return -EINVAL;
21920 }
21921
21922 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
21923 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053021924 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
21925 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
21926 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021927
21928 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
21929 {
21930 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
21931
21932 /* default value */
21933 pConfig->num_accept_mac = 0;
21934 pConfig->num_deny_mac = 0;
21935
21936 /**
21937 * access control policy
21938 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
21939 * listed in hostapd.deny file.
21940 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
21941 * listed in hostapd.accept file.
21942 */
21943 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
21944 {
21945 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
21946 }
21947 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
21948 {
21949 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
21950 }
21951 else
21952 {
21953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21954 "%s:Acl Policy : %d is not supported",
21955 __func__, params->acl_policy);
21956 return -ENOTSUPP;
21957 }
21958
21959 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
21960 {
21961 pConfig->num_accept_mac = params->n_acl_entries;
21962 for (i = 0; i < params->n_acl_entries; i++)
21963 {
21964 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21965 "** Add ACL MAC entry %i in WhiletList :"
21966 MAC_ADDRESS_STR, i,
21967 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
21968
21969 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
21970 sizeof(qcmacaddr));
21971 }
21972 }
21973 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
21974 {
21975 pConfig->num_deny_mac = params->n_acl_entries;
21976 for (i = 0; i < params->n_acl_entries; i++)
21977 {
21978 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21979 "** Add ACL MAC entry %i in BlackList :"
21980 MAC_ADDRESS_STR, i,
21981 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
21982
21983 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
21984 sizeof(qcmacaddr));
21985 }
21986 }
21987
21988 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
21989 {
21990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21991 "%s: SAP Set Mac Acl fail", __func__);
21992 return -EINVAL;
21993 }
21994 }
21995 else
21996 {
21997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053021998 "%s: Invalid device_mode = %s (%d)",
21999 __func__, hdd_device_modetoString(pAdapter->device_mode),
22000 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053022001 return -EINVAL;
22002 }
22003
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022004 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053022005 return 0;
22006}
22007
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053022008static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
22009 struct net_device *dev,
22010 const struct cfg80211_acl_data *params)
22011{
22012 int ret;
22013 vos_ssr_protect(__func__);
22014 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
22015 vos_ssr_unprotect(__func__);
22016
22017 return ret;
22018}
22019
Leo Chang9056f462013-08-01 19:21:11 -070022020#ifdef WLAN_NL80211_TESTMODE
22021#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070022022void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070022023(
22024 void *pAdapter,
22025 void *indCont
22026)
22027{
Leo Changd9df8aa2013-09-26 13:32:26 -070022028 tSirLPHBInd *lphbInd;
22029 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053022030 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070022031
22032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070022033 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070022034
c_hpothu73f35e62014-04-18 13:40:08 +053022035 if (pAdapter == NULL)
22036 {
22037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22038 "%s: pAdapter is NULL\n",__func__);
22039 return;
22040 }
22041
Leo Chang9056f462013-08-01 19:21:11 -070022042 if (NULL == indCont)
22043 {
22044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070022045 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070022046 return;
22047 }
22048
c_hpothu73f35e62014-04-18 13:40:08 +053022049 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070022050 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070022051 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053022052 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070022053 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070022054 GFP_ATOMIC);
22055 if (!skb)
22056 {
22057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22058 "LPHB timeout, NL buffer alloc fail");
22059 return;
22060 }
22061
Leo Changac3ba772013-10-07 09:47:04 -070022062 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070022063 {
22064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22065 "WLAN_HDD_TM_ATTR_CMD put fail");
22066 goto nla_put_failure;
22067 }
Leo Changac3ba772013-10-07 09:47:04 -070022068 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070022069 {
22070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22071 "WLAN_HDD_TM_ATTR_TYPE put fail");
22072 goto nla_put_failure;
22073 }
Leo Changac3ba772013-10-07 09:47:04 -070022074 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070022075 sizeof(tSirLPHBInd), lphbInd))
22076 {
22077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22078 "WLAN_HDD_TM_ATTR_DATA put fail");
22079 goto nla_put_failure;
22080 }
Leo Chang9056f462013-08-01 19:21:11 -070022081 cfg80211_testmode_event(skb, GFP_ATOMIC);
22082 return;
22083
22084nla_put_failure:
22085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22086 "NLA Put fail");
22087 kfree_skb(skb);
22088
22089 return;
22090}
22091#endif /* FEATURE_WLAN_LPHB */
22092
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053022093static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070022094{
22095 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
22096 int err = 0;
22097#ifdef FEATURE_WLAN_LPHB
22098 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070022099 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022100
22101 ENTER();
22102
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022103 err = wlan_hdd_validate_context(pHddCtx);
22104 if (0 != err)
22105 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022106 return err;
22107 }
Leo Chang9056f462013-08-01 19:21:11 -070022108#endif /* FEATURE_WLAN_LPHB */
22109
22110 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
22111 if (err)
22112 {
22113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22114 "%s Testmode INV ATTR", __func__);
22115 return err;
22116 }
22117
22118 if (!tb[WLAN_HDD_TM_ATTR_CMD])
22119 {
22120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22121 "%s Testmode INV CMD", __func__);
22122 return -EINVAL;
22123 }
22124
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053022125 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
22126 TRACE_CODE_HDD_CFG80211_TESTMODE,
22127 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070022128 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
22129 {
22130#ifdef FEATURE_WLAN_LPHB
22131 /* Low Power Heartbeat configuration request */
22132 case WLAN_HDD_TM_CMD_WLAN_HB:
22133 {
22134 int buf_len;
22135 void *buf;
22136 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080022137 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070022138
22139 if (!tb[WLAN_HDD_TM_ATTR_DATA])
22140 {
22141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22142 "%s Testmode INV DATA", __func__);
22143 return -EINVAL;
22144 }
22145
22146 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
22147 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080022148
Manjeet Singh3c577442017-02-10 19:03:38 +053022149 if (buf_len > sizeof(*hb_params)) {
22150 hddLog(LOGE, FL("buf_len=%d exceeded hb_params size limit"),
22151 buf_len);
22152 return -ERANGE;
22153 }
22154
Amar Singhal05852702014-02-04 14:40:00 -080022155 hb_params_temp =(tSirLPHBReq *)buf;
22156 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
22157 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
22158 return -EINVAL;
22159
Leo Chang9056f462013-08-01 19:21:11 -070022160 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
22161 if (NULL == hb_params)
22162 {
22163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22164 "%s Request Buffer Alloc Fail", __func__);
22165 return -EINVAL;
22166 }
22167
Ashish Kumar Dhanotiya3a8c0a72017-07-13 18:58:59 +053022168 vos_mem_zero(hb_params, sizeof(tSirLPHBReq));
Leo Chang9056f462013-08-01 19:21:11 -070022169 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070022170 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
22171 hb_params,
22172 wlan_hdd_cfg80211_lphb_ind_handler);
22173 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070022174 {
Leo Changd9df8aa2013-09-26 13:32:26 -070022175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22176 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070022177 vos_mem_free(hb_params);
22178 }
Leo Chang9056f462013-08-01 19:21:11 -070022179 return 0;
22180 }
22181#endif /* FEATURE_WLAN_LPHB */
22182 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053022183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22184 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070022185 return -EOPNOTSUPP;
22186 }
22187
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022188 EXIT();
22189 return err;
Leo Chang9056f462013-08-01 19:21:11 -070022190}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053022191
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053022192static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
22193#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
22194 struct wireless_dev *wdev,
22195#endif
22196 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053022197{
22198 int ret;
22199
22200 vos_ssr_protect(__func__);
22201 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
22202 vos_ssr_unprotect(__func__);
22203
22204 return ret;
22205}
Leo Chang9056f462013-08-01 19:21:11 -070022206#endif /* CONFIG_NL80211_TESTMODE */
22207
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053022208extern void hdd_set_wlan_suspend_mode(bool suspend);
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053022209static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022210 struct net_device *dev,
22211 int idx, struct survey_info *survey)
22212{
22213 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
22214 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053022215 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022216 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053022217 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022218 v_S7_t snr,rssi;
22219 int status, i, j, filled = 0;
22220
22221 ENTER();
22222
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022223 if (NULL == pAdapter)
22224 {
22225 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
22226 "%s: HDD adapter is Null", __func__);
22227 return -ENODEV;
22228 }
22229
22230 if (NULL == wiphy)
22231 {
22232 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
22233 "%s: wiphy is Null", __func__);
22234 return -ENODEV;
22235 }
22236
22237 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
22238 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022239 if (0 != status)
22240 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022241 return status;
22242 }
22243
Mihir Sheted9072e02013-08-21 17:02:29 +053022244 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
22245
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022246 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053022247 0 != pAdapter->survey_idx ||
22248 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022249 {
22250 /* The survey dump ops when implemented completely is expected to
22251 * return a survey of all channels and the ops is called by the
22252 * kernel with incremental values of the argument 'idx' till it
22253 * returns -ENONET. But we can only support the survey for the
22254 * operating channel for now. survey_idx is used to track
22255 * that the ops is called only once and then return -ENONET for
22256 * the next iteration
22257 */
22258 pAdapter->survey_idx = 0;
22259 return -ENONET;
22260 }
22261
Mukul Sharma9d5233b2015-06-11 20:28:20 +053022262 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
22263 {
22264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22265 "%s: Roaming in progress, hence return ", __func__);
22266 return -ENONET;
22267 }
22268
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022269 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
22270
22271 wlan_hdd_get_snr(pAdapter, &snr);
22272 wlan_hdd_get_rssi(pAdapter, &rssi);
22273
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053022274 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
22275 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
22276 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022277 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
22278 hdd_wlan_get_freq(channel, &freq);
22279
22280
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053022281 for (i = 0; i < HDD_NUM_NL80211_BANDS; i++)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022282 {
22283 if (NULL == wiphy->bands[i])
22284 {
22285 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
22286 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
22287 continue;
22288 }
22289
22290 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
22291 {
22292 struct ieee80211_supported_band *band = wiphy->bands[i];
22293
22294 if (band->channels[j].center_freq == (v_U16_t)freq)
22295 {
22296 survey->channel = &band->channels[j];
22297 /* The Rx BDs contain SNR values in dB for the received frames
22298 * while the supplicant expects noise. So we calculate and
22299 * return the value of noise (dBm)
22300 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
22301 */
22302 survey->noise = rssi - snr;
22303 survey->filled = SURVEY_INFO_NOISE_DBM;
22304 filled = 1;
22305 }
22306 }
22307 }
22308
22309 if (filled)
22310 pAdapter->survey_idx = 1;
22311 else
22312 {
22313 pAdapter->survey_idx = 0;
22314 return -ENONET;
22315 }
22316
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022317 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022318 return 0;
22319}
22320
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053022321static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
22322 struct net_device *dev,
22323 int idx, struct survey_info *survey)
22324{
22325 int ret;
22326
22327 vos_ssr_protect(__func__);
22328 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
22329 vos_ssr_unprotect(__func__);
22330
22331 return ret;
22332}
22333
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022334/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022335 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022336 * this is called when cfg80211 driver resume
22337 * driver updates latest sched_scan scan result(if any) to cfg80211 database
22338 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022339int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022340{
22341 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
22342 hdd_adapter_t *pAdapter;
22343 hdd_adapter_list_node_t *pAdapterNode, *pNext;
22344 VOS_STATUS status = VOS_STATUS_SUCCESS;
22345
22346 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022347
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053022348 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022349 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022350 return 0;
22351 }
22352
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053022353 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
22354 NO_SESSION, pHddCtx->isWiphySuspended));
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053022355
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053022356 if (pHddCtx->is_ap_mode_wow_supported)
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053022357 {
22358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22359 "%s: Resume SoftAP", __func__);
22360 hdd_set_wlan_suspend_mode(false);
22361 }
22362
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022363 spin_lock(&pHddCtx->schedScan_lock);
22364 pHddCtx->isWiphySuspended = FALSE;
22365 if (TRUE != pHddCtx->isSchedScanUpdatePending)
22366 {
22367 spin_unlock(&pHddCtx->schedScan_lock);
22368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22369 "%s: Return resume is not due to PNO indication", __func__);
22370 return 0;
22371 }
22372 // Reset flag to avoid updatating cfg80211 data old results again
22373 pHddCtx->isSchedScanUpdatePending = FALSE;
22374 spin_unlock(&pHddCtx->schedScan_lock);
22375
22376 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
22377
22378 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
22379 {
22380 pAdapter = pAdapterNode->pAdapter;
22381 if ( (NULL != pAdapter) &&
22382 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
22383 {
22384 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053022385 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
22387 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053022388 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022389 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053022390 {
22391 /* Acquire wakelock to handle the case where APP's tries to
22392 * suspend immediately after updating the scan results. Whis
22393 * results in app's is in suspended state and not able to
22394 * process the connect request to AP
22395 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053022396 hdd_prevent_suspend_timeout(2000,
22397 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022398 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053022399 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022400
22401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22402 "%s : cfg80211 scan result database updated", __func__);
22403
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022404 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022405 return 0;
22406
22407 }
22408 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
22409 pAdapterNode = pNext;
22410 }
22411
22412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22413 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022414 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022415 return 0;
22416}
22417
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022418int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
22419{
22420 int ret;
22421
22422 vos_ssr_protect(__func__);
22423 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
22424 vos_ssr_unprotect(__func__);
22425
22426 return ret;
22427}
22428
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022429/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022430 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022431 * this is called when cfg80211 driver suspends
22432 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022433int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022434 struct cfg80211_wowlan *wow)
22435{
22436 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022437 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022438
22439 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022440
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022441 ret = wlan_hdd_validate_context(pHddCtx);
22442 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022443 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022444 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022445 }
22446
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053022447 if (pHddCtx->is_ap_mode_wow_supported) {
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053022448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22449 "%s: Suspend SoftAP", __func__);
22450 hdd_set_wlan_suspend_mode(true);
22451 }
22452
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022453
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053022454 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
22455 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
22456 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022457 pHddCtx->isWiphySuspended = TRUE;
22458
22459 EXIT();
22460
22461 return 0;
22462}
22463
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022464int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
22465 struct cfg80211_wowlan *wow)
22466{
22467 int ret;
22468
22469 vos_ssr_protect(__func__);
22470 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
22471 vos_ssr_unprotect(__func__);
22472
22473 return ret;
22474}
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022475
22476#ifdef FEATURE_OEM_DATA_SUPPORT
22477static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022478 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022479{
22480 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
22481
22482 ENTER();
22483
22484 if (wlan_hdd_validate_context(pHddCtx)) {
22485 return;
22486 }
22487 if (!pMsg)
22488 {
22489 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
22490 return;
22491 }
22492
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022493 send_oem_data_rsp_msg(evLen, pMsg);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022494
22495 EXIT();
22496 return;
22497
22498}
22499
22500void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022501 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022502{
22503 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
22504
22505 ENTER();
22506
22507 if (wlan_hdd_validate_context(pHddCtx)) {
22508 return;
22509 }
22510
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022511 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d) evLen %d"), evType, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022512
22513 switch(evType) {
22514 case SIR_HAL_START_OEM_DATA_RSP_IND_NEW:
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022515 wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022516 break;
22517 default:
22518 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
22519 break;
22520 }
22521 EXIT();
22522}
22523#endif
22524
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053022525#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
22526 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053022527/**
22528 * __wlan_hdd_cfg80211_abort_scan() - cfg80211 abort scan api
22529 * @wiphy: Pointer to wiphy
22530 * @wdev: Pointer to wireless device structure
22531 *
22532 * This function is used to abort an ongoing scan
22533 *
22534 * Return: None
22535 */
22536static void __wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
22537 struct wireless_dev *wdev)
22538{
22539 struct net_device *dev = wdev->netdev;
22540 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
22541 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
22542 int ret;
22543
22544 ENTER();
22545
22546 if (NULL == adapter) {
22547 hddLog(VOS_TRACE_LEVEL_FATAL, FL("HDD adapter is NULL"));
22548 return;
22549 }
22550
22551 ret = wlan_hdd_validate_context(hdd_ctx);
22552 if (0 != ret)
22553 return;
22554
22555 wlan_hdd_scan_abort(adapter);
22556
22557 return;
22558}
22559
22560/**
22561 * wlan_hdd_cfg80211_abort_scan - cfg80211 abort scan api
22562 * @wiphy: Pointer to wiphy
22563 * @wdev: Pointer to wireless device structure
22564 *
22565 * Return: None
22566 */
22567void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
22568 struct wireless_dev *wdev)
22569{
22570 vos_ssr_protect(__func__);
22571 __wlan_hdd_cfg80211_abort_scan(wiphy, wdev);
22572 vos_ssr_unprotect(__func__);
22573
22574 return;
22575}
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053022576#endif
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053022577
Abhishek Singh936c6932017-11-07 17:28:23 +053022578#ifdef CHANNEL_SWITCH_SUPPORTED
22579/**
22580 * __wlan_hdd_cfg80211_channel_switch()- function to switch
22581 * channel in SAP/GO
22582 * @wiphy: wiphy pointer
22583 * @dev: dev pointer.
22584 * @csa_params: Change channel params
22585 *
22586 * This function is called to switch channel in SAP/GO
22587 *
22588 * Return: 0 if success else return non zero
22589 */
22590static int __wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy,
22591 struct net_device *dev, struct cfg80211_csa_settings *csa_params)
22592{
22593 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
22594 hdd_context_t *hdd_ctx;
22595 uint8_t channel;
22596 int ret;
Abhishek Singh10e17cf2018-03-12 14:34:22 +053022597 ptSapContext sap_ctx;
Abhishek Singh936c6932017-11-07 17:28:23 +053022598 v_CONTEXT_t vos_ctx;
22599
22600 hddLog(LOGE, FL("Set Freq %d"), csa_params->chandef.chan->center_freq);
22601
22602 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
22603 ret = wlan_hdd_validate_context(hdd_ctx);
22604 if (ret)
22605 return ret;
22606
22607 vos_ctx = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
22608 if (!vos_ctx) {
22609 hddLog(LOGE, FL("Vos ctx is null"));
22610 return -EINVAL;
22611 }
22612
Abhishek Singh10e17cf2018-03-12 14:34:22 +053022613 if (WLAN_HDD_SOFTAP != adapter->device_mode)
Abhishek Singh936c6932017-11-07 17:28:23 +053022614 return -ENOTSUPP;
22615
Abhishek Singh10e17cf2018-03-12 14:34:22 +053022616 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
22617 if (!sap_ctx) {
22618 hddLog(LOGE, FL("sap_ctx is NULL"));
22619 return -EINVAL;
22620 }
22621
22622 ret = wlansap_chk_n_set_chan_change_in_progress(sap_ctx);
22623 if (ret)
22624 return ret;
22625
22626 INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp);
22627
Abhishek Singh936c6932017-11-07 17:28:23 +053022628 channel = vos_freq_to_chan(csa_params->chandef.chan->center_freq);
Abhishek Singhceb6fe22017-11-27 13:53:18 +053022629 ret = wlansap_set_channel_change(vos_ctx, channel, false);
Abhishek Singh936c6932017-11-07 17:28:23 +053022630
Abhishek Singh10e17cf2018-03-12 14:34:22 +053022631 if (ret) {
22632 wlansap_reset_chan_change_in_progress(sap_ctx);
22633 complete(&sap_ctx->ecsa_info.chan_switch_comp);
22634 }
22635
Abhishek Singh936c6932017-11-07 17:28:23 +053022636 return ret;
22637}
22638
22639/**
22640 * wlan_hdd_cfg80211_channel_switch()- function to switch
22641 * channel in SAP/GO
22642 * @wiphy: wiphy pointer
22643 * @dev: dev pointer.
22644 * @csa_params: Change channel params
22645 *
22646 * This function is called to switch channel in SAP/GO
22647 *
22648 * Return: 0 if success else return non zero
22649 */
22650static int wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy,
22651 struct net_device *dev, struct cfg80211_csa_settings *csa_params)
22652{
22653 int ret;
22654
22655 vos_ssr_protect(__func__);
22656 ret = __wlan_hdd_cfg80211_channel_switch(wiphy, dev, csa_params);
22657 vos_ssr_unprotect(__func__);
22658
22659 return ret;
22660}
22661#endif
22662
Jeff Johnson295189b2012-06-20 16:38:30 -070022663/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053022664static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070022665{
22666 .add_virtual_intf = wlan_hdd_add_virtual_intf,
22667 .del_virtual_intf = wlan_hdd_del_virtual_intf,
22668 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
22669 .change_station = wlan_hdd_change_station,
22670#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
22671 .add_beacon = wlan_hdd_cfg80211_add_beacon,
22672 .del_beacon = wlan_hdd_cfg80211_del_beacon,
22673 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070022674#else
22675 .start_ap = wlan_hdd_cfg80211_start_ap,
22676 .change_beacon = wlan_hdd_cfg80211_change_beacon,
22677 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070022678#endif
22679 .change_bss = wlan_hdd_cfg80211_change_bss,
22680 .add_key = wlan_hdd_cfg80211_add_key,
22681 .get_key = wlan_hdd_cfg80211_get_key,
22682 .del_key = wlan_hdd_cfg80211_del_key,
22683 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080022684#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070022685 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080022686#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070022687 .scan = wlan_hdd_cfg80211_scan,
22688 .connect = wlan_hdd_cfg80211_connect,
22689 .disconnect = wlan_hdd_cfg80211_disconnect,
22690 .join_ibss = wlan_hdd_cfg80211_join_ibss,
22691 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
22692 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
22693 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
22694 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070022695 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
22696 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053022697 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070022698#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
22699 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
22700 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
22701 .set_txq_params = wlan_hdd_set_txq_params,
22702#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070022703 .get_station = wlan_hdd_cfg80211_get_station,
22704 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
22705 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070022706 .add_station = wlan_hdd_cfg80211_add_station,
22707#ifdef FEATURE_WLAN_LFR
22708 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
22709 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
22710 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
22711#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070022712#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
22713 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
22714#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080022715#ifdef FEATURE_WLAN_TDLS
22716 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
22717 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
22718#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053022719#ifdef WLAN_FEATURE_GTK_OFFLOAD
22720 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
22721#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053022722#ifdef FEATURE_WLAN_SCAN_PNO
22723 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
22724 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
22725#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022726 .resume = wlan_hdd_cfg80211_resume_wlan,
22727 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053022728 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070022729#ifdef WLAN_NL80211_TESTMODE
22730 .testmode_cmd = wlan_hdd_cfg80211_testmode,
22731#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022732 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053022733#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
22734 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053022735 .abort_scan = wlan_hdd_cfg80211_abort_scan,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053022736#endif
Abhishek Singh936c6932017-11-07 17:28:23 +053022737#ifdef CHANNEL_SWITCH_SUPPORTED
22738 .channel_switch = wlan_hdd_cfg80211_channel_switch,
22739#endif
22740
Abhinav Kumar118efd02019-08-07 16:41:07 +053022741#if defined(WLAN_FEATURE_SAE) && \
22742 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
22743 .external_auth = wlan_hdd_cfg80211_external_auth,
22744#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070022745};
22746