blob: 0094c7f801192bcb5979930722733b1d61f9d8e8 [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
Sushant Kaushik8e644982015-09-23 12:18:54 +05306368static const struct
6369nla_policy
6370qca_wlan_vendor_wifi_logger_start_policy
6371[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = {
6372 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]
6373 = {.type = NLA_U32 },
6374 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]
6375 = {.type = NLA_U32 },
6376 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]
6377 = {.type = NLA_U32 },
6378};
6379
6380/**
6381 * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable
6382 * or disable the collection of packet statistics from the firmware
6383 * @wiphy: WIPHY structure pointer
6384 * @wdev: Wireless device structure pointer
6385 * @data: Pointer to the data received
6386 * @data_len: Length of the data received
6387 *
6388 * This function is used to enable or disable the collection of packet
6389 * statistics from the firmware
6390 *
6391 * Return: 0 on success and errno on failure
6392 */
6393static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
6394 struct wireless_dev *wdev,
6395 const void *data,
6396 int data_len)
6397{
6398 eHalStatus status;
6399 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6400 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1];
6401 tAniWifiStartLog start_log;
6402
6403 status = wlan_hdd_validate_context(hdd_ctx);
6404 if (0 != status) {
6405 return -EINVAL;
6406 }
6407
6408 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX,
6409 data, data_len,
6410 qca_wlan_vendor_wifi_logger_start_policy)) {
6411 hddLog(LOGE, FL("Invalid attribute"));
6412 return -EINVAL;
6413 }
6414
6415 /* Parse and fetch ring id */
6416 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) {
6417 hddLog(LOGE, FL("attr ATTR failed"));
6418 return -EINVAL;
6419 }
6420 start_log.ringId = nla_get_u32(
6421 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]);
6422 hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId);
6423
6424 /* Parse and fetch verbose level */
6425 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) {
6426 hddLog(LOGE, FL("attr verbose_level failed"));
6427 return -EINVAL;
6428 }
6429 start_log.verboseLevel = nla_get_u32(
6430 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]);
6431 hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel);
6432
6433 /* Parse and fetch flag */
6434 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) {
6435 hddLog(LOGE, FL("attr flag failed"));
6436 return -EINVAL;
6437 }
6438 start_log.flag = nla_get_u32(
6439 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]);
6440 hddLog(LOG1, FL("flag=%d"), start_log.flag);
6441
6442 if ((RING_ID_PER_PACKET_STATS == start_log.ringId) &&
Sushant Kaushik33200572015-08-05 16:46:20 +05306443 (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable ||
6444 !vos_isPktStatsEnabled()))
6445
Sushant Kaushik8e644982015-09-23 12:18:54 +05306446 {
6447 hddLog(LOGE, FL("per pkt stats not enabled"));
6448 return -EINVAL;
6449 }
Sushant Kaushik8e644982015-09-23 12:18:54 +05306450
Sushant Kaushik33200572015-08-05 16:46:20 +05306451 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
Sushant Kaushik8e644982015-09-23 12:18:54 +05306452 return 0;
6453}
6454
6455/**
6456 * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable
6457 * or disable the collection of packet statistics from the firmware
6458 * @wiphy: WIPHY structure pointer
6459 * @wdev: Wireless device structure pointer
6460 * @data: Pointer to the data received
6461 * @data_len: Length of the data received
6462 *
6463 * This function is used to enable or disable the collection of packet
6464 * statistics from the firmware
6465 *
6466 * Return: 0 on success and errno on failure
6467 */
6468static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
6469 struct wireless_dev *wdev,
6470 const void *data,
6471 int data_len)
c_manjeecfd1efb2015-09-25 19:32:34 +05306472{
6473 int ret = 0;
6474
6475 vos_ssr_protect(__func__);
Sushant Kaushik8e644982015-09-23 12:18:54 +05306476
6477 ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy,
6478 wdev, data, data_len);
c_manjeecfd1efb2015-09-25 19:32:34 +05306479 vos_ssr_unprotect(__func__);
6480
6481 return ret;
c_manjeecfd1efb2015-09-25 19:32:34 +05306482}
6483
6484
Agarwal Ashish738843c2014-09-25 12:27:56 +05306485static const struct nla_policy
6486wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
6487 +1] =
6488{
6489 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
6490};
6491
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306492static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306493 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306494 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306495 int data_len)
6496{
6497 struct net_device *dev = wdev->netdev;
6498 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6499 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6500 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6501 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
6502 eHalStatus status;
6503 u32 dfsFlag = 0;
6504
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306505 ENTER();
6506
Agarwal Ashish738843c2014-09-25 12:27:56 +05306507 status = wlan_hdd_validate_context(pHddCtx);
6508 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05306509 return -EINVAL;
6510 }
6511 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
6512 data, data_len,
6513 wlan_hdd_set_no_dfs_flag_config_policy)) {
6514 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6515 return -EINVAL;
6516 }
6517
6518 /* Parse and fetch required bandwidth kbps */
6519 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
6520 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
6521 return -EINVAL;
6522 }
6523
6524 dfsFlag = nla_get_u32(
6525 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
6526 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
6527 dfsFlag);
6528
6529 pHddCtx->disable_dfs_flag = dfsFlag;
6530
6531 sme_disable_dfs_channel(hHal, dfsFlag);
6532 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306533
6534 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05306535 return 0;
6536}
Atul Mittal115287b2014-07-08 13:26:33 +05306537
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306538static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
6539 struct wireless_dev *wdev,
6540 const void *data,
6541 int data_len)
6542{
6543 int ret = 0;
6544
6545 vos_ssr_protect(__func__);
6546 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
6547 vos_ssr_unprotect(__func__);
6548
6549 return ret;
6550
6551}
6552
Mukul Sharma2a271632014-10-13 14:59:01 +05306553const struct
6554nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
6555{
6556 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05306557 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = {
6558 .type = NLA_UNSPEC,
6559 .len = HDD_MAC_ADDR_LEN},
Mukul Sharma2a271632014-10-13 14:59:01 +05306560};
6561
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306562static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05306563 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05306564{
6565
6566 u8 bssid[6] = {0};
6567 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6568 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6569 eHalStatus status = eHAL_STATUS_SUCCESS;
6570 v_U32_t isFwrRoamEnabled = FALSE;
6571 int ret;
6572
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306573 ENTER();
6574
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306575 ret = wlan_hdd_validate_context(pHddCtx);
6576 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306577 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05306578 }
6579
6580 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
6581 data, data_len,
6582 qca_wlan_vendor_attr);
6583 if (ret){
6584 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6585 return -EINVAL;
6586 }
6587
6588 /* Parse and fetch Enable flag */
6589 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
6590 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
6591 return -EINVAL;
6592 }
6593
6594 isFwrRoamEnabled = nla_get_u32(
6595 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
6596
6597 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
6598
6599 /* Parse and fetch bssid */
6600 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6601 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
6602 return -EINVAL;
6603 }
6604
6605 memcpy(bssid, nla_data(
6606 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6607 sizeof(bssid));
6608 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
6609
6610 //Update roaming
6611 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306612 if (!HAL_STATUS_SUCCESS(status)) {
6613 hddLog(LOGE,
6614 FL("sme_ConfigFwrRoaming failed (err=%d)"), status);
6615 return -EINVAL;
6616 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306617 EXIT();
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306618 return 0;
Mukul Sharma2a271632014-10-13 14:59:01 +05306619}
6620
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306621static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
6622 struct wireless_dev *wdev, const void *data, int data_len)
6623{
6624 int ret = 0;
6625
6626 vos_ssr_protect(__func__);
6627 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
6628 vos_ssr_unprotect(__func__);
6629
6630 return ret;
6631}
6632
Sushant Kaushik847890c2015-09-28 16:05:17 +05306633static const struct
6634nla_policy
6635qca_wlan_vendor_get_wifi_info_policy[
6636 QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = {
6637 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
6638 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
6639};
6640
6641
6642/**
6643 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6644 * @wiphy: pointer to wireless wiphy structure.
6645 * @wdev: pointer to wireless_dev structure.
6646 * @data: Pointer to the data to be passed via vendor interface
6647 * @data_len:Length of the data to be passed
6648 *
6649 * This is called when wlan driver needs to send wifi driver related info
6650 * (driver/fw version) to the user space application upon request.
6651 *
6652 * Return: Return the Success or Failure code.
6653 */
6654static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6655 struct wireless_dev *wdev,
6656 const void *data, int data_len)
6657{
6658 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6659 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
6660 tSirVersionString version;
6661 uint32 version_len;
6662 uint8 attr;
6663 int status;
6664 struct sk_buff *reply_skb = NULL;
6665
6666 if (VOS_FTM_MODE == hdd_get_conparam()) {
6667 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6668 return -EINVAL;
6669 }
6670
6671 status = wlan_hdd_validate_context(hdd_ctx);
6672 if (0 != status) {
6673 hddLog(LOGE, FL("HDD context is not valid"));
6674 return -EINVAL;
6675 }
6676
6677 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
6678 data_len, qca_wlan_vendor_get_wifi_info_policy)) {
6679 hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
6680 return -EINVAL;
6681 }
6682
6683 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
6684 hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"),
6685 QWLAN_VERSIONSTR);
6686 strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
6687 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
6688 } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
6689 hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"),
6690 hdd_ctx->fw_Version);
6691 strlcpy(version, hdd_ctx->fw_Version, sizeof(version));
6692 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
6693 } else {
6694 hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
6695 return -EINVAL;
6696 }
6697
6698 version_len = strlen(version);
6699 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6700 version_len + NLA_HDRLEN + NLMSG_HDRLEN);
6701 if (!reply_skb) {
6702 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6703 return -ENOMEM;
6704 }
6705
6706 if (nla_put(reply_skb, attr, version_len, version)) {
6707 hddLog(LOGE, FL("nla put fail"));
6708 kfree_skb(reply_skb);
6709 return -EINVAL;
6710 }
6711
6712 return cfg80211_vendor_cmd_reply(reply_skb);
6713}
6714
6715/**
6716 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6717 * @wiphy: pointer to wireless wiphy structure.
6718 * @wdev: pointer to wireless_dev structure.
6719 * @data: Pointer to the data to be passed via vendor interface
6720 * @data_len:Length of the data to be passed
6721 * @data_len: Length of the data received
6722 *
6723 * This function is used to enable or disable the collection of packet
6724 * statistics from the firmware
6725 *
6726 * Return: 0 on success and errno on failure
6727 */
6728
6729static int
6730wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6731 struct wireless_dev *wdev,
6732 const void *data, int data_len)
6733
6734
6735{
6736 int ret = 0;
6737
6738 vos_ssr_protect(__func__);
6739 ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy,
6740 wdev, data, data_len);
6741 vos_ssr_unprotect(__func__);
6742
6743 return ret;
6744}
6745
6746
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306747/*
6748 * define short names for the global vendor params
6749 * used by __wlan_hdd_cfg80211_monitor_rssi()
6750 */
6751#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX
6752#define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID
6753#define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL
6754#define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI
6755#define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI
6756
6757/**---------------------------------------------------------------------------
6758
6759 \brief hdd_rssi_monitor_start_done - callback to be executed when rssi
6760 monitor start is completed successfully.
6761
6762 \return - None
6763
6764 --------------------------------------------------------------------------*/
6765void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6766{
6767 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6768
6769 if (NULL == pHddCtx)
6770 {
6771 hddLog(VOS_TRACE_LEVEL_ERROR,
6772 "%s: HDD context is NULL",__func__);
6773 return;
6774 }
6775
6776 if (VOS_STATUS_SUCCESS == status)
6777 {
6778 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful"));
6779 }
6780 else
6781 {
6782 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful"));
6783 }
6784
6785 return;
6786}
6787
6788/**---------------------------------------------------------------------------
6789
6790 \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor
6791 stop is completed successfully.
6792
6793 \return - None
6794
6795 --------------------------------------------------------------------------*/
6796void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6797{
6798 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6799
6800 if (NULL == pHddCtx)
6801 {
6802 hddLog(VOS_TRACE_LEVEL_ERROR,
6803 "%s: HDD context is NULL",__func__);
6804 return;
6805 }
6806
6807 if (VOS_STATUS_SUCCESS == status)
6808 {
6809 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful"));
6810 }
6811 else
6812 {
6813 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful"));
6814 }
6815
6816 return;
6817}
6818
6819/**
6820 * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi
6821 * @wiphy: Pointer to wireless phy
6822 * @wdev: Pointer to wireless device
6823 * @data: Pointer to data
6824 * @data_len: Data length
6825 *
6826 * Return: 0 on success, negative errno on failure
6827 */
6828
6829static int
6830__wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy,
6831 struct wireless_dev *wdev,
6832 const void *data,
6833 int data_len)
6834{
6835 struct net_device *dev = wdev->netdev;
6836 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6837 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6838 hdd_station_ctx_t *pHddStaCtx;
6839 struct nlattr *tb[PARAM_MAX + 1];
6840 tpSirRssiMonitorReq pReq;
6841 eHalStatus status;
6842 int ret;
6843 uint32_t control;
6844 static const struct nla_policy policy[PARAM_MAX + 1] = {
6845 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6846 [PARAM_CONTROL] = { .type = NLA_U32 },
6847 [PARAM_MIN_RSSI] = { .type = NLA_S8 },
6848 [PARAM_MAX_RSSI] = { .type = NLA_S8 },
6849 };
6850
6851 ENTER();
6852
6853 ret = wlan_hdd_validate_context(hdd_ctx);
6854 if (0 != ret) {
6855 return -EINVAL;
6856 }
6857
6858 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6859 hddLog(LOGE, FL("Not in Connected state!"));
6860 return -ENOTSUPP;
6861 }
6862
6863 if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) {
6864 hddLog(LOGE, FL("Invalid ATTR"));
6865 return -EINVAL;
6866 }
6867
6868 if (!tb[PARAM_REQUEST_ID]) {
6869 hddLog(LOGE, FL("attr request id failed"));
6870 return -EINVAL;
6871 }
6872
6873 if (!tb[PARAM_CONTROL]) {
6874 hddLog(LOGE, FL("attr control failed"));
6875 return -EINVAL;
6876 }
6877
6878 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6879
6880 pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq));
6881 if(NULL == pReq)
6882 {
6883 hddLog(LOGE,
6884 FL("vos_mem_alloc failed "));
6885 return eHAL_STATUS_FAILED_ALLOC;
6886 }
6887 vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0);
6888
6889 pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
6890 pReq->sessionId = pAdapter->sessionId;
6891 pReq->rssiMonitorCbContext = hdd_ctx;
6892 control = nla_get_u32(tb[PARAM_CONTROL]);
6893 vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6894
6895 hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"),
6896 pReq->requestId, pReq->sessionId, control);
6897
6898 if (control == QCA_WLAN_RSSI_MONITORING_START) {
6899 if (!tb[PARAM_MIN_RSSI]) {
6900 hddLog(LOGE, FL("attr min rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306901 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306902 }
6903
6904 if (!tb[PARAM_MAX_RSSI]) {
6905 hddLog(LOGE, FL("attr max rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306906 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306907 }
6908
6909 pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]);
6910 pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]);
6911 pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done;
6912
6913 if (!(pReq->minRssi < pReq->maxRssi)) {
6914 hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"),
6915 pReq->minRssi, pReq->maxRssi);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306916 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306917 }
6918 hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"),
6919 pReq->minRssi, pReq->maxRssi);
6920 status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq);
6921
6922 }
6923 else if (control == QCA_WLAN_RSSI_MONITORING_STOP) {
6924 pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done;
6925 status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq);
6926 }
6927 else {
6928 hddLog(LOGE, FL("Invalid control cmd: %d"), control);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306929 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306930 }
6931
6932 if (!HAL_STATUS_SUCCESS(status)) {
6933 hddLog(LOGE,
6934 FL("sme_set_rssi_monitoring failed(err=%d)"), status);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306935 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306936 }
6937
6938 return 0;
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306939fail:
6940 vos_mem_free(pReq);
6941 return -EINVAL;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306942}
6943
6944/*
6945 * done with short names for the global vendor params
6946 * used by __wlan_hdd_cfg80211_monitor_rssi()
6947 */
6948#undef PARAM_MAX
6949#undef PARAM_CONTROL
6950#undef PARAM_REQUEST_ID
6951#undef PARAM_MAX_RSSI
6952#undef PARAM_MIN_RSSI
6953
6954/**
6955 * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
6956 * @wiphy: wiphy structure pointer
6957 * @wdev: Wireless device structure pointer
6958 * @data: Pointer to the data received
6959 * @data_len: Length of @data
6960 *
6961 * Return: 0 on success; errno on failure
6962 */
6963static int
6964wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
6965 const void *data, int data_len)
6966{
6967 int ret;
6968
6969 vos_ssr_protect(__func__);
6970 ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len);
6971 vos_ssr_unprotect(__func__);
6972
6973 return ret;
6974}
6975
6976/**
6977 * hdd_rssi_threshold_breached_cb() - rssi breached NL event
6978 * @hddctx: HDD context
6979 * @data: rssi breached event data
6980 *
6981 * This function reads the rssi breached event %data and fill in the skb with
6982 * NL attributes and send up the NL event.
6983 * This callback execute in atomic context and must not invoke any
6984 * blocking calls.
6985 *
6986 * Return: none
6987 */
6988void hdd_rssi_threshold_breached_cb(void *hddctx,
6989 struct rssi_breach_event *data)
6990{
6991 hdd_context_t *pHddCtx = (hdd_context_t *)hddctx;
6992 int status;
6993 struct sk_buff *skb;
6994
6995 ENTER();
6996 status = wlan_hdd_validate_context(pHddCtx);
6997
6998 if (0 != status) {
6999 return;
7000 }
7001
7002 if (!data) {
7003 hddLog(LOGE, FL("data is null"));
7004 return;
7005 }
7006
7007 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
7008#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
7009 NULL,
7010#endif
7011 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
7012 QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
7013 GFP_KERNEL);
7014
7015 if (!skb) {
7016 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
7017 return;
7018 }
7019
7020 hddLog(LOG1, "Req Id: %u Current rssi: %d",
7021 data->request_id, data->curr_rssi);
7022 hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR,
7023 MAC_ADDR_ARRAY(data->curr_bssid.bytes));
7024
7025 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID,
7026 data->request_id) ||
7027 nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID,
7028 sizeof(data->curr_bssid), data->curr_bssid.bytes) ||
7029 nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI,
7030 data->curr_rssi)) {
7031 hddLog(LOGE, FL("nla put fail"));
7032 goto fail;
7033 }
7034
7035 cfg80211_vendor_event(skb, GFP_KERNEL);
7036 return;
7037
7038fail:
7039 kfree_skb(skb);
7040 return;
7041}
7042
7043
7044
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307045/**
7046 * __wlan_hdd_cfg80211_setband() - set band
7047 * @wiphy: Pointer to wireless phy
7048 * @wdev: Pointer to wireless device
7049 * @data: Pointer to data
7050 * @data_len: Data length
7051 *
7052 * Return: 0 on success, negative errno on failure
7053 */
7054static int
7055__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
7056 struct wireless_dev *wdev,
7057 const void *data,
7058 int data_len)
7059{
7060 struct net_device *dev = wdev->netdev;
7061 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7062 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
7063 int ret;
7064 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
7065 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
7066
7067 ENTER();
7068
7069 ret = wlan_hdd_validate_context(hdd_ctx);
7070 if (0 != ret) {
7071 hddLog(LOGE, FL("HDD context is not valid"));
7072 return ret;
7073 }
7074
7075 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7076 policy)) {
7077 hddLog(LOGE, FL("Invalid ATTR"));
7078 return -EINVAL;
7079 }
7080
7081 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
7082 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
7083 return -EINVAL;
7084 }
7085
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05307086 hdd_ctx->isSetBandByNL = TRUE;
7087 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307088 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05307089 hdd_ctx->isSetBandByNL = FALSE;
7090
7091 EXIT();
7092 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307093}
7094
7095/**
7096 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
7097 * @wiphy: wiphy structure pointer
7098 * @wdev: Wireless device structure pointer
7099 * @data: Pointer to the data received
7100 * @data_len: Length of @data
7101 *
7102 * Return: 0 on success; errno on failure
7103 */
7104static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
7105 struct wireless_dev *wdev,
7106 const void *data,
7107 int data_len)
7108{
7109 int ret = 0;
7110
7111 vos_ssr_protect(__func__);
7112 ret = __wlan_hdd_cfg80211_setband(wiphy,
7113 wdev, data, data_len);
7114 vos_ssr_unprotect(__func__);
7115
7116 return ret;
7117}
7118
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307119#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
7120/**
7121 * hdd_map_req_id_to_pattern_id() - map request id to pattern id
7122 * @hdd_ctx: HDD context
7123 * @request_id: [input] request id
7124 * @pattern_id: [output] pattern id
7125 *
7126 * This function loops through request id to pattern id array
7127 * if the slot is available, store the request id and return pattern id
7128 * if entry exists, return the pattern id
7129 *
7130 * Return: 0 on success and errno on failure
7131 */
7132static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
7133 uint32_t request_id,
7134 uint8_t *pattern_id)
7135{
7136 uint32_t i;
7137
7138 mutex_lock(&hdd_ctx->op_ctx.op_lock);
7139 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
7140 {
7141 if (hdd_ctx->op_ctx.op_table[i].request_id == 0)
7142 {
7143 hdd_ctx->op_ctx.op_table[i].request_id = request_id;
7144 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
7145 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7146 return 0;
7147 } else if (hdd_ctx->op_ctx.op_table[i].request_id ==
7148 request_id) {
7149 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
7150 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7151 return 0;
7152 }
7153 }
7154 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7155 return -EINVAL;
7156}
7157
7158/**
7159 * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id
7160 * @hdd_ctx: HDD context
7161 * @request_id: [input] request id
7162 * @pattern_id: [output] pattern id
7163 *
7164 * This function loops through request id to pattern id array
7165 * reset request id to 0 (slot available again) and
7166 * return pattern id
7167 *
7168 * Return: 0 on success and errno on failure
7169 */
7170static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
7171 uint32_t request_id,
7172 uint8_t *pattern_id)
7173{
7174 uint32_t i;
7175
7176 mutex_lock(&hdd_ctx->op_ctx.op_lock);
7177 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
7178 {
7179 if (hdd_ctx->op_ctx.op_table[i].request_id == request_id)
7180 {
7181 hdd_ctx->op_ctx.op_table[i].request_id = 0;
7182 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
7183 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7184 return 0;
7185 }
7186 }
7187 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7188 return -EINVAL;
7189}
7190
7191
7192/*
7193 * define short names for the global vendor params
7194 * used by __wlan_hdd_cfg80211_offloaded_packets()
7195 */
7196#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX
7197#define PARAM_REQUEST_ID \
7198 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID
7199#define PARAM_CONTROL \
7200 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL
7201#define PARAM_IP_PACKET \
7202 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA
7203#define PARAM_SRC_MAC_ADDR \
7204 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR
7205#define PARAM_DST_MAC_ADDR \
7206 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR
7207#define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD
7208
7209/**
7210 * wlan_hdd_add_tx_ptrn() - add tx pattern
7211 * @adapter: adapter pointer
7212 * @hdd_ctx: hdd context
7213 * @tb: nl attributes
7214 *
7215 * This function reads the NL attributes and forms a AddTxPtrn message
7216 * posts it to SME.
7217 *
7218 */
7219static int
7220wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
7221 struct nlattr **tb)
7222{
7223 struct sSirAddPeriodicTxPtrn *add_req;
7224 eHalStatus status;
7225 uint32_t request_id, ret, len;
7226 uint8_t pattern_id = 0;
7227 v_MACADDR_t dst_addr;
7228 uint16_t eth_type = htons(ETH_P_IP);
7229
7230 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
7231 {
7232 hddLog(LOGE, FL("Not in Connected state!"));
7233 return -ENOTSUPP;
7234 }
7235
7236 add_req = vos_mem_malloc(sizeof(*add_req));
7237 if (!add_req)
7238 {
7239 hddLog(LOGE, FL("memory allocation failed"));
7240 return -ENOMEM;
7241 }
7242
7243 /* Parse and fetch request Id */
7244 if (!tb[PARAM_REQUEST_ID])
7245 {
7246 hddLog(LOGE, FL("attr request id failed"));
7247 goto fail;
7248 }
7249
7250 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
7251 hddLog(LOG1, FL("Request Id: %u"), request_id);
7252 if (request_id == 0)
7253 {
7254 hddLog(LOGE, FL("request_id cannot be zero"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05307255 goto fail;
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307256 }
7257
7258 if (!tb[PARAM_PERIOD])
7259 {
7260 hddLog(LOGE, FL("attr period failed"));
7261 goto fail;
7262 }
7263 add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]);
7264 hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs);
7265 if (add_req->usPtrnIntervalMs == 0)
7266 {
7267 hddLog(LOGE, FL("Invalid interval zero, return failure"));
7268 goto fail;
7269 }
7270
7271 if (!tb[PARAM_SRC_MAC_ADDR])
7272 {
7273 hddLog(LOGE, FL("attr source mac address failed"));
7274 goto fail;
7275 }
7276 nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR],
7277 VOS_MAC_ADDR_SIZE);
7278 hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR,
7279 MAC_ADDR_ARRAY(add_req->macAddress));
7280
7281 if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes,
7282 VOS_MAC_ADDR_SIZE))
7283 {
7284 hddLog(LOGE,
7285 FL("input src mac address and connected ap bssid are different"));
7286 goto fail;
7287 }
7288
7289 if (!tb[PARAM_DST_MAC_ADDR])
7290 {
7291 hddLog(LOGE, FL("attr dst mac address failed"));
7292 goto fail;
7293 }
7294 nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE);
7295 hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR,
7296 MAC_ADDR_ARRAY(dst_addr.bytes));
7297
7298 if (!tb[PARAM_IP_PACKET])
7299 {
7300 hddLog(LOGE, FL("attr ip packet failed"));
7301 goto fail;
7302 }
7303 add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]);
7304 hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize);
7305
7306 if (add_req->ucPtrnSize < 0 ||
7307 add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE -
7308 HDD_ETH_HEADER_LEN))
7309 {
7310 hddLog(LOGE, FL("Invalid IP packet len: %d"),
7311 add_req->ucPtrnSize);
7312 goto fail;
7313 }
7314
7315 len = 0;
7316 vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE);
7317 len += VOS_MAC_ADDR_SIZE;
7318 vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress,
7319 VOS_MAC_ADDR_SIZE);
7320 len += VOS_MAC_ADDR_SIZE;
7321 vos_mem_copy(&add_req->ucPattern[len], &eth_type, 2);
7322 len += 2;
7323
7324 /*
7325 * This is the IP packet, add 14 bytes Ethernet (802.3) header
7326 * ------------------------------------------------------------
7327 * | 14 bytes Ethernet (802.3) header | IP header and payload |
7328 * ------------------------------------------------------------
7329 */
7330 vos_mem_copy(&add_req->ucPattern[len],
7331 nla_data(tb[PARAM_IP_PACKET]),
7332 add_req->ucPtrnSize);
7333 add_req->ucPtrnSize += len;
7334
7335 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7336 add_req->ucPattern, add_req->ucPtrnSize);
7337
7338 ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
7339 if (ret)
7340 {
7341 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
7342 goto fail;
7343 }
7344 add_req->ucPtrnId = pattern_id;
7345 hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId);
7346
7347 status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req);
7348 if (!HAL_STATUS_SUCCESS(status))
7349 {
7350 hddLog(LOGE,
7351 FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status);
7352 goto fail;
7353 }
7354
7355 EXIT();
7356 vos_mem_free(add_req);
7357 return 0;
7358
7359fail:
7360 vos_mem_free(add_req);
7361 return -EINVAL;
7362}
7363
7364/**
7365 * wlan_hdd_del_tx_ptrn() - delete tx pattern
7366 * @adapter: adapter pointer
7367 * @hdd_ctx: hdd context
7368 * @tb: nl attributes
7369 *
7370 * This function reads the NL attributes and forms a DelTxPtrn message
7371 * posts it to SME.
7372 *
7373 */
7374static int
7375wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
7376 struct nlattr **tb)
7377{
7378 struct sSirDelPeriodicTxPtrn *del_req;
7379 eHalStatus status;
7380 uint32_t request_id, ret;
7381 uint8_t pattern_id = 0;
7382
7383 /* Parse and fetch request Id */
7384 if (!tb[PARAM_REQUEST_ID])
7385 {
7386 hddLog(LOGE, FL("attr request id failed"));
7387 return -EINVAL;
7388 }
7389 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
7390 if (request_id == 0)
7391 {
7392 hddLog(LOGE, FL("request_id cannot be zero"));
7393 return -EINVAL;
7394 }
7395
7396 ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
7397 if (ret)
7398 {
7399 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
7400 return -EINVAL;
7401 }
7402
7403 del_req = vos_mem_malloc(sizeof(*del_req));
7404 if (!del_req)
7405 {
7406 hddLog(LOGE, FL("memory allocation failed"));
7407 return -ENOMEM;
7408 }
7409
7410 vos_mem_set(del_req, sizeof(*del_req), 0);
7411 vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes,
7412 VOS_MAC_ADDR_SIZE);
7413 hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress));
7414 del_req->ucPatternIdBitmap |= (0x1 << pattern_id);
7415 hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"),
7416 request_id, pattern_id, del_req->ucPatternIdBitmap);
7417
7418 status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req);
7419 if (!HAL_STATUS_SUCCESS(status))
7420 {
7421 hddLog(LOGE,
7422 FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status);
7423 goto fail;
7424 }
7425
7426 EXIT();
7427 vos_mem_free(del_req);
7428 return 0;
7429
7430fail:
7431 vos_mem_free(del_req);
7432 return -EINVAL;
7433}
7434
7435
7436/**
7437 * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets
7438 * @wiphy: Pointer to wireless phy
7439 * @wdev: Pointer to wireless device
7440 * @data: Pointer to data
7441 * @data_len: Data length
7442 *
7443 * Return: 0 on success, negative errno on failure
7444 */
7445static int
7446__wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7447 struct wireless_dev *wdev,
7448 const void *data,
7449 int data_len)
7450{
7451 struct net_device *dev = wdev->netdev;
7452 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7453 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7454 struct nlattr *tb[PARAM_MAX + 1];
7455 uint8_t control;
7456 int ret;
7457 static const struct nla_policy policy[PARAM_MAX + 1] =
7458 {
7459 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
7460 [PARAM_CONTROL] = { .type = NLA_U32 },
7461 [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY,
7462 .len = VOS_MAC_ADDR_SIZE },
7463 [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY,
7464 .len = VOS_MAC_ADDR_SIZE },
7465 [PARAM_PERIOD] = { .type = NLA_U32 },
7466 };
7467
7468 ENTER();
7469
7470 ret = wlan_hdd_validate_context(hdd_ctx);
7471 if (0 != ret)
7472 {
7473 hddLog(LOGE, FL("HDD context is not valid"));
7474 return ret;
7475 }
7476
7477 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
7478 {
7479 hddLog(LOGE,
7480 FL("Periodic Tx Pattern Offload feature is not supported in FW!"));
7481 return -ENOTSUPP;
7482 }
7483
7484 if (nla_parse(tb, PARAM_MAX, data, data_len, policy))
7485 {
7486 hddLog(LOGE, FL("Invalid ATTR"));
7487 return -EINVAL;
7488 }
7489
7490 if (!tb[PARAM_CONTROL])
7491 {
7492 hddLog(LOGE, FL("attr control failed"));
7493 return -EINVAL;
7494 }
7495 control = nla_get_u32(tb[PARAM_CONTROL]);
7496 hddLog(LOG1, FL("Control: %d"), control);
7497
7498 if (control == WLAN_START_OFFLOADED_PACKETS)
7499 return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb);
7500 else if (control == WLAN_STOP_OFFLOADED_PACKETS)
7501 return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb);
7502 else
7503 {
7504 hddLog(LOGE, FL("Invalid control: %d"), control);
7505 return -EINVAL;
7506 }
7507}
7508
7509/*
7510 * done with short names for the global vendor params
7511 * used by __wlan_hdd_cfg80211_offloaded_packets()
7512 */
7513#undef PARAM_MAX
7514#undef PARAM_REQUEST_ID
7515#undef PARAM_CONTROL
7516#undef PARAM_IP_PACKET
7517#undef PARAM_SRC_MAC_ADDR
7518#undef PARAM_DST_MAC_ADDR
7519#undef PARAM_PERIOD
7520
7521/**
7522 * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets
7523 * @wiphy: wiphy structure pointer
7524 * @wdev: Wireless device structure pointer
7525 * @data: Pointer to the data received
7526 * @data_len: Length of @data
7527 *
7528 * Return: 0 on success; errno on failure
7529 */
7530static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7531 struct wireless_dev *wdev,
7532 const void *data,
7533 int data_len)
7534{
7535 int ret = 0;
7536
7537 vos_ssr_protect(__func__);
7538 ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy,
7539 wdev, data, data_len);
7540 vos_ssr_unprotect(__func__);
7541
7542 return ret;
7543}
7544#endif
7545
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307546static const struct
7547nla_policy
7548qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = {
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05307549 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = {
7550 .type = NLA_BINARY,
7551 .len = HDD_MAC_ADDR_LEN},
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307552};
7553
7554/**
7555 * wlan_hdd_cfg80211_get_link_properties() - This function is used to
7556 * get link properties like nss, rate flags and operating frequency for
7557 * the connection with the given peer.
7558 * @wiphy: WIPHY structure pointer
7559 * @wdev: Wireless device structure pointer
7560 * @data: Pointer to the data received
7561 * @data_len: Length of the data received
7562 *
7563 * This function return the above link properties on success.
7564 *
7565 * Return: 0 on success and errno on failure
7566 */
7567static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
7568 struct wireless_dev *wdev,
7569 const void *data,
7570 int data_len)
7571{
7572 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7573 struct net_device *dev = wdev->netdev;
7574 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7575 hdd_station_ctx_t *hdd_sta_ctx;
7576 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1];
7577 uint8_t peer_mac[VOS_MAC_ADDR_SIZE];
7578 uint32_t sta_id;
7579 struct sk_buff *reply_skb;
7580 uint32_t rate_flags = 0;
7581 uint8_t nss;
7582 uint8_t final_rate_flags = 0;
7583 uint32_t freq;
7584 v_CONTEXT_t pVosContext = NULL;
7585 ptSapContext pSapCtx = NULL;
7586
7587 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
7588 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
7589 return -EINVAL;
7590 }
7591
7592 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7593 qca_wlan_vendor_attr_policy)) {
7594 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute"));
7595 return -EINVAL;
7596 }
7597
7598 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
7599 hddLog(VOS_TRACE_LEVEL_ERROR,
7600 FL("Attribute peerMac not provided for mode=%d"),
7601 adapter->device_mode);
7602 return -EINVAL;
7603 }
7604
Ashish Kumar Dhanotiyaddaf0482017-06-23 15:22:42 +05307605 if (nla_len(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) < sizeof(peer_mac)) {
7606 hddLog(VOS_TRACE_LEVEL_ERROR,
7607 FL("Attribute peerMac is invalid=%d"),
7608 adapter->device_mode);
7609 return -EINVAL;
7610 }
7611
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307612 memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
7613 sizeof(peer_mac));
7614 hddLog(VOS_TRACE_LEVEL_INFO,
7615 FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"),
7616 MAC_ADDR_ARRAY(peer_mac), adapter->device_mode);
7617
7618 if (adapter->device_mode == WLAN_HDD_INFRA_STATION ||
7619 adapter->device_mode == WLAN_HDD_P2P_CLIENT) {
7620 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
7621 if ((hdd_sta_ctx->conn_info.connState !=
7622 eConnectionState_Associated) ||
7623 !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac,
7624 VOS_MAC_ADDRESS_LEN)) {
7625 hddLog(VOS_TRACE_LEVEL_ERROR,
7626 FL("Not Associated to mac "MAC_ADDRESS_STR),
7627 MAC_ADDR_ARRAY(peer_mac));
7628 return -EINVAL;
7629 }
7630
7631 nss = 1; //pronto supports only one spatial stream
7632 freq = vos_chan_to_freq(
7633 hdd_sta_ctx->conn_info.operationChannel);
7634 rate_flags = hdd_sta_ctx->conn_info.rate_flags;
7635
7636 } else if (adapter->device_mode == WLAN_HDD_P2P_GO ||
7637 adapter->device_mode == WLAN_HDD_SOFTAP) {
7638
7639 pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext;
7640 pSapCtx = VOS_GET_SAP_CB(pVosContext);
7641 if(pSapCtx == NULL){
7642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7643 FL("psapCtx is NULL"));
7644 return -ENOENT;
7645 }
7646
7647
7648 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
7649 if (pSapCtx->aStaInfo[sta_id].isUsed &&
7650 !vos_is_macaddr_broadcast(
7651 &pSapCtx->aStaInfo[sta_id].macAddrSTA) &&
7652 vos_mem_compare(
7653 &pSapCtx->aStaInfo[sta_id].macAddrSTA,
7654 peer_mac, VOS_MAC_ADDRESS_LEN))
7655 break;
7656 }
7657
7658 if (WLAN_MAX_STA_COUNT == sta_id) {
7659 hddLog(VOS_TRACE_LEVEL_ERROR,
7660 FL("No active peer with mac="MAC_ADDRESS_STR),
7661 MAC_ADDR_ARRAY(peer_mac));
7662 return -EINVAL;
7663 }
7664
7665 nss = 1; //pronto supports only one spatial stream
7666 freq = vos_chan_to_freq(
7667 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel);
7668 rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags;
7669 } else {
7670 hddLog(VOS_TRACE_LEVEL_ERROR,
7671 FL("Not Associated! with mac"MAC_ADDRESS_STR),
7672 MAC_ADDR_ARRAY(peer_mac));
7673 return -EINVAL;
7674 }
7675
7676 if (!(rate_flags & eHAL_TX_RATE_LEGACY)) {
7677 if (rate_flags & eHAL_TX_RATE_VHT80) {
7678 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307679#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
7680 !defined(WITH_BACKPORTS)
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307681 final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307682#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307683 } else if (rate_flags & eHAL_TX_RATE_VHT40) {
7684 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307685#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
7686 !defined(WITH_BACKPORTS)
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307687 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307688#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307689 } else if (rate_flags & eHAL_TX_RATE_VHT20) {
7690 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7691 } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) {
7692 final_rate_flags |= RATE_INFO_FLAGS_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307693#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
7694 !defined(WITH_BACKPORTS)
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307695 if (rate_flags & eHAL_TX_RATE_HT40)
7696 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307697#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307698 }
7699
7700 if (rate_flags & eHAL_TX_RATE_SGI) {
7701 if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS))
7702 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7703 final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI;
7704 }
7705 }
7706
7707 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7708 sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN);
7709
7710 if (NULL == reply_skb) {
7711 hddLog(VOS_TRACE_LEVEL_ERROR,
7712 FL("getLinkProperties: skb alloc failed"));
7713 return -EINVAL;
7714 }
7715
7716 if (nla_put_u8(reply_skb,
7717 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS,
7718 nss) ||
7719 nla_put_u8(reply_skb,
7720 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS,
7721 final_rate_flags) ||
7722 nla_put_u32(reply_skb,
7723 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ,
7724 freq)) {
7725 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed"));
7726 kfree_skb(reply_skb);
7727 return -EINVAL;
7728 }
7729
7730 return cfg80211_vendor_cmd_reply(reply_skb);
7731}
7732
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307733#define BEACON_MISS_THRESH_2_4 \
7734 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24
7735#define BEACON_MISS_THRESH_5_0 \
7736 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307737#define PARAM_WIFICONFIG_MAX QCA_WLAN_VENDOR_ATTR_CONFIG_MAX
7738#define PARAM_MODULATED_DTIM QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM
7739#define PARAM_STATS_AVG_FACTOR QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR
7740#define PARAM_GUARD_TIME QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307741#define PARAM_BCNMISS_PENALTY_PARAM_COUNT \
7742 QCA_WLAN_VENDOR_ATTR_CONFIG_PENALIZE_AFTER_NCONS_BEACON_MISS
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05307743#define PARAM_FORCE_RSN_IE \
7744 QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE
Ashish Kumar Dhanotiyaf59c7762018-04-10 17:54:25 +05307745/*
7746 * hdd_set_qpower() - Process the qpower command and invoke the SME api
7747 * @hdd_ctx: hdd context
7748 * @enable: Value received in the command, 1 for disable and 2 for enable
7749 *
7750 * Return: void
7751 */
7752static void hdd_set_qpower(hdd_context_t *hdd_ctx, uint8_t enable)
7753{
7754 if (!hdd_ctx) {
7755 hddLog(LOGE, "hdd_ctx NULL");
7756 return;
7757 }
7758
7759 sme_set_qpower(hdd_ctx->hHal, enable);
7760}
7761
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307762/**
7763 * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7764 * vendor command
7765 *
7766 * @wiphy: wiphy device pointer
7767 * @wdev: wireless device pointer
7768 * @data: Vendor command data buffer
7769 * @data_len: Buffer length
7770 *
7771 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7772 *
7773 * Return: EOK or other error codes.
7774 */
7775
7776static int __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7777 struct wireless_dev *wdev,
7778 const void *data,
7779 int data_len)
7780{
7781 struct net_device *dev = wdev->netdev;
7782 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7783 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7784 hdd_station_ctx_t *pHddStaCtx;
7785 struct nlattr *tb[PARAM_WIFICONFIG_MAX + 1];
7786 tpSetWifiConfigParams pReq;
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307787 tModifyRoamParamsReqParams modifyRoamParamsReq;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307788 eHalStatus status;
7789 int ret_val;
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307790 uint8_t hb_thresh_val;
Ashish Kumar Dhanotiyaf59c7762018-04-10 17:54:25 +05307791 uint8_t qpower;
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307792
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307793 static const struct nla_policy policy[PARAM_WIFICONFIG_MAX + 1] = {
7794 [PARAM_STATS_AVG_FACTOR] = { .type = NLA_U16 },
7795 [PARAM_MODULATED_DTIM] = { .type = NLA_U32 },
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307796 [PARAM_GUARD_TIME] = { .type = NLA_U32},
7797 [PARAM_BCNMISS_PENALTY_PARAM_COUNT] =
7798 { .type = NLA_U32},
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307799 [BEACON_MISS_THRESH_2_4] = { .type = NLA_U8 },
7800 [BEACON_MISS_THRESH_5_0] = { .type = NLA_U8 },
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05307801 [PARAM_FORCE_RSN_IE] = {.type = NLA_U8 },
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307802 };
7803
7804 ENTER();
7805
7806 if (VOS_FTM_MODE == hdd_get_conparam()) {
7807 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7808 return -EINVAL;
7809 }
7810
7811 ret_val = wlan_hdd_validate_context(pHddCtx);
7812 if (ret_val) {
7813 return ret_val;
7814 }
7815
7816 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7817
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307818 if (nla_parse(tb, PARAM_WIFICONFIG_MAX, data, data_len, policy)) {
7819 hddLog(LOGE, FL("Invalid ATTR"));
7820 return -EINVAL;
7821 }
7822
7823 /* check the Wifi Capability */
7824 if ( (TRUE != pHddCtx->cfg_ini->fEnableWifiConfig) &&
7825 (TRUE != sme_IsFeatureSupportedByFW(WIFI_CONFIG)))
7826 {
7827 hddLog(VOS_TRACE_LEVEL_ERROR,
7828 FL("WIFICONFIG not supported by Firmware"));
7829 return -EINVAL;
7830 }
7831
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307832 if (tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]) {
7833 modifyRoamParamsReq.param = WIFI_CONFIG_SET_BCNMISS_PENALTY_COUNT;
7834 modifyRoamParamsReq.value =
7835 nla_get_u32(tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]);
7836
7837 if (eHAL_STATUS_SUCCESS !=
7838 sme_setBcnMissPenaltyCount(pHddCtx->hHal,&modifyRoamParamsReq))
7839 {
7840 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed", __func__);
7841 ret_val = -EINVAL;
7842 }
7843 return ret_val;
7844 }
7845
7846 /* Moved this down in order to provide provision to set beacon
7847 * miss penalty count irrespective of connection state.
7848 */
7849 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
7850 hddLog(LOGE, FL("Not in Connected state!"));
7851 return -ENOTSUPP;
7852 }
7853
7854 pReq = vos_mem_malloc(sizeof(tSetWifiConfigParams));
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307855
7856 if (!pReq) {
7857 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7858 "%s: Not able to allocate memory for tSetWifiConfigParams",
7859 __func__);
7860 return eHAL_STATUS_E_MALLOC_FAILED;
7861 }
7862
7863 vos_mem_set(pReq, sizeof(tSetWifiConfigParams), 0);
7864
7865 pReq->sessionId = pAdapter->sessionId;
7866 vos_mem_copy( &pReq->bssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
7867
7868 if (tb[PARAM_MODULATED_DTIM]) {
7869 pReq->paramValue = nla_get_u32(
7870 tb[PARAM_MODULATED_DTIM]);
7871 hddLog(LOG1, FL("Modulated DTIM: pReq->paramValue:%d "),
7872 pReq->paramValue);
Arun Khandavalli876886f2015-11-23 11:42:27 +05307873 pHddCtx->cfg_ini->enableDynamicDTIM = pReq->paramValue;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307874 hdd_set_pwrparams(pHddCtx);
7875 if (BMPS == pmcGetPmcState(pHddCtx->hHal)) {
7876 hddLog( LOG1, FL("WifiConfig: Requesting FullPower!"));
7877
7878 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
7879 iw_full_power_cbfn, pAdapter,
7880 eSME_FULL_PWR_NEEDED_BY_HDD);
7881 }
7882 else
7883 {
7884 hddLog( LOG1, FL("WifiConfig Not in BMPS state"));
7885 }
7886 }
7887
7888 if (tb[PARAM_STATS_AVG_FACTOR]) {
7889 pReq->paramType = WIFI_CONFIG_SET_AVG_STATS_FACTOR;
7890 pReq->paramValue = nla_get_u16(
7891 tb[PARAM_STATS_AVG_FACTOR]);
7892 hddLog(LOG1, FL("AVG_STATS_FACTOR pReq->paramType:%d,pReq->paramValue:%d "),
7893 pReq->paramType, pReq->paramValue);
7894 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7895
7896 if (eHAL_STATUS_SUCCESS != status)
7897 {
7898 vos_mem_free(pReq);
7899 pReq = NULL;
7900 ret_val = -EPERM;
7901 return ret_val;
7902 }
7903 }
7904
7905
7906 if (tb[PARAM_GUARD_TIME]) {
7907 pReq->paramType = WIFI_CONFIG_SET_GUARD_TIME;
7908 pReq->paramValue = nla_get_u32(
7909 tb[PARAM_GUARD_TIME]);
7910 hddLog(LOG1, FL("GUARD_TIME pReq->paramType:%d,pReq->paramValue:%d "),
7911 pReq->paramType, pReq->paramValue);
7912 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7913
7914 if (eHAL_STATUS_SUCCESS != status)
7915 {
7916 vos_mem_free(pReq);
7917 pReq = NULL;
7918 ret_val = -EPERM;
7919 return ret_val;
7920 }
7921
7922 }
7923
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307924 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]) {
7925 hb_thresh_val = nla_get_u8(
7926 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]);
7927
7928 hddLog(LOG1, "WLAN set heartbeat threshold for 2.4Ghz %d",
7929 hb_thresh_val);
7930 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7931 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
7932 NULL, eANI_BOOLEAN_FALSE);
7933
7934 status = sme_update_hb_threshold(
7935 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
7936 WNI_CFG_HEART_BEAT_THRESHOLD,
7937 hb_thresh_val, eCSR_BAND_24);
7938 if (eHAL_STATUS_SUCCESS != status) {
7939 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
7940 vos_mem_free(pReq);
7941 pReq = NULL;
7942 return -EPERM;
7943 }
7944 }
7945
7946 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]) {
7947 hb_thresh_val = nla_get_u8(
7948 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]);
7949
7950 hddLog(LOG1, "WLAN set heartbeat threshold for 5Ghz %d",
7951 hb_thresh_val);
7952 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7953 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
7954 NULL, eANI_BOOLEAN_FALSE);
7955
7956 status = sme_update_hb_threshold(
7957 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
7958 WNI_CFG_HEART_BEAT_THRESHOLD,
7959 hb_thresh_val, eCSR_BAND_5G);
7960 if (eHAL_STATUS_SUCCESS != status) {
7961 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
7962 vos_mem_free(pReq);
7963 pReq = NULL;
7964 return -EPERM;
7965 }
7966 }
7967
Ashish Kumar Dhanotiyaf59c7762018-04-10 17:54:25 +05307968 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER]) {
7969 qpower = nla_get_u8(
7970 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER]);
7971
7972 if(qpower > 1) {
7973 hddLog(LOGE, "Invalid QPOWER value %d", qpower);
7974 vos_mem_free(pReq);
7975 pReq = NULL;
7976 return -EINVAL;
7977 }
7978 /* FW is expacting qpower as 1 for Disable and 2 for enable */
7979 qpower++;
7980 hdd_set_qpower(pHddCtx, qpower);
7981 }
7982
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05307983 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE] &&
7984 pHddCtx->cfg_ini->force_rsne_override) {
7985 uint8_t force_rsne_override;
7986
7987 force_rsne_override =
7988 nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE]);
7989 if (force_rsne_override > 1) {
7990 hddLog(LOGE, "Invalid test_mode %d", force_rsne_override);
7991 ret_val = -EINVAL;
7992 }
7993 pHddCtx->force_rsne_override = force_rsne_override;
7994 hddLog(LOG1, "force_rsne_override - %d",
7995 pHddCtx->force_rsne_override);
7996 }
7997
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307998 EXIT();
7999 return ret_val;
8000}
8001
8002/**
8003 * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
8004 * vendor command
8005 *
8006 * @wiphy: wiphy device pointer
8007 * @wdev: wireless device pointer
8008 * @data: Vendor command data buffer
8009 * @data_len: Buffer length
8010 *
8011 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
8012 *
8013 * Return: EOK or other error codes.
8014 */
8015static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
8016 struct wireless_dev *wdev,
8017 const void *data,
8018 int data_len)
8019{
8020 int ret;
8021
8022 vos_ssr_protect(__func__);
8023 ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev,
8024 data, data_len);
8025 vos_ssr_unprotect(__func__);
8026
8027 return ret;
8028}
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308029
8030/*
8031 * define short names for the global vendor params
8032 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
8033 */
8034#define STATS_SET_INVALID \
8035 QCA_ATTR_NUD_STATS_SET_INVALID
8036#define STATS_SET_START \
8037 QCA_ATTR_NUD_STATS_SET_START
8038#define STATS_GW_IPV4 \
8039 QCA_ATTR_NUD_STATS_GW_IPV4
8040#define STATS_SET_MAX \
8041 QCA_ATTR_NUD_STATS_SET_MAX
8042
8043const struct nla_policy
8044qca_wlan_vendor_set_nud_stats[STATS_SET_MAX +1] =
8045{
8046 [STATS_SET_START] = {.type = NLA_FLAG },
8047 [STATS_GW_IPV4] = {.type = NLA_U32 },
8048};
8049
8050/**
8051 * hdd_set_nud_stats_cb() - hdd callback api to get status
8052 * @data: pointer to adapter
8053 * @rsp: status
8054 *
8055 * Return: None
8056 */
8057static void hdd_set_nud_stats_cb(void *data, VOS_STATUS rsp)
8058{
8059
8060 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
8061
8062 if (NULL == adapter)
8063 return;
8064
8065 if (VOS_STATUS_SUCCESS == rsp) {
8066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8067 "%s success received STATS_SET_START", __func__);
8068 } else {
8069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8070 "%s STATS_SET_START Failed!!", __func__);
8071 }
8072 return;
8073}
8074
8075/**
8076 * __wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
8077 * @wiphy: pointer to wireless wiphy structure.
8078 * @wdev: pointer to wireless_dev structure.
8079 * @data: pointer to apfind configuration data.
8080 * @data_len: the length in byte of apfind data.
8081 *
8082 * This is called when wlan driver needs to send arp stats to
8083 * firmware.
8084 *
8085 * Return: An error code or 0 on success.
8086 */
8087static int __wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
8088 struct wireless_dev *wdev,
8089 const void *data, int data_len)
8090{
8091 struct nlattr *tb[STATS_SET_MAX + 1];
8092 struct net_device *dev = wdev->netdev;
8093 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8094 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308095 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308096 setArpStatsParams arp_stats_params;
8097 int err = 0;
8098
8099 ENTER();
8100
8101 err = wlan_hdd_validate_context(hdd_ctx);
8102 if (0 != err)
8103 return err;
8104
8105 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
8106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8107 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
8108 return -EINVAL;
8109 }
8110
8111 err = nla_parse(tb, STATS_SET_MAX, data, data_len,
8112 qca_wlan_vendor_set_nud_stats);
8113 if (err)
8114 {
8115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8116 "%s STATS_SET_START ATTR", __func__);
8117 return err;
8118 }
8119
8120 if (tb[STATS_SET_START])
8121 {
8122 if (!tb[STATS_GW_IPV4]) {
8123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8124 "%s STATS_SET_START CMD", __func__);
8125 return -EINVAL;
8126 }
8127 arp_stats_params.flag = true;
8128 arp_stats_params.ip_addr = nla_get_u32(tb[STATS_GW_IPV4]);
8129 } else {
8130 arp_stats_params.flag = false;
8131 }
Anurag Chouhan630c5562017-03-23 14:51:47 +05308132 if (arp_stats_params.flag)
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8134 "%s STATS_SET_START Cleared!!", __func__);
Anurag Chouhan630c5562017-03-23 14:51:47 +05308135 vos_mem_zero(&adapter->hdd_stats.hddArpStats,
8136 sizeof(adapter->hdd_stats.hddArpStats));
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308137
8138 arp_stats_params.pkt_type = 1; // ARP packet type
8139
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308140 if (arp_stats_params.flag) {
8141 hdd_ctx->track_arp_ip = arp_stats_params.ip_addr;
8142 WLANTL_SetARPFWDatapath(pVosContext, true);
8143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8144 "%s Set FW in data path for ARP with tgt IP :%d",
8145 __func__, hdd_ctx->track_arp_ip);
8146 }
8147 else {
8148 WLANTL_SetARPFWDatapath(pVosContext, false);
8149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8150 "%s Remove FW from data path", __func__);
8151 }
8152
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308153 arp_stats_params.rsp_cb_fn = hdd_set_nud_stats_cb;
8154 arp_stats_params.data_ctx = adapter;
8155
8156 if (eHAL_STATUS_SUCCESS !=
8157 sme_set_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
8158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8159 "%s STATS_SET_START CMD Failed!!", __func__);
8160 return -EINVAL;
8161 }
8162
8163 EXIT();
8164
8165 return err;
8166}
8167
8168/**
8169 * wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
8170 * @wiphy: pointer to wireless wiphy structure.
8171 * @wdev: pointer to wireless_dev structure.
8172 * @data: pointer to apfind configuration data.
8173 * @data_len: the length in byte of apfind data.
8174 *
8175 * This is called when wlan driver needs to send arp stats to
8176 * firmware.
8177 *
8178 * Return: An error code or 0 on success.
8179 */
8180static int wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
8181 struct wireless_dev *wdev,
8182 const void *data, int data_len)
8183{
8184 int ret;
8185
8186 vos_ssr_protect(__func__);
8187 ret = __wlan_hdd_cfg80211_set_nud_stats(wiphy, wdev, data, data_len);
8188 vos_ssr_unprotect(__func__);
8189
8190 return ret;
8191}
8192#undef STATS_SET_INVALID
8193#undef STATS_SET_START
8194#undef STATS_GW_IPV4
8195#undef STATS_SET_MAX
8196
8197/*
8198 * define short names for the global vendor params
8199 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
8200 */
8201#define STATS_GET_INVALID \
8202 QCA_ATTR_NUD_STATS_SET_INVALID
8203#define COUNT_FROM_NETDEV \
8204 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
8205#define COUNT_TO_LOWER_MAC \
8206 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
8207#define RX_COUNT_BY_LOWER_MAC \
8208 QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
8209#define COUNT_TX_SUCCESS \
8210 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
8211#define RSP_RX_COUNT_BY_LOWER_MAC \
8212 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
8213#define RSP_RX_COUNT_BY_UPPER_MAC \
8214 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
8215#define RSP_COUNT_TO_NETDEV \
8216 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
8217#define RSP_COUNT_OUT_OF_ORDER_DROP \
8218 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
8219#define AP_LINK_ACTIVE \
8220 QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
8221#define AP_LINK_DAD \
8222 QCA_ATTR_NUD_STATS_AP_LINK_DAD
8223#define STATS_GET_MAX \
8224 QCA_ATTR_NUD_STATS_GET_MAX
8225
8226const struct nla_policy
8227qca_wlan_vendor_get_nud_stats[STATS_GET_MAX +1] =
8228{
8229 [COUNT_FROM_NETDEV] = {.type = NLA_U16 },
8230 [COUNT_TO_LOWER_MAC] = {.type = NLA_U16 },
8231 [RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
8232 [COUNT_TX_SUCCESS] = {.type = NLA_U16 },
8233 [RSP_RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
8234 [RSP_RX_COUNT_BY_UPPER_MAC] = {.type = NLA_U16 },
8235 [RSP_COUNT_TO_NETDEV] = {.type = NLA_U16 },
8236 [RSP_COUNT_OUT_OF_ORDER_DROP] = {.type = NLA_U16 },
8237 [AP_LINK_ACTIVE] = {.type = NLA_FLAG },
8238 [AP_LINK_DAD] = {.type = NLA_FLAG },
8239};
8240
8241static void hdd_get_nud_stats_cb(void *data, rsp_stats *rsp)
8242{
8243
8244 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
Hanumanth Reddy Pothula8f528c72018-02-26 16:49:25 +05308245 hdd_context_t *hdd_ctx;
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308246 struct hdd_nud_stats_context *context;
8247 int status;
8248
8249 ENTER();
8250
8251 if (NULL == adapter)
8252 return;
8253
Hanumanth Reddy Pothula8f528c72018-02-26 16:49:25 +05308254 if (!rsp) {
8255 hddLog(LOGE, FL("data is null"));
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308256 return;
8257 }
8258
Hanumanth Reddy Pothula8f528c72018-02-26 16:49:25 +05308259 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
8260 status = wlan_hdd_validate_context(hdd_ctx);
8261 if (0 != status) {
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308262 return;
8263 }
8264
8265 adapter->hdd_stats.hddArpStats.tx_fw_cnt = rsp->tx_fw_cnt;
8266 adapter->hdd_stats.hddArpStats.rx_fw_cnt = rsp->rx_fw_cnt;
8267 adapter->hdd_stats.hddArpStats.tx_ack_cnt = rsp->tx_ack_cnt;
8268 adapter->dad |= rsp->dad;
8269
8270 spin_lock(&hdd_context_lock);
8271 context = &hdd_ctx->nud_stats_context;
8272 complete(&context->response_event);
8273 spin_unlock(&hdd_context_lock);
8274
8275 return;
8276}
8277static int __wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
8278 struct wireless_dev *wdev,
8279 const void *data, int data_len)
8280{
8281 int err = 0;
8282 unsigned long rc;
8283 struct hdd_nud_stats_context *context;
8284 struct net_device *dev = wdev->netdev;
8285 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8286 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
8287 getArpStatsParams arp_stats_params;
8288 struct sk_buff *skb;
8289
8290 ENTER();
8291
8292 err = wlan_hdd_validate_context(hdd_ctx);
8293 if (0 != err)
8294 return err;
8295
8296 arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE;
8297 arp_stats_params.get_rsp_cb_fn = hdd_get_nud_stats_cb;
8298 arp_stats_params.data_ctx = adapter;
8299
8300 spin_lock(&hdd_context_lock);
8301 context = &hdd_ctx->nud_stats_context;
8302 INIT_COMPLETION(context->response_event);
8303 spin_unlock(&hdd_context_lock);
8304
8305 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
8306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8307 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
8308 return -EINVAL;
8309 }
8310
8311 if (eHAL_STATUS_SUCCESS !=
8312 sme_get_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
8313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8314 "%s STATS_SET_START CMD Failed!!", __func__);
8315 return -EINVAL;
8316 }
8317
8318 rc = wait_for_completion_timeout(&context->response_event,
8319 msecs_to_jiffies(WLAN_WAIT_TIME_NUD_STATS));
8320 if (!rc)
8321 {
8322 hddLog(LOGE,
8323 FL("Target response timed out request "));
8324 return -ETIMEDOUT;
8325 }
8326
8327 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
8328 WLAN_NUD_STATS_LEN);
8329 if (!skb)
8330 {
8331 hddLog(VOS_TRACE_LEVEL_ERROR,
8332 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
8333 __func__);
8334 return -ENOMEM;
8335 }
8336
8337 if (nla_put_u16(skb, COUNT_FROM_NETDEV,
8338 adapter->hdd_stats.hddArpStats.txCount) ||
8339 nla_put_u16(skb, COUNT_TO_LOWER_MAC,
8340 adapter->hdd_stats.hddArpStats.tx_host_fw_sent) ||
8341 nla_put_u16(skb, RX_COUNT_BY_LOWER_MAC,
8342 adapter->hdd_stats.hddArpStats.tx_fw_cnt) ||
8343 nla_put_u16(skb, COUNT_TX_SUCCESS,
8344 adapter->hdd_stats.hddArpStats.tx_ack_cnt) ||
8345 nla_put_u16(skb, RSP_RX_COUNT_BY_LOWER_MAC,
8346 adapter->hdd_stats.hddArpStats.rx_fw_cnt) ||
8347 nla_put_u16(skb, RSP_RX_COUNT_BY_UPPER_MAC,
8348 adapter->hdd_stats.hddArpStats.rxCount) ||
8349 nla_put_u16(skb, RSP_COUNT_TO_NETDEV,
8350 adapter->hdd_stats.hddArpStats.rxDelivered) ||
8351 nla_put_u16(skb, RSP_COUNT_OUT_OF_ORDER_DROP,
8352 adapter->hdd_stats.hddArpStats.rx_host_drop_reorder)) {
8353 hddLog(LOGE, FL("nla put fail"));
8354 kfree_skb(skb);
8355 return -EINVAL;
8356 }
8357 if (adapter->con_status)
8358 nla_put_flag(skb, AP_LINK_ACTIVE);
8359 if (adapter->dad)
8360 nla_put_flag(skb, AP_LINK_DAD);
8361
8362 cfg80211_vendor_cmd_reply(skb);
8363 return err;
8364}
8365
8366static int wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
8367 struct wireless_dev *wdev,
8368 const void *data, int data_len)
8369{
8370 int ret;
8371
8372 vos_ssr_protect(__func__);
8373 ret = __wlan_hdd_cfg80211_get_nud_stats(wiphy, wdev, data, data_len);
8374 vos_ssr_unprotect(__func__);
8375
8376 return ret;
8377}
8378
8379#undef QCA_ATTR_NUD_STATS_SET_INVALID
8380#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
8381#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
8382#undef QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
8383#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
8384#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
8385#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
8386#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
8387#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
8388#undef QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
8389#undef QCA_ATTR_NUD_STATS_GET_MAX
8390
8391
8392
Kapil Guptaee33bf12016-12-20 18:27:37 +05308393#ifdef WLAN_FEATURE_APFIND
8394/**
8395 * __wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
8396 * @wiphy: pointer to wireless wiphy structure.
8397 * @wdev: pointer to wireless_dev structure.
8398 * @data: pointer to apfind configuration data.
8399 * @data_len: the length in byte of apfind data.
8400 *
8401 * This is called when wlan driver needs to send APFIND configurations to
8402 * firmware.
8403 *
8404 * Return: An error code or 0 on success.
8405 */
8406static int __wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
8407 struct wireless_dev *wdev,
8408 const void *data, int data_len)
8409{
8410 struct sme_ap_find_request_req apfind_req;
8411 VOS_STATUS status;
8412 int ret_val;
8413 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
8414
8415 ENTER();
8416
8417 ret_val = wlan_hdd_validate_context(hdd_ctx);
8418 if (ret_val)
8419 return ret_val;
8420
8421 if (VOS_FTM_MODE == hdd_get_conparam()) {
8422 hddLog(LOGE, FL("Command not allowed in FTM mode"));
8423 return -EPERM;
8424 }
8425
8426 apfind_req.request_data_len = data_len;
8427 apfind_req.request_data = data;
8428
8429 status = sme_apfind_set_cmd(&apfind_req);
8430 if (VOS_STATUS_SUCCESS != status) {
8431 ret_val = -EIO;
8432 }
8433 return ret_val;
8434}
8435
8436/**
8437 * wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
8438 * @wiphy: pointer to wireless wiphy structure.
8439 * @wdev: pointer to wireless_dev structure.
8440 * @data: pointer to apfind configuration data.
8441 * @data_len: the length in byte of apfind data.
8442 *
8443 * This is called when wlan driver needs to send APFIND configurations to
8444 * firmware.
8445 *
8446 * Return: An error code or 0 on success.
8447 */
8448static int wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
8449 struct wireless_dev *wdev,
8450 const void *data, int data_len)
8451{
8452 int ret;
8453
8454 vos_ssr_protect(__func__);
8455 ret = __wlan_hdd_cfg80211_apfind_cmd(wiphy, wdev, data, data_len);
8456 vos_ssr_unprotect(__func__);
8457
8458 return ret;
8459}
8460#endif /* WLAN_FEATURE_APFIND */
Hanumanth Reddy Pothula49c3f902018-02-16 16:01:13 +05308461
8462/**
8463 * __wlan_hdd_cfg80211_get_logger_supp_feature() - Get the wifi logger features
8464 * @wiphy: pointer to wireless wiphy structure.
8465 * @wdev: pointer to wireless_dev structure.
8466 * @data: Pointer to the data to be passed via vendor interface
8467 * @data_len:Length of the data to be passed
8468 *
8469 * This is called by userspace to know the supported logger features
8470 *
8471 * Return: Return the Success or Failure code.
8472 */
8473static int
8474__wlan_hdd_cfg80211_get_logger_supp_feature(struct wiphy *wiphy,
8475 struct wireless_dev *wdev,
8476 const void *data, int data_len)
8477{
8478 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
8479 int status;
8480 uint32_t features;
8481 struct sk_buff *reply_skb = NULL;
8482
8483 if (VOS_FTM_MODE == hdd_get_conparam()) {
8484 hddLog(LOGE, FL("Command not allowed in FTM mode"));
8485 return -EINVAL;
8486 }
8487
8488 status = wlan_hdd_validate_context(hdd_ctx);
8489 if (0 != status)
8490 return -EINVAL;
8491
8492 features = 0;
8493
Hanumanth Reddy Pothula49c3f902018-02-16 16:01:13 +05308494 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
8495 sizeof(uint32_t) + NLA_HDRLEN + NLMSG_HDRLEN);
8496 if (!reply_skb) {
8497 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
8498 return -ENOMEM;
8499 }
8500
8501 hddLog(LOG1, FL("Supported logger features: 0x%0x"), features);
8502 if (nla_put_u32(reply_skb, QCA_WLAN_VENDOR_ATTR_LOGGER_SUPPORTED,
8503 features)) {
8504 hddLog(LOGE, FL("nla put fail"));
8505 kfree_skb(reply_skb);
8506 return -EINVAL;
8507 }
8508
8509 return cfg80211_vendor_cmd_reply(reply_skb);
8510}
8511
8512/**
8513 * wlan_hdd_cfg80211_get_logger_supp_feature() - Get the wifi logger features
8514 * @wiphy: pointer to wireless wiphy structure.
8515 * @wdev: pointer to wireless_dev structure.
8516 * @data: Pointer to the data to be passed via vendor interface
8517 * @data_len:Length of the data to be passed
8518 *
8519 * This is called by userspace to know the supported logger features
8520 *
8521 * Return: Return the Success or Failure code.
8522 */
8523static int
8524wlan_hdd_cfg80211_get_logger_supp_feature(struct wiphy *wiphy,
8525 struct wireless_dev *wdev,
8526 const void *data, int data_len)
8527{
8528 int ret;
8529
8530 vos_ssr_protect(__func__);
8531 ret = __wlan_hdd_cfg80211_get_logger_supp_feature(wiphy, wdev,
8532 data, data_len);
8533 vos_ssr_unprotect(__func__);
8534
8535 return ret;
8536}
8537
Sunil Duttc69bccb2014-05-26 21:30:20 +05308538const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
8539{
Mukul Sharma2a271632014-10-13 14:59:01 +05308540 {
8541 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8542 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
8543 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8544 WIPHY_VENDOR_CMD_NEED_NETDEV |
8545 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308546 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05308547 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05308548
8549 {
8550 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8551 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
8552 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8553 WIPHY_VENDOR_CMD_NEED_NETDEV |
8554 WIPHY_VENDOR_CMD_NEED_RUNNING,
8555 .doit = wlan_hdd_cfg80211_nan_request
8556 },
8557
Sunil Duttc69bccb2014-05-26 21:30:20 +05308558#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8559 {
8560 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8561 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
8562 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8563 WIPHY_VENDOR_CMD_NEED_NETDEV |
8564 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308565 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05308566 },
8567
8568 {
8569 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8570 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
8571 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8572 WIPHY_VENDOR_CMD_NEED_NETDEV |
8573 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308574 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05308575 },
8576
8577 {
8578 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8579 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
8580 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8581 WIPHY_VENDOR_CMD_NEED_NETDEV |
8582 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308583 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05308584 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308585#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05308586#ifdef WLAN_FEATURE_EXTSCAN
8587 {
8588 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8589 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
8590 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8591 WIPHY_VENDOR_CMD_NEED_NETDEV |
8592 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308593 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05308594 },
8595 {
8596 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8597 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
8598 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8599 WIPHY_VENDOR_CMD_NEED_NETDEV |
8600 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308601 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05308602 },
8603 {
8604 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8605 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
8606 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8607 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308608 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05308609 },
8610 {
8611 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8612 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
8613 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8614 WIPHY_VENDOR_CMD_NEED_NETDEV |
8615 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308616 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05308617 },
8618 {
8619 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8620 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
8621 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8622 WIPHY_VENDOR_CMD_NEED_NETDEV |
8623 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308624 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05308625 },
8626 {
8627 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8628 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
8629 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8630 WIPHY_VENDOR_CMD_NEED_NETDEV |
8631 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308632 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05308633 },
8634 {
8635 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8636 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
8637 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8638 WIPHY_VENDOR_CMD_NEED_NETDEV |
8639 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308640 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05308641 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05308642#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05308643/*EXT TDLS*/
8644 {
8645 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8646 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
8647 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8648 WIPHY_VENDOR_CMD_NEED_NETDEV |
8649 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308650 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05308651 },
8652 {
8653 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8654 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
8655 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8656 WIPHY_VENDOR_CMD_NEED_NETDEV |
8657 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308658 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05308659 },
8660 {
8661 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8662 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
8663 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8664 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308665 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05308666 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05308667 {
8668 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8669 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
8670 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8671 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308672 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05308673 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05308674 {
8675 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8676 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
8677 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8678 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308679 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05308680 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05308681 {
8682 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8683 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
8684 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8685 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308686 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05308687 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05308688 {
8689 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8690 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
8691 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8692 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308693 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05308694 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05308695 {
8696 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8697 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
8698 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8699 WIPHY_VENDOR_CMD_NEED_NETDEV |
8700 WIPHY_VENDOR_CMD_NEED_RUNNING,
8701 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05308702 },
8703 {
8704 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8705 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
8706 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8707 WIPHY_VENDOR_CMD_NEED_NETDEV,
8708 .doit = wlan_hdd_cfg80211_wifi_logger_start
8709 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05308710 {
8711 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8712 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
8713 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8714 WIPHY_VENDOR_CMD_NEED_NETDEV|
8715 WIPHY_VENDOR_CMD_NEED_RUNNING,
8716 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05308717 },
8718 {
8719 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8720 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
8721 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8722 WIPHY_VENDOR_CMD_NEED_NETDEV |
8723 WIPHY_VENDOR_CMD_NEED_RUNNING,
8724 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05308725 },
8726 {
8727 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8728 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
8729 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8730 WIPHY_VENDOR_CMD_NEED_NETDEV |
8731 WIPHY_VENDOR_CMD_NEED_RUNNING,
8732 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05308733 },
8734#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
8735 {
8736 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8737 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
8738 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8739 WIPHY_VENDOR_CMD_NEED_NETDEV |
8740 WIPHY_VENDOR_CMD_NEED_RUNNING,
8741 .doit = wlan_hdd_cfg80211_offloaded_packets
Deepthi Gowriae6a1662015-10-12 12:59:37 +05308742 },
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05308743#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05308744 {
8745 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8746 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
8747 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8748 WIPHY_VENDOR_CMD_NEED_NETDEV |
8749 WIPHY_VENDOR_CMD_NEED_RUNNING,
8750 .doit = wlan_hdd_cfg80211_get_link_properties
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05308751 },
8752 {
8753 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8754 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION,
8755 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8756 WIPHY_VENDOR_CMD_NEED_NETDEV |
8757 WIPHY_VENDOR_CMD_NEED_RUNNING,
8758 .doit = wlan_hdd_cfg80211_wifi_configuration_set
Kapil Guptaee33bf12016-12-20 18:27:37 +05308759 },
8760#ifdef WLAN_FEATURE_APFIND
8761 {
8762 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8763 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_APFIND,
8764 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8765 WIPHY_VENDOR_CMD_NEED_NETDEV,
8766 .doit = wlan_hdd_cfg80211_apfind_cmd
8767 },
8768#endif /* WLAN_FEATURE_APFIND */
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308769 {
8770 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8771 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_SET,
8772 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8773 WIPHY_VENDOR_CMD_NEED_NETDEV |
8774 WIPHY_VENDOR_CMD_NEED_RUNNING,
8775 .doit = wlan_hdd_cfg80211_set_nud_stats
8776 },
8777 {
8778 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8779 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
8780 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8781 WIPHY_VENDOR_CMD_NEED_NETDEV |
8782 WIPHY_VENDOR_CMD_NEED_RUNNING,
8783 .doit = wlan_hdd_cfg80211_get_nud_stats
8784 },
Anurag Chouhanfcd20172017-07-19 17:25:19 +05308785 {
8786 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8787 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_STATION,
8788 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8789 WIPHY_VENDOR_CMD_NEED_NETDEV |
8790 WIPHY_VENDOR_CMD_NEED_RUNNING,
8791 .doit = hdd_cfg80211_get_station_cmd
8792 },
Hanumanth Reddy Pothula49c3f902018-02-16 16:01:13 +05308793 {
8794 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8795 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_LOGGER_FEATURE_SET,
8796 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
Hanumanth Reddy Pothula07c95582018-05-23 12:41:22 +05308797 WIPHY_VENDOR_CMD_NEED_NETDEV,
Hanumanth Reddy Pothula49c3f902018-02-16 16:01:13 +05308798 .doit = wlan_hdd_cfg80211_get_logger_supp_feature
8799 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308800};
8801
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008802/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05308803static const
8804struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008805{
8806#ifdef FEATURE_WLAN_CH_AVOID
8807 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05308808 .vendor_id = QCA_NL80211_VENDOR_ID,
8809 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008810 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308811#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
8812#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8813 {
8814 /* Index = 1*/
8815 .vendor_id = QCA_NL80211_VENDOR_ID,
8816 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
8817 },
8818 {
8819 /* Index = 2*/
8820 .vendor_id = QCA_NL80211_VENDOR_ID,
8821 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
8822 },
8823 {
8824 /* Index = 3*/
8825 .vendor_id = QCA_NL80211_VENDOR_ID,
8826 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
8827 },
8828 {
8829 /* Index = 4*/
8830 .vendor_id = QCA_NL80211_VENDOR_ID,
8831 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
8832 },
8833 {
8834 /* Index = 5*/
8835 .vendor_id = QCA_NL80211_VENDOR_ID,
8836 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
8837 },
8838 {
8839 /* Index = 6*/
8840 .vendor_id = QCA_NL80211_VENDOR_ID,
8841 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
8842 },
8843#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05308844#ifdef WLAN_FEATURE_EXTSCAN
8845 {
8846 .vendor_id = QCA_NL80211_VENDOR_ID,
8847 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
8848 },
8849 {
8850 .vendor_id = QCA_NL80211_VENDOR_ID,
8851 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
8852 },
8853 {
8854 .vendor_id = QCA_NL80211_VENDOR_ID,
8855 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
8856 },
8857 {
8858 .vendor_id = QCA_NL80211_VENDOR_ID,
8859 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
8860 },
8861 {
8862 .vendor_id = QCA_NL80211_VENDOR_ID,
8863 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
8864 },
8865 {
8866 .vendor_id = QCA_NL80211_VENDOR_ID,
8867 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
8868 },
8869 {
8870 .vendor_id = QCA_NL80211_VENDOR_ID,
8871 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
8872 },
8873 {
8874 .vendor_id = QCA_NL80211_VENDOR_ID,
8875 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
8876 },
8877 {
8878 .vendor_id = QCA_NL80211_VENDOR_ID,
8879 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
8880 },
8881 {
8882 .vendor_id = QCA_NL80211_VENDOR_ID,
8883 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
8884 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05308885#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05308886/*EXT TDLS*/
8887 {
8888 .vendor_id = QCA_NL80211_VENDOR_ID,
8889 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
8890 },
Srinivas Dasaribd1cf642017-01-23 14:54:41 +05308891 [QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX] = {
Srinivas Dasari030bad32015-02-18 23:23:54 +05308892 .vendor_id = QCA_NL80211_VENDOR_ID,
8893 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
8894 },
8895
Sushant Kaushik084f6592015-09-10 13:11:56 +05308896 {
8897 .vendor_id = QCA_NL80211_VENDOR_ID,
8898 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05308899 },
8900 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
8901 .vendor_id = QCA_NL80211_VENDOR_ID,
8902 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
8903 },
Padma, Santhosh Kumar7bbc7d92015-12-08 20:23:19 +05308904 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = {
8905 .vendor_id = QCA_NL80211_VENDOR_ID,
8906 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST
8907 },
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308908 [QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET_INDEX] = {
8909 .vendor_id = QCA_NL80211_VENDOR_ID,
8910 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
8911 },
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +05308912 [QCA_NL80211_VENDOR_SUBCMD_HANG_REASON_INDEX] = {
8913 .vendor_id = QCA_NL80211_VENDOR_ID,
8914 .subcmd = QCA_NL80211_VENDOR_SUBCMD_HANG,
8915 },
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +05308916 [QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES_INDEX] = {
8917 .vendor_id = QCA_NL80211_VENDOR_ID,
8918 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
8919 },
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008920};
8921
Jeff Johnson295189b2012-06-20 16:38:30 -07008922/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308923 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308924 * This function is called by hdd_wlan_startup()
8925 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308926 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07008927 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308928struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07008929{
8930 struct wiphy *wiphy;
8931 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308932 /*
8933 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07008934 */
8935 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
8936
8937 if (!wiphy)
8938 {
8939 /* Print error and jump into err label and free the memory */
8940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
8941 return NULL;
8942 }
8943
Sunil Duttc69bccb2014-05-26 21:30:20 +05308944
Jeff Johnson295189b2012-06-20 16:38:30 -07008945 return wiphy;
8946}
8947
Anurag Chouhan343af7e2016-12-16 13:11:19 +05308948#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,4,0)) || \
8949 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
8950/**
8951 * hdd_config_sched_scan_plans_to_wiphy() - configure sched scan plans to wiphy
8952 * @wiphy: pointer to wiphy
8953 * @config: pointer to config
8954 *
8955 * Return: None
8956 */
8957static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
8958 hdd_config_t *config)
8959{
8960 wiphy->max_sched_scan_plans = MAX_SCHED_SCAN_PLANS;
8961 if (config->max_sched_scan_plan_interval)
8962 wiphy->max_sched_scan_plan_interval =
8963 config->max_sched_scan_plan_interval;
8964 if (config->max_sched_scan_plan_iterations)
8965 wiphy->max_sched_scan_plan_iterations =
8966 config->max_sched_scan_plan_iterations;
8967}
8968#else
8969static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
8970 hdd_config_t *config)
8971{
8972}
8973#endif
8974
Jeff Johnson295189b2012-06-20 16:38:30 -07008975/*
8976 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308977 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07008978 * private ioctl to change the band value
8979 */
8980int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
8981{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308982 int i, j;
8983 eNVChannelEnabledType channelEnabledState;
8984
Jeff Johnsone7245742012-09-05 17:12:55 -07008985 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308986
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05308987 for (i = 0; i < HDD_NUM_NL80211_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008988 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308989
8990 if (NULL == wiphy->bands[i])
8991 {
8992 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
8993 __func__, i);
8994 continue;
8995 }
8996
8997 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8998 {
8999 struct ieee80211_supported_band *band = wiphy->bands[i];
9000
9001 channelEnabledState = vos_nv_getChannelEnabledState(
9002 band->channels[j].hw_value);
9003
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309004 if (HDD_NL80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309005 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309006 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309007 continue;
9008 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309009 else if (HDD_NL80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309010 {
9011 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
9012 continue;
9013 }
9014
9015 if (NV_CHANNEL_DISABLE == channelEnabledState ||
9016 NV_CHANNEL_INVALID == channelEnabledState)
9017 {
9018 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
9019 }
9020 else if (NV_CHANNEL_DFS == channelEnabledState)
9021 {
9022 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
9023 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
9024 }
9025 else
9026 {
9027 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
9028 |IEEE80211_CHAN_RADAR);
9029 }
9030 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009031 }
9032 return 0;
9033}
Abhishek Singh2f3c4752018-04-11 14:58:53 +05309034
9035/**
9036 * hdd_add_channel_switch_support()- Adds Channel Switch flag if supported
9037 * @wiphy: Pointer to the wiphy.
9038 *
9039 * This Function adds Channel Switch support flag, if channel switch is
9040 * supported by kernel.
9041 * Return: void.
9042 */
9043#ifdef CHANNEL_SWITCH_SUPPORTED
9044static inline
9045void hdd_add_channel_switch_support(struct wiphy *wiphy)
9046{
9047 wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
9048 wiphy->max_num_csa_counters = WLAN_HDD_MAX_NUM_CSA_COUNTERS;
9049}
9050#else
9051static inline
9052void hdd_add_channel_switch_support(struct wiphy *wiphy)
9053{
9054}
9055#endif
9056
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05309057#if defined(CFG80211_SCAN_RANDOM_MAC_ADDR) || \
9058 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
9059void wlan_hdd_cfg80211_scan_randomization_init(struct wiphy *wiphy)
9060{
9061 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
9062 hdd_config_t *config = hdd_ctx->cfg_ini;
9063
9064 if (config->enableMacSpoofing != MAC_ADDR_SPOOFING_FW_HOST_ENABLE)
9065 return;
9066
9067 wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
9068}
9069#endif
9070
Abhinav Kumar118efd02019-08-07 16:41:07 +05309071#if defined(WLAN_FEATURE_SAE) && \
9072 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
Abhinav Kumar97821072019-08-02 14:29:48 +05309073/**
9074 * wlan_hdd_cfg80211_set_wiphy_sae_feature() - Indicates support of SAE feature
9075 * @wiphy: Pointer to wiphy
9076 * @config: pointer to config
9077 *
9078 * This function is used to indicate the support of SAE
9079 *
9080 * Return: None
9081 */
9082static
9083void wlan_hdd_cfg80211_set_wiphy_sae_feature(struct wiphy *wiphy,
9084 hdd_config_t *config)
9085{
9086 if (config->is_sae_enabled)
9087 wiphy->features |= NL80211_FEATURE_SAE;
9088}
9089#else
9090static
9091void wlan_hdd_cfg80211_set_wiphy_sae_feature(struct wiphy *wiphy,
9092 hdd_config_t *config)
9093{
9094}
9095#endif
9096
Jeff Johnson295189b2012-06-20 16:38:30 -07009097/*
9098 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309099 * This function is called by hdd_wlan_startup()
9100 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07009101 * This function is used to initialize and register wiphy structure.
9102 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309103int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009104 struct wiphy *wiphy,
9105 hdd_config_t *pCfg
9106 )
9107{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309108 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05309109 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9110
Jeff Johnsone7245742012-09-05 17:12:55 -07009111 ENTER();
9112
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 /* Now bind the underlying wlan device with wiphy */
9114 set_wiphy_dev(wiphy, dev);
9115
9116 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07009117
Kiet Lam6c583332013-10-14 05:37:09 +05309118#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07009119 /* the flag for the other case would be initialzed in
9120 vos_init_wiphy_from_nv_bin */
Manjeet Singh9e19de62016-08-18 18:26:41 +05309121#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
9122 wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
9123#else
Amar Singhal0a402232013-10-11 20:57:16 -07009124 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05309125#endif
Manjeet Singh9e19de62016-08-18 18:26:41 +05309126#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07009127
Amar Singhalfddc28c2013-09-05 13:03:40 -07009128 /* This will disable updating of NL channels from passive to
9129 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05309130#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
9131 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
9132#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07009133 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05309134#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07009135
Nachiket Kukade5b2e7332018-04-06 14:40:22 +05309136#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) || defined(WITH_BACKPORTS)
9137 wiphy->wowlan = &wowlan_support_cfg80211_init;
9138#else
Nachiket Kukade1e1b90e2018-05-10 15:26:13 +05309139 wiphy->wowlan.flags = WIPHY_WOWLAN_ANY |
9140 WIPHY_WOWLAN_MAGIC_PKT;
Nachiket Kukade5b2e7332018-04-06 14:40:22 +05309141 wiphy->wowlan.n_patterns = WOWL_MAX_PTRNS_ALLOWED;
9142 wiphy->wowlan.pattern_min_len = 1;
9143 wiphy->wowlan.pattern_max_len = WOWL_PTRN_MAX_SIZE;
9144#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07009145
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009146#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07009147 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
9148 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
9149 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07009150 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05309151#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Rajeev Kumar Sirasanagandla0d6dd752016-08-17 15:01:39 +05309152 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05309153#else
9154 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
9155#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009156#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07009157
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009158#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07009159 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08009160#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07009161 || pCfg->isFastRoamIniFeatureEnabled
9162#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009163#ifdef FEATURE_WLAN_ESE
9164 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07009165#endif
9166 )
9167 {
9168 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
9169 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08009170#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009171#ifdef FEATURE_WLAN_TDLS
9172 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
9173 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
9174#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309175#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05309176 if (pCfg->configPNOScanSupport)
9177 {
9178 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
9179 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
9180 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
9181 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
9182 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309183#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009184
Abhishek Singh10d85972015-04-17 10:27:23 +05309185#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
9186 wiphy->features |= NL80211_FEATURE_HT_IBSS;
9187#endif
9188
Amar Singhalfddc28c2013-09-05 13:03:40 -07009189#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07009190 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
9191 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07009192 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07009193 driver need to determine what to do with both
9194 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07009195
9196 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07009197#else
9198 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07009199#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009200
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309201 wiphy->max_scan_ssids = MAX_SCAN_SSID;
9202
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05309203 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07009204
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309205 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
9206
Jeff Johnson295189b2012-06-20 16:38:30 -07009207 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05309208 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
9209 | BIT(NL80211_IFTYPE_ADHOC)
9210 | BIT(NL80211_IFTYPE_P2P_CLIENT)
9211 | BIT(NL80211_IFTYPE_P2P_GO)
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05309212 | BIT(NL80211_IFTYPE_AP)
9213 | BIT(NL80211_IFTYPE_MONITOR);
Jeff Johnson295189b2012-06-20 16:38:30 -07009214
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309215 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009216 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309217#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
9218 if( pCfg->enableMCC )
9219 {
9220 /* Currently, supports up to two channels */
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05309221 wlan_hdd_iface_combination[0].num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009222
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309223 if( !pCfg->allowMCCGODiffBI )
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05309224 wlan_hdd_iface_combination[0].beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009225
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309226 }
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05309227 wiphy->iface_combinations = wlan_hdd_iface_combination;
9228 wiphy->n_iface_combinations = ARRAY_SIZE(wlan_hdd_iface_combination);
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009229#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309230 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009231
Jeff Johnson295189b2012-06-20 16:38:30 -07009232 /* Before registering we need to update the ht capabilitied based
9233 * on ini values*/
9234 if( !pCfg->ShortGI20MhzEnable )
9235 {
9236 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
9237 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
Jeff Johnson295189b2012-06-20 16:38:30 -07009238 }
9239
9240 if( !pCfg->ShortGI40MhzEnable )
9241 {
9242 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
9243 }
9244
9245 if( !pCfg->nChannelBondingMode5GHz )
9246 {
9247 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
9248 }
Agrawal Ashish97dec502015-11-26 20:20:58 +05309249 /*
9250 * In case of static linked driver at the time of driver unload,
9251 * module exit doesn't happens. Module cleanup helps in cleaning
9252 * of static memory.
9253 * If driver load happens statically, at the time of driver unload,
9254 * wiphy flags don't get reset because of static memory.
9255 * It's better not to store channel in static memory.
9256 */
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309257 wiphy->bands[HDD_NL80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
9258 wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels =
Agrawal Ashish97dec502015-11-26 20:20:58 +05309259 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_2_4_GHZ));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309260 if (wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels == NULL)
Agrawal Ashish97dec502015-11-26 20:20:58 +05309261 {
9262 hddLog(VOS_TRACE_LEVEL_ERROR,
9263 FL("Not enough memory to allocate channels"));
9264 return -ENOMEM;
9265 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309266 vos_mem_copy(wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels,
Agrawal Ashish97dec502015-11-26 20:20:58 +05309267 &hdd_channels_2_4_GHZ[0],
9268 sizeof(hdd_channels_2_4_GHZ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009269
Agrawal Ashish97dec502015-11-26 20:20:58 +05309270 if (true == hdd_is_5g_supported(pHddCtx))
9271 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309272 wiphy->bands[HDD_NL80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
9273 wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels =
Agrawal Ashish97dec502015-11-26 20:20:58 +05309274 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_5_GHZ));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309275 if (wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels == NULL)
Agrawal Ashish97dec502015-11-26 20:20:58 +05309276 {
9277 hddLog(VOS_TRACE_LEVEL_ERROR,
9278 FL("Not enough memory to allocate channels"));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309279 vos_mem_free(wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels);
9280 wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels = NULL;
Agrawal Ashish97dec502015-11-26 20:20:58 +05309281 return -ENOMEM;
9282 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309283 vos_mem_copy(wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels,
Agrawal Ashish97dec502015-11-26 20:20:58 +05309284 &hdd_channels_5_GHZ[0],
9285 sizeof(hdd_channels_5_GHZ));
9286 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309287
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309288 for (i = 0; i < HDD_NUM_NL80211_BANDS; i++)
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309289 {
9290
9291 if (NULL == wiphy->bands[i])
9292 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05309293 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309294 __func__, i);
9295 continue;
9296 }
9297
9298 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9299 {
9300 struct ieee80211_supported_band *band = wiphy->bands[i];
9301
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309302 if (HDD_NL80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309303 {
9304 // Enable social channels for P2P
9305 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
9306 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
9307 else
9308 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
9309 continue;
9310 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309311 else if (HDD_NL80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309312 {
9313 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
9314 continue;
9315 }
9316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009317 }
9318 /*Initialise the supported cipher suite details*/
9319 wiphy->cipher_suites = hdd_cipher_suites;
9320 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
9321
9322 /*signal strength in mBm (100*dBm) */
9323 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
9324
9325#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05309326 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07009327#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009328
Abhishek Singh2f3c4752018-04-11 14:58:53 +05309329 hdd_add_channel_switch_support(wiphy);
Sunil Duttc69bccb2014-05-26 21:30:20 +05309330 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
9331 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08009332 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
9333 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
9334
Anurag Chouhan343af7e2016-12-16 13:11:19 +05309335 hdd_config_sched_scan_plans_to_wiphy(wiphy, pCfg);
Abhinav Kumar97821072019-08-02 14:29:48 +05309336 wlan_hdd_cfg80211_set_wiphy_sae_feature(wiphy, pCfg);
Anurag Chouhan343af7e2016-12-16 13:11:19 +05309337
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309338 EXIT();
9339 return 0;
9340}
9341
9342/* In this function we are registering wiphy. */
9343int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
9344{
9345 ENTER();
9346 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 if (0 > wiphy_register(wiphy))
9348 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309349 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
9351 return -EIO;
9352 }
9353
9354 EXIT();
9355 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309356}
Jeff Johnson295189b2012-06-20 16:38:30 -07009357
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309358/* In this function we are updating channel list when,
9359 regulatory domain is FCC and country code is US.
9360 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
9361 As per FCC smart phone is not a indoor device.
9362 GO should not opeate on indoor channels */
9363void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
9364{
9365 int j;
9366 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9367 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
9368 //Default counrtycode from NV at the time of wiphy initialization.
9369 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
9370 &defaultCountryCode[0]))
9371 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009372 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309373 }
9374 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
9375 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309376 if (NULL == wiphy->bands[HDD_NL80211_BAND_5GHZ])
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309377 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309378 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[HDD_NL80211_BAND_5GHZ] is NULL",__func__ );
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309379 return;
9380 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309381 for (j = 0; j < wiphy->bands[HDD_NL80211_BAND_5GHZ]->n_channels; j++)
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309382 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309383 struct ieee80211_supported_band *band = wiphy->bands[HDD_NL80211_BAND_5GHZ];
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309384 // Mark UNII -1 band channel as passive
9385 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
9386 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
9387 }
9388 }
9389}
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05309390/* This function registers for all frame which supplicant is interested in */
9391void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009392{
Jeff Johnson295189b2012-06-20 16:38:30 -07009393 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9394 /* Register for all P2P action, public action etc frames */
9395 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
Jeff Johnsone7245742012-09-05 17:12:55 -07009396 ENTER();
Abhishek Singh16e05762015-11-30 14:29:27 +05309397 /* Register frame indication call back */
9398 sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame);
Jeff Johnson295189b2012-06-20 16:38:30 -07009399 /* Right now we are registering these frame when driver is getting
9400 initialized. Once we will move to 2.6.37 kernel, in which we have
9401 frame register ops, we will move this code as a part of that */
9402 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309403 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07009404 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
9405
9406 /* GAS Initial Response */
9407 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9408 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309409
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 /* GAS Comeback Request */
9411 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9412 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
9413
9414 /* GAS Comeback Response */
9415 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9416 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
9417
9418 /* P2P Public Action */
9419 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309420 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07009421 P2P_PUBLIC_ACTION_FRAME_SIZE );
9422
9423 /* P2P Action */
9424 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9425 (v_U8_t*)P2P_ACTION_FRAME,
9426 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07009427
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05309428 /* WNM BSS Transition Request frame */
9429 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9430 (v_U8_t*)WNM_BSS_ACTION_FRAME,
9431 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07009432
9433 /* WNM-Notification */
9434 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9435 (v_U8_t*)WNM_NOTIFICATION_FRAME,
9436 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07009437}
9438
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05309439void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009440{
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9442 /* Register for all P2P action, public action etc frames */
9443 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
9444
Jeff Johnsone7245742012-09-05 17:12:55 -07009445 ENTER();
9446
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 /* Right now we are registering these frame when driver is getting
9448 initialized. Once we will move to 2.6.37 kernel, in which we have
9449 frame register ops, we will move this code as a part of that */
9450 /* GAS Initial Request */
9451
9452 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9453 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
9454
9455 /* GAS Initial Response */
9456 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9457 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309458
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 /* GAS Comeback Request */
9460 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9461 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
9462
9463 /* GAS Comeback Response */
9464 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9465 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
9466
9467 /* P2P Public Action */
9468 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309469 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07009470 P2P_PUBLIC_ACTION_FRAME_SIZE );
9471
9472 /* P2P Action */
9473 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9474 (v_U8_t*)P2P_ACTION_FRAME,
9475 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07009476 /* WNM-Notification */
9477 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9478 (v_U8_t*)WNM_NOTIFICATION_FRAME,
9479 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07009480}
9481
9482#ifdef FEATURE_WLAN_WAPI
9483void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05309484 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07009485{
9486 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9487 tCsrRoamSetKey setKey;
9488 v_BOOL_t isConnected = TRUE;
9489 int status = 0;
9490 v_U32_t roamId= 0xFF;
9491 tANI_U8 *pKeyPtr = NULL;
9492 int n = 0;
9493
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309494 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
9495 __func__, hdd_device_modetoString(pAdapter->device_mode),
9496 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009497
Gopichand Nakkalae7480202013-02-11 15:24:22 +05309498 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 setKey.keyId = key_index; // Store Key ID
9500 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
9501 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
9502 setKey.paeRole = 0 ; // the PAE role
9503 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9504 {
9505 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
9506 }
9507 else
9508 {
9509 isConnected = hdd_connIsConnected(pHddStaCtx);
9510 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
9511 }
9512 setKey.keyLength = key_Len;
9513 pKeyPtr = setKey.Key;
9514 memcpy( pKeyPtr, key, key_Len);
9515
Arif Hussain6d2a3322013-11-17 19:50:10 -08009516 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 __func__, key_Len);
9518 for (n = 0 ; n < key_Len; n++)
9519 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
9520 __func__,n,setKey.Key[n]);
9521
9522 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9523 if ( isConnected )
9524 {
9525 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9526 pAdapter->sessionId, &setKey, &roamId );
9527 }
9528 if ( status != 0 )
9529 {
9530 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9531 "[%4d] sme_RoamSetKey returned ERROR status= %d",
9532 __LINE__, status );
9533 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9534 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309535 /* Need to clear any trace of key value in the memory.
9536 * Thus zero out the memory even though it is local
9537 * variable.
9538 */
9539 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07009540}
9541#endif /* FEATURE_WLAN_WAPI*/
9542
9543#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309544int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 beacon_data_t **ppBeacon,
9546 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009547#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309548int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009549 beacon_data_t **ppBeacon,
9550 struct cfg80211_beacon_data *params,
9551 int dtim_period)
9552#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309553{
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 int size;
9555 beacon_data_t *beacon = NULL;
9556 beacon_data_t *old = NULL;
Kapil Gupta137ef892016-12-13 19:38:00 +05309557 int head_len, tail_len, proberesp_ies_len, assocresp_ies_len;
9558 const u8 *head, *tail, *proberesp_ies, *assocresp_ies;
Jeff Johnson295189b2012-06-20 16:38:30 -07009559
Jeff Johnsone7245742012-09-05 17:12:55 -07009560 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309562 {
9563 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9564 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309566 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009567
9568 old = pAdapter->sessionCtx.ap.beacon;
9569
9570 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309571 {
9572 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9573 FL("session(%d) old and new heads points to NULL"),
9574 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309576 }
9577
9578 if (params->tail && !params->tail_len)
9579 {
9580 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9581 FL("tail_len is zero but tail is not NULL"));
9582 return -EINVAL;
9583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009584
Jeff Johnson295189b2012-06-20 16:38:30 -07009585#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
9586 /* Kernel 3.0 is not updating dtim_period for set beacon */
9587 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309588 {
9589 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9590 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009593#endif
9594
Kapil Gupta137ef892016-12-13 19:38:00 +05309595 if (params->head)
9596 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 head_len = params->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309598 head = params->head;
9599 } else
9600 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 head_len = old->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309602 head = old->head;
9603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009604
Kapil Gupta137ef892016-12-13 19:38:00 +05309605 if (params->tail || !old)
9606 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 tail_len = params->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309608 tail = params->tail;
9609 } else
9610 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009611 tail_len = old->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309612 tail = old->tail;
9613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009614
Kapil Gupta137ef892016-12-13 19:38:00 +05309615 if (params->proberesp_ies || !old)
9616 {
9617 proberesp_ies_len = params->proberesp_ies_len;
9618 proberesp_ies = params->proberesp_ies;
9619 } else
9620 {
9621 proberesp_ies_len = old->proberesp_ies_len;
9622 proberesp_ies = old->proberesp_ies;
9623 }
9624
9625 if (params->assocresp_ies || !old)
9626 {
9627 assocresp_ies_len = params->assocresp_ies_len;
9628 assocresp_ies = params->assocresp_ies;
9629 } else
9630 {
9631 assocresp_ies_len = old->assocresp_ies_len;
9632 assocresp_ies = old->assocresp_ies;
9633 }
9634
9635 size = sizeof(beacon_data_t) + head_len + tail_len +
9636 proberesp_ies_len + assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07009637
9638 beacon = kzalloc(size, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009639 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309640 {
9641 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9642 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009645
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009646#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Kapil Gupta137ef892016-12-13 19:38:00 +05309647 if (params->dtim_period)
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 beacon->dtim_period = params->dtim_period;
9649 else
9650 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009651#else
Kapil Gupta137ef892016-12-13 19:38:00 +05309652 if (dtim_period)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009653 beacon->dtim_period = dtim_period;
9654 else
9655 beacon->dtim_period = old->dtim_period;
9656#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309657
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
9659 beacon->tail = beacon->head + head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309660 beacon->proberesp_ies = beacon->tail + tail_len;
9661 beacon->assocresp_ies = beacon->proberesp_ies + proberesp_ies_len;
9662
Jeff Johnson295189b2012-06-20 16:38:30 -07009663 beacon->head_len = head_len;
9664 beacon->tail_len = tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309665 beacon->proberesp_ies_len = proberesp_ies_len;
9666 beacon->assocresp_ies_len= assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07009667
c_manjee527ecac2017-01-25 12:25:27 +05309668 if (head && head_len)
9669 memcpy(beacon->head, head, head_len);
9670 if (tail && tail_len)
9671 memcpy(beacon->tail, tail, tail_len);
9672 if (proberesp_ies && proberesp_ies_len)
9673 memcpy(beacon->proberesp_ies, proberesp_ies, proberesp_ies_len);
9674 if (assocresp_ies && assocresp_ies_len)
9675 memcpy(beacon->assocresp_ies, assocresp_ies, assocresp_ies_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009676
9677 *ppBeacon = beacon;
9678
9679 kfree(old);
9680
9681 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009682}
Jeff Johnson295189b2012-06-20 16:38:30 -07009683
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309684v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
9685#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
9686 const v_U8_t *pIes,
9687#else
9688 v_U8_t *pIes,
9689#endif
9690 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009691{
9692 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309693 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07009694 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309695
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309697 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009698 elem_id = ptr[0];
9699 elem_len = ptr[1];
9700 left -= 2;
9701 if(elem_len > left)
9702 {
9703 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009704 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009705 eid,elem_len,left);
9706 return NULL;
9707 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309708 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009709 {
9710 return ptr;
9711 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309712
Jeff Johnson295189b2012-06-20 16:38:30 -07009713 left -= elem_len;
9714 ptr += (elem_len + 2);
9715 }
9716 return NULL;
9717}
9718
Jeff Johnson295189b2012-06-20 16:38:30 -07009719/* Check if rate is 11g rate or not */
9720static int wlan_hdd_rate_is_11g(u8 rate)
9721{
Sanjay Devnani28322e22013-06-21 16:13:40 -07009722 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009723 u8 i;
9724 for (i = 0; i < 8; i++)
9725 {
9726 if(rate == gRateArray[i])
9727 return TRUE;
9728 }
9729 return FALSE;
9730}
9731
9732/* Check for 11g rate and set proper 11g only mode */
9733static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
9734 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
9735{
9736 u8 i, num_rates = pIe[0];
9737
9738 pIe += 1;
9739 for ( i = 0; i < num_rates; i++)
9740 {
9741 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
9742 {
9743 /* If rate set have 11g rate than change the mode to 11G */
9744 *pSapHw_mode = eSAP_DOT11_MODE_11g;
9745 if (pIe[i] & BASIC_RATE_MASK)
9746 {
9747 /* If we have 11g rate as basic rate, it means mode
9748 is 11g only mode.
9749 */
9750 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
9751 *pCheckRatesfor11g = FALSE;
9752 }
9753 }
9754 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
9755 {
9756 *require_ht = TRUE;
9757 }
9758 }
9759 return;
9760}
9761
9762static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
9763{
9764 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9765 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9766 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9767 u8 checkRatesfor11g = TRUE;
9768 u8 require_ht = FALSE;
9769 u8 *pIe=NULL;
9770
9771 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
9772
9773 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
9774 pBeacon->head_len, WLAN_EID_SUPP_RATES);
9775 if (pIe != NULL)
9776 {
9777 pIe += 1;
9778 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
9779 &pConfig->SapHw_mode);
9780 }
9781
9782 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
9783 WLAN_EID_EXT_SUPP_RATES);
9784 if (pIe != NULL)
9785 {
9786
9787 pIe += 1;
9788 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
9789 &pConfig->SapHw_mode);
9790 }
9791
9792 if( pConfig->channel > 14 )
9793 {
9794 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
9795 }
9796
9797 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
9798 WLAN_EID_HT_CAPABILITY);
9799
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309800 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009801 {
9802 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
9803 if(require_ht)
9804 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
9805 }
9806}
9807
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309808static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
9809 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
9810{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009811 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309812 v_U8_t *pIe = NULL;
9813 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9814
9815 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
9816 pBeacon->tail, pBeacon->tail_len);
9817
9818 if (pIe)
9819 {
9820 ielen = pIe[1] + 2;
9821 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
9822 {
9823 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
9824 }
9825 else
9826 {
9827 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
9828 return -EINVAL;
9829 }
9830 *total_ielen += ielen;
9831 }
9832 return 0;
9833}
9834
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009835static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
9836 v_U8_t *genie, v_U8_t *total_ielen)
9837{
9838 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9839 int left = pBeacon->tail_len;
9840 v_U8_t *ptr = pBeacon->tail;
9841 v_U8_t elem_id, elem_len;
9842 v_U16_t ielen = 0;
9843
9844 if ( NULL == ptr || 0 == left )
9845 return;
9846
9847 while (left >= 2)
9848 {
9849 elem_id = ptr[0];
9850 elem_len = ptr[1];
9851 left -= 2;
9852 if (elem_len > left)
9853 {
9854 hddLog( VOS_TRACE_LEVEL_ERROR,
9855 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
9856 elem_id, elem_len, left);
9857 return;
9858 }
Ashish Kumar Dhanotiya6af276b2017-08-22 16:53:48 +05309859 if ((IE_EID_VENDOR == elem_id) && (elem_len >= WPS_OUI_TYPE_SIZE))
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009860 {
9861 /* skipping the VSIE's which we don't want to include or
9862 * it will be included by existing code
9863 */
9864 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
9865#ifdef WLAN_FEATURE_WFD
9866 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
9867#endif
9868 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9869 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9870 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
9871 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9872 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
9873 {
9874 ielen = ptr[1] + 2;
9875 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
9876 {
9877 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
9878 *total_ielen += ielen;
9879 }
9880 else
9881 {
9882 hddLog( VOS_TRACE_LEVEL_ERROR,
9883 "IE Length is too big "
9884 "IEs eid=%d elem_len=%d total_ie_lent=%d",
9885 elem_id, elem_len, *total_ielen);
9886 }
9887 }
9888 }
9889
9890 left -= elem_len;
9891 ptr += (elem_len + 2);
9892 }
9893 return;
9894}
9895
Kapil Gupta137ef892016-12-13 19:38:00 +05309896int wlan_hdd_cfg80211_update_apies(hdd_adapter_t *pHostapdAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009897{
9898 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309899 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009900 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07009901 int ret = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +05309902 beacon_data_t *pBeacon = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009903
9904 genie = vos_mem_malloc(MAX_GENIE_LEN);
9905
9906 if(genie == NULL) {
9907
9908 return -ENOMEM;
9909 }
9910
Kapil Gupta137ef892016-12-13 19:38:00 +05309911 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309912 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9913 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07009914 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309915 hddLog(LOGE,
9916 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309917 ret = -EINVAL;
9918 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009919 }
9920
9921#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309922 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9923 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
9924 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309925 hddLog(LOGE,
9926 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309927 ret = -EINVAL;
9928 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009929 }
9930#endif
9931
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309932 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9933 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07009934 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309935 hddLog(LOGE,
9936 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309937 ret = -EINVAL;
9938 goto done;
9939 }
9940
9941 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
9942 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009943 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009945
9946 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9947 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
9948 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
9949 {
9950 hddLog(LOGE,
9951 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009952 ret = -EINVAL;
9953 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 }
9955
9956 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9957 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
9958 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
9959 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
9960 ==eHAL_STATUS_FAILURE)
9961 {
9962 hddLog(LOGE,
9963 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009964 ret = -EINVAL;
9965 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009966 }
9967
9968 // Added for ProResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +05309969 if ((pBeacon->proberesp_ies != NULL) && (pBeacon->proberesp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009970 {
Kapil Gupta137ef892016-12-13 19:38:00 +05309971 u16 rem_probe_resp_ie_len = pBeacon->proberesp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07009972 u8 probe_rsp_ie_len[3] = {0};
9973 u8 counter = 0;
9974 /* Check Probe Resp Length if it is greater then 255 then Store
9975 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
9976 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
9977 Store More then 255 bytes into One Variable.
9978 */
9979 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
9980 {
9981 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
9982 {
9983 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
9984 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
9985 }
9986 else
9987 {
9988 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
9989 rem_probe_resp_ie_len = 0;
9990 }
9991 }
9992
9993 rem_probe_resp_ie_len = 0;
9994
9995 if (probe_rsp_ie_len[0] > 0)
9996 {
9997 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9998 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
Kapil Gupta137ef892016-12-13 19:38:00 +05309999 (tANI_U8*)&pBeacon->
10000 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -070010001 probe_rsp_ie_len[0], NULL,
10002 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10003 {
10004 hddLog(LOGE,
10005 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010006 ret = -EINVAL;
10007 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010008 }
10009 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
10010 }
10011
10012 if (probe_rsp_ie_len[1] > 0)
10013 {
10014 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10015 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
Kapil Gupta137ef892016-12-13 19:38:00 +053010016 (tANI_U8*)&pBeacon->
10017 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -070010018 probe_rsp_ie_len[1], NULL,
10019 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10020 {
10021 hddLog(LOGE,
10022 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010023 ret = -EINVAL;
10024 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010025 }
10026 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
10027 }
10028
10029 if (probe_rsp_ie_len[2] > 0)
10030 {
10031 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10032 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
Kapil Gupta137ef892016-12-13 19:38:00 +053010033 (tANI_U8*)&pBeacon->
10034 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 probe_rsp_ie_len[2], NULL,
10036 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10037 {
10038 hddLog(LOGE,
10039 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010040 ret = -EINVAL;
10041 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010042 }
10043 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
10044 }
10045
10046 if (probe_rsp_ie_len[1] == 0 )
10047 {
10048 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10049 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
10050 eANI_BOOLEAN_FALSE) )
10051 {
10052 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010053 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010054 }
10055 }
10056
10057 if (probe_rsp_ie_len[2] == 0 )
10058 {
10059 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10060 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
10061 eANI_BOOLEAN_FALSE) )
10062 {
10063 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010064 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 }
10066 }
10067
10068 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10069 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
10070 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
10071 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
10072 == eHAL_STATUS_FAILURE)
10073 {
10074 hddLog(LOGE,
10075 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010076 ret = -EINVAL;
10077 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010078 }
10079 }
10080 else
10081 {
10082 // Reset WNI_CFG_PROBE_RSP Flags
10083 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
10084
10085 hddLog(VOS_TRACE_LEVEL_INFO,
10086 "%s: No Probe Response IE received in set beacon",
10087 __func__);
10088 }
10089
10090 // Added for AssocResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +053010091 if ((pBeacon->assocresp_ies != NULL) && (pBeacon->assocresp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010092 {
10093 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
Kapil Gupta137ef892016-12-13 19:38:00 +053010094 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)pBeacon->assocresp_ies,
10095 pBeacon->assocresp_ies_len, NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -070010096 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10097 {
10098 hddLog(LOGE,
10099 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010100 ret = -EINVAL;
10101 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010102 }
10103
10104 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10105 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
10106 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
10107 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
10108 == eHAL_STATUS_FAILURE)
10109 {
10110 hddLog(LOGE,
10111 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010112 ret = -EINVAL;
10113 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010114 }
10115 }
10116 else
10117 {
10118 hddLog(VOS_TRACE_LEVEL_INFO,
10119 "%s: No Assoc Response IE received in set beacon",
10120 __func__);
10121
10122 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10123 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
10124 eANI_BOOLEAN_FALSE) )
10125 {
10126 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010127 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010128 }
10129 }
10130
Jeff Johnsone7245742012-09-05 17:12:55 -070010131done:
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +053010133 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010134}
Jeff Johnson295189b2012-06-20 16:38:30 -070010135
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010136/*
Jeff Johnson295189b2012-06-20 16:38:30 -070010137 * FUNCTION: wlan_hdd_validate_operation_channel
10138 * called by wlan_hdd_cfg80211_start_bss() and
10139 * wlan_hdd_cfg80211_set_channel()
10140 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010141 * channel list.
10142 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010143VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -070010144{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010145
Jeff Johnson295189b2012-06-20 16:38:30 -070010146 v_U32_t num_ch = 0;
10147 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
10148 u32 indx = 0;
10149 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010150 v_U8_t fValidChannel = FALSE, count = 0;
10151 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010152
Jeff Johnson295189b2012-06-20 16:38:30 -070010153 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
10154
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010155 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070010156 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010157 /* Validate the channel */
10158 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -070010159 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010160 if ( channel == rfChannels[count].channelNum )
10161 {
10162 fValidChannel = TRUE;
10163 break;
10164 }
10165 }
10166 if (fValidChannel != TRUE)
10167 {
10168 hddLog(VOS_TRACE_LEVEL_ERROR,
10169 "%s: Invalid Channel [%d]", __func__, channel);
10170 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010171 }
10172 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010173 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010174 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010175 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
10176 valid_ch, &num_ch))
10177 {
10178 hddLog(VOS_TRACE_LEVEL_ERROR,
10179 "%s: failed to get valid channel list", __func__);
10180 return VOS_STATUS_E_FAILURE;
10181 }
10182 for (indx = 0; indx < num_ch; indx++)
10183 {
10184 if (channel == valid_ch[indx])
10185 {
10186 break;
10187 }
10188 }
10189
Rashmi Ramanna3b59e122014-04-10 14:45:13 +053010190 if (indx >= num_ch)
10191 {
10192 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
10193 {
10194 eCsrBand band;
10195 unsigned int freq;
10196
10197 sme_GetFreqBand(hHal, &band);
10198
10199 if (eCSR_BAND_5G == band)
10200 {
10201#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
10202 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
10203 {
10204 freq = ieee80211_channel_to_frequency(channel,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053010205 HDD_NL80211_BAND_2GHZ);
Rashmi Ramanna3b59e122014-04-10 14:45:13 +053010206 }
10207 else
10208 {
10209 freq = ieee80211_channel_to_frequency(channel,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053010210 HDD_NL80211_BAND_5GHZ);
Rashmi Ramanna3b59e122014-04-10 14:45:13 +053010211 }
10212#else
10213 freq = ieee80211_channel_to_frequency(channel);
10214#endif
10215 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
10216 return VOS_STATUS_SUCCESS;
10217 }
10218 }
10219
10220 hddLog(VOS_TRACE_LEVEL_ERROR,
10221 "%s: Invalid Channel [%d]", __func__, channel);
10222 return VOS_STATUS_E_FAILURE;
10223 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010224 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +053010225
Jeff Johnson295189b2012-06-20 16:38:30 -070010226 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010227
Jeff Johnson295189b2012-06-20 16:38:30 -070010228}
10229
Viral Modi3a32cc52013-02-08 11:14:52 -080010230/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010231 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -080010232 * This function is used to set the channel number
10233 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010234static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -080010235 struct ieee80211_channel *chan,
10236 enum nl80211_channel_type channel_type
10237 )
10238{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010239 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -080010240 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -070010241 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -080010242 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010243 hdd_context_t *pHddCtx;
10244 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -080010245
10246 ENTER();
10247
10248 if( NULL == dev )
10249 {
10250 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010251 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -080010252 return -ENODEV;
10253 }
10254 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010255
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010256 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10257 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
10258 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -080010259 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010260 "%s: device_mode = %s (%d) freq = %d", __func__,
10261 hdd_device_modetoString(pAdapter->device_mode),
10262 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010263
10264 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10265 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010266 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -080010267 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010268 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -080010269 }
10270
10271 /*
10272 * Do freq to chan conversion
10273 * TODO: for 11a
10274 */
10275
10276 channel = ieee80211_frequency_to_channel(freq);
10277
10278 /* Check freq range */
10279 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
10280 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
10281 {
10282 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010283 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -080010284 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
10285 WNI_CFG_CURRENT_CHANNEL_STAMAX);
10286 return -EINVAL;
10287 }
10288
10289 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
10290
Gopichand Nakkala6ab19562013-03-07 13:59:42 +053010291 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
10292 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -080010293 {
10294 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
10295 {
10296 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010297 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -080010298 return -EINVAL;
10299 }
10300 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10301 "%s: set channel to [%d] for device mode =%d",
10302 __func__, channel,pAdapter->device_mode);
10303 }
10304 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -080010305 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -080010306 )
10307 {
10308 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10309 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
10310 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10311
10312 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
10313 {
10314 /* Link is up then return cant set channel*/
10315 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010316 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -080010317 return -EINVAL;
10318 }
10319
10320 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
10321 pHddStaCtx->conn_info.operationChannel = channel;
10322 pRoamProfile->ChannelInfo.ChannelList =
10323 &pHddStaCtx->conn_info.operationChannel;
10324 }
10325 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -080010326 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -080010327 )
10328 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010329 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
10330 {
10331 if(VOS_STATUS_SUCCESS !=
10332 wlan_hdd_validate_operation_channel(pAdapter,channel))
10333 {
10334 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010335 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010336 return -EINVAL;
10337 }
10338 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
10339 }
10340 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -080010341 {
10342 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
10343
10344 /* If auto channel selection is configured as enable/ 1 then ignore
10345 channel set by supplicant
10346 */
10347 if ( cfg_param->apAutoChannelSelection )
10348 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010349 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
10350 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -080010351 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010352 "%s: set channel to auto channel (0) for device mode =%s (%d)",
10353 __func__, hdd_device_modetoString(pAdapter->device_mode),
10354 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -080010355 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010356 else
10357 {
10358 if(VOS_STATUS_SUCCESS !=
10359 wlan_hdd_validate_operation_channel(pAdapter,channel))
10360 {
10361 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010362 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010363 return -EINVAL;
10364 }
10365 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
10366 }
Viral Modi3a32cc52013-02-08 11:14:52 -080010367 }
10368 }
10369 else
10370 {
10371 hddLog(VOS_TRACE_LEVEL_FATAL,
10372 "%s: Invalid device mode failed to set valid channel", __func__);
10373 return -EINVAL;
10374 }
10375 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010376 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -080010377}
10378
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010379static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
10380 struct net_device *dev,
10381 struct ieee80211_channel *chan,
10382 enum nl80211_channel_type channel_type
10383 )
10384{
10385 int ret;
10386
10387 vos_ssr_protect(__func__);
10388 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
10389 vos_ssr_unprotect(__func__);
10390
10391 return ret;
10392}
10393
Anurag Chouhan83026002016-12-13 22:46:21 +053010394#ifdef DHCP_SERVER_OFFLOAD
10395void hdd_dhcp_server_offload_done(void *fw_dhcp_srv_offload_cb_context,
10396 VOS_STATUS status)
10397{
10398 hdd_adapter_t* adapter = (hdd_adapter_t*)fw_dhcp_srv_offload_cb_context;
10399
10400 ENTER();
10401
10402 if (NULL == adapter)
10403 {
10404 hddLog(VOS_TRACE_LEVEL_ERROR,
10405 "%s: adapter is NULL",__func__);
10406 return;
10407 }
10408
10409 adapter->dhcp_status.dhcp_offload_status = status;
10410 vos_event_set(&adapter->dhcp_status.vos_event);
10411 return;
10412}
10413
10414/**
10415 * wlan_hdd_set_dhcp_server_offload() - set dhcp server offload
10416 * @hostapd_adapter: pointer to hostapd adapter.
Anurag Chouhan638f5e22017-03-06 12:28:43 +053010417 * @re_init: flag set if api called post ssr
Anurag Chouhan83026002016-12-13 22:46:21 +053010418 *
10419 * Return: None
10420 */
Anurag Chouhan638f5e22017-03-06 12:28:43 +053010421VOS_STATUS wlan_hdd_set_dhcp_server_offload(hdd_adapter_t *hostapd_adapter,
10422 bool re_init)
Anurag Chouhan83026002016-12-13 22:46:21 +053010423{
10424 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(hostapd_adapter);
10425 sir_dhcp_srv_offload_info dhcp_srv_info;
10426 tANI_U8 num_entries = 0;
10427 tANI_U8 srv_ip[IPADDR_NUM_ENTRIES];
10428 tANI_U8 num;
10429 tANI_U32 temp;
10430 VOS_STATUS ret;
10431
10432 ENTER();
10433
Anurag Chouhan638f5e22017-03-06 12:28:43 +053010434 if (!re_init) {
10435 ret = wlan_hdd_validate_context(hdd_ctx);
10436 if (0 != ret)
10437 return VOS_STATUS_E_INVAL;
10438 }
Anurag Chouhan83026002016-12-13 22:46:21 +053010439
10440 /* Prepare the request to send to SME */
10441 dhcp_srv_info = vos_mem_malloc(sizeof(*dhcp_srv_info));
10442 if (NULL == dhcp_srv_info) {
10443 hddLog(VOS_TRACE_LEVEL_ERROR,
10444 "%s: could not allocate tDhcpSrvOffloadInfo!", __func__);
10445 return VOS_STATUS_E_NOMEM;
10446 }
10447
10448 vos_mem_zero(dhcp_srv_info, sizeof(*dhcp_srv_info));
10449
10450 dhcp_srv_info->bssidx = hostapd_adapter->sessionId;
10451 dhcp_srv_info->dhcp_srv_offload_enabled = TRUE;
10452 dhcp_srv_info->dhcp_client_num = hdd_ctx->cfg_ini->dhcp_max_num_clients;
10453 dhcp_srv_info->start_lsb = hdd_ctx->cfg_ini->dhcp_start_lsb;
10454 dhcp_srv_info->dhcp_offload_callback = hdd_dhcp_server_offload_done;
10455 dhcp_srv_info->dhcp_server_offload_cb_context = hostapd_adapter;
10456
10457 hdd_string_to_u8_array(hdd_ctx->cfg_ini->dhcp_srv_ip,
10458 srv_ip,
10459 &num_entries,
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +053010460 IPADDR_NUM_ENTRIES, ".", false);
Anurag Chouhan83026002016-12-13 22:46:21 +053010461 if (num_entries != IPADDR_NUM_ENTRIES) {
10462 hddLog(VOS_TRACE_LEVEL_ERROR,
10463 "%s: incorrect IP address (%s) assigned for DHCP server!",
10464 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
10465 vos_mem_free(dhcp_srv_info);
10466 return VOS_STATUS_E_FAILURE;
10467 }
10468
10469 if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) {
10470 hddLog(VOS_TRACE_LEVEL_ERROR,
10471 "%s: invalid IP address (%s)! It could NOT be multicast IP address!",
10472 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
10473 vos_mem_free(dhcp_srv_info);
10474 return VOS_STATUS_E_FAILURE;
10475 }
10476
10477 if (srv_ip[IPADDR_NUM_ENTRIES-1] >= DHCP_START_POOL_ADDRESS) {
10478 hddLog(VOS_TRACE_LEVEL_ERROR,
10479 "%s: invalid IP address (%s)! The last field must be less than 100!",
10480 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
10481 vos_mem_free(dhcp_srv_info);
10482 return VOS_STATUS_E_FAILURE;
10483 }
10484
10485 for (num = 0; num < num_entries; num++) {
10486 temp = srv_ip[num];
10487 dhcp_srv_info->dhcp_srv_ip |= (temp << (8 * num));
10488 }
10489
10490 if (eHAL_STATUS_SUCCESS !=
10491 sme_set_dhcp_srv_offload(hdd_ctx->hHal, dhcp_srv_info)) {
10492 hddLog(VOS_TRACE_LEVEL_ERROR,
10493 "%s: sme_set_dhcp_srv_offload fail!", __func__);
10494 vos_mem_free(dhcp_srv_info);
10495 return VOS_STATUS_E_FAILURE;
10496 }
10497
10498 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10499 "%s: enable DHCP Server offload successfully!", __func__);
10500
10501 vos_mem_free(dhcp_srv_info);
10502 return 0;
10503}
10504#endif /* DHCP_SERVER_OFFLOAD */
10505
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010506/*
10507 * hdd_modify_indoor_channel_state_flags() - modify wiphy flags and cds state
10508 * @wiphy_chan: wiphy channel number
10509 * @rfChannel: channel hw value
10510 * @disable: Disable/enable the flags
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010511 * @hdd_ctx: The HDD context handler
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010512 *
10513 * Modify wiphy flags and cds state if channel is indoor.
10514 *
10515 * Return: void
10516 */
10517void hdd_modify_indoor_channel_state_flags(struct ieee80211_channel *wiphy_chan,
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010518 v_U32_t rfChannel, bool disable, hdd_context_t *hdd_ctx)
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010519{
10520 v_U32_t channelLoop;
10521 eRfChannels channelEnum = INVALID_RF_CHANNEL;
10522
10523 for (channelLoop = 0; channelLoop <= RF_CHAN_165; channelLoop++) {
10524
10525 if (rfChannels[channelLoop].channelNum == rfChannel) {
10526 channelEnum = (eRfChannels)channelLoop;
10527 break;
10528 }
10529 }
10530
10531 if (INVALID_RF_CHANNEL == channelEnum)
10532 return;
10533
10534 if (disable) {
10535 if (wiphy_chan->flags & IEEE80211_CHAN_INDOOR_ONLY) {
10536 wiphy_chan->flags |=
10537 IEEE80211_CHAN_DISABLED;
10538 regChannels[channelEnum].enabled =
10539 NV_CHANNEL_DISABLE;
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010540 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %d marked as DISABLE",
10541 channelEnum);
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010542 }
10543 } else {
10544 if (wiphy_chan->flags & IEEE80211_CHAN_INDOOR_ONLY) {
10545 wiphy_chan->flags &=
10546 ~IEEE80211_CHAN_DISABLED;
10547 /*
10548 * Indoor channels are marked as DFS
10549 * during regulatory processing
10550 */
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010551 if ((wiphy_chan->flags & (IEEE80211_CHAN_RADAR |
10552 IEEE80211_CHAN_PASSIVE_SCAN)) ||
10553 ((hdd_ctx->cfg_ini->indoor_channel_support == false)
10554 && (wiphy_chan->flags &
10555 IEEE80211_CHAN_INDOOR_ONLY))) {
10556 regChannels[channelEnum].enabled = NV_CHANNEL_DFS;
10557 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %d marked as DFS",
10558 channelEnum);
10559 } else {
10560 regChannels[channelEnum].enabled =
10561 NV_CHANNEL_ENABLE;
10562 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %d marked as ENABLE",
10563 channelEnum);
10564 }
10565 }
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010566
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010567 }
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010568}
10569
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010570void hdd_update_indoor_channel(hdd_context_t *hdd_ctx, bool disable)
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010571{
10572 int band_num;
10573 int chan_num;
10574 v_U32_t rfChannel;
10575 struct ieee80211_channel *wiphy_chan;
10576 struct wiphy *wiphy;
10577
10578 ENTER();
10579 hddLog(VOS_TRACE_LEVEL_INFO, "disable: %d", disable);
10580
10581 wiphy = hdd_ctx->wiphy;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053010582 for (band_num = 0; band_num < HDD_NUM_NL80211_BANDS; band_num++) {
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010583
10584 if (wiphy->bands[band_num] == NULL)
10585 continue;
10586
10587 for (chan_num = 0;
10588 chan_num < wiphy->bands[band_num]->n_channels;
10589 chan_num++) {
10590
10591 wiphy_chan =
10592 &(wiphy->bands[band_num]->channels[chan_num]);
10593 rfChannel = wiphy->bands[band_num]->channels[chan_num].hw_value;
10594
10595 hdd_modify_indoor_channel_state_flags(wiphy_chan, rfChannel,
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010596 disable, hdd_ctx);
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010597 }
10598 }
10599 EXIT();
10600}
10601
Ganesh Kondabattini19813af2018-01-25 17:32:44 +053010602int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
10603{
Dundi Raviteja49de66b2018-07-27 12:22:57 +053010604 eHalStatus status;
10605 int result = 0;
Ganesh Kondabattini19813af2018-01-25 17:32:44 +053010606 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10607 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10608 long ret;
10609 eConnectionState prev_conn_state;
10610 uint32_t wait_time = WLAN_WAIT_TIME_DISCONNECT;
10611
10612 ENTER();
10613
Ganesh Kondabattini19813af2018-01-25 17:32:44 +053010614 /* Indicate sme of disconnect so that in progress connection or preauth
10615 * can be aborted
10616 */
10617 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
10618 pAdapter->sessionId);
10619 pHddCtx->isAmpAllowed = VOS_TRUE;
10620
10621 /* Need to apply spin lock before decreasing active sessions
10622 * as there can be chance for double decrement if context switch
10623 * Calls hdd_DisConnectHandler.
10624 */
10625
10626 prev_conn_state = pHddStaCtx->conn_info.connState;
10627
10628 spin_lock_bh(&pAdapter->lock_for_active_session);
10629 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
10630 {
10631 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
10632 }
10633 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
10634 spin_unlock_bh(&pAdapter->lock_for_active_session);
10635 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
10636
10637 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10638 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
10639
10640 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10641
10642 /*
10643 * stop tx queues before deleting STA/BSS context from the firmware.
10644 * tx has to be disabled because the firmware can get busy dropping
10645 * the tx frames after BSS/STA has been deleted and will not send
10646 * back a response resulting in WDI timeout
10647 */
10648 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
10649 netif_tx_disable(pAdapter->dev);
10650 netif_carrier_off(pAdapter->dev);
10651
10652 wlan_hdd_check_and_stop_mon(pAdapter, true);
10653
10654 /*issue disconnect*/
10655 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10656 pAdapter->sessionId, reason);
10657 if((eHAL_STATUS_CMD_NOT_QUEUED == status) &&
10658 prev_conn_state != eConnectionState_Connecting)
10659 {
10660 hddLog(LOG1,
10661 FL("status = %d, already disconnected"), status);
10662 result = 0;
10663 /*
10664 * Wait here instead of returning directly. This will block the
10665 * next connect command and allow processing of the disconnect
10666 * in SME else we might hit some race conditions leading to SME
10667 * and HDD out of sync. As disconnect is already in progress,
10668 * wait here for 1 sec instead of 5 sec.
10669 */
10670 wait_time = WLAN_WAIT_DISCONNECT_ALREADY_IN_PROGRESS;
10671 goto wait_for_disconnect;
10672 }
10673 /*
10674 * Wait here instead of returning directly, this will block the next
10675 * connect command and allow processing of the scan for ssid and
10676 * the previous connect command in CSR. Else we might hit some
10677 * race conditions leading to SME and HDD out of sync.
10678 */
10679 else if(eHAL_STATUS_CMD_NOT_QUEUED == status)
10680 {
10681 hddLog(LOG1,
10682 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
10683 }
10684 else if ( 0 != status )
10685 {
10686 hddLog(LOGE,
10687 FL("csrRoamDisconnect failure, returned %d"),
10688 (int)status);
10689 result = -EINVAL;
10690 goto disconnected;
10691 }
10692wait_for_disconnect:
10693 ret = wait_for_completion_timeout(&pAdapter->disconnect_comp_var,
10694 msecs_to_jiffies(wait_time));
10695 if (!ret && (eHAL_STATUS_CMD_NOT_QUEUED != status))
10696 {
10697 hddLog(LOGE,
10698 "%s: Failed to disconnect, timed out", __func__);
10699 result = -ETIMEDOUT;
10700 }
10701disconnected:
10702 hddLog(LOG1,
10703 FL("Set HDD connState to eConnectionState_NotConnected"));
10704 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
10705#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
10706 /* Sending disconnect event to userspace for kernel version < 3.11
10707 * is handled by __cfg80211_disconnect call to __cfg80211_disconnected
10708 */
10709 hddLog(LOG1, FL("Send disconnected event to userspace"));
10710
10711 wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true,
10712 WLAN_REASON_UNSPECIFIED);
10713#endif
10714
10715 EXIT();
10716 return result;
10717}
10718
Ganesh Kondabattini19813af2018-01-25 17:32:44 +053010719void hdd_check_and_disconnect_sta_on_invalid_channel(hdd_context_t *hdd_ctx)
10720{
10721
10722 hdd_adapter_t *sta_adapter;
10723 tANI_U8 sta_chan;
10724
10725 sta_chan = hdd_get_operating_channel(hdd_ctx, WLAN_HDD_INFRA_STATION);
10726
10727 if (!sta_chan) {
10728 hddLog(LOG1, FL("STA not connected"));
10729 return;
10730 }
10731
10732 hddLog(LOG1, FL("STA connected on chan %hu"), sta_chan);
10733
10734 if (sme_IsChannelValid(hdd_ctx->hHal, sta_chan)) {
10735 hddLog(LOG1, FL("STA connected on chan %hu and it is valid"),
10736 sta_chan);
10737 return;
10738 }
10739
10740 sta_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION);
10741
10742 if (!sta_adapter) {
10743 hddLog(LOG1, FL("STA adapter doesn't exist"));
10744 return;
10745 }
10746
10747 hddLog(LOG1, FL("chan %hu not valid, issue disconnect"), sta_chan);
10748 /* Issue Disconnect request */
10749 wlan_hdd_disconnect(sta_adapter, eCSR_DISCONNECT_REASON_DEAUTH);
10750}
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010751
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010752int wlan_hdd_restore_channels(hdd_context_t *hdd_ctx)
10753{
10754 struct hdd_cache_channels *cache_chann;
10755 struct wiphy *wiphy;
10756 int freq, status, rfChannel;
10757 int i, band_num, channel_num;
10758 struct ieee80211_channel *wiphy_channel;
10759
10760 ENTER();
10761
10762 if (!hdd_ctx) {
10763 hddLog(VOS_TRACE_LEVEL_FATAL, "HDD Context is NULL");
10764 return -EINVAL;
10765 }
10766
10767 wiphy = hdd_ctx->wiphy;
10768
10769 mutex_lock(&hdd_ctx->cache_channel_lock);
10770
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +053010771 cache_chann = hdd_ctx->original_channels;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010772
10773 if (!cache_chann || !cache_chann->num_channels) {
10774 hddLog(VOS_TRACE_LEVEL_INFO,
10775 "%s channel list is NULL or num channels are zero",
10776 __func__);
10777 mutex_unlock(&hdd_ctx->cache_channel_lock);
10778 return -EINVAL;
10779 }
10780
10781 for (i = 0; i < cache_chann->num_channels; i++) {
10782 status = hdd_wlan_get_freq(
10783 cache_chann->channel_info[i].channel_num,
10784 &freq);
10785
Rajeev Kumar Sirasanagandla17b649a2018-03-19 16:58:30 +053010786 for (band_num = 0; band_num < HDD_NUM_NL80211_BANDS;
10787 band_num++) {
Dundi Raviteja1d019fd2018-09-23 18:18:22 +053010788 if (!wiphy->bands[band_num])
10789 continue;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010790 for (channel_num = 0; channel_num <
10791 wiphy->bands[band_num]->n_channels;
10792 channel_num++) {
10793 wiphy_channel = &(wiphy->bands[band_num]->
10794 channels[channel_num]);
10795 if (wiphy_channel->center_freq == freq) {
10796 rfChannel = wiphy_channel->hw_value;
10797 /*
10798 *Restore the orginal states
10799 *of the channels
10800 */
10801 vos_nv_set_channel_state(
10802 rfChannel,
10803 cache_chann->
10804 channel_info[i].reg_status);
10805 wiphy_channel->flags =
10806 cache_chann->
10807 channel_info[i].wiphy_status;
Ashish Kumar Dhanotiya1cf97dd2019-03-11 16:59:25 +053010808 hddLog(VOS_TRACE_LEVEL_DEBUG,
10809 "Restore channel %d reg_stat %d wiphy_stat 0x%x",
10810 cache_chann->
10811 channel_info[i].channel_num,
10812 cache_chann->
10813 channel_info[i].reg_status,
10814 wiphy_channel->flags);
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010815 break;
10816 }
10817 }
10818 if (channel_num < wiphy->bands[band_num]->n_channels)
10819 break;
10820 }
10821 }
10822
10823 mutex_unlock(&hdd_ctx->cache_channel_lock);
10824
10825 status = sme_update_channel_list((tpAniSirGlobal)hdd_ctx->hHal);
10826 if (status)
10827 hddLog(VOS_TRACE_LEVEL_ERROR, "Can't Restore channel list");
10828 EXIT();
10829
10830 return 0;
10831}
10832
Ashish Kumar Dhanotiya1cf97dd2019-03-11 16:59:25 +053010833int wlan_hdd_disable_channels(hdd_context_t *hdd_ctx)
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010834{
10835 struct hdd_cache_channels *cache_chann;
10836 struct wiphy *wiphy;
10837 int freq, status, rfChannel;
10838 int i, band_num, band_ch_num;
10839 struct ieee80211_channel *wiphy_channel;
10840
10841 if (!hdd_ctx) {
10842 hddLog(VOS_TRACE_LEVEL_FATAL, "HDD Context is NULL");
10843 return -EINVAL;
10844 }
10845
10846 wiphy = hdd_ctx->wiphy;
10847
10848 mutex_lock(&hdd_ctx->cache_channel_lock);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +053010849 cache_chann = hdd_ctx->original_channels;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010850
10851 if (!cache_chann || !cache_chann->num_channels) {
10852 hddLog(VOS_TRACE_LEVEL_INFO,
10853 "%s channel list is NULL or num channels are zero",
10854 __func__);
10855 mutex_unlock(&hdd_ctx->cache_channel_lock);
10856 return -EINVAL;
10857 }
10858
10859 for (i = 0; i < cache_chann->num_channels; i++) {
10860 status = hdd_wlan_get_freq(
10861 cache_chann->channel_info[i].channel_num,
10862 &freq);
10863
Rajeev Kumar Sirasanagandla17b649a2018-03-19 16:58:30 +053010864 for (band_num = 0; band_num < HDD_NUM_NL80211_BANDS;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010865 band_num++) {
Dundi Raviteja1d019fd2018-09-23 18:18:22 +053010866 if (!wiphy->bands[band_num])
10867 continue;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010868 for (band_ch_num = 0; band_ch_num <
10869 wiphy->bands[band_num]->n_channels;
10870 band_ch_num++) {
10871 wiphy_channel = &(wiphy->bands[band_num]->
10872 channels[band_ch_num]);
10873 if (wiphy_channel->center_freq == freq) {
10874 rfChannel = wiphy_channel->hw_value;
10875 /*
10876 * Cache the current states of
10877 * the channels
10878 */
10879 cache_chann->
10880 channel_info[i].reg_status =
10881 vos_nv_getChannelEnabledState(
10882 rfChannel);
10883
10884 cache_chann->
10885 channel_info[i].wiphy_status =
10886 wiphy_channel->flags;
10887 hddLog(VOS_TRACE_LEVEL_INFO,
10888 "Disable channel %d reg_stat %d wiphy_stat 0x%x",
10889 cache_chann->
10890 channel_info[i].channel_num,
10891 cache_chann->
10892 channel_info[i].reg_status,
10893 wiphy_channel->flags);
10894
10895 vos_nv_set_channel_state(
10896 rfChannel,
10897 NV_CHANNEL_DISABLE);
10898 wiphy_channel->flags |=
10899 IEEE80211_CHAN_DISABLED;
10900 break;
10901 }
10902 }
10903 if (band_ch_num < wiphy->bands[band_num]->n_channels)
10904 break;
10905 }
10906 }
10907
10908 mutex_unlock(&hdd_ctx->cache_channel_lock);
10909 sme_update_channel_list((tpAniSirGlobal)hdd_ctx->hHal);
10910 return 0;
10911}
10912
Jeff Johnson295189b2012-06-20 16:38:30 -070010913#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10914static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
10915 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010916#else
10917static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
10918 struct cfg80211_beacon_data *params,
10919 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010920 enum nl80211_hidden_ssid hidden_ssid,
10921 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010922#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010923{
10924 tsap_Config_t *pConfig;
10925 beacon_data_t *pBeacon = NULL;
10926 struct ieee80211_mgmt *pMgmt_frame;
10927 v_U8_t *pIe=NULL;
10928 v_U16_t capab_info;
10929 eCsrAuthType RSNAuthType;
10930 eCsrEncryptionType RSNEncryptType;
10931 eCsrEncryptionType mcRSNEncryptType;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010932 int status = VOS_STATUS_SUCCESS, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010933 tpWLAN_SAPEventCB pSapEventCallback;
10934 hdd_hostapd_state_t *pHostapdState;
Jeff Johnson295189b2012-06-20 16:38:30 -070010935 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053010936 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010937 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053010938 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -070010939 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -080010940 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Vignesh Viswanathan36575f82018-06-14 16:52:21 +053010941 hdd_adapter_t *sta_adapter;
Peng Xu2446a892014-09-05 17:21:18 +053010942 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -070010943 v_BOOL_t MFPCapable = VOS_FALSE;
10944 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +053010945 v_BOOL_t sapEnable11AC =
10946 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Kapil Gupta137ef892016-12-13 19:38:00 +053010947 u_int16_t prev_rsn_length = 0;
10948
Jeff Johnson295189b2012-06-20 16:38:30 -070010949 ENTER();
10950
Nitesh Shah9b066282017-06-06 18:05:52 +053010951 wlan_hdd_tdls_disable_offchan_and_teardown_links(pHddCtx);
Vignesh Viswanathan36575f82018-06-14 16:52:21 +053010952
10953 /*
10954 * For STA+SAP concurrency support from GUI, first STA connection gets
10955 * triggered and while it is in progress, SAP start also comes up.
10956 * Once STA association is successful, STA connect event is sent to
10957 * kernel which gets queued in kernel workqueue and supplicant won't
10958 * process M1 received from AP and send M2 until this NL80211_CONNECT
10959 * event is received. Workqueue is not scheduled as RTNL lock is already
10960 * taken by hostapd thread which has issued start_bss command to driver.
10961 * Driver cannot complete start_bss as the pending command at the head
10962 * of the SME command pending list is hw_mode_update for STA session
10963 * which cannot be processed as SME is in WAITforKey state for STA
10964 * interface. The start_bss command for SAP interface is queued behind
10965 * the hw_mode_update command and so it cannot be processed until
10966 * hw_mode_update command is processed. This is causing a deadlock so
10967 * disconnect the STA interface first if connection or key exchange is
10968 * in progress and then start SAP interface.
10969 */
10970 sta_adapter = hdd_get_sta_connection_in_progress(pHddCtx);
10971 if (sta_adapter) {
10972 hddLog(LOG1, FL("Disconnecting STA with session id: %d"),
10973 sta_adapter->sessionId);
10974 wlan_hdd_disconnect(sta_adapter, eCSR_DISCONNECT_REASON_DEAUTH);
10975 }
10976
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053010977 iniConfig = pHddCtx->cfg_ini;
10978
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010979 /* Mark the indoor channel (passive) to disable */
Sourav Mohapatra8b149332018-03-06 14:28:18 +053010980 if (iniConfig->disable_indoor_channel &&
10981 pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) {
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010982 hdd_update_indoor_channel(pHddCtx, true);
10983
10984 if (!VOS_IS_STATUS_SUCCESS(
10985 sme_update_channel_list((tpAniSirGlobal)pHddCtx->hHal))) {
10986 hdd_update_indoor_channel(pHddCtx, false);
10987 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
10988 FL("Can't start BSS: update channel list failed"));
Bala Venkatesh5c06a252018-07-12 16:08:04 +053010989 ret = eHAL_STATUS_FAILURE;
10990 goto tdls_enable;
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010991 }
Ganesh Kondabattini19813af2018-01-25 17:32:44 +053010992
10993 /* check if STA is on indoor channel */
10994 if (hdd_is_sta_sap_scc_allowed_on_dfs_chan(pHddCtx))
10995 hdd_check_and_disconnect_sta_on_invalid_channel(pHddCtx);
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010996 }
10997
Jeff Johnson295189b2012-06-20 16:38:30 -070010998 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
10999
11000 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
11001
11002 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
11003
11004 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
11005
11006 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
11007
11008 //channel is already set in the set_channel Call back
11009 //pConfig->channel = pCommitConfig->channel;
11010
11011 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011012 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -070011013 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
11014
11015 pConfig->dtim_period = pBeacon->dtim_period;
11016
Arif Hussain6d2a3322013-11-17 19:50:10 -080011017 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -070011018 pConfig->dtim_period);
11019
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -080011020 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -070011021 {
11022 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -070011023 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +053011024 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
11025 {
11026 tANI_BOOLEAN restartNeeded;
11027 pConfig->ieee80211d = 1;
11028 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
11029 sme_setRegInfo(hHal, pConfig->countryCode);
11030 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
11031 }
11032 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -070011033 {
Jeff Johnson32d95a32012-09-10 13:15:23 -070011034 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011035 pConfig->ieee80211d = 1;
11036 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
11037 sme_setRegInfo(hHal, pConfig->countryCode);
11038 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -070011039 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070011040 else
11041 {
11042 pConfig->ieee80211d = 0;
11043 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011044 /*
11045 * If auto channel is configured i.e. channel is 0,
11046 * so skip channel validation.
11047 */
11048 if( AUTO_CHANNEL_SELECT != pConfig->channel )
11049 {
11050 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
11051 {
11052 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011053 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011054 ret = -EINVAL;
11055 goto error;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011056 }
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +053011057 pConfig->user_config_channel = pConfig->channel;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011058 }
11059 else
11060 {
11061 if(1 != pHddCtx->is_dynamic_channel_range_set)
11062 {
11063 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
11064 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
11065 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
11066 }
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +053011067 pHddCtx->is_dynamic_channel_range_set = 0;
11068 pConfig->user_config_channel = SAP_DEFAULT_24GHZ_CHANNEL;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011069 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011070 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070011071 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011072 {
11073 pConfig->ieee80211d = 0;
11074 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053011075
11076#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
11077 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
11078 pConfig->authType = eSAP_OPEN_SYSTEM;
11079 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
11080 pConfig->authType = eSAP_SHARED_KEY;
11081 else
11082 pConfig->authType = eSAP_AUTO_SWITCH;
11083#else
11084 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
11085 pConfig->authType = eSAP_OPEN_SYSTEM;
11086 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
11087 pConfig->authType = eSAP_SHARED_KEY;
11088 else
11089 pConfig->authType = eSAP_AUTO_SWITCH;
11090#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011091
11092 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011093
11094 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -070011095 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053011096#ifdef SAP_AUTH_OFFLOAD
11097 /* In case of sap offload, hostapd.conf is configuted with open mode and
11098 * security is configured from ini file. Due to open mode in hostapd.conf
11099 * privacy bit is set to false which will result in not sending,
11100 * data packets as encrypted.
11101 * If enable_sap_auth_offload is enabled in ini and
11102 * sap_auth_offload_sec_type is type of WPA2-PSK,
11103 * driver will set privacy bit to 1.
11104 */
11105 if (pHddCtx->cfg_ini->enable_sap_auth_offload &&
11106 pHddCtx->cfg_ini->sap_auth_offload_sec_type)
11107 pConfig->privacy = VOS_TRUE;
11108#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011109
11110 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
11111
11112 /*Set wps station to configured*/
11113 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
11114
11115 if(pIe)
11116 {
11117 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
11118 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011119 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011120 ret = -EINVAL;
11121 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070011122 }
11123 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
11124 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070011125 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -070011126 /* Check 15 bit of WPS IE as it contain information for wps state
11127 * WPS state
11128 */
11129 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
11130 {
11131 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
11132 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
11133 {
11134 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
11135 }
11136 }
11137 }
11138 else
11139 {
11140 pConfig->wps_state = SAP_WPS_DISABLED;
11141 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011142 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -070011143
c_hpothufe599e92014-06-16 11:38:55 +053011144 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
11145 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
11146 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
11147 eCSR_ENCRYPT_TYPE_NONE;
11148
Jeff Johnson295189b2012-06-20 16:38:30 -070011149 pConfig->RSNWPAReqIELength = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +053011150 memset(&pConfig->RSNWPAReqIE[0], 0, sizeof(pConfig->RSNWPAReqIE));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011151 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -070011152 WLAN_EID_RSN);
11153 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011154 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011155 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053011156 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
11157 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
11158 pConfig->RSNWPAReqIELength);
11159 else
11160 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
11161 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011162 /* The actual processing may eventually be more extensive than
11163 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -070011164 * by the app.
11165 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011166 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -070011167 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
11168 &RSNEncryptType,
11169 &mcRSNEncryptType,
11170 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -080011171 &MFPCapable,
11172 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +053011173 pConfig->RSNWPAReqIE[1]+2,
11174 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011175
11176 if( VOS_STATUS_SUCCESS == status )
11177 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011178 /* Now copy over all the security attributes you have
11179 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -070011180 * */
11181 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
11182 pConfig->mcRSNEncryptType = mcRSNEncryptType;
11183 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
11184 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011185 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -080011186 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011187 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
11188 }
11189 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011190
Jeff Johnson295189b2012-06-20 16:38:30 -070011191 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
11192 pBeacon->tail, pBeacon->tail_len);
11193
11194 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
11195 {
Kapil Gupta137ef892016-12-13 19:38:00 +053011196 if (pConfig->RSNWPAReqIE[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070011197 {
11198 /*Mixed mode WPA/WPA2*/
Kapil Gupta137ef892016-12-13 19:38:00 +053011199 prev_rsn_length = pConfig->RSNWPAReqIELength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011200 pConfig->RSNWPAReqIELength += pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053011201 if (pConfig->RSNWPAReqIELength <=
11202 (sizeof(pConfig->RSNWPAReqIE) - prev_rsn_length))
11203 memcpy(&pConfig->RSNWPAReqIE[0] + prev_rsn_length, pIe,
11204 pIe[1] + 2);
11205 else
11206 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
11207 pConfig->RSNWPAReqIELength);
11208
Jeff Johnson295189b2012-06-20 16:38:30 -070011209 }
11210 else
11211 {
11212 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053011213 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
11214 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
11215 pConfig->RSNWPAReqIELength);
11216 else
11217 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
11218 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011219 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -070011220 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
11221 &RSNEncryptType,
11222 &mcRSNEncryptType,
11223 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -080011224 &MFPCapable,
11225 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +053011226 pConfig->RSNWPAReqIE[1]+2,
11227 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011228
11229 if( VOS_STATUS_SUCCESS == status )
11230 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011231 /* Now copy over all the security attributes you have
11232 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -070011233 * */
11234 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
11235 pConfig->mcRSNEncryptType = mcRSNEncryptType;
11236 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
11237 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011238 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -080011239 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011240 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
11241 }
11242 }
11243 }
11244
Kapil Gupta137ef892016-12-13 19:38:00 +053011245 if (pConfig->RSNWPAReqIELength > sizeof(pConfig->RSNWPAReqIE)) {
Jeff Johnson4416a782013-03-25 14:17:50 -070011246 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011247 ret = -EINVAL;
11248 goto error;
Jeff Johnson4416a782013-03-25 14:17:50 -070011249 }
11250
Jeff Johnson295189b2012-06-20 16:38:30 -070011251 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
11252
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011253#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070011254 if (params->ssid != NULL)
11255 {
11256 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
11257 pConfig->SSIDinfo.ssid.length = params->ssid_len;
11258 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
11259 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
11260 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011261#else
11262 if (ssid != NULL)
11263 {
11264 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
11265 pConfig->SSIDinfo.ssid.length = ssid_len;
11266 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
11267 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
11268 }
11269#endif
11270
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011271 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -070011272 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011273
Jeff Johnson295189b2012-06-20 16:38:30 -070011274 /* default value */
11275 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
11276 pConfig->num_accept_mac = 0;
11277 pConfig->num_deny_mac = 0;
11278
11279 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
11280 pBeacon->tail, pBeacon->tail_len);
11281
11282 /* pIe for black list is following form:
11283 type : 1 byte
11284 length : 1 byte
11285 OUI : 4 bytes
11286 acl type : 1 byte
11287 no of mac addr in black list: 1 byte
11288 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011289 */
11290 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070011291 {
11292 pConfig->SapMacaddr_acl = pIe[6];
11293 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -080011294 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011295 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011296 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
11297 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011298 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
11299 for (i = 0; i < pConfig->num_deny_mac; i++)
11300 {
11301 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
11302 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011303 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011304 }
11305 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
11306 pBeacon->tail, pBeacon->tail_len);
11307
11308 /* pIe for white list is following form:
11309 type : 1 byte
11310 length : 1 byte
11311 OUI : 4 bytes
11312 acl type : 1 byte
11313 no of mac addr in white list: 1 byte
11314 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011315 */
11316 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070011317 {
11318 pConfig->SapMacaddr_acl = pIe[6];
11319 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -080011320 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011321 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011322 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
11323 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011324 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
11325 for (i = 0; i < pConfig->num_accept_mac; i++)
11326 {
11327 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
11328 acl_entry++;
11329 }
11330 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011331
Jeff Johnson295189b2012-06-20 16:38:30 -070011332 wlan_hdd_set_sapHwmode(pHostapdAdapter);
11333
Jeff Johnsone7245742012-09-05 17:12:55 -070011334#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -080011335 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +053011336 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
11337 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +053011338 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
11339 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -080011340 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
11341 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +053011342 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
11343 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011344 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +053011345 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -070011346 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +053011347 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011348
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053011349 /* If ACS disable and selected channel <= 14
11350 * OR
11351 * ACS enabled and ACS operating band is choosen as 2.4
11352 * AND
11353 * VHT in 2.4G Disabled
11354 * THEN
11355 * Fallback to 11N mode
11356 */
11357 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
11358 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +053011359 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053011360 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011361 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +053011362 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
11363 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011364 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
11365 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011366 }
11367#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011368
Jeff Johnson295189b2012-06-20 16:38:30 -070011369 // ht_capab is not what the name conveys,this is used for protection bitmap
11370 pConfig->ht_capab =
11371 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
11372
Kapil Gupta137ef892016-12-13 19:38:00 +053011373 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 {
11375 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011376 ret = -EINVAL;
11377 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070011378 }
11379
11380 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011381 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -070011382 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
11383 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011384 pConfig->obssProtEnabled =
11385 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -070011386
Chet Lanctot8cecea22014-02-11 19:09:36 -080011387#ifdef WLAN_FEATURE_11W
11388 pConfig->mfpCapable = MFPCapable;
11389 pConfig->mfpRequired = MFPRequired;
11390 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
11391 pConfig->mfpCapable, pConfig->mfpRequired);
11392#endif
11393
Arif Hussain6d2a3322013-11-17 19:50:10 -080011394 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -070011395 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -080011396 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
11397 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
11398 (int)pConfig->channel);
11399 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
11400 pConfig->SapHw_mode, pConfig->privacy,
11401 pConfig->authType);
11402 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
11403 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
11404 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
11405 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011406
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011407 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -070011408 {
11409 //Bss already started. just return.
11410 //TODO Probably it should update some beacon params.
11411 hddLog( LOGE, "Bss Already started...Ignore the request");
11412 EXIT();
11413 return 0;
11414 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011415
Agarwal Ashish51325b52014-06-16 16:50:49 +053011416 if (vos_max_concurrent_connections_reached()) {
11417 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011418 ret = -EINVAL;
11419 goto error;
Agarwal Ashish51325b52014-06-16 16:50:49 +053011420 }
11421
Jeff Johnson295189b2012-06-20 16:38:30 -070011422 pConfig->persona = pHostapdAdapter->device_mode;
11423
Peng Xu2446a892014-09-05 17:21:18 +053011424 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
11425 if ( NULL != psmeConfig)
11426 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011427 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +053011428 sme_GetConfigParam(hHal, psmeConfig);
11429 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011430#ifdef WLAN_FEATURE_AP_HT40_24G
11431 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
11432 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
11433 && pHddCtx->cfg_ini->apHT40_24GEnabled)
11434 {
11435 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
11436 sme_UpdateConfig (hHal, psmeConfig);
11437 }
11438#endif
Peng Xu2446a892014-09-05 17:21:18 +053011439 vos_mem_free(psmeConfig);
11440 }
Peng Xuafc34e32014-09-25 13:23:55 +053011441 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +053011442
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011443 set_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 pSapEventCallback = hdd_hostapd_SAPEventCB;
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +053011445
11446 vos_event_reset(&pHostapdState->vosEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -070011447 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
11448 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
11449 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011450 hddLog(LOGE,FL("SAP Start Bss fail"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011451 ret = -EINVAL;
11452 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 }
11454
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011455 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011456 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
11457
11458 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011459
Jeff Johnson295189b2012-06-20 16:38:30 -070011460 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011461 {
11462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011463 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -070011464 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070011465 VOS_ASSERT(0);
11466 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011467
Jeff Johnson295189b2012-06-20 16:38:30 -070011468 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053011469 if (WLANSAP_get_sessionId(pVosContext, &pHostapdAdapter->sessionId) !=
11470 VOS_STATUS_SUCCESS)
11471 {
11472 hddLog(LOGE,FL("Fail to get Softap sessionID"));
11473 VOS_ASSERT(0);
11474 }
Kaushik, Sushantf6070802014-10-15 15:09:23 +053011475 /* Initialize WMM configuation */
11476 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +053011477 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011478
Anurag Chouhan83026002016-12-13 22:46:21 +053011479#ifdef DHCP_SERVER_OFFLOAD
11480 /* set dhcp server offload */
11481 if (iniConfig->enable_dhcp_srv_offload &&
11482 sme_IsFeatureSupportedByFW(SAP_OFFLOADS)) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011483 vos_event_reset(&pHostapdAdapter->dhcp_status.vos_event);
Anurag Chouhan638f5e22017-03-06 12:28:43 +053011484 status = wlan_hdd_set_dhcp_server_offload(pHostapdAdapter, false);
Anurag Chouhan83026002016-12-13 22:46:21 +053011485 if (!VOS_IS_STATUS_SUCCESS(status))
11486 {
11487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11488 ("HDD DHCP Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011489 vos_event_reset(&pHostapdState->vosEvent);
11490 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
11491 status = vos_wait_single_event(&pHostapdState->vosEvent,
11492 10000);
11493 if (!VOS_IS_STATUS_SUCCESS(status)) {
11494 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011495 ret = -EINVAL;
11496 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011497 }
11498 }
Anurag Chouhan83026002016-12-13 22:46:21 +053011499 }
Anurag Chouhan83026002016-12-13 22:46:21 +053011500 status = vos_wait_single_event(&pHostapdAdapter->dhcp_status.vos_event, 2000);
11501 if (!VOS_IS_STATUS_SUCCESS(status) || pHostapdAdapter->dhcp_status.dhcp_offload_status)
11502 {
11503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11504 ("ERROR: DHCP HDD vos wait for single_event failed!! %d"),
11505 pHostapdAdapter->dhcp_status.dhcp_offload_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011506 vos_event_reset(&pHostapdState->vosEvent);
11507 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
11508 status = vos_wait_single_event(&pHostapdState->vosEvent,
11509 10000);
11510 if (!VOS_IS_STATUS_SUCCESS(status)) {
11511 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011512 ret = -EINVAL;
11513 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011514 }
11515 }
Anurag Chouhan83026002016-12-13 22:46:21 +053011516 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011517#ifdef MDNS_OFFLOAD
11518 if (iniConfig->enable_mdns_offload) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011519 vos_event_reset(&pHostapdAdapter->mdns_status.vos_event);
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011520 status = wlan_hdd_set_mdns_offload(pHostapdAdapter);
11521 if (VOS_IS_STATUS_SUCCESS(status))
11522 {
11523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11524 ("HDD MDNS Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011525 vos_event_reset(&pHostapdState->vosEvent);
11526 if (VOS_STATUS_SUCCESS ==
11527 WLANSAP_StopBss(pHddCtx->pvosContext)) {
11528 status = vos_wait_single_event(&pHostapdState->vosEvent,
11529 10000);
11530 if (!VOS_IS_STATUS_SUCCESS(status)) {
11531 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011532 ret = -EINVAL;
11533 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011534 }
11535 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011536 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011537 status = vos_wait_single_event(&pHostapdAdapter->
11538 mdns_status.vos_event, 2000);
11539 if (!VOS_IS_STATUS_SUCCESS(status) ||
11540 pHostapdAdapter->mdns_status.mdns_enable_status ||
11541 pHostapdAdapter->mdns_status.mdns_fqdn_status ||
11542 pHostapdAdapter->mdns_status.mdns_resp_status)
11543 {
11544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11545 ("MDNS HDD vos wait for single_event failed!! enable %d fqdn %d resp %d"),
11546 pHostapdAdapter->mdns_status.mdns_enable_status,
11547 pHostapdAdapter->mdns_status.mdns_fqdn_status,
11548 pHostapdAdapter->mdns_status.mdns_resp_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011549 vos_event_reset(&pHostapdState->vosEvent);
11550 if (VOS_STATUS_SUCCESS ==
11551 WLANSAP_StopBss(pHddCtx->pvosContext)) {
11552 status = vos_wait_single_event(&pHostapdState->vosEvent,
11553 10000);
11554 if (!VOS_IS_STATUS_SUCCESS(status)) {
11555 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011556 ret = -EINVAL;
11557 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011558 }
11559 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011560 }
11561 }
11562#endif /* MDNS_OFFLOAD */
11563 } else {
11564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11565 ("DHCP Disabled ini %d, FW %d"),
11566 iniConfig->enable_dhcp_srv_offload,
11567 sme_IsFeatureSupportedByFW(SAP_OFFLOADS));
Anurag Chouhan83026002016-12-13 22:46:21 +053011568 }
11569#endif /* DHCP_SERVER_OFFLOAD */
11570
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011571#ifdef WLAN_FEATURE_P2P_DEBUG
11572 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
11573 {
11574 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
11575 {
11576 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
11577 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -080011578 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011579 }
11580 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
11581 {
11582 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
11583 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -080011584 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011585 }
11586 }
11587#endif
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +053011588 /* Check and restart SAP if it is on Unsafe channel */
11589 hdd_check_for_unsafe_ch(pHostapdAdapter, pHddCtx);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011590
Jeff Johnson295189b2012-06-20 16:38:30 -070011591 pHostapdState->bCommit = TRUE;
11592 EXIT();
11593
11594 return 0;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011595error:
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011596 /* Revert the indoor to passive marking if START BSS fails */
Sourav Mohapatra8b149332018-03-06 14:28:18 +053011597 if (iniConfig->disable_indoor_channel &&
11598 pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) {
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011599 hdd_update_indoor_channel(pHddCtx, false);
11600 sme_update_channel_list((tpAniSirGlobal)pHddCtx->hHal);
11601 }
11602
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011603 clear_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
Bala Venkatesh5c06a252018-07-12 16:08:04 +053011604
11605tdls_enable:
11606 if (ret != eHAL_STATUS_SUCCESS)
11607 wlan_hdd_tdls_reenable(pHddCtx);
11608
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011609 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070011610}
11611
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011612#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011613static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011614 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070011615 struct beacon_parameters *params)
11616{
11617 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011618 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011619 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011620
11621 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011622
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011623 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11624 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
11625 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011626 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
11627 hdd_device_modetoString(pAdapter->device_mode),
11628 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011629
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011630 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11631 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011632 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011633 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011634 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011635 }
11636
Agarwal Ashish51325b52014-06-16 16:50:49 +053011637 if (vos_max_concurrent_connections_reached()) {
11638 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
11639 return -EINVAL;
11640 }
11641
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011642 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011643 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070011644 )
11645 {
11646 beacon_data_t *old,*new;
11647
11648 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011649
Jeff Johnson295189b2012-06-20 16:38:30 -070011650 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011651 {
11652 hddLog(VOS_TRACE_LEVEL_WARN,
11653 FL("already beacon info added to session(%d)"),
11654 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070011655 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011656 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011657
11658 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
11659
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011660 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -070011661 {
11662 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011663 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011664 return -EINVAL;
11665 }
11666
11667 pAdapter->sessionCtx.ap.beacon = new;
11668
11669 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
11670 }
11671
11672 EXIT();
11673 return status;
11674}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011675
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011676static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
11677 struct net_device *dev,
11678 struct beacon_parameters *params)
11679{
11680 int ret;
11681
11682 vos_ssr_protect(__func__);
11683 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
11684 vos_ssr_unprotect(__func__);
11685
11686 return ret;
11687}
11688
11689static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 struct net_device *dev,
11691 struct beacon_parameters *params)
11692{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011693 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011694 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11695 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011696 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011697
11698 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011699
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011700 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11701 TRACE_CODE_HDD_CFG80211_SET_BEACON,
11702 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
11703 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11704 __func__, hdd_device_modetoString(pAdapter->device_mode),
11705 pAdapter->device_mode);
11706
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011707 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11708 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011709 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011710 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011711 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011712 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011713
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011714 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011715 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011716 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011717 {
11718 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011719
Jeff Johnson295189b2012-06-20 16:38:30 -070011720 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011721
Jeff Johnson295189b2012-06-20 16:38:30 -070011722 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011723 {
11724 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11725 FL("session(%d) old and new heads points to NULL"),
11726 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070011727 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011728 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011729
11730 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
11731
11732 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011733 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011734 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011735 return -EINVAL;
11736 }
11737
11738 pAdapter->sessionCtx.ap.beacon = new;
11739
11740 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
11741 }
11742
11743 EXIT();
11744 return status;
11745}
11746
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011747static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
11748 struct net_device *dev,
11749 struct beacon_parameters *params)
11750{
11751 int ret;
11752
11753 vos_ssr_protect(__func__);
11754 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
11755 vos_ssr_unprotect(__func__);
11756
11757 return ret;
11758}
11759
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011760#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
11761
11762#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011763static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011764 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011765#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011766static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011767 struct net_device *dev)
11768#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011769{
11770 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Vignesh Viswanathan5caacc22018-06-14 17:14:20 +053011771 hdd_adapter_t *staAdapter = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070011772 hdd_context_t *pHddCtx = NULL;
11773 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011774 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011775 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070011776
11777 ENTER();
11778
11779 if (NULL == pAdapter)
11780 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011781 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011782 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011783 return -ENODEV;
11784 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011785
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011786 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11787 TRACE_CODE_HDD_CFG80211_STOP_AP,
11788 pAdapter->sessionId, pAdapter->device_mode));
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)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011792 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011793 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -070011794 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011795
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011796 pScanInfo = &pHddCtx->scan_info;
11797
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011798 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11799 __func__, hdd_device_modetoString(pAdapter->device_mode),
11800 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011801
Vignesh Viswanathan5caacc22018-06-14 17:14:20 +053011802 /*
11803 * if a sta connection is in progress in another adapter, disconnect
11804 * the sta and complete the sap operation. sta will reconnect
11805 * after sap stop is done.
11806 */
11807 staAdapter = hdd_get_sta_connection_in_progress(pHddCtx);
11808 if (staAdapter) {
11809 hddLog(LOG1, FL("disconnecting sta with session id: %d"),
11810 staAdapter->sessionId);
11811 wlan_hdd_disconnect(staAdapter, eCSR_DISCONNECT_REASON_DEAUTH);
11812 }
11813
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011814 ret = wlan_hdd_scan_abort(pAdapter);
11815
Girish Gowli4bf7a632014-06-12 13:42:11 +053011816 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -070011817 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011818 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11819 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011820
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011821 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -070011822 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11824 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -080011825
Jeff Johnsone7245742012-09-05 17:12:55 -070011826 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011827 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -070011828 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011829 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070011830 }
11831
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053011832 /* Delete all associated STAs before stopping AP/P2P GO */
11833 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +053011834 hdd_hostapd_stop(dev);
11835
Jeff Johnson295189b2012-06-20 16:38:30 -070011836 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070011838 )
11839 {
11840 beacon_data_t *old;
11841
11842 old = pAdapter->sessionCtx.ap.beacon;
11843
11844 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011845 {
11846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11847 FL("session(%d) beacon data points to NULL"),
11848 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070011849 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011850 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011851
Jeff Johnson295189b2012-06-20 16:38:30 -070011852 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011853
11854 mutex_lock(&pHddCtx->sap_lock);
11855 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
11856 {
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +053011857 hdd_hostapd_state_t *pHostapdState =
11858 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
11859
Abhishek Singh10e17cf2018-03-12 14:34:22 +053011860 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
11861 hdd_wait_for_ecsa_complete(pHddCtx);
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +053011862 vos_event_reset(&pHostapdState->vosEvent);
11863
Jeff Johnson4416a782013-03-25 14:17:50 -070011864 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011866 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
11867
11868 if (!VOS_IS_STATUS_SUCCESS(status))
11869 {
11870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011871 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011872 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011873 }
11874 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011875 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +053011876 /* BSS stopped, clear the active sessions for this device mode */
11877 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 }
11879 mutex_unlock(&pHddCtx->sap_lock);
11880
11881 if(status != VOS_STATUS_SUCCESS)
11882 {
11883 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011884 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011885 return -EINVAL;
11886 }
11887
Jeff Johnson4416a782013-03-25 14:17:50 -070011888 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070011889 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
11890 ==eHAL_STATUS_FAILURE)
11891 {
11892 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011893 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070011894 }
11895
Jeff Johnson4416a782013-03-25 14:17:50 -070011896 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070011897 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
11898 eANI_BOOLEAN_FALSE) )
11899 {
11900 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011901 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070011902 }
11903
11904 // Reset WNI_CFG_PROBE_RSP Flags
11905 wlan_hdd_reset_prob_rspies(pAdapter);
11906
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011907 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
11908
Jeff Johnson295189b2012-06-20 16:38:30 -070011909 pAdapter->sessionCtx.ap.beacon = NULL;
11910 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011911#ifdef WLAN_FEATURE_P2P_DEBUG
11912 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
11913 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
11914 {
11915 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
11916 "GO got removed");
11917 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
11918 }
11919#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011920 }
11921 EXIT();
11922 return status;
11923}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011924
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011925#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
11926static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
11927 struct net_device *dev)
11928{
11929 int ret;
11930
11931 vos_ssr_protect(__func__);
11932 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
11933 vos_ssr_unprotect(__func__);
11934
11935 return ret;
11936}
11937#else
11938static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
11939 struct net_device *dev)
11940{
11941 int ret;
11942
11943 vos_ssr_protect(__func__);
11944 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
11945 vos_ssr_unprotect(__func__);
11946
11947 return ret;
11948}
11949#endif
11950
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011951#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
11952
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011953static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053011954 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011955 struct cfg80211_ap_settings *params)
11956{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053011957 hdd_adapter_t *pAdapter;
11958 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011959 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011960
11961 ENTER();
11962
Girish Gowlib143d7a2015-02-18 19:39:55 +053011963 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070011964 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011965 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +053011966 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053011967 return -ENODEV;
11968 }
11969
11970 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11971 if (NULL == pAdapter)
11972 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011973 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053011974 "%s: HDD adapter is Null", __func__);
11975 return -ENODEV;
11976 }
11977
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011978 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11979 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
11980 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053011981 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
11982 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011983 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053011984 "%s: HDD adapter magic is invalid", __func__);
11985 return -ENODEV;
11986 }
11987
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011988 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
11989
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053011990 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011991 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011992 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053011993 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011994 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053011995 }
11996
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011997 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
11998 __func__, hdd_device_modetoString(pAdapter->device_mode),
11999 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012000
12001 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012002 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012003 )
12004 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012005 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012006
12007 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012008
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012009 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012010 {
12011 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
12012 FL("already beacon info added to session(%d)"),
12013 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012014 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012015 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012016
Girish Gowlib143d7a2015-02-18 19:39:55 +053012017#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
12018 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
12019 &new,
12020 &params->beacon);
12021#else
12022 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
12023 &new,
12024 &params->beacon,
12025 params->dtim_period);
12026#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012027
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012028 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012029 {
12030 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012031 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012032 return -EINVAL;
12033 }
12034 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -080012035#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -070012036 wlan_hdd_cfg80211_set_channel(wiphy, dev,
12037#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
12038 params->channel, params->channel_type);
12039#else
12040 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
12041#endif
Viral Modi3a32cc52013-02-08 11:14:52 -080012042#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012043 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053012044 params->ssid_len, params->hidden_ssid,
12045 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012046 }
12047
12048 EXIT();
12049 return status;
12050}
12051
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012052static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
12053 struct net_device *dev,
12054 struct cfg80211_ap_settings *params)
12055{
12056 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012057
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012058 vos_ssr_protect(__func__);
12059 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
12060 vos_ssr_unprotect(__func__);
12061
12062 return ret;
12063}
12064
12065static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012066 struct net_device *dev,
12067 struct cfg80211_beacon_data *params)
12068{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012069 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012070 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012071 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012072
12073 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012074
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012075 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12076 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
12077 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -080012078 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012079 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012080
12081 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12082 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012083 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070012084 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012085 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070012086 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012087
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012088 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012089 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012090 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012091 {
12092 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012093
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012094 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012095
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012096 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012097 {
12098 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12099 FL("session(%d) beacon data points to NULL"),
12100 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012101 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012102 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012103
12104 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
12105
12106 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012107 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012108 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012109 return -EINVAL;
12110 }
12111
12112 pAdapter->sessionCtx.ap.beacon = new;
12113
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053012114 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
12115 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012116 }
12117
12118 EXIT();
12119 return status;
12120}
12121
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012122static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
12123 struct net_device *dev,
12124 struct cfg80211_beacon_data *params)
12125{
12126 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012127
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012128 vos_ssr_protect(__func__);
12129 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
12130 vos_ssr_unprotect(__func__);
12131
12132 return ret;
12133}
12134
12135#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070012136
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012137static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012138 struct net_device *dev,
12139 struct bss_parameters *params)
12140{
12141 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012142 hdd_context_t *pHddCtx;
12143 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012144
12145 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012146
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012147 if (NULL == pAdapter)
12148 {
12149 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12150 "%s: HDD adapter is Null", __func__);
12151 return -ENODEV;
12152 }
12153 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012154 ret = wlan_hdd_validate_context(pHddCtx);
12155 if (0 != ret)
12156 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012157 return ret;
12158 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012159 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12160 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
12161 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012162 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12163 __func__, hdd_device_modetoString(pAdapter->device_mode),
12164 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012165
12166 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012167 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012168 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012169 {
12170 /* ap_isolate == -1 means that in change bss, upper layer doesn't
12171 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012172 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -070012173 {
12174 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012175 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012176 }
12177
12178 EXIT();
12179 return 0;
12180}
12181
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012182static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
12183 struct net_device *dev,
12184 struct bss_parameters *params)
12185{
12186 int ret;
12187
12188 vos_ssr_protect(__func__);
12189 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
12190 vos_ssr_unprotect(__func__);
12191
12192 return ret;
12193}
Kiet Lam10841362013-11-01 11:36:50 +053012194/* FUNCTION: wlan_hdd_change_country_code_cd
12195* to wait for contry code completion
12196*/
12197void* wlan_hdd_change_country_code_cb(void *pAdapter)
12198{
12199 hdd_adapter_t *call_back_pAdapter = pAdapter;
12200 complete(&call_back_pAdapter->change_country_code);
12201 return NULL;
12202}
12203
Jeff Johnson295189b2012-06-20 16:38:30 -070012204/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053012205 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -070012206 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
12207 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053012208int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012209 struct net_device *ndev,
12210 enum nl80211_iftype type,
12211 u32 *flags,
12212 struct vif_params *params
12213 )
12214{
12215 struct wireless_dev *wdev;
12216 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012217 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012218 tCsrRoamProfile *pRoamProfile = NULL;
Sourav Mohapatra85ef5062018-11-13 14:02:20 +053012219 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012221 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012222 eMib_dot11DesiredBssType connectedBssType;
12223 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012224 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012225
12226 ENTER();
12227
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012228 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012229 {
12230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12231 "%s: Adapter context is null", __func__);
12232 return VOS_STATUS_E_FAILURE;
12233 }
12234
12235 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12236 if (!pHddCtx)
12237 {
12238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12239 "%s: HDD context is null", __func__);
12240 return VOS_STATUS_E_FAILURE;
12241 }
12242
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012243 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12244 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
12245 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012246 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012247 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012248 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012249 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012250 }
12251
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012252 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12253 __func__, hdd_device_modetoString(pAdapter->device_mode),
12254 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012255
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053012256 if (pHddCtx->concurrency_mode == VOS_STA_MON) {
12257 hddLog(VOS_TRACE_LEVEL_FATAL,
12258 "%s: STA + MON is in progress, cannot change interface",
12259 __func__);
12260 }
12261
Agarwal Ashish51325b52014-06-16 16:50:49 +053012262 if (vos_max_concurrent_connections_reached()) {
12263 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12264 return -EINVAL;
12265 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012266 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070012267 wdev = ndev->ieee80211_ptr;
12268
12269#ifdef WLAN_BTAMP_FEATURE
12270 if((NL80211_IFTYPE_P2P_CLIENT == type)||
12271 (NL80211_IFTYPE_ADHOC == type)||
12272 (NL80211_IFTYPE_AP == type)||
12273 (NL80211_IFTYPE_P2P_GO == type))
12274 {
12275 pHddCtx->isAmpAllowed = VOS_FALSE;
12276 // stop AMP traffic
12277 status = WLANBAP_StopAmp();
12278 if(VOS_STATUS_SUCCESS != status )
12279 {
12280 pHddCtx->isAmpAllowed = VOS_TRUE;
12281 hddLog(VOS_TRACE_LEVEL_FATAL,
12282 "%s: Failed to stop AMP", __func__);
12283 return -EINVAL;
12284 }
12285 }
12286#endif //WLAN_BTAMP_FEATURE
12287 /* Reset the current device mode bit mask*/
12288 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
12289
Bala Venkatesh5c06a252018-07-12 16:08:04 +053012290 if (((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
12291 (type == NL80211_IFTYPE_P2P_CLIENT || type == NL80211_IFTYPE_P2P_GO)) ||
12292 type == NL80211_IFTYPE_AP)
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053012293 {
12294 /* Notify Mode change in case of concurrency.
12295 * Below function invokes TDLS teardown Functionality Since TDLS is
12296 * not Supported in case of concurrency i.e Once P2P session
12297 * is detected disable offchannel and teardown TDLS links
12298 */
12299 hddLog(LOG1,
12300 FL("Device mode = %d Interface type = %d"),
12301 pAdapter->device_mode, type);
12302 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
12303 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053012304
Jeff Johnson295189b2012-06-20 16:38:30 -070012305 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070012306 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070012307 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070012308 )
12309 {
12310 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012311 if (!pWextState)
12312 {
12313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12314 "%s: pWextState is null", __func__);
12315 return VOS_STATUS_E_FAILURE;
12316 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012317 pRoamProfile = &pWextState->roamProfile;
12318 LastBSSType = pRoamProfile->BSSType;
12319
12320 switch (type)
12321 {
12322 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070012323 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070012324 hddLog(VOS_TRACE_LEVEL_INFO,
12325 "%s: setting interface Type to INFRASTRUCTURE", __func__);
12326 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070012327#ifdef WLAN_FEATURE_11AC
12328 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
12329 {
12330 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
12331 }
12332#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012333 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070012334 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080012336 //Check for sub-string p2p to confirm its a p2p interface
12337 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012338 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053012339#ifdef FEATURE_WLAN_TDLS
12340 mutex_lock(&pHddCtx->tdls_lock);
12341 wlan_hdd_tdls_exit(pAdapter, TRUE);
12342 mutex_unlock(&pHddCtx->tdls_lock);
12343#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080012344 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
12345 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
12346 }
12347 else
12348 {
12349 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070012350 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080012351 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012352 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053012353
Jeff Johnson295189b2012-06-20 16:38:30 -070012354 case NL80211_IFTYPE_ADHOC:
12355 hddLog(VOS_TRACE_LEVEL_INFO,
12356 "%s: setting interface Type to ADHOC", __func__);
12357 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
12358 pRoamProfile->phyMode =
12359 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070012360 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012361 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053012362 hdd_set_ibss_ops( pAdapter );
12363 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053012364
12365 status = hdd_sta_id_hash_attach(pAdapter);
12366 if (VOS_STATUS_SUCCESS != status) {
12367 hddLog(VOS_TRACE_LEVEL_ERROR,
12368 FL("Failed to initialize hash for IBSS"));
12369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012370 break;
12371
12372 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070012373 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 {
12375 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
12376 "%s: setting interface Type to %s", __func__,
12377 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
12378
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080012379 //Cancel any remain on channel for GO mode
12380 if (NL80211_IFTYPE_P2P_GO == type)
12381 {
12382 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
12383 }
Sourav Mohapatra85ef5062018-11-13 14:02:20 +053012384 if (NL80211_IFTYPE_AP == type)
12385 {
12386 /*
12387 * As Loading WLAN Driver one interface being created
12388 * for p2p device address. This will take one HW STA and
12389 * the max number of clients that can connect to softAP
12390 * will be reduced by one. so while changing the interface
12391 * type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 interface
12392 * as it is not required in SoftAP mode.
12393 */
12394
12395 // Get P2P Adapter
12396 pP2pAdapter = hdd_get_adapter(pHddCtx,
12397 WLAN_HDD_P2P_DEVICE);
12398 if (pP2pAdapter)
12399 {
Min Liuf3481952018-12-10 16:01:14 +080012400 wlan_hdd_release_intf_addr(pHddCtx,
12401 pP2pAdapter->macAddressCurrent.bytes);
Sourav Mohapatra85ef5062018-11-13 14:02:20 +053012402 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
12403 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
12404 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
12405 }
12406 }
12407
Swaroop Goltia2e32212014-04-09 23:37:33 +053012408 //Disable IMPS & BMPS for SAP/GO
12409 if(VOS_STATUS_E_FAILURE ==
12410 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
12411 {
12412 //Fail to Exit BMPS
12413 VOS_ASSERT(0);
12414 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053012415
12416 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
12417
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012418#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070012419
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012420 /* A Mutex Lock is introduced while changing the mode to
12421 * protect the concurrent access for the Adapters by TDLS
12422 * module.
12423 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012424 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012425#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053012427 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070012429 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
12430 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012431#ifdef FEATURE_WLAN_TDLS
12432 mutex_unlock(&pHddCtx->tdls_lock);
12433#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070012434 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
12435 (pConfig->apRandomBssidEnabled))
12436 {
12437 /* To meet Android requirements create a randomized
12438 MAC address of the form 02:1A:11:Fx:xx:xx */
12439 get_random_bytes(&ndev->dev_addr[3], 3);
12440 ndev->dev_addr[0] = 0x02;
12441 ndev->dev_addr[1] = 0x1A;
12442 ndev->dev_addr[2] = 0x11;
12443 ndev->dev_addr[3] |= 0xF0;
12444 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
12445 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080012446 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
12447 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070012448 }
12449
Jeff Johnson295189b2012-06-20 16:38:30 -070012450 hdd_set_ap_ops( pAdapter->dev );
12451
Kiet Lam10841362013-11-01 11:36:50 +053012452 /* This is for only SAP mode where users can
12453 * control country through ini.
12454 * P2P GO follows station country code
12455 * acquired during the STA scanning. */
12456 if((NL80211_IFTYPE_AP == type) &&
12457 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
12458 {
12459 int status = 0;
12460 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
12461 "%s: setting country code from INI ", __func__);
12462 init_completion(&pAdapter->change_country_code);
12463 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
12464 (void *)(tSmeChangeCountryCallback)
12465 wlan_hdd_change_country_code_cb,
12466 pConfig->apCntryCode, pAdapter,
12467 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053012468 eSIR_FALSE,
12469 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053012470 if (eHAL_STATUS_SUCCESS == status)
12471 {
12472 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012473 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053012474 &pAdapter->change_country_code,
12475 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012476 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053012477 {
12478 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012479 FL("SME Timed out while setting country code %ld"),
12480 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080012481
12482 if (pHddCtx->isLogpInProgress)
12483 {
12484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12485 "%s: LOGP in Progress. Ignore!!!", __func__);
12486 return -EAGAIN;
12487 }
Kiet Lam10841362013-11-01 11:36:50 +053012488 }
12489 }
12490 else
12491 {
12492 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012493 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053012494 return -EINVAL;
12495 }
12496 }
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +053012497 status = hdd_init_ap_mode(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -070012498 if(status != VOS_STATUS_SUCCESS)
12499 {
12500 hddLog(VOS_TRACE_LEVEL_FATAL,
12501 "%s: Error initializing the ap mode", __func__);
12502 return -EINVAL;
12503 }
12504 hdd_set_conparam(1);
12505
Nirav Shah7e3c8132015-06-22 23:51:42 +053012506 status = hdd_sta_id_hash_attach(pAdapter);
12507 if (VOS_STATUS_SUCCESS != status)
12508 {
12509 hddLog(VOS_TRACE_LEVEL_ERROR,
12510 FL("Failed to initialize hash for AP"));
12511 return -EINVAL;
12512 }
12513
Jeff Johnson295189b2012-06-20 16:38:30 -070012514 /*interface type changed update in wiphy structure*/
12515 if(wdev)
12516 {
12517 wdev->iftype = type;
12518 pHddCtx->change_iface = type;
12519 }
12520 else
12521 {
12522 hddLog(VOS_TRACE_LEVEL_ERROR,
12523 "%s: ERROR !!!! Wireless dev is NULL", __func__);
12524 return -EINVAL;
12525 }
12526 goto done;
12527 }
12528
12529 default:
12530 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
12531 __func__);
12532 return -EOPNOTSUPP;
12533 }
12534 }
12535 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012536 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070012537 )
12538 {
12539 switch(type)
12540 {
12541 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070012542 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053012544
Sourav Mohapatra85ef5062018-11-13 14:02:20 +053012545 if (pAdapter->device_mode == WLAN_HDD_SOFTAP
12546 && !hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE)) {
12547 /*
12548 * The p2p interface was deleted while SoftAP mode was init,
12549 * create that interface now that the SoftAP is going down.
12550 */
12551 pP2pAdapter = hdd_open_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE,
12552 "p2p%d", wlan_hdd_get_intf_addr(pHddCtx),
12553 VOS_TRUE);
12554 }
12555
Deepthi Gowri500fc472014-08-11 19:53:10 +053012556 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Sourav Mohapatra85ef5062018-11-13 14:02:20 +053012557
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012558#ifdef FEATURE_WLAN_TDLS
12559
12560 /* A Mutex Lock is introduced while changing the mode to
12561 * protect the concurrent access for the Adapters by TDLS
12562 * module.
12563 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012564 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012565#endif
c_hpothu002231a2015-02-05 14:58:51 +053012566 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080012568 //Check for sub-string p2p to confirm its a p2p interface
12569 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080012570 {
12571 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
12572 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
12573 }
12574 else
12575 {
12576 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070012577 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080012578 }
Agrawal Ashishcfe83282016-09-29 13:03:45 +053012579
12580 /* set con_mode to STA only when no SAP concurrency mode */
12581 if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO)))
12582 hdd_set_conparam(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012583 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
12585 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012586#ifdef FEATURE_WLAN_TDLS
12587 mutex_unlock(&pHddCtx->tdls_lock);
12588#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053012589 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 if( VOS_STATUS_SUCCESS != status )
12591 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070012592 /* In case of JB, for P2P-GO, only change interface will be called,
12593 * This is the right place to enable back bmps_imps()
12594 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012595 if (pHddCtx->hdd_wlan_suspended)
12596 {
12597 hdd_set_pwrparams(pHddCtx);
12598 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012599 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070012600 goto done;
12601 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070012604 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
12605 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012606 goto done;
12607 default:
12608 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
12609 __func__);
12610 return -EOPNOTSUPP;
12611
12612 }
12613
12614 }
12615 else
12616 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012617 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
12618 __func__, hdd_device_modetoString(pAdapter->device_mode),
12619 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012620 return -EOPNOTSUPP;
12621 }
12622
12623
12624 if(pRoamProfile)
12625 {
12626 if ( LastBSSType != pRoamProfile->BSSType )
12627 {
12628 /*interface type changed update in wiphy structure*/
12629 wdev->iftype = type;
12630
12631 /*the BSS mode changed, We need to issue disconnect
12632 if connected or in IBSS disconnect state*/
12633 if ( hdd_connGetConnectedBssType(
12634 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
12635 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
12636 {
12637 /*need to issue a disconnect to CSR.*/
12638 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12639 if( eHAL_STATUS_SUCCESS ==
12640 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12641 pAdapter->sessionId,
12642 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12643 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012644 ret = wait_for_completion_interruptible_timeout(
12645 &pAdapter->disconnect_comp_var,
12646 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12647 if (ret <= 0)
12648 {
12649 hddLog(VOS_TRACE_LEVEL_ERROR,
12650 FL("wait on disconnect_comp_var failed %ld"), ret);
12651 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012652 }
12653 }
12654 }
12655 }
12656
12657done:
12658 /*set bitmask based on updated value*/
12659 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070012660
12661 /* Only STA mode support TM now
12662 * all other mode, TM feature should be disabled */
12663 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
12664 (~VOS_STA & pHddCtx->concurrency_mode) )
12665 {
12666 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
12667 }
12668
Jeff Johnson295189b2012-06-20 16:38:30 -070012669#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012670 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012671 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070012672 {
12673 //we are ok to do AMP
12674 pHddCtx->isAmpAllowed = VOS_TRUE;
12675 }
12676#endif //WLAN_BTAMP_FEATURE
12677 EXIT();
12678 return 0;
12679}
12680
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053012681/*
12682 * FUNCTION: wlan_hdd_cfg80211_change_iface
12683 * wrapper function to protect the actual implementation from SSR.
12684 */
12685int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
12686 struct net_device *ndev,
12687 enum nl80211_iftype type,
12688 u32 *flags,
12689 struct vif_params *params
12690 )
12691{
12692 int ret;
12693
12694 vos_ssr_protect(__func__);
12695 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
12696 vos_ssr_unprotect(__func__);
12697
12698 return ret;
12699}
12700
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012701#ifdef FEATURE_WLAN_TDLS
12702static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012703 struct net_device *dev,
12704#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12705 const u8 *mac,
12706#else
12707 u8 *mac,
12708#endif
12709 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012710{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012711 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012712 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012713 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012714 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012715 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053012716 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012717
12718 ENTER();
12719
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012720 if (!dev) {
12721 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
12722 return -EINVAL;
12723 }
12724
12725 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12726 if (!pAdapter) {
12727 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
12728 return -EINVAL;
12729 }
12730
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053012731 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012732 {
12733 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12734 "Invalid arguments");
12735 return -EINVAL;
12736 }
Hoonki Lee27511902013-03-14 18:19:06 -070012737
12738 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
12739 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
12740 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012741 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070012742 "%s: TDLS mode is disabled OR not enabled in FW."
12743 MAC_ADDRESS_STR " Request declined.",
12744 __func__, MAC_ADDR_ARRAY(mac));
12745 return -ENOTSUPP;
12746 }
12747
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012748 if (pHddCtx->isLogpInProgress)
12749 {
12750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12751 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053012752 wlan_hdd_tdls_set_link_status(pAdapter,
12753 mac,
12754 eTDLS_LINK_IDLE,
12755 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012756 return -EBUSY;
12757 }
12758
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053012759 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053012760 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012761
12762 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012763 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012764 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
12765 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053012766 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012767 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070012768 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012769
12770 /* in add station, we accept existing valid staId if there is */
12771 if ((0 == update) &&
12772 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
12773 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012774 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012776 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012777 " link_status %d. staId %d. add station ignored.",
12778 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012779 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012780 return 0;
12781 }
12782 /* in change station, we accept only when staId is valid */
12783 if ((1 == update) &&
12784 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
12785 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
12786 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012787 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012788 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012789 "%s: " MAC_ADDRESS_STR
12790 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012791 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
12792 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
12793 mutex_unlock(&pHddCtx->tdls_lock);
12794 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012795 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012796 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070012797
12798 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053012799 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012800 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012801 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12802 "%s: " MAC_ADDRESS_STR
12803 " TDLS setup is ongoing. Request declined.",
12804 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070012805 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012806 }
12807
12808 /* first to check if we reached to maximum supported TDLS peer.
12809 TODO: for now, return -EPERM looks working fine,
12810 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012811 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
12812 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012813 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012814 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12815 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012816 " TDLS Max peer already connected. Request declined."
12817 " Num of peers (%d), Max allowed (%d).",
12818 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
12819 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070012820 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012821 }
12822 else
12823 {
12824 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012825 mutex_lock(&pHddCtx->tdls_lock);
12826 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012827 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012828 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012829 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012830 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12831 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
12832 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012833 return -EPERM;
12834 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012835 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012836 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012837 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053012838 wlan_hdd_tdls_set_link_status(pAdapter,
12839 mac,
12840 eTDLS_LINK_CONNECTING,
12841 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012842
Jeff Johnsond75fe012013-04-06 10:53:06 -070012843 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053012844 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012845 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012847 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070012848 if(StaParams->htcap_present)
12849 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070012851 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070012853 "ht_capa->extended_capabilities: %0x",
12854 StaParams->HTCap.extendedHtCapInfo);
12855 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012857 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012859 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070012860 if(StaParams->vhtcap_present)
12861 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070012863 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
12864 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
12865 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
12866 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012867 {
12868 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012869 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012870 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012872 "[%d]: %x ", i, StaParams->supported_rates[i]);
12873 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070012874 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053012875 else if ((1 == update) && (NULL == StaParams))
12876 {
12877 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12878 "%s : update is true, but staParams is NULL. Error!", __func__);
12879 return -EPERM;
12880 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012881
12882 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
12883
12884 if (!update)
12885 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053012886 /*Before adding sta make sure that device exited from BMPS*/
12887 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
12888 {
12889 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12890 "%s: Adding tdls peer sta. Disable BMPS", __func__);
12891 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
12892 if (status != VOS_STATUS_SUCCESS) {
12893 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
12894 }
12895 }
12896
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012897 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012898 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012899 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053012900 hddLog(VOS_TRACE_LEVEL_ERROR,
12901 FL("Failed to add TDLS peer STA. Enable Bmps"));
12902 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012903 return -EPERM;
12904 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012905 }
12906 else
12907 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012908 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012909 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012910 if (ret != eHAL_STATUS_SUCCESS) {
12911 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
12912 return -EPERM;
12913 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012914 }
12915
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012916 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012917 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
12918
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053012919 mutex_lock(&pHddCtx->tdls_lock);
12920 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
12921
Masti, Narayanraddi07262462016-01-19 12:40:06 +053012922 if ((pTdlsPeer != NULL) &&
12923 (pTdlsPeer->link_status == eTDLS_LINK_TEARING))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012924 {
Masti, Narayanraddi07262462016-01-19 12:40:06 +053012925 hddLog(VOS_TRACE_LEVEL_ERROR,
12926 FL("peer link status %u"), pTdlsPeer->link_status);
12927 mutex_unlock(&pHddCtx->tdls_lock);
12928 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012929 }
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053012930 mutex_unlock(&pHddCtx->tdls_lock);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012931
Masti, Narayanraddi07262462016-01-19 12:40:06 +053012932 if (ret <= 0)
12933 {
12934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12935 "%s: timeout waiting for tdls add station indication %ld",
12936 __func__, ret);
12937 goto error;
12938 }
12939
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012940 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
12941 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012943 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070012944 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012945 }
12946
12947 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070012948
12949error:
Atul Mittal115287b2014-07-08 13:26:33 +053012950 wlan_hdd_tdls_set_link_status(pAdapter,
12951 mac,
12952 eTDLS_LINK_IDLE,
12953 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070012954 return -EPERM;
12955
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012956}
12957#endif
12958
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053012959VOS_STATUS wlan_hdd_send_sta_authorized_event(
12960 hdd_adapter_t *adapter,
12961 hdd_context_t *hdd_ctx,
12962 const v_MACADDR_t *mac_addr)
12963{
12964 struct sk_buff *vendor_event;
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053012965 VOS_STATUS status;
Sourav Mohapatra55dfabe2019-04-03 15:09:21 +053012966 struct nl80211_sta_flag_update sta_flags;
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053012967
12968 ENTER();
12969
12970 if (!hdd_ctx) {
12971 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is null"));
12972 return -EINVAL;
12973 }
12974
12975 vendor_event =
12976 cfg80211_vendor_event_alloc(
Ashish Kumar Dhanotiyac99fbef2018-04-11 12:23:32 +053012977 hdd_ctx->wiphy,
12978#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
12979 &adapter->wdev,
12980#endif
12981 sizeof(sta_flags) +
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053012982 VOS_MAC_ADDR_SIZE + NLMSG_HDRLEN,
12983 QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES_INDEX,
12984 GFP_KERNEL);
12985 if (!vendor_event) {
12986 hddLog(VOS_TRACE_LEVEL_ERROR,
12987 FL("cfg80211_vendor_event_alloc failed"));
12988 return -EINVAL;
12989 }
12990
Sourav Mohapatra55dfabe2019-04-03 15:09:21 +053012991 sta_flags.mask |= BIT(NL80211_STA_FLAG_AUTHORIZED);
12992 sta_flags.set = true;
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053012993
Sourav Mohapatra55dfabe2019-04-03 15:09:21 +053012994 status = nla_put(vendor_event,
12995 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_STA_FLAGS,
12996 sizeof(struct nl80211_sta_flag_update),
12997 &sta_flags);
12998
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053012999 if (status) {
13000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("STA flag put fails"));
13001 kfree_skb(vendor_event);
13002 return VOS_STATUS_E_FAILURE;
13003 }
Sourav Mohapatra55dfabe2019-04-03 15:09:21 +053013004
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013005 status = nla_put(vendor_event,
Sourav Mohapatra55dfabe2019-04-03 15:09:21 +053013006 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_MAC_ADDR,
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013007 VOS_MAC_ADDR_SIZE, mac_addr->bytes);
13008 if (status) {
13009 hddLog(VOS_TRACE_LEVEL_ERROR, FL("STA MAC put fails"));
13010 kfree_skb(vendor_event);
13011 return VOS_STATUS_E_FAILURE;
13012 }
13013
13014 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
13015
13016 EXIT();
13017 return 0;
13018}
13019
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013020static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013022#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13023 const u8 *mac,
13024#else
Jeff Johnson295189b2012-06-20 16:38:30 -070013025 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013026#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013027 struct station_parameters *params)
13028{
13029 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013030 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053013031 hdd_context_t *pHddCtx;
13032 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013033 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013034 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070013035#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013036 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013037 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013038 tANI_U8 isOffChannelSupported = 0;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013039 tANI_U8 isQosWmmSta = FALSE;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070013040#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070013041
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013042 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013043
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013044 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053013045 if ((NULL == pAdapter))
13046 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053013048 "invalid adapter ");
13049 return -EINVAL;
13050 }
13051
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013052 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13053 TRACE_CODE_HDD_CHANGE_STATION,
13054 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053013055 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053013056
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013057 ret = wlan_hdd_validate_context(pHddCtx);
13058 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053013059 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013060 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053013061 }
13062
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013063 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13064
13065 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013066 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13068 "invalid HDD station context");
13069 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013071 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
13072
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013073 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
13074 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070013075 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013076 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070013077 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013078 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070013079 WLANTL_STA_AUTHENTICATED);
13080
Gopichand Nakkala29149562013-05-10 21:43:41 +053013081 if (status != VOS_STATUS_SUCCESS)
13082 {
13083 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13084 "%s: Not able to change TL state to AUTHENTICATED", __func__);
13085 return -EINVAL;
13086 }
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013087 status = wlan_hdd_send_sta_authorized_event(pAdapter, pHddCtx,
13088 &STAMacAddress);
13089 if (status != VOS_STATUS_SUCCESS)
13090 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013091 }
13092 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070013093 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
13094 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053013095#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013096 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
13097 StaParams.capability = params->capability;
13098 StaParams.uapsd_queues = params->uapsd_queues;
13099 StaParams.max_sp = params->max_sp;
13100
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013101 /* Convert (first channel , number of channels) tuple to
13102 * the total list of channels. This goes with the assumption
13103 * that if the first channel is < 14, then the next channels
13104 * are an incremental of 1 else an incremental of 4 till the number
13105 * of channels.
13106 */
13107 if (0 != params->supported_channels_len) {
13108 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
Ashish Kumar Dhanotiyaf01ec752018-04-25 15:50:15 +053013109 for ( i = 0 ; i < params->supported_channels_len
13110 && j < SIR_MAC_MAX_SUPP_CHANNELS; i+=2)
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013111 {
13112 int wifi_chan_index;
13113 StaParams.supported_channels[j] = params->supported_channels[i];
13114 wifi_chan_index =
13115 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
13116 no_of_channels = params->supported_channels[i+1];
Ashish Kumar Dhanotiyaf01ec752018-04-25 15:50:15 +053013117 for(k=1; k <= no_of_channels
13118 && j < SIR_MAC_MAX_SUPP_CHANNELS - 1; k++)
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013119 {
13120 StaParams.supported_channels[j+1] =
13121 StaParams.supported_channels[j] + wifi_chan_index;
13122 j+=1;
13123 }
13124 }
13125 StaParams.supported_channels_len = j;
13126 }
SaidiReddy Yenuga0f1a1592017-04-05 13:18:26 +053013127 if (params->supported_oper_classes_len >
13128 SIR_MAC_MAX_SUPP_OPER_CLASSES) {
13129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13130 "received oper classes:%d, resetting it to max supported %d",
13131 params->supported_oper_classes_len,
13132 SIR_MAC_MAX_SUPP_OPER_CLASSES);
13133 params->supported_oper_classes_len =
13134 SIR_MAC_MAX_SUPP_OPER_CLASSES;
13135 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013136 vos_mem_copy(StaParams.supported_oper_classes,
13137 params->supported_oper_classes,
13138 params->supported_oper_classes_len);
13139 StaParams.supported_oper_classes_len =
13140 params->supported_oper_classes_len;
13141
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053013142 if (params->ext_capab_len > sizeof(StaParams.extn_capability)) {
13143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13144 "received extn capabilities:%d, resetting it to max supported",
13145 params->ext_capab_len);
13146 params->ext_capab_len = sizeof(StaParams.extn_capability);
13147 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013148 if (0 != params->ext_capab_len)
13149 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053013150 params->ext_capab_len);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013151
13152 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070013153 {
13154 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013155 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070013156 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013157
13158 StaParams.supported_rates_len = params->supported_rates_len;
13159
13160 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
13161 * The supported_rates array , for all the structures propogating till Add Sta
13162 * to the firmware has to be modified , if the supplicant (ieee80211) is
13163 * modified to send more rates.
13164 */
13165
13166 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
13167 */
13168 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
13169 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
13170
13171 if (0 != StaParams.supported_rates_len) {
13172 int i = 0;
13173 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
13174 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013175 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013176 "Supported Rates with Length %d", StaParams.supported_rates_len);
13177 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013178 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013179 "[%d]: %0x", i, StaParams.supported_rates[i]);
13180 }
13181
13182 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070013183 {
13184 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013185 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070013186 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013187
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013188 if (0 != params->ext_capab_len ) {
13189 /*Define A Macro : TODO Sunil*/
13190 if ((1<<4) & StaParams.extn_capability[3]) {
13191 isBufSta = 1;
13192 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013193 /* TDLS Channel Switching Support */
13194 if ((1<<6) & StaParams.extn_capability[3]) {
13195 isOffChannelSupported = 1;
13196 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013197 }
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013198
13199 if (pHddCtx->cfg_ini->fEnableTDLSWmmMode &&
Nitesh Shah48df4c02016-08-12 16:27:33 +053013200 (params->ht_capa || params->vht_capa ||
13201 (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME))))
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013202 /* TDLS Peer is WME/QoS capable */
13203 isQosWmmSta = TRUE;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013204
13205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13206 "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d",
13207 __func__, isQosWmmSta, StaParams.htcap_present);
13208
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013209 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
13210 &StaParams, isBufSta,
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013211 isOffChannelSupported,
13212 isQosWmmSta);
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013213
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013214 if (VOS_STATUS_SUCCESS != status) {
13215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13216 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
13217 return -EINVAL;
13218 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013219 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
13220
13221 if (VOS_STATUS_SUCCESS != status) {
13222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13223 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
13224 return -EINVAL;
13225 }
13226 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070013227#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053013228 }
Jeff Johnsone7245742012-09-05 17:12:55 -070013229 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 return status;
13231}
13232
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013233#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
13234static int wlan_hdd_change_station(struct wiphy *wiphy,
13235 struct net_device *dev,
13236 const u8 *mac,
13237 struct station_parameters *params)
13238#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013239static int wlan_hdd_change_station(struct wiphy *wiphy,
13240 struct net_device *dev,
13241 u8 *mac,
13242 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013243#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013244{
13245 int ret;
13246
13247 vos_ssr_protect(__func__);
13248 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
13249 vos_ssr_unprotect(__func__);
13250
13251 return ret;
13252}
13253
Jeff Johnson295189b2012-06-20 16:38:30 -070013254/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013255 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070013256 * This function is used to initialize the key information
13257 */
13258#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013259static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013260 struct net_device *ndev,
13261 u8 key_index, bool pairwise,
13262 const u8 *mac_addr,
13263 struct key_params *params
13264 )
13265#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013266static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013267 struct net_device *ndev,
13268 u8 key_index, const u8 *mac_addr,
13269 struct key_params *params
13270 )
13271#endif
13272{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013273 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070013274 tCsrRoamSetKey setKey;
13275 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013276 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013277 v_U32_t roamId= 0xFF;
13278 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013279 hdd_hostapd_state_t *pHostapdState;
13280 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013281 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013282 hdd_context_t *pHddCtx;
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013283 uint8_t i;
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013284 v_MACADDR_t *peerMacAddr;
13285 u64 rsc_counter = 0;
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013286 uint8_t staid = HDD_MAX_STA_COUNT;
13287 bool pairwise_set_key = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070013288
13289 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013290
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013291 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13292 TRACE_CODE_HDD_CFG80211_ADD_KEY,
13293 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013294 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13295 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013296 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013297 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013298 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013299 }
13300
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013301 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13302 __func__, hdd_device_modetoString(pAdapter->device_mode),
13303 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013304
13305 if (CSR_MAX_NUM_KEY <= key_index)
13306 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013307 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013308 key_index);
13309
13310 return -EINVAL;
13311 }
13312
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013313 if (CSR_MAX_KEY_LEN < params->key_len)
13314 {
13315 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
13316 params->key_len);
13317
13318 return -EINVAL;
13319 }
13320
Jingxiang Gec438aea2017-10-26 16:44:00 +080013321 if (CSR_MAX_RSC_LEN < params->seq_len)
13322 {
13323 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Invalid seq length %d", __func__,
13324 params->seq_len);
Ashish Kumar Dhanotiya9783b182017-12-08 14:50:46 +053013325
13326 return -EINVAL;
Jingxiang Gec438aea2017-10-26 16:44:00 +080013327 }
13328
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013329 hddLog(VOS_TRACE_LEVEL_INFO,
Jingxiang Gec438aea2017-10-26 16:44:00 +080013330 "%s: called with key index = %d & key length %d & seq length %d",
13331 __func__, key_index, params->key_len, params->seq_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013332
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013333 peerMacAddr = (v_MACADDR_t *)mac_addr;
13334
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 /*extract key idx, key len and key*/
13336 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
13337 setKey.keyId = key_index;
13338 setKey.keyLength = params->key_len;
13339 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
Jingxiang Gec438aea2017-10-26 16:44:00 +080013340 vos_mem_copy(&setKey.keyRsc[0], params->seq, params->seq_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013341
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013342 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013343 {
13344 case WLAN_CIPHER_SUITE_WEP40:
13345 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
13346 break;
13347
13348 case WLAN_CIPHER_SUITE_WEP104:
13349 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
13350 break;
13351
13352 case WLAN_CIPHER_SUITE_TKIP:
13353 {
13354 u8 *pKey = &setKey.Key[0];
13355 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
13356
13357 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
13358
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013359 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070013360
13361 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013362 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070013363 |--------------|----------|----------|
13364 <---16bytes---><--8bytes--><--8bytes-->
13365
13366 */
13367 /*Sme expects the 32 bytes key to be in the below order
13368
13369 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013370 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070013371 |--------------|----------|----------|
13372 <---16bytes---><--8bytes--><--8bytes-->
13373 */
13374 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013375 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013376
13377 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013378 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013379
13380 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013381 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013382
13383
13384 break;
13385 }
13386
13387 case WLAN_CIPHER_SUITE_CCMP:
13388 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
13389 break;
13390
13391#ifdef FEATURE_WLAN_WAPI
13392 case WLAN_CIPHER_SUITE_SMS4:
13393 {
13394 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
13395 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
13396 params->key, params->key_len);
13397 return 0;
13398 }
13399#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070013400
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013401#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013402 case WLAN_CIPHER_SUITE_KRK:
13403 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
13404 break;
13405#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070013406
13407#ifdef WLAN_FEATURE_11W
13408 case WLAN_CIPHER_SUITE_AES_CMAC:
13409 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070013410 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070013411#endif
13412
Jeff Johnson295189b2012-06-20 16:38:30 -070013413 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070013414 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070013415 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013416 status = -EOPNOTSUPP;
13417 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013418 }
13419
13420 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
13421 __func__, setKey.encType);
13422
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013423 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070013424#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13425 (!pairwise)
13426#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013427 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013428#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013429 )
13430 {
13431 /* set group key*/
13432 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13433 "%s- %d: setting Broadcast key",
13434 __func__, __LINE__);
13435 setKey.keyDirection = eSIR_RX_ONLY;
13436 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
13437 }
13438 else
13439 {
13440 /* set pairwise key*/
13441 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13442 "%s- %d: setting pairwise key",
13443 __func__, __LINE__);
13444 setKey.keyDirection = eSIR_TX_RX;
13445 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013446 pairwise_set_key = true;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013447 }
13448 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
13449 {
13450 setKey.keyDirection = eSIR_TX_RX;
13451 /*Set the group key*/
13452 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
13453 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013454
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013455 if ( 0 != status )
13456 {
13457 hddLog(VOS_TRACE_LEVEL_ERROR,
13458 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013459 status = -EINVAL;
13460 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013461 }
13462 /*Save the keys here and call sme_RoamSetKey for setting
13463 the PTK after peer joins the IBSS network*/
13464 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
13465 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013466 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013467 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053013468 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
13469 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
13470 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013471 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013472 if( pHostapdState->bssState == BSS_START )
13473 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013474 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13475 vos_status = wlan_hdd_check_ula_done(pAdapter);
13476
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013477 if (peerMacAddr && (pairwise_set_key == true))
13478 staid = hdd_sta_id_find_from_mac_addr(pAdapter, peerMacAddr);
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013479
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013480 if ( vos_status != VOS_STATUS_SUCCESS )
13481 {
13482 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13483 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
13484 __LINE__, vos_status );
13485
13486 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
13487
13488 status = -EINVAL;
13489 goto end;
13490 }
13491
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 status = WLANSAP_SetKeySta( pVosContext, &setKey);
13493
13494 if ( status != eHAL_STATUS_SUCCESS )
13495 {
13496 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13497 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
13498 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013499 status = -EINVAL;
13500 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013501 }
13502 }
13503
13504 /* Saving WEP keys */
13505 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
13506 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
13507 {
13508 //Save the wep key in ap context. Issue setkey after the BSS is started.
13509 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
13510 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
13511 }
13512 else
13513 {
13514 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013515 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
13517 }
13518 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013519 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
13520 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013521 {
13522 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13523 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13524
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013525#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13526 if (!pairwise)
13527#else
13528 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
13529#endif
13530 {
13531 /* set group key*/
13532 if (pHddStaCtx->roam_info.deferKeyComplete)
13533 {
13534 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13535 "%s- %d: Perform Set key Complete",
13536 __func__, __LINE__);
13537 hdd_PerformRoamSetKeyComplete(pAdapter);
13538 }
13539 }
13540
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013541 if (pairwise_set_key == true)
13542 staid = pHddStaCtx->conn_info.staId[0];
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013543
Jeff Johnson295189b2012-06-20 16:38:30 -070013544 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
13545
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080013546 pWextState->roamProfile.Keys.defaultIndex = key_index;
13547
13548
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013549 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 params->key, params->key_len);
13551
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013552
Jeff Johnson295189b2012-06-20 16:38:30 -070013553 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
13554
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013555 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070013556 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013557 __func__, setKey.peerMac[0], setKey.peerMac[1],
13558 setKey.peerMac[2], setKey.peerMac[3],
13559 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070013560 setKey.keyDirection);
13561
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013562 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053013563
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013564 if ( vos_status != VOS_STATUS_SUCCESS )
13565 {
13566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
13568 __LINE__, vos_status );
13569
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013570 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013571
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013572 status = -EINVAL;
13573 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013574
13575 }
13576
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013577#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013578 /* The supplicant may attempt to set the PTK once pre-authentication
13579 is done. Save the key in the UMAC and include it in the ADD BSS
13580 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013581 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013582 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013583 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013584 hddLog(VOS_TRACE_LEVEL_INFO_MED,
13585 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013586 status = 0;
13587 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013588 }
13589 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
13590 {
13591 hddLog(VOS_TRACE_LEVEL_ERROR,
13592 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013593 status = -EINVAL;
13594 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013595 }
13596#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070013597
13598 /* issue set key request to SME*/
13599 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
13600 pAdapter->sessionId, &setKey, &roamId );
13601
13602 if ( 0 != status )
13603 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013604 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013605 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
13606 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013607 status = -EINVAL;
13608 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 }
13610
13611
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013612 /* in case of IBSS as there was no information available about WEP keys during
13613 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070013614 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013615 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
13616 !( ( IW_AUTH_KEY_MGMT_802_1X
13617 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070013618 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
13619 )
13620 &&
13621 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
13622 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
13623 )
13624 )
13625 {
13626 setKey.keyDirection = eSIR_RX_ONLY;
13627 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
13628
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013629 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070013630 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013631 __func__, setKey.peerMac[0], setKey.peerMac[1],
13632 setKey.peerMac[2], setKey.peerMac[3],
13633 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 setKey.keyDirection);
13635
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013636 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013637 pAdapter->sessionId, &setKey, &roamId );
13638
13639 if ( 0 != status )
13640 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013641 hddLog(VOS_TRACE_LEVEL_ERROR,
13642 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 __func__, status);
13644 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013645 status = -EINVAL;
13646 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013647 }
13648 }
13649 }
13650
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013651 if (pairwise_set_key == true) {
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013652 for (i = 0; i < params->seq_len; i++) {
13653 rsc_counter |= (params->seq[i] << i*8);
13654 }
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013655 WLANTL_SetKeySeqCounter(pVosContext, rsc_counter, staid);
13656 }
13657
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013658end:
13659 /* Need to clear any trace of key value in the memory.
13660 * Thus zero out the memory even though it is local
13661 * variable.
13662 */
13663 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013664 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013665 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013666}
13667
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013668#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13669static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
13670 struct net_device *ndev,
13671 u8 key_index, bool pairwise,
13672 const u8 *mac_addr,
13673 struct key_params *params
13674 )
13675#else
13676static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
13677 struct net_device *ndev,
13678 u8 key_index, const u8 *mac_addr,
13679 struct key_params *params
13680 )
13681#endif
13682{
13683 int ret;
13684 vos_ssr_protect(__func__);
13685#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13686 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
13687 mac_addr, params);
13688#else
13689 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
13690 params);
13691#endif
13692 vos_ssr_unprotect(__func__);
13693
13694 return ret;
13695}
13696
Jeff Johnson295189b2012-06-20 16:38:30 -070013697/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013698 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 * This function is used to get the key information
13700 */
13701#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013702static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013703 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013705 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 const u8 *mac_addr, void *cookie,
13707 void (*callback)(void *cookie, struct key_params*)
13708 )
13709#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013710static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013711 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 struct net_device *ndev,
13713 u8 key_index, const u8 *mac_addr, void *cookie,
13714 void (*callback)(void *cookie, struct key_params*)
13715 )
13716#endif
13717{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013718 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013719 hdd_wext_state_t *pWextState = NULL;
13720 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013721 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013722 hdd_context_t *pHddCtx;
13723 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013724
13725 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013726
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013727 if (NULL == pAdapter)
13728 {
13729 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13730 "%s: HDD adapter is Null", __func__);
13731 return -ENODEV;
13732 }
13733
13734 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13735 ret = wlan_hdd_validate_context(pHddCtx);
13736 if (0 != ret)
13737 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013738 return ret;
13739 }
13740
13741 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13742 pRoamProfile = &(pWextState->roamProfile);
13743
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013744 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13745 __func__, hdd_device_modetoString(pAdapter->device_mode),
13746 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013747
Jeff Johnson295189b2012-06-20 16:38:30 -070013748 memset(&params, 0, sizeof(params));
13749
13750 if (CSR_MAX_NUM_KEY <= key_index)
13751 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013752 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013753 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013754 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013755
13756 switch(pRoamProfile->EncryptionType.encryptionType[0])
13757 {
13758 case eCSR_ENCRYPT_TYPE_NONE:
13759 params.cipher = IW_AUTH_CIPHER_NONE;
13760 break;
13761
13762 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
13763 case eCSR_ENCRYPT_TYPE_WEP40:
13764 params.cipher = WLAN_CIPHER_SUITE_WEP40;
13765 break;
13766
13767 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
13768 case eCSR_ENCRYPT_TYPE_WEP104:
13769 params.cipher = WLAN_CIPHER_SUITE_WEP104;
13770 break;
13771
13772 case eCSR_ENCRYPT_TYPE_TKIP:
13773 params.cipher = WLAN_CIPHER_SUITE_TKIP;
13774 break;
13775
13776 case eCSR_ENCRYPT_TYPE_AES:
13777 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
13778 break;
13779
13780 default:
13781 params.cipher = IW_AUTH_CIPHER_NONE;
13782 break;
13783 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013784
c_hpothuaaf19692014-05-17 17:01:48 +053013785 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13786 TRACE_CODE_HDD_CFG80211_GET_KEY,
13787 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013788
Jeff Johnson295189b2012-06-20 16:38:30 -070013789 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
13790 params.seq_len = 0;
13791 params.seq = NULL;
13792 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
13793 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013794 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013795 return 0;
13796}
13797
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013798#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13799static int wlan_hdd_cfg80211_get_key(
13800 struct wiphy *wiphy,
13801 struct net_device *ndev,
13802 u8 key_index, bool pairwise,
13803 const u8 *mac_addr, void *cookie,
13804 void (*callback)(void *cookie, struct key_params*)
13805 )
13806#else
13807static int wlan_hdd_cfg80211_get_key(
13808 struct wiphy *wiphy,
13809 struct net_device *ndev,
13810 u8 key_index, const u8 *mac_addr, void *cookie,
13811 void (*callback)(void *cookie, struct key_params*)
13812 )
13813#endif
13814{
13815 int ret;
13816
13817 vos_ssr_protect(__func__);
13818#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13819 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
13820 mac_addr, cookie, callback);
13821#else
13822 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
13823 callback);
13824#endif
13825 vos_ssr_unprotect(__func__);
13826
13827 return ret;
13828}
13829
Jeff Johnson295189b2012-06-20 16:38:30 -070013830/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013831 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 * This function is used to delete the key information
13833 */
13834#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013835static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013837 u8 key_index,
13838 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070013839 const u8 *mac_addr
13840 )
13841#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013842static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013843 struct net_device *ndev,
13844 u8 key_index,
13845 const u8 *mac_addr
13846 )
13847#endif
13848{
13849 int status = 0;
13850
13851 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013852 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070013853 //it is observed that this is invalidating peer
13854 //key index whenever re-key is done. This is affecting data link.
13855 //It should be ok to ignore del_key.
13856#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013857 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
13858 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013859 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13860 tCsrRoamSetKey setKey;
13861 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013862
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 ENTER();
13864
13865 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
13866 __func__,pAdapter->device_mode);
13867
13868 if (CSR_MAX_NUM_KEY <= key_index)
13869 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013870 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 key_index);
13872
13873 return -EINVAL;
13874 }
13875
13876 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
13877 setKey.keyId = key_index;
13878
13879 if (mac_addr)
13880 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
13881 else
13882 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
13883
13884 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
13885
13886 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013888 )
13889 {
13890
13891 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070013892 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
13893 if( pHostapdState->bssState == BSS_START)
13894 {
13895 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013896
Jeff Johnson295189b2012-06-20 16:38:30 -070013897 if ( status != eHAL_STATUS_SUCCESS )
13898 {
13899 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13900 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
13901 __LINE__, status );
13902 }
13903 }
13904 }
13905 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013906 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070013907 )
13908 {
13909 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13910
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013911 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
13912
13913 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070013914 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013915 __func__, setKey.peerMac[0], setKey.peerMac[1],
13916 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070013917 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013918 if(pAdapter->sessionCtx.station.conn_info.connState ==
13919 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070013920 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013921 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013923
Jeff Johnson295189b2012-06-20 16:38:30 -070013924 if ( 0 != status )
13925 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013926 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 "%s: sme_RoamSetKey failure, returned %d",
13928 __func__, status);
13929 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
13930 return -EINVAL;
13931 }
13932 }
13933 }
13934#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070013935 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013936 return status;
13937}
13938
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013939#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13940static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
13941 struct net_device *ndev,
13942 u8 key_index,
13943 bool pairwise,
13944 const u8 *mac_addr
13945 )
13946#else
13947static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
13948 struct net_device *ndev,
13949 u8 key_index,
13950 const u8 *mac_addr
13951 )
13952#endif
13953{
13954 int ret;
13955
13956 vos_ssr_protect(__func__);
13957#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13958 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
13959 mac_addr);
13960#else
13961 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
13962#endif
13963 vos_ssr_unprotect(__func__);
13964
13965 return ret;
13966}
13967
Jeff Johnson295189b2012-06-20 16:38:30 -070013968/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013969 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 * This function is used to set the default tx key index
13971 */
13972#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013973static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 struct net_device *ndev,
13975 u8 key_index,
13976 bool unicast, bool multicast)
13977#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013978static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 struct net_device *ndev,
13980 u8 key_index)
13981#endif
13982{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013983 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013984 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053013985 hdd_wext_state_t *pWextState;
13986 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013987 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013988
13989 ENTER();
13990
Gopichand Nakkala29149562013-05-10 21:43:41 +053013991 if ((NULL == pAdapter))
13992 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053013994 "invalid adapter");
13995 return -EINVAL;
13996 }
13997
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013998 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13999 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
14000 pAdapter->sessionId, key_index));
14001
Gopichand Nakkala29149562013-05-10 21:43:41 +053014002 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14003 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14004
14005 if ((NULL == pWextState) || (NULL == pHddStaCtx))
14006 {
14007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14008 "invalid Wext state or HDD context");
14009 return -EINVAL;
14010 }
14011
Arif Hussain6d2a3322013-11-17 19:50:10 -080014012 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014014
Jeff Johnson295189b2012-06-20 16:38:30 -070014015 if (CSR_MAX_NUM_KEY <= key_index)
14016 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014017 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014018 key_index);
14019
14020 return -EINVAL;
14021 }
14022
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014023 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14024 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014025 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014026 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014027 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014028 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014029
Jeff Johnson295189b2012-06-20 16:38:30 -070014030 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070014031 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014032 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014033 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053014034 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080014035 pHddStaCtx->conn_info.ucEncryptionType) &&
Hu Wangb1f68cb2017-08-23 20:01:49 +080014036#ifdef FEATURE_WLAN_WAPI
14037 (eCSR_ENCRYPT_TYPE_WPI !=
14038 pHddStaCtx->conn_info.ucEncryptionType) &&
14039#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014040 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080014041 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070014042 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014043 {
14044 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070014045 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014046
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 tCsrRoamSetKey setKey;
14048 v_U32_t roamId= 0xFF;
14049 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014050
14051 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014052 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014053
Jeff Johnson295189b2012-06-20 16:38:30 -070014054 Keys->defaultIndex = (u8)key_index;
14055 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
14056 setKey.keyId = key_index;
14057 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014058
14059 vos_mem_copy(&setKey.Key[0],
14060 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070014061 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014062
Gopichand Nakkala29149562013-05-10 21:43:41 +053014063 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014064
14065 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070014066 &pHddStaCtx->conn_info.bssId[0],
14067 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014068
Gopichand Nakkala29149562013-05-10 21:43:41 +053014069 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
14070 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
14071 eCSR_ENCRYPT_TYPE_WEP104)
14072 {
14073 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
14074 even though ap is configured for WEP-40 encryption. In this canse the key length
14075 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
14076 type(104) and switching encryption type to 40*/
14077 pWextState->roamProfile.EncryptionType.encryptionType[0] =
14078 eCSR_ENCRYPT_TYPE_WEP40;
14079 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
14080 eCSR_ENCRYPT_TYPE_WEP40;
14081 }
14082
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014083 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014085
Jeff Johnson295189b2012-06-20 16:38:30 -070014086 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014087 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070014088 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014089
Jeff Johnson295189b2012-06-20 16:38:30 -070014090 if ( 0 != status )
14091 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014092 hddLog(VOS_TRACE_LEVEL_ERROR,
14093 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014094 status);
14095 return -EINVAL;
14096 }
14097 }
14098 }
14099
14100 /* In SoftAp mode setting key direction for default mode */
14101 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
14102 {
14103 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
14104 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
14105 (eCSR_ENCRYPT_TYPE_AES !=
14106 pWextState->roamProfile.EncryptionType.encryptionType[0])
14107 )
14108 {
14109 /* Saving key direction for default key index to TX default */
14110 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
14111 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
14112 }
14113 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014114 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014115 return status;
14116}
14117
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053014118#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14119static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
14120 struct net_device *ndev,
14121 u8 key_index,
14122 bool unicast, bool multicast)
14123#else
14124static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
14125 struct net_device *ndev,
14126 u8 key_index)
14127#endif
14128{
14129 int ret;
14130 vos_ssr_protect(__func__);
14131#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14132 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
14133 multicast);
14134#else
14135 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
14136#endif
14137 vos_ssr_unprotect(__func__);
14138
14139 return ret;
14140}
14141
Jeff Johnson295189b2012-06-20 16:38:30 -070014142/*
14143 * FUNCTION: wlan_hdd_cfg80211_inform_bss
14144 * This function is used to inform the BSS details to nl80211 interface.
14145 */
14146static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
14147 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
14148{
14149 struct net_device *dev = pAdapter->dev;
14150 struct wireless_dev *wdev = dev->ieee80211_ptr;
14151 struct wiphy *wiphy = wdev->wiphy;
14152 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
14153 int chan_no;
14154 int ie_length;
14155 const char *ie;
14156 unsigned int freq;
14157 struct ieee80211_channel *chan;
14158 int rssi = 0;
14159 struct cfg80211_bss *bss = NULL;
14160
Jeff Johnson295189b2012-06-20 16:38:30 -070014161 if( NULL == pBssDesc )
14162 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014163 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 return bss;
14165 }
14166
14167 chan_no = pBssDesc->channelId;
14168 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
14169 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
14170
14171 if( NULL == ie )
14172 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014173 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014174 return bss;
14175 }
14176
14177#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
14178 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
14179 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014180 freq = ieee80211_channel_to_frequency(chan_no, HDD_NL80211_BAND_2GHZ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014181 }
14182 else
14183 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014184 freq = ieee80211_channel_to_frequency(chan_no, HDD_NL80211_BAND_5GHZ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 }
14186#else
14187 freq = ieee80211_channel_to_frequency(chan_no);
14188#endif
14189
14190 chan = __ieee80211_get_channel(wiphy, freq);
14191
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053014192 if (!chan) {
14193 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
14194 return NULL;
14195 }
14196
Abhishek Singhaee43942014-06-16 18:55:47 +053014197 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070014198
Anand N Sunkad9f80b742015-07-30 20:05:51 +053014199 return cfg80211_inform_bss(wiphy, chan,
14200#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14201 CFG80211_BSS_FTYPE_UNKNOWN,
14202#endif
14203 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014204 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070014205 pBssDesc->capabilityInfo,
14206 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053014207 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070014208}
14209
Abhishek Singhe6137b82019-03-22 20:06:09 +053014210void wlan_hdd_cfg80211_unlink_bss(hdd_adapter_t *pAdapter, tSirMacAddr bssid)
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053014211{
14212 struct net_device *dev = pAdapter->dev;
14213 struct wireless_dev *wdev = dev->ieee80211_ptr;
14214 struct wiphy *wiphy = wdev->wiphy;
14215 struct cfg80211_bss *bss = NULL;
14216
Abhishek Singh5a597e62016-12-05 15:16:30 +053014217 bss = hdd_get_bss_entry(wiphy,
14218 NULL, bssid,
14219 NULL, 0);
Abhishek Singhe6137b82019-03-22 20:06:09 +053014220 if (!bss) {
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053014221 hddLog(LOGE, FL("BSS not present"));
14222 } else {
14223 hddLog(LOG1, FL("cfg80211_unlink_bss called for BSSID "
14224 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(bssid));
14225 cfg80211_unlink_bss(wiphy, bss);
Abhishek Singhe6137b82019-03-22 20:06:09 +053014226 /* cfg80211_get_bss get bss with ref count so release it */
14227 cfg80211_put_bss(wiphy, bss);
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053014228 }
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053014229}
Jeff Johnson295189b2012-06-20 16:38:30 -070014230
14231
14232/*
14233 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
14234 * This function is used to inform the BSS details to nl80211 interface.
14235 */
14236struct cfg80211_bss*
14237wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
14238 tSirBssDescription *bss_desc
14239 )
14240{
14241 /*
14242 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
14243 already exists in bss data base of cfg80211 for that particular BSS ID.
14244 Using cfg80211_inform_bss_frame to update the bss entry instead of
14245 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
14246 now there is no possibility to get the mgmt(probe response) frame from PE,
14247 converting bss_desc to ieee80211_mgmt(probe response) and passing to
14248 cfg80211_inform_bss_frame.
14249 */
14250 struct net_device *dev = pAdapter->dev;
14251 struct wireless_dev *wdev = dev->ieee80211_ptr;
14252 struct wiphy *wiphy = wdev->wiphy;
14253 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080014254#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
14255 qcom_ie_age *qie_age = NULL;
14256 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
14257#else
Jeff Johnson295189b2012-06-20 16:38:30 -070014258 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080014259#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014260 const char *ie =
14261 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
14262 unsigned int freq;
14263 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053014264 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014265 struct cfg80211_bss *bss_status = NULL;
Hanumanth Reddy Pothulae04e06c2018-05-31 14:41:36 +053014266 size_t frame_len = ie_length + offsetof(struct ieee80211_mgmt,
14267 u.probe_resp.variable);
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070014269 hdd_context_t *pHddCtx;
14270 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070014271#ifdef WLAN_OPEN_SOURCE
14272 struct timespec ts;
14273#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014274
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014275
Wilson Yangf80a0542013-10-07 13:02:37 -070014276 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14277 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070014278 if (0 != status)
14279 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070014280 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070014281 }
14282
Hanumanth Reddy Pothula33548e22018-05-31 13:28:51 +053014283 mgmt = kzalloc(frame_len, GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070014284 if (!mgmt)
14285 {
14286 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14287 "%s: memory allocation failed ", __func__);
14288 return NULL;
14289 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070014290
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070014292
14293#ifdef WLAN_OPEN_SOURCE
14294 /* Android does not want the timestamp from the frame.
14295 Instead it wants a monotonic increasing value */
14296 get_monotonic_boottime(&ts);
14297 mgmt->u.probe_resp.timestamp =
14298 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
14299#else
14300 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070014301 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
14302 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070014303
14304#endif
14305
Jeff Johnson295189b2012-06-20 16:38:30 -070014306 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
14307 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080014308
14309#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
14310 /* GPS Requirement: need age ie per entry. Using vendor specific. */
14311 /* Assuming this is the last IE, copy at the end */
14312 ie_length -=sizeof(qcom_ie_age);
14313 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
14314 qie_age->element_id = QCOM_VENDOR_IE_ID;
14315 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
14316 qie_age->oui_1 = QCOM_OUI1;
14317 qie_age->oui_2 = QCOM_OUI2;
14318 qie_age->oui_3 = QCOM_OUI3;
14319 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
Selvaraj, Sridhar4b3a8362016-10-12 12:34:08 +053014320 /* Lowi expects the timestamp of bss in units of 1/10 ms. In driver all
14321 * bss related timestamp is in units of ms. Due to this when scan results
14322 * are sent to lowi the scan age is high.To address this, send age in units
14323 * of 1/10 ms.
14324 */
14325 qie_age->age = (vos_timer_get_system_time() -
14326 bss_desc->nReceivedTime)/10;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080014327#endif
14328
Jeff Johnson295189b2012-06-20 16:38:30 -070014329 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053014330 if (bss_desc->fProbeRsp)
14331 {
14332 mgmt->frame_control |=
14333 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
14334 }
14335 else
14336 {
14337 mgmt->frame_control |=
14338 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
14339 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014340
14341#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014342 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014343 (wiphy->bands[HDD_NL80211_BAND_2GHZ] != NULL))
Jeff Johnson295189b2012-06-20 16:38:30 -070014344 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014345 freq = ieee80211_channel_to_frequency(chan_no, HDD_NL80211_BAND_2GHZ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014346 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014347 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014348 (wiphy->bands[HDD_NL80211_BAND_5GHZ] != NULL))
Jeff Johnson295189b2012-06-20 16:38:30 -070014349
14350 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014351 freq = ieee80211_channel_to_frequency(chan_no, HDD_NL80211_BAND_5GHZ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014352 }
14353 else
14354 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053014355 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
14356 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070014357 kfree(mgmt);
14358 return NULL;
14359 }
14360#else
14361 freq = ieee80211_channel_to_frequency(chan_no);
14362#endif
14363 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080014364 /*when the band is changed on the fly using the GUI, three things are done
14365 * 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)
14366 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
14367 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
14368 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
14369 * and discards the channels correponding to previous band and calls back with zero bss results.
14370 * 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
14371 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
14372 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
14373 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
14374 * So drop the bss and continue to next bss.
14375 */
14376 if(chan == NULL)
14377 {
Deepthi Gowri306657b2016-04-28 17:10:41 +053014378 hddLog(VOS_TRACE_LEVEL_ERROR,
14379 FL("chan pointer is NULL, chan_no: %d freq: %d"),
14380 chan_no, freq);
Chilam Ngc4244af2013-04-01 15:37:32 -070014381 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080014382 return NULL;
14383 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053014384 /*To keep the rssi icon of the connected AP in the scan window
14385 *and the rssi icon of the wireless networks in sync
14386 * */
14387 if (( eConnectionState_Associated ==
14388 pAdapter->sessionCtx.station.conn_info.connState ) &&
14389 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
14390 pAdapter->sessionCtx.station.conn_info.bssId,
14391 WNI_CFG_BSSID_LEN)) &&
14392 (pHddCtx->hdd_wlan_suspended == FALSE))
14393 {
14394 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
14395 rssi = (pAdapter->rssi * 100);
14396 }
14397 else
14398 {
14399 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
14400 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014401
Nirav Shah20ac06f2013-12-12 18:14:06 +053014402 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053014403 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
14404 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053014405
Jeff Johnson295189b2012-06-20 16:38:30 -070014406 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
14407 frame_len, rssi, GFP_KERNEL);
14408 kfree(mgmt);
14409 return bss_status;
14410}
14411
14412/*
14413 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
14414 * This function is used to update the BSS data base of CFG8011
14415 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014416struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014417 tCsrRoamInfo *pRoamInfo
14418 )
14419{
14420 tCsrRoamConnectedProfile roamProfile;
14421 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14422 struct cfg80211_bss *bss = NULL;
14423
14424 ENTER();
14425
14426 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
14427 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
14428
14429 if (NULL != roamProfile.pBssDesc)
14430 {
Girish Gowlif4b68022014-08-28 23:18:57 +053014431 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
14432 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014433
14434 if (NULL == bss)
14435 {
14436 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
14437 __func__);
14438 }
14439
14440 sme_RoamFreeConnectProfile(hHal, &roamProfile);
14441 }
14442 else
14443 {
14444 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
14445 __func__);
14446 }
14447 return bss;
14448}
14449
14450/*
14451 * FUNCTION: wlan_hdd_cfg80211_update_bss
14452 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014453static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
14454 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070014455 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014456{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014457 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014458 tCsrScanResultInfo *pScanResult;
14459 eHalStatus status = 0;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014460 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070014461 tScanResultHandle pResult;
14462 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070014463 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014464 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070014465 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014466
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014467 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14468 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
14469 NO_SESSION, pAdapter->sessionId));
14470
Wilson Yangf80a0542013-10-07 13:02:37 -070014471 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014472 ret = wlan_hdd_validate_context(pHddCtx);
14473 if (0 != ret)
Jeff Johnson295189b2012-06-20 16:38:30 -070014474 {
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014475 return ret;
Wilson Yangf80a0542013-10-07 13:02:37 -070014476 }
14477
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014478 if (pAdapter->request != NULL)
14479 {
14480 if ((pAdapter->request->n_ssids == 1)
14481 && (pAdapter->request->ssids != NULL)
14482 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
14483 is_p2p_scan = true;
14484 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014485 /*
14486 * start getting scan results and populate cgf80211 BSS database
14487 */
14488 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
14489
14490 /* no scan results */
14491 if (NULL == pResult)
14492 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053014493 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
14494 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053014495 wlan_hdd_get_frame_logs(pAdapter,
14496 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070014497 return status;
14498 }
14499
14500 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
14501
14502 while (pScanResult)
14503 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014504 /*
14505 * cfg80211_inform_bss() is not updating ie field of bss entry, if
14506 * entry already exists in bss data base of cfg80211 for that
14507 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
14508 * bss entry instead of cfg80211_inform_bss, But this call expects
14509 * mgmt packet as input. As of now there is no possibility to get
14510 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070014511 * ieee80211_mgmt(probe response) and passing to c
14512 * fg80211_inform_bss_frame.
14513 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014514 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
14515 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
14516 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014517 pScanResult = sme_ScanResultGetNext(hHal, pResult);
14518 continue; //Skip the non p2p bss entries
14519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014520 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
14521 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014522
Jeff Johnson295189b2012-06-20 16:38:30 -070014523
14524 if (NULL == bss_status)
14525 {
14526 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014527 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014528 }
14529 else
14530 {
Yue Maf49ba872013-08-19 12:04:25 -070014531 cfg80211_put_bss(
14532#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
14533 wiphy,
14534#endif
14535 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070014536 }
14537
14538 pScanResult = sme_ScanResultGetNext(hHal, pResult);
14539 }
14540
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014541 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014542 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014543 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014544}
14545
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014546void
14547hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
14548{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014549 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080014550 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014551} /****** end hddPrintMacAddr() ******/
14552
14553void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070014554hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014555{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014556 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014557 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070014558 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
14559 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
14560 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014561} /****** end hddPrintPmkId() ******/
14562
14563//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
14564//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
14565
14566//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
14567//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
14568
14569#define dump_bssid(bssid) \
14570 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070014571 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
14572 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014573 }
14574
14575#define dump_pmkid(pMac, pmkid) \
14576 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070014577 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
14578 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014579 }
14580
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070014581#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014582/*
14583 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
14584 * This function is used to notify the supplicant of a new PMKSA candidate.
14585 */
14586int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014587 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014588 int index, bool preauth )
14589{
Jeff Johnsone7245742012-09-05 17:12:55 -070014590#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014591 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070014592 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014593
14594 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070014595 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014596
14597 if( NULL == pRoamInfo )
14598 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014599 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014600 return -EINVAL;
14601 }
14602
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070014603 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
14604 {
14605 dump_bssid(pRoamInfo->bssid);
14606 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014607 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070014608 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014609#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014610 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014611}
14612#endif //FEATURE_WLAN_LFR
14613
Yue Maef608272013-04-08 23:09:17 -070014614#ifdef FEATURE_WLAN_LFR_METRICS
14615/*
14616 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
14617 * 802.11r/LFR metrics reporting function to report preauth initiation
14618 *
14619 */
14620#define MAX_LFR_METRICS_EVENT_LENGTH 100
14621VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
14622 tCsrRoamInfo *pRoamInfo)
14623{
14624 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
14625 union iwreq_data wrqu;
14626
14627 ENTER();
14628
14629 if (NULL == pAdapter)
14630 {
14631 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
14632 return VOS_STATUS_E_FAILURE;
14633 }
14634
14635 /* create the event */
14636 memset(&wrqu, 0, sizeof(wrqu));
14637 memset(metrics_notification, 0, sizeof(metrics_notification));
14638
14639 wrqu.data.pointer = metrics_notification;
14640 wrqu.data.length = scnprintf(metrics_notification,
14641 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
14642 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
14643
14644 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
14645
14646 EXIT();
14647
14648 return VOS_STATUS_SUCCESS;
14649}
14650
14651/*
14652 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
14653 * 802.11r/LFR metrics reporting function to report preauth completion
14654 * or failure
14655 */
14656VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
14657 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
14658{
14659 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
14660 union iwreq_data wrqu;
14661
14662 ENTER();
14663
14664 if (NULL == pAdapter)
14665 {
14666 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
14667 return VOS_STATUS_E_FAILURE;
14668 }
14669
14670 /* create the event */
14671 memset(&wrqu, 0, sizeof(wrqu));
14672 memset(metrics_notification, 0, sizeof(metrics_notification));
14673
14674 scnprintf(metrics_notification, sizeof(metrics_notification),
14675 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
14676 MAC_ADDR_ARRAY(pRoamInfo->bssid));
14677
14678 if (1 == preauth_status)
14679 strncat(metrics_notification, " TRUE", 5);
14680 else
14681 strncat(metrics_notification, " FALSE", 6);
14682
14683 wrqu.data.pointer = metrics_notification;
14684 wrqu.data.length = strlen(metrics_notification);
14685
14686 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
14687
14688 EXIT();
14689
14690 return VOS_STATUS_SUCCESS;
14691}
14692
14693/*
14694 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
14695 * 802.11r/LFR metrics reporting function to report handover initiation
14696 *
14697 */
14698VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
14699 tCsrRoamInfo *pRoamInfo)
14700{
14701 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
14702 union iwreq_data wrqu;
14703
14704 ENTER();
14705
14706 if (NULL == pAdapter)
14707 {
14708 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
14709 return VOS_STATUS_E_FAILURE;
14710 }
14711
14712 /* create the event */
14713 memset(&wrqu, 0, sizeof(wrqu));
14714 memset(metrics_notification, 0, sizeof(metrics_notification));
14715
14716 wrqu.data.pointer = metrics_notification;
14717 wrqu.data.length = scnprintf(metrics_notification,
14718 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
14719 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
14720
14721 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
14722
14723 EXIT();
14724
14725 return VOS_STATUS_SUCCESS;
14726}
14727#endif
14728
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014729
14730/**
14731 * wlan_hdd_cfg80211_validate_scan_req - validate scan request
14732 * @scan_req: scan request to be checked
14733 *
14734 * Return: true or false
14735 */
14736#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
14737static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
14738 cfg80211_scan_request
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014739 *scan_req, hdd_context_t
14740 *hdd_ctx)
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014741{
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014742 if (!scan_req || !scan_req->wiphy ||
14743 scan_req->wiphy != hdd_ctx->wiphy) {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014744 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
14745 return false;
14746 }
14747 if (vos_is_load_unload_in_progress(VOS_MODULE_ID_HDD, NULL)) {
14748 hddLog(VOS_TRACE_LEVEL_ERROR, "Load/Unload in progress");
14749 return false;
14750 }
14751 return true;
14752}
14753#else
14754static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
14755 cfg80211_scan_request
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014756 *scan_req, hdd_context_t
14757 *hdd_ctx)
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014758{
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014759 if (!scan_req || !scan_req->wiphy ||
14760 scan_req->wiphy != hdd_ctx->wiphy) {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014761 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
14762 return false;
14763 }
14764 return true;
14765}
14766#endif
14767
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014768#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))
14769/**
14770 * hdd_cfg80211_scan_done() - Scan completed callback to cfg80211
14771 * @adapter: Pointer to the adapter
14772 * @req : Scan request
14773 * @aborted : true scan aborted false scan success
14774 *
14775 * This function notifies scan done to cfg80211
14776 *
14777 * Return: none
14778 */
14779static void hdd_cfg80211_scan_done(hdd_adapter_t *adapter,
14780 struct cfg80211_scan_request *req,
14781 bool aborted)
14782{
14783 struct cfg80211_scan_info info = {
14784 .aborted = aborted
14785 };
14786
14787 if (adapter->dev->flags & IFF_UP)
14788 cfg80211_scan_done(req, &info);
14789 else
14790 hddLog(LOGW,
14791 FL("IFF_UP flag reset for %s"), adapter->dev->name);
14792}
14793#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
14794/**
14795 * hdd_cfg80211_scan_done() - Scan completed callback to cfg80211
14796 * @adapter: Pointer to the adapter
14797 * @req : Scan request
14798 * @aborted : true scan aborted false scan success
14799 *
14800 * This function notifies scan done to cfg80211
14801 *
14802 * Return: none
14803 */
14804static void hdd_cfg80211_scan_done(hdd_adapter_t *adapter,
14805 struct cfg80211_scan_request *req,
14806 bool aborted)
14807{
14808 if (adapter->dev->flags & IFF_UP)
14809 cfg80211_scan_done(req, aborted);
14810 else
14811 hddLog(LOGW,
14812 FL("IFF_UP flag reset for %s"), adapter->dev->name);
14813}
14814#else
14815/**
14816 * hdd_cfg80211_scan_done() - Scan completed callback to cfg80211
14817 * @adapter: Pointer to the adapter
14818 * @req : Scan request
14819 * @aborted : true scan aborted false scan success
14820 *
14821 * This function notifies scan done to cfg80211
14822 *
14823 * Return: none
14824 */
14825static void hdd_cfg80211_scan_done(hdd_adapter_t *adapter,
14826 struct cfg80211_scan_request *req,
14827 bool aborted)
14828{
14829 cfg80211_scan_done(req, aborted);
14830}
14831#endif
14832
Mukul Sharmab392b642017-08-17 17:45:29 +053014833#define NET_DEV_IS_IFF_UP(pAdapter) (pAdapter->dev->flags & IFF_UP)
Jeff Johnson295189b2012-06-20 16:38:30 -070014834/*
14835 * FUNCTION: hdd_cfg80211_scan_done_callback
14836 * scanning callback function, called after finishing scan
14837 *
14838 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014839static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070014840 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
14841{
14842 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014843 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070014844 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014845 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070014846 struct cfg80211_scan_request *req = NULL;
14847 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014848 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014849 long waitRet = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014850 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070014851
14852 ENTER();
14853
c_manjee1b4ab9a2016-10-26 11:36:55 +053014854 if (!pAdapter || pAdapter->magic != WLAN_HDD_ADAPTER_MAGIC ||
14855 !pAdapter->dev) {
14856 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Adapter is not valid"));
14857 return 0;
14858 }
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014859 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053014860 if (NULL == pHddCtx) {
14861 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014862 return 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014863 }
14864
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053014865#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mukul Sharmab392b642017-08-17 17:45:29 +053014866 if (!NET_DEV_IS_IFF_UP(pAdapter))
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053014867 {
14868 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down"));
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053014869 }
14870#endif
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014871 pScanInfo = &pHddCtx->scan_info;
14872
Jeff Johnson295189b2012-06-20 16:38:30 -070014873 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070014874 "%s called with halHandle = %pK, pContext = %pK,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080014875 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014876 __func__, halHandle, pContext, (int) scanId, (int) status);
14877
Kiet Lamac06e2c2013-10-23 16:25:07 +053014878 pScanInfo->mScanPendingCounter = 0;
14879
Jeff Johnson295189b2012-06-20 16:38:30 -070014880 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014881 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070014882 &pScanInfo->scan_req_completion_event,
14883 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014884 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070014885 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014886 hddLog(VOS_TRACE_LEVEL_ERROR,
14887 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070014888 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070014889 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070014890 }
14891
Yue Maef608272013-04-08 23:09:17 -070014892 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014893 {
14894 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070014895 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070014896 }
14897
14898 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014899 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014900 {
14901 hddLog(VOS_TRACE_LEVEL_INFO,
14902 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080014903 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070014904 (int) scanId);
14905 }
14906
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053014907#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mukul Sharmab392b642017-08-17 17:45:29 +053014908 if (NET_DEV_IS_IFF_UP(pAdapter))
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053014909#endif
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014910 {
14911 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
14912 pAdapter);
14913 if (0 > ret)
14914 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053014915 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014916
Jeff Johnson295189b2012-06-20 16:38:30 -070014917 /* If any client wait scan result through WEXT
14918 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070014919 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070014920 {
14921 /* The other scan request waiting for current scan finish
14922 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070014923 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070014924 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070014925 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 }
14927 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070014928 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070014929 {
14930 struct net_device *dev = pAdapter->dev;
14931 union iwreq_data wrqu;
14932 int we_event;
14933 char *msg;
14934
14935 memset(&wrqu, '\0', sizeof(wrqu));
14936 we_event = SIOCGIWSCAN;
14937 msg = NULL;
14938 wireless_send_event(dev, we_event, &wrqu, msg);
14939 }
14940 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070014941 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014942
14943 /* Get the Scan Req */
14944 req = pAdapter->request;
mukul sharmae7041822015-12-03 15:09:21 +053014945 pAdapter->request = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014946
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014947 /* Scan is no longer pending */
14948 pScanInfo->mScanPending = VOS_FALSE;
14949
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014950 if (!wlan_hdd_cfg80211_validate_scan_req(req, pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014952#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
14953 hddLog(VOS_TRACE_LEVEL_ERROR, FL("interface state %s"),
Mukul Sharmab392b642017-08-17 17:45:29 +053014954 NET_DEV_IS_IFF_UP(pAdapter) ? "up" : "down");
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014955#endif
14956
14957 if (pAdapter->dev) {
14958 hddLog(VOS_TRACE_LEVEL_ERROR, FL("device name %s"),
14959 pAdapter->dev->name);
14960 }
mukul sharmae7041822015-12-03 15:09:21 +053014961 complete(&pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -070014962 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 }
14964
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014965 /* last_scan_timestamp is used to decide if new scan
14966 * is needed or not on station interface. If last station
14967 * scan time and new station scan time is less then
14968 * last_scan_timestamp ; driver will return cached scan.
Hanumanth Reddy Pothulaf31f65c2018-01-30 19:51:27 +053014969 * Also only last_scan_timestamp is updated here last_scan_channellist
14970 * is updated on receiving scan request itself to make sure kernel
14971 * allocated scan request(scan_req) object is not dereferenced here,
14972 * because interface down, where kernel frees scan_req, may happen any
14973 * time while driver is processing scan_done_callback. So it's better
14974 * not to access scan_req in this routine.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014975 */
Hanumanth Reddy Pothulaf31f65c2018-01-30 19:51:27 +053014976 if (pScanInfo->no_cck == FALSE) { // no_cck will be set during p2p find
14977 if (status == eCSR_SCAN_SUCCESS)
14978 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
14979 else {
14980 vos_mem_zero(pHddCtx->scan_info.last_scan_channelList,
14981 sizeof(pHddCtx->scan_info.last_scan_channelList));
14982 pHddCtx->scan_info.last_scan_numChannels = 0;
14983 pScanInfo->last_scan_timestamp = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014984 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014985 }
14986
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070014987 /*
14988 * cfg80211_scan_done informing NL80211 about completion
14989 * of scanning
14990 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014991 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
14992 {
14993 aborted = true;
14994 }
mukul sharmae7041822015-12-03 15:09:21 +053014995
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014996#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mukul Sharmab392b642017-08-17 17:45:29 +053014997 if (NET_DEV_IS_IFF_UP(pAdapter) &&
14998 wlan_hdd_cfg80211_validate_scan_req(req, pHddCtx))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014999#endif
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053015000 hdd_cfg80211_scan_done(pAdapter, req, aborted);
mukul sharmae7041822015-12-03 15:09:21 +053015001
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080015002 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070015003
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015004allow_suspend:
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053015005 if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
15006 ) && (pHddCtx->spoofMacAddr.isEnabled
15007 || pHddCtx->spoofMacAddr.isReqDeferred)) {
Siddharth Bhal76972212014-10-15 16:22:51 +053015008 /* Generate new random mac addr for next scan */
15009 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +053015010
15011 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
15012 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhal76972212014-10-15 16:22:51 +053015013 }
15014
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070015015 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015016 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070015017
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070015018 /* Acquire wakelock to handle the case where APP's tries to suspend
15019 * immediatly after the driver gets connect request(i.e after scan)
15020 * from supplicant, this result in app's is suspending and not able
15021 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015022 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070015023
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015024#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mukul Sharmab392b642017-08-17 17:45:29 +053015025 if (NET_DEV_IS_IFF_UP(pAdapter))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015026#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070015027#ifdef FEATURE_WLAN_TDLS
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015028 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070015029#endif
15030
Jeff Johnson295189b2012-06-20 16:38:30 -070015031 EXIT();
15032 return 0;
15033}
15034
15035/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053015036 * FUNCTION: hdd_isConnectionInProgress
15037 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015038 *
15039 */
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015040v_BOOL_t hdd_isConnectionInProgress(hdd_context_t *pHddCtx, v_U8_t *session_id,
15041 scan_reject_states *reason)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015042{
15043 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
15044 hdd_station_ctx_t *pHddStaCtx = NULL;
15045 hdd_adapter_t *pAdapter = NULL;
15046 VOS_STATUS status = 0;
15047 v_U8_t staId = 0;
15048 v_U8_t *staMac = NULL;
15049
15050 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
15051
15052 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
15053 {
15054 pAdapter = pAdapterNode->pAdapter;
15055
15056 if( pAdapter )
15057 {
15058 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015059 "%s: Adapter with device mode %s (%d) exists",
15060 __func__, hdd_device_modetoString(pAdapter->device_mode),
15061 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015062 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053015063 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
15064 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
15065 (eConnectionState_Connecting ==
15066 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
15067 {
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015068 hddLog(LOG1,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070015069 "%s: %pK(%d) Connection is in progress", __func__,
Rashmi Ramannab1429032014-04-26 14:59:09 +053015070 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015071 if (session_id && reason)
15072 {
15073 *session_id = pAdapter->sessionId;
15074 *reason = eHDD_CONNECTION_IN_PROGRESS;
15075 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053015076 return VOS_TRUE;
15077 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015078 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053015079 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015080 {
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015081 hddLog(LOG1,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070015082 "%s: %pK(%d) Reassociation is in progress", __func__,
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015083 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015084 if (session_id && reason)
15085 {
15086 *session_id = pAdapter->sessionId;
15087 *reason = eHDD_REASSOC_IN_PROGRESS;
15088 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015089 return VOS_TRUE;
15090 }
15091 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015092 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
15093 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015094 {
15095 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15096 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Vignesh Viswanathan0ac8e562018-06-14 17:24:10 +053015097 sme_is_sta_key_exchange_in_progress(pHddCtx->hHal,
15098 pAdapter->sessionId))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015099 {
15100 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015101 hddLog(LOG1,
Arif Hussain24bafea2013-11-15 15:10:03 -080015102 "%s: client " MAC_ADDRESS_STR
15103 " is in the middle of WPS/EAPOL exchange.", __func__,
15104 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015105 if (session_id && reason)
15106 {
15107 *session_id = pAdapter->sessionId;
15108 *reason = eHDD_EAPOL_IN_PROGRESS;
15109 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053015110 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015111 }
15112 }
15113 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
15114 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
15115 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015116 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
15117 ptSapContext pSapCtx = NULL;
15118 pSapCtx = VOS_GET_SAP_CB(pVosContext);
15119 if(pSapCtx == NULL){
15120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15121 FL("psapCtx is NULL"));
15122 return VOS_FALSE;
15123 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015124 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
15125 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015126 if ((pSapCtx->aStaInfo[staId].isUsed) &&
15127 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015128 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015129 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015130
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015131 hddLog(LOG1,
Arif Hussain24bafea2013-11-15 15:10:03 -080015132 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
15133 "middle of WPS/EAPOL exchange.", __func__,
15134 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015135 if (session_id && reason)
15136 {
15137 *session_id = pAdapter->sessionId;
15138 *reason = eHDD_SAP_EAPOL_IN_PROGRESS;
15139 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053015140 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015141 }
15142 }
15143 }
15144 }
15145 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
15146 pAdapterNode = pNext;
15147 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053015148 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015149}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015150
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053015151/**
15152 * csr_scan_request_assign_bssid() - Set the BSSID received from Supplicant
15153 * to the Scan request
15154 * @scanRequest: Pointer to the csr scan request
15155 * @request: Pointer to the scan request from supplicant
15156 *
15157 * Return: None
15158 */
15159#ifdef CFG80211_SCAN_BSSID
15160static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
15161 struct cfg80211_scan_request *request)
15162{
15163 vos_mem_copy(scanRequest->bssid, request->bssid, VOS_MAC_ADDR_SIZE);
15164}
15165#else
15166static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
15167 struct cfg80211_scan_request *request)
15168{
15169}
15170#endif
15171
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +053015172#if defined(CFG80211_SCAN_RANDOM_MAC_ADDR) || \
15173 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
15174/**
15175 * hdd_is_wiphy_scan_random_support() - Check NL80211 scan randomization support
15176 * @wiphy: Pointer to wiphy structure
15177 *
15178 * This function is used to check whether @wiphy supports
15179 * NL80211 scan randomization feature.
15180 *
15181 * Return: If randomization is supported then return true else false.
15182 */
15183static bool
15184hdd_is_wiphy_scan_random_support(struct wiphy *wiphy)
15185{
15186 if (wiphy->features & NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR)
15187 return true;
15188
15189 return false;
15190}
15191
15192/**
15193 * hdd_is_nl_scan_random() - Check for randomization flag in cfg80211 scan
15194 * @nl_scan: cfg80211 scan request
15195 *
15196 * This function is used to check whether scan randomization flag is set for
15197 * current cfg80211 scan request identified by @nl_scan.
15198 *
15199 * Return: If randomization flag is set then return true else false.
15200 */
15201static bool
15202hdd_is_nl_scan_random(struct cfg80211_scan_request *nl_scan)
15203{
15204 if (nl_scan->flags & NL80211_SCAN_FLAG_RANDOM_ADDR)
15205 return true;
15206
15207 return false;
15208}
15209#else
15210static bool
15211hdd_is_wiphy_scan_random_support(struct wiphy *wiphy)
15212{
15213 return false;
15214}
15215
15216static bool
15217hdd_is_nl_scan_random(struct cfg80211_scan_request *nl_scan)
15218{
15219 return false;
15220}
15221#endif
15222
15223/**
15224 * hdd_generate_scan_random_mac() - Generate Random mac addr for cfg80211 scan
15225 * @mac_addr: Input mac-addr from which random-mac address is to be generated
15226 * @mac_mask: Bits of mac_addr which should not be randomized
15227 * @random_mac: Output pointer to hold generated random mac address
15228 *
15229 * This function is used generate random mac address using @mac_addr and
15230 * @mac_mask with following logic:
15231 * Bit value 0 in the mask means that we should randomize that bit.
15232 * Bit value 1 in the mask means that we should take specific bit value
15233 * from mac address provided.
15234 *
15235 * Return: None
15236 */
15237static void
15238hdd_generate_scan_random_mac(uint8_t *mac_addr, uint8_t *mac_mask,
15239 uint8_t *random_mac)
15240{
15241 uint32_t i;
15242 uint8_t random_byte;
15243
15244 for (i = 0; i < VOS_MAC_ADDRESS_LEN; i++) {
15245 random_byte = 0;
15246 get_random_bytes(&random_byte, 1);
15247 random_mac[i] = (mac_addr[i] & mac_mask[i]) |
15248 (random_byte & (~(mac_mask[i])));
15249 }
15250
15251 /*
15252 * Make sure locally administered bit is set if that
15253 * particular bit in the mask is 0
15254 */
15255 if (!(mac_mask[0] & 0x2))
15256 random_mac[0] |= 0x2;
15257
15258 /*
15259 * Make sure multicast/group address bit is NOT set if that
15260 * particular bit in the mask is 0
15261 */
15262 if (!(mac_mask[0] & 0x1))
15263 random_mac[0] &= ~0x1;
15264}
15265
15266/**
15267 * hdd_spoof_scan() - Spoof cfg80211 scan
15268 * @wiphy: Pointer to wiphy
15269 * @adapter: Pointer to adapter for which scan is requested
15270 * @nl_scan: Cfg80211 scan request
15271 * @is_p2p_scan: Check for p2p scan
15272 * @csr_scan: Pointer to internal (csr) scan request
15273 *
15274 * This function is used for following purposes:
15275 * (a) If cfg80211 supports scan randomization then this function invokes helper
15276 * functions to generate random-mac address.
15277 * (b) If the cfg80211 doesn't support scan randomization then randomize scans
15278 * using spoof mac received with VENDOR_SUBCMD_MAC_OUI.
15279 * (c) Configure the random-mac in transport layer.
15280 *
15281 * Return: For success return 0 else return negative value.
15282 */
15283static int
15284hdd_spoof_scan(struct wiphy *wiphy, hdd_adapter_t *adapter,
15285 struct cfg80211_scan_request *nl_scan,
15286 bool is_p2p_scan, tCsrScanRequest *csr_scan)
15287{
15288 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
15289 hdd_config_t *config = hdd_ctx->cfg_ini;
15290 uint8_t random_mac[VOS_MAC_ADDRESS_LEN];
15291 VOS_STATUS vos_status;
15292 eHalStatus hal_status;
15293
15294 csr_scan->nl_scan = true;
15295 csr_scan->scan_randomize = false;
15296
15297 if (config->enableMacSpoofing != MAC_ADDR_SPOOFING_FW_HOST_ENABLE ||
15298 !sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN))
15299 return 0;
15300
15301 vos_flush_delayed_work(&hdd_ctx->spoof_mac_addr_work);
15302
15303 if (hdd_is_wiphy_scan_random_support(wiphy)) {
15304 if (!hdd_is_nl_scan_random(nl_scan) || is_p2p_scan)
15305 return 0;
15306
15307 hdd_generate_scan_random_mac(nl_scan->mac_addr,
15308 nl_scan->mac_addr_mask,
15309 random_mac);
15310
15311 hddLog(VOS_TRACE_LEVEL_INFO,
15312 FL("cfg80211 scan random attributes:"));
15313 hddLog(VOS_TRACE_LEVEL_INFO, "mac-addr: "MAC_ADDRESS_STR
15314 " mac-mask: "MAC_ADDRESS_STR
15315 " random-mac: "MAC_ADDRESS_STR,
15316 MAC_ADDR_ARRAY(nl_scan->mac_addr),
15317 MAC_ADDR_ARRAY(nl_scan->mac_addr_mask),
15318 MAC_ADDR_ARRAY(random_mac));
15319
15320 hal_status = sme_SpoofMacAddrReq(hdd_ctx->hHal,
15321 (v_MACADDR_t *)random_mac,
15322 false);
15323 if (hal_status != eHAL_STATUS_SUCCESS) {
15324 hddLog(LOGE,
15325 FL("Send of Spoof request failed"));
15326 hddLog(LOGE,
15327 FL("Disable spoofing and use self-mac"));
15328 return 0;
15329 }
15330
15331 vos_status = WLANTL_updateSpoofMacAddr(hdd_ctx->pvosContext,
15332 (v_MACADDR_t*)random_mac,
15333 &adapter->macAddressCurrent);
15334 if(vos_status != VOS_STATUS_SUCCESS) {
15335 hddLog(VOS_TRACE_LEVEL_ERROR,
15336 FL("Failed to update spoof mac in TL"));
15337 return -EINVAL;
15338 }
15339
15340 csr_scan->scan_randomize = true;
15341
15342 return 0;
15343 }
15344
15345 /*
15346 * If wiphy does not support cfg80211 scan randomization then scan
15347 * will be randomized using the vendor MAC OUI.
15348 */
15349 if (!hdd_ctx->spoofMacAddr.isEnabled)
15350 return 0;
15351
15352 hddLog(VOS_TRACE_LEVEL_INFO,
15353 FL("MAC Spoofing enabled for current scan and spoof addr is:"
15354 MAC_ADDRESS_STR),
15355 MAC_ADDR_ARRAY(hdd_ctx->spoofMacAddr.randomMacAddr.bytes));
15356
15357 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
15358 * to fill TxBds for probe request during current scan
15359 */
15360 vos_status = WLANTL_updateSpoofMacAddr(hdd_ctx->pvosContext,
15361 &hdd_ctx->spoofMacAddr.randomMacAddr, &adapter->macAddressCurrent);
15362 if(vos_status != VOS_STATUS_SUCCESS) {
15363 hddLog(VOS_TRACE_LEVEL_ERROR,
15364 FL("Failed to update spoof mac in TL"));
15365 return -EINVAL;
15366 }
15367
15368 csr_scan->scan_randomize = true;
15369
15370 return 0;
15371}
15372
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015373/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015374 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070015375 * this scan respond to scan trigger and update cfg80211 scan database
15376 * later, scan dump command can be used to recieve scan results
15377 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015378int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080015379#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
15380 struct net_device *dev,
15381#endif
15382 struct cfg80211_scan_request *request)
15383{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053015384 hdd_adapter_t *pAdapter = NULL;
15385 hdd_context_t *pHddCtx = NULL;
15386 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015387 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015388 tCsrScanRequest scanRequest;
15389 tANI_U8 *channelList = NULL, i;
15390 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015391 int status;
15392 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015393 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015394 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053015395 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053015396 bool is_p2p_scan = false;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015397 v_U8_t curr_session_id;
15398 scan_reject_states curr_reason;
Jeff Johnson295189b2012-06-20 16:38:30 -070015399
Siddharth Bhal0c162d02014-05-06 19:50:42 +053015400#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
15401 struct net_device *dev = NULL;
15402 if (NULL == request)
15403 {
15404 hddLog(VOS_TRACE_LEVEL_ERROR,
15405 "%s: scan req param null", __func__);
15406 return -EINVAL;
15407 }
15408 dev = request->wdev->netdev;
15409#endif
15410
15411 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
15412 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
15413 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15414
Jeff Johnson295189b2012-06-20 16:38:30 -070015415 ENTER();
15416
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015417 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
15418 __func__, hdd_device_modetoString(pAdapter->device_mode),
15419 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015420
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015421 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015422 if (0 != status)
15423 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015424 return status;
15425 }
15426
Siddharth Bhal0c162d02014-05-06 19:50:42 +053015427 if (NULL == pwextBuf)
15428 {
15429 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
15430 __func__);
15431 return -EIO;
15432 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015433 cfg_param = pHddCtx->cfg_ini;
15434 pScanInfo = &pHddCtx->scan_info;
15435
Jeff Johnson295189b2012-06-20 16:38:30 -070015436#ifdef WLAN_BTAMP_FEATURE
15437 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015438 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070015439 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080015440 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015441 "%s: No scanning when AMP is on", __func__);
15442 return -EOPNOTSUPP;
15443 }
15444#endif
15445 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015446 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070015447 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015448 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015449 "%s: Not scanning on device_mode = %s (%d)",
15450 __func__, hdd_device_modetoString(pAdapter->device_mode),
15451 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015452 return -EOPNOTSUPP;
15453 }
15454
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053015455 if (pAdapter->device_mode == WLAN_HDD_MONITOR) {
15456 hddLog(LOGE, FL("Scan is not supported for monitor adapter"));
15457 return -EOPNOTSUPP;
15458 }
15459
Jeff Johnson295189b2012-06-20 16:38:30 -070015460 if (TRUE == pScanInfo->mScanPending)
15461 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053015462 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
15463 {
15464 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
15465 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015466 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070015467 }
15468
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053015469 // Don't allow scan if PNO scan is going on.
15470 if (pHddCtx->isPnoEnable)
15471 {
15472 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15473 FL("pno scan in progress"));
15474 return -EBUSY;
15475 }
15476
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015477 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070015478 //Channel and action frame is pending
15479 //Otherwise Cancel Remain On Channel and allow Scan
15480 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015481 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070015482 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053015483 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070015484 return -EBUSY;
15485 }
15486
Jeff Johnson295189b2012-06-20 16:38:30 -070015487 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
15488 {
15489 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080015490 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015491 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015492 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015493 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
15494 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053015495 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015496 "%s: MAX TM Level Scan not allowed", __func__);
15497 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015498 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070015499 }
15500 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
15501
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015502 /* Check if scan is allowed at this point of time.
15503 */
Hanumanth Reddy Pothulaec960842016-09-14 19:04:26 +053015504 if (TRUE == pHddCtx->btCoexModeSet)
15505 {
15506 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15507 FL("BTCoex Mode operation in progress"));
15508 return -EBUSY;
15509 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015510 if (hdd_isConnectionInProgress(pHddCtx, &curr_session_id, &curr_reason))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015511 {
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015512
15513 if (!(pHddCtx->scan_reject_cnt % HDD_SCAN_REJECT_RATE_LIMIT))
15514 hddLog(LOGE, FL("Scan not allowed Session %d reason %d"),
15515 curr_session_id, curr_reason);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015516 if (pHddCtx->last_scan_reject_session_id != curr_session_id ||
15517 pHddCtx->last_scan_reject_reason != curr_reason ||
15518 !pHddCtx->last_scan_reject_timestamp)
15519 {
15520 pHddCtx->last_scan_reject_session_id = curr_session_id;
15521 pHddCtx->last_scan_reject_reason = curr_reason;
Abhishek Singh3e500772017-07-17 10:13:43 +053015522 pHddCtx->last_scan_reject_timestamp =
Abhinav Kumar61d1bfe2018-07-26 00:30:22 +053015523 jiffies + msecs_to_jiffies(SCAN_REJECT_THRESHOLD_TIME);
Abhishek Singhe4b12562017-06-20 16:53:39 +053015524 pHddCtx->scan_reject_cnt = 0;
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053015525 }
Abhishek Singhe4b12562017-06-20 16:53:39 +053015526 else
15527 {
15528 pHddCtx->scan_reject_cnt++;
15529
Abhishek Singhe4b12562017-06-20 16:53:39 +053015530 if ((pHddCtx->scan_reject_cnt >=
15531 SCAN_REJECT_THRESHOLD) &&
Abhinav Kumar61d1bfe2018-07-26 00:30:22 +053015532 vos_system_time_after(jiffies,
Abhishek Singh3e500772017-07-17 10:13:43 +053015533 pHddCtx->last_scan_reject_timestamp))
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015534 {
Abhinav Kumar61d1bfe2018-07-26 00:30:22 +053015535 hddLog(LOGE, FL("Session %d reason %d reject cnt %d reject timestamp %lu jiffies %lu"),
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015536 curr_session_id, curr_reason, pHddCtx->scan_reject_cnt,
Abhinav Kumar61d1bfe2018-07-26 00:30:22 +053015537 pHddCtx->last_scan_reject_timestamp, jiffies);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015538 pHddCtx->last_scan_reject_timestamp = 0;
Abhishek Singhe4b12562017-06-20 16:53:39 +053015539 pHddCtx->scan_reject_cnt = 0;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015540 if (pHddCtx->cfg_ini->enableFatalEvent)
15541 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
15542 WLAN_LOG_INDICATOR_HOST_DRIVER,
15543 WLAN_LOG_REASON_SCAN_NOT_ALLOWED,
15544 FALSE, FALSE);
15545 else
15546 {
15547 hddLog(LOGE, FL("Triggering SSR"));
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +053015548 vos_wlanRestart(VOS_SCAN_REQ_EXPIRED);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015549 }
15550 }
15551 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015552 return -EBUSY;
15553 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015554 pHddCtx->last_scan_reject_timestamp = 0;
15555 pHddCtx->last_scan_reject_session_id = 0xFF;
15556 pHddCtx->last_scan_reject_reason = 0;
Abhishek Singhe4b12562017-06-20 16:53:39 +053015557 pHddCtx->scan_reject_cnt = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015558
Jeff Johnson295189b2012-06-20 16:38:30 -070015559 vos_mem_zero( &scanRequest, sizeof(scanRequest));
15560
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015561 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
15562 * Becasue of this, driver is assuming that this is not wildcard scan and so
15563 * is not aging out the scan results.
15564 */
Hanumanth Reddy Pothula998efeb2017-10-31 15:43:19 +053015565 if ((request->ssids) && (request->n_ssids == 1) &&
15566 ('\0' == request->ssids->ssid[0])) {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015567 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015568 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015569
15570 if ((request->ssids) && (0 < request->n_ssids))
15571 {
15572 tCsrSSIDInfo *SsidInfo;
15573 int j;
15574 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
15575 /* Allocate num_ssid tCsrSSIDInfo structure */
15576 SsidInfo = scanRequest.SSIDs.SSIDList =
15577 ( tCsrSSIDInfo *)vos_mem_malloc(
15578 request->n_ssids*sizeof(tCsrSSIDInfo));
15579
15580 if(NULL == scanRequest.SSIDs.SSIDList)
15581 {
15582 hddLog(VOS_TRACE_LEVEL_ERROR,
15583 "%s: memory alloc failed SSIDInfo buffer", __func__);
15584 return -ENOMEM;
15585 }
15586
15587 /* copy all the ssid's and their length */
15588 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
15589 {
15590 /* get the ssid length */
15591 SsidInfo->SSID.length = request->ssids[j].ssid_len;
15592 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
15593 SsidInfo->SSID.length);
15594 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
15595 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
15596 j, SsidInfo->SSID.ssId);
15597 }
15598 /* set the scan type to active */
15599 scanRequest.scanType = eSIR_ACTIVE_SCAN;
15600 }
15601 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070015602 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053015603 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15604 TRACE_CODE_HDD_CFG80211_SCAN,
15605 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070015606 /* set the scan type to active */
15607 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070015608 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015609 else
15610 {
15611 /*Set the scan type to default type, in this case it is ACTIVE*/
15612 scanRequest.scanType = pScanInfo->scan_mode;
15613 }
15614 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
15615 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070015616
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053015617 csr_scan_request_assign_bssid(&scanRequest, request);
15618
Jeff Johnson295189b2012-06-20 16:38:30 -070015619 /* set BSSType to default type */
15620 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
15621
15622 /*TODO: scan the requested channels only*/
15623
15624 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015625 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070015626 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015627 hddLog(VOS_TRACE_LEVEL_WARN,
15628 "No of Scan Channels exceeded limit: %d", request->n_channels);
15629 request->n_channels = MAX_CHANNEL;
15630 }
15631
15632 hddLog(VOS_TRACE_LEVEL_INFO,
15633 "No of Scan Channels: %d", request->n_channels);
15634
15635
15636 if( request->n_channels )
15637 {
15638 char chList [(request->n_channels*5)+1];
15639 int len;
15640 channelList = vos_mem_malloc( request->n_channels );
15641 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053015642 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015643 hddLog(VOS_TRACE_LEVEL_ERROR,
15644 "%s: memory alloc failed channelList", __func__);
15645 status = -ENOMEM;
15646 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053015647 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015648
15649 for( i = 0, len = 0; i < request->n_channels ; i++ )
15650 {
15651 channelList[i] = request->channels[i]->hw_value;
15652 len += snprintf(chList+len, 5, "%d ", channelList[i]);
15653 }
15654
Nirav Shah20ac06f2013-12-12 18:14:06 +053015655 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015656 "Channel-List: %s ", chList);
15657 }
c_hpothu53512302014-04-15 18:49:53 +053015658
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015659 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
15660 scanRequest.ChannelInfo.ChannelList = channelList;
15661
15662 /* set requestType to full scan */
15663 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
15664
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015665 /* if there is back to back scan happening in driver with in
15666 * nDeferScanTimeInterval interval driver should defer new scan request
15667 * and should provide last cached scan results instead of new channel list.
15668 * This rule is not applicable if scan is p2p scan.
15669 * This condition will work only in case when last request no of channels
15670 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053015671 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053015672 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015673 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015674
Sushant Kaushik86592172015-04-27 16:35:03 +053015675 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
15676 /* if wps ie is NULL , then only defer scan */
15677 if ( pWpsIe == NULL &&
15678 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053015679 {
15680 if ( pScanInfo->last_scan_timestamp !=0 &&
15681 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
15682 {
15683 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
15684 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
15685 vos_mem_compare(pScanInfo->last_scan_channelList,
15686 channelList, pScanInfo->last_scan_numChannels))
15687 {
15688 hddLog(VOS_TRACE_LEVEL_WARN,
15689 " New and old station scan time differ is less then %u",
15690 pHddCtx->cfg_ini->nDeferScanTimeInterval);
15691
15692 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015693 pAdapter);
15694
Agarwal Ashish57e84372014-12-05 18:26:53 +053015695 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053015696 "Return old cached scan as all channels and no of channels are same");
15697
Agarwal Ashish57e84372014-12-05 18:26:53 +053015698 if (0 > ret)
15699 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015700
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053015701 hdd_cfg80211_scan_done(pAdapter, request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053015702
15703 status = eHAL_STATUS_SUCCESS;
15704 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053015705 }
15706 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015707 }
15708
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015709 /* Flush the scan results(only p2p beacons) for STA scan and P2P
15710 * search (Flush on both full scan and social scan but not on single
15711 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
15712 */
15713
15714 /* Supplicant does single channel scan after 8-way handshake
15715 * and in that case driver shoudnt flush scan results. If
15716 * driver flushes the scan results here and unfortunately if
15717 * the AP doesnt respond to our probe req then association
15718 * fails which is not desired
15719 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053015720 if ((request->n_ssids == 1)
15721 && (request->ssids != NULL)
15722 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
15723 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015724
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053015725 if( is_p2p_scan ||
15726 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015727 {
15728 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
15729 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
15730 pAdapter->sessionId );
15731 }
15732
15733 if( request->ie_len )
15734 {
15735 /* save this for future association (join requires this) */
15736 /*TODO: Array needs to be converted to dynamic allocation,
15737 * as multiple ie.s can be sent in cfg80211_scan_request structure
15738 * CR 597966
15739 */
15740 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
15741 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
15742 pScanInfo->scanAddIE.length = request->ie_len;
15743
15744 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
15745 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
15746 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070015747 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015748 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070015749 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015750 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
15751 memcpy( pwextBuf->roamProfile.addIEScan,
15752 request->ie, request->ie_len);
15753 }
15754 else
15755 {
15756 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
15757 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015758 }
15759
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015760 }
15761 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
15762 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
15763
15764 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
15765 request->ie_len);
15766 if (pP2pIe != NULL)
15767 {
15768#ifdef WLAN_FEATURE_P2P_DEBUG
15769 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
15770 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
15771 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053015772 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015773 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
15774 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
15775 "Go nego completed to Connection is started");
15776 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
15777 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053015778 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015779 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
15780 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070015781 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015782 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
15783 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
15784 "Disconnected state to Connection is started");
15785 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
15786 "for 4way Handshake");
15787 }
15788#endif
15789
15790 /* no_cck will be set during p2p find to disable 11b rates */
15791 if(TRUE == request->no_cck)
15792 {
15793 hddLog(VOS_TRACE_LEVEL_INFO,
15794 "%s: This is a P2P Search", __func__);
15795 scanRequest.p2pSearch = 1;
15796
15797 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053015798 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015799 /* set requestType to P2P Discovery */
15800 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
15801 }
15802
15803 /*
15804 Skip Dfs Channel in case of P2P Search
15805 if it is set in ini file
15806 */
15807 if(cfg_param->skipDfsChnlInP2pSearch)
15808 {
15809 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053015810 }
15811 else
15812 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015813 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053015814 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015815
Agarwal Ashish4f616132013-12-30 23:32:50 +053015816 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015817 }
15818 }
15819
15820 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
15821
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015822#ifdef FEATURE_WLAN_TDLS
15823 /* if tdls disagree scan right now, return immediately.
15824 tdls will schedule the scan when scan is allowed. (return SUCCESS)
15825 or will reject the scan if any TDLS is in progress. (return -EBUSY)
15826 */
15827 status = wlan_hdd_tdls_scan_callback (pAdapter,
15828 wiphy,
15829#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
15830 dev,
15831#endif
15832 request);
Abhishek Singhe2b63952016-01-05 18:27:29 +053015833 if (status <= 0)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015834 {
Abhishek Singhe2b63952016-01-05 18:27:29 +053015835 if (!status)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015836 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
15837 "scan rejected %d", __func__, status);
15838 else
15839 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
15840 __func__, status);
Abhishek Singhe2b63952016-01-05 18:27:29 +053015841 hdd_wlan_block_scan_by_tdls();
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053015842 goto free_mem;
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015843 }
15844#endif
15845
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070015846 /* acquire the wakelock to avoid the apps suspend during the scan. To
15847 * address the following issues.
15848 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
15849 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
15850 * for long time, this result in apps running at full power for long time.
15851 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
15852 * be stuck in full power because of resume BMPS
15853 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015854 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070015855
Nirav Shah20ac06f2013-12-12 18:14:06 +053015856 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
15857 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015858 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
15859 scanRequest.requestType, scanRequest.scanType,
15860 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053015861 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
15862
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +053015863 ret = hdd_spoof_scan(wiphy, pAdapter, request, is_p2p_scan, &scanRequest);
15864 if(ret) {
15865 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
15866 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053015867#ifdef FEATURE_WLAN_TDLS
15868 wlan_hdd_tdls_scan_done_callback(pAdapter);
15869#endif
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +053015870 goto free_mem;
Siddharth Bhal76972212014-10-15 16:22:51 +053015871 }
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +053015872
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053015873 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070015874 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070015875 pAdapter->sessionId, &scanRequest, &scanId,
15876 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070015877
Jeff Johnson295189b2012-06-20 16:38:30 -070015878 if (eHAL_STATUS_SUCCESS != status)
15879 {
15880 hddLog(VOS_TRACE_LEVEL_ERROR,
15881 "%s: sme_ScanRequest returned error %d", __func__, status);
15882 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070015883 if(eHAL_STATUS_RESOURCES == status)
15884 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053015885 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
15886 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070015887 status = -EBUSY;
15888 } else {
15889 status = -EIO;
15890 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015891 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015892
15893#ifdef FEATURE_WLAN_TDLS
15894 wlan_hdd_tdls_scan_done_callback(pAdapter);
15895#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015896 goto free_mem;
15897 }
15898
15899 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053015900 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015901 pAdapter->request = request;
15902 pScanInfo->scanId = scanId;
Hanumanth Reddy Pothulaf31f65c2018-01-30 19:51:27 +053015903 pScanInfo->no_cck = request->no_cck;
15904 pHddCtx->scan_info.last_scan_numChannels = request->n_channels;
15905 for (i = 0; i < pHddCtx->scan_info.last_scan_numChannels; i++) {
15906 pHddCtx->scan_info.last_scan_channelList[i] =
15907 request->channels[i]->hw_value;
15908 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015909
15910 complete(&pScanInfo->scan_req_completion_event);
15911
15912free_mem:
15913 if( scanRequest.SSIDs.SSIDList )
15914 {
15915 vos_mem_free(scanRequest.SSIDs.SSIDList);
15916 }
15917
15918 if( channelList )
15919 vos_mem_free( channelList );
15920
15921 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015922 return status;
15923}
15924
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015925int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
15926#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
15927 struct net_device *dev,
15928#endif
15929 struct cfg80211_scan_request *request)
15930{
15931 int ret;
15932
15933 vos_ssr_protect(__func__);
15934 ret = __wlan_hdd_cfg80211_scan(wiphy,
15935#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
15936 dev,
15937#endif
15938 request);
15939 vos_ssr_unprotect(__func__);
15940
15941 return ret;
15942}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015943
15944void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
15945{
15946 v_U8_t iniDot11Mode =
15947 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
15948 eHddDot11Mode hddDot11Mode = iniDot11Mode;
15949
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053015950 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
15951 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015952 switch ( iniDot11Mode )
15953 {
15954 case eHDD_DOT11_MODE_AUTO:
15955 case eHDD_DOT11_MODE_11ac:
15956 case eHDD_DOT11_MODE_11ac_ONLY:
15957#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053015958 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
15959 sme_IsFeatureSupportedByFW(DOT11AC) )
15960 hddDot11Mode = eHDD_DOT11_MODE_11ac;
15961 else
15962 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015963#else
15964 hddDot11Mode = eHDD_DOT11_MODE_11n;
15965#endif
15966 break;
15967 case eHDD_DOT11_MODE_11n:
15968 case eHDD_DOT11_MODE_11n_ONLY:
15969 hddDot11Mode = eHDD_DOT11_MODE_11n;
15970 break;
15971 default:
15972 hddDot11Mode = iniDot11Mode;
15973 break;
15974 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053015975#ifdef WLAN_FEATURE_AP_HT40_24G
15976 if (operationChannel > SIR_11B_CHANNEL_END)
15977#endif
15978 {
15979 /* This call decides required channel bonding mode */
15980 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015981 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
Abhishek Singh02b823e2017-10-30 17:53:20 +053015982 operationChannel, eHT_MAX_CHANNEL_WIDTH);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053015983 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015984}
15985
Jeff Johnson295189b2012-06-20 16:38:30 -070015986/*
15987 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015988 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070015989 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015990int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053015991 const u8 *ssid, size_t ssid_len, const u8 *bssid,
15992 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070015993{
15994 int status = 0;
15995 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080015996 hdd_context_t *pHddCtx;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053015997 hdd_station_ctx_t *hdd_sta_ctx;
Jeff Johnson295189b2012-06-20 16:38:30 -070015998 v_U32_t roamId;
15999 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070016000 eCsrAuthType RSNAuthType;
16001
16002 ENTER();
16003
16004 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080016005 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053016006 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080016007
16008 status = wlan_hdd_validate_context(pHddCtx);
16009 if (status)
16010 {
Yue Mae36e3552014-03-05 17:06:20 -080016011 return status;
16012 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016013
Jeff Johnson295189b2012-06-20 16:38:30 -070016014 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
16015 {
16016 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
16017 return -EINVAL;
16018 }
16019
Nitesh Shah9b066282017-06-06 18:05:52 +053016020
Jeff Johnson295189b2012-06-20 16:38:30 -070016021 pRoamProfile = &pWextState->roamProfile;
16022
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016023 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070016024 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016025 hdd_station_ctx_t *pHddStaCtx;
16026 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Abhishek Singh6782c9e2017-06-06 13:37:45 +053016027 pHddStaCtx->get_mgmt_log_sent = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016028
Siddharth Bhalda0d1622015-04-24 15:47:49 +053016029 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
16030
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016031 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070016032 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
16033 {
16034 /*QoS not enabled in cfg file*/
16035 pRoamProfile->uapsd_mask = 0;
16036 }
16037 else
16038 {
16039 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016040 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070016041 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
16042 }
16043
16044 pRoamProfile->SSIDs.numOfSSIDs = 1;
16045 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
16046 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016047 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070016048 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
16049 ssid, ssid_len);
16050
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016051 vos_mem_zero(pRoamProfile->BSSIDs.bssid, WNI_CFG_BSSID_LEN);
16052 vos_mem_zero(pRoamProfile->bssid_hint, WNI_CFG_BSSID_LEN);
16053
Jeff Johnson295189b2012-06-20 16:38:30 -070016054 if (bssid)
16055 {
16056 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016057 vos_mem_copy(pRoamProfile->BSSIDs.bssid, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070016058 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016059 /* Save BSSID in seperate variable as well, as RoamProfile
16060 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070016061 case of join failure we should send valid BSSID to supplicant
16062 */
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016063 vos_mem_copy(pWextState->req_bssId, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070016064 WNI_CFG_BSSID_LEN);
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016065
Jeff Johnson295189b2012-06-20 16:38:30 -070016066 }
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016067 else if (bssid_hint)
Dhanashri Atre51981c62013-06-13 11:47:57 -070016068 {
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016069 /* Store bssid_hint to use in the scan filter. */
16070 vos_mem_copy(pRoamProfile->bssid_hint, bssid_hint,
16071 WNI_CFG_BSSID_LEN);
16072 /*
16073 * Save BSSID in seperate variable as well, as RoamProfile
16074 * BSSID is getting zeroed out in the association process. And in
16075 * case of join failure we should send valid BSSID to supplicant
16076 */
16077 vos_mem_copy(pWextState->req_bssId, bssid_hint,
16078 WNI_CFG_BSSID_LEN);
16079 hddLog(LOG1, FL(" bssid_hint: "MAC_ADDRESS_STR),
16080 MAC_ADDR_ARRAY(pRoamProfile->bssid_hint));
Dhanashri Atre51981c62013-06-13 11:47:57 -070016081 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016082
Abhishek Singhb3e376c2017-01-04 15:27:13 +053016083
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053016084 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
16085 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070016086 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
16087 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016088 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016089 /*set gen ie*/
16090 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
16091 /*set auth*/
16092 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
16093 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016094#ifdef FEATURE_WLAN_WAPI
16095 if (pAdapter->wapi_info.nWapiMode)
16096 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016097 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016098 switch (pAdapter->wapi_info.wapiAuthMode)
16099 {
16100 case WAPI_AUTH_MODE_PSK:
16101 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016102 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016103 pAdapter->wapi_info.wapiAuthMode);
16104 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
16105 break;
16106 }
16107 case WAPI_AUTH_MODE_CERT:
16108 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016109 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016110 pAdapter->wapi_info.wapiAuthMode);
16111 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
16112 break;
16113 }
16114 } // End of switch
16115 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
16116 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
16117 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016118 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016119 pRoamProfile->AuthType.numEntries = 1;
16120 pRoamProfile->EncryptionType.numEntries = 1;
16121 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
16122 pRoamProfile->mcEncryptionType.numEntries = 1;
16123 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
16124 }
16125 }
16126#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016127#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016128 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016129 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
16130 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
16131 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016132 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
16133 sizeof (tSirGtkOffloadParams));
16134 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016135 }
16136#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016137 pRoamProfile->csrPersona = pAdapter->device_mode;
16138
Jeff Johnson32d95a32012-09-10 13:15:23 -070016139 if( operatingChannel )
16140 {
16141 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
16142 pRoamProfile->ChannelInfo.numOfChannels = 1;
16143 }
Chet Lanctot186b5732013-03-18 10:26:30 -070016144 else
16145 {
16146 pRoamProfile->ChannelInfo.ChannelList = NULL;
16147 pRoamProfile->ChannelInfo.numOfChannels = 0;
16148 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016149 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
16150 {
16151 hdd_select_cbmode(pAdapter,operatingChannel);
16152 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053016153
Agarwal Ashish40f9b872015-09-01 16:17:35 +053016154 /*
16155 * Change conn_state to connecting before sme_RoamConnect(),
16156 * because sme_RoamConnect() has a direct path to call
16157 * hdd_smeRoamCallback(), which will change the conn_state
16158 * If direct path, conn_state will be accordingly changed
16159 * to NotConnected or Associated by either
16160 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
16161 * in sme_RoamCallback()
16162 * if sme_RomConnect is to be queued,
16163 * Connecting state will remain until it is completed.
16164 * If connection state is not changed,
16165 * connection state will remain in eConnectionState_NotConnected state.
16166 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
16167 * if conn state is eConnectionState_NotConnected.
16168 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
16169 * informed of connect result indication which is an issue.
16170 */
16171
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053016172 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
16173 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053016174 {
16175 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053016176 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080016177 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
16178 eConnectionState_Connecting);
Abhishek Singh10e17cf2018-03-12 14:34:22 +053016179 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
16180 hdd_wait_for_ecsa_complete(pHddCtx);
Abhishek Singhf4669da2014-05-26 15:07:49 +053016181 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +053016182
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016183 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070016184 pAdapter->sessionId, pRoamProfile, &roamId);
16185
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053016186 if ((eHAL_STATUS_SUCCESS != status) &&
16187 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
16188 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053016189
16190 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053016191 hddLog(VOS_TRACE_LEVEL_ERROR,
16192 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
16193 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080016194 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053016195 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080016196 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053016197 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080016198
16199 pRoamProfile->ChannelInfo.ChannelList = NULL;
16200 pRoamProfile->ChannelInfo.numOfChannels = 0;
16201
Jeff Johnson295189b2012-06-20 16:38:30 -070016202 }
16203 else
16204 {
16205 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
16206 return -EINVAL;
16207 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080016208 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016209 return status;
16210}
16211
16212/*
16213 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
16214 * This function is used to set the authentication type (OPEN/SHARED).
16215 *
16216 */
16217static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
16218 enum nl80211_auth_type auth_type)
16219{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016220 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016221 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16222
16223 ENTER();
16224
16225 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016226 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070016227 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016228 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053016229 hddLog(VOS_TRACE_LEVEL_INFO,
16230 "%s: set authentication type to AUTOSWITCH", __func__);
16231 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
16232 break;
16233
16234 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016235#ifdef WLAN_FEATURE_VOWIFI_11R
16236 case NL80211_AUTHTYPE_FT:
16237#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016238 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070016239 "%s: set authentication type to OPEN", __func__);
16240 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
16241 break;
16242
16243 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016244 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070016245 "%s: set authentication type to SHARED", __func__);
16246 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
16247 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016248#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070016249 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016250 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070016251 "%s: set authentication type to CCKM WPA", __func__);
16252 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
16253 break;
16254#endif
Abhinav Kumar4d44f632019-08-02 13:55:54 +053016255 case NL80211_AUTHTYPE_SAE:
16256 hddLog(LOG1, "set authentication type to SAE");
16257 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SAE;
16258 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016259
16260 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016261 hddLog(VOS_TRACE_LEVEL_ERROR,
16262 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016263 auth_type);
16264 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
16265 return -EINVAL;
16266 }
16267
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016268 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070016269 pHddStaCtx->conn_info.authType;
16270 return 0;
16271}
16272
16273/*
16274 * FUNCTION: wlan_hdd_set_akm_suite
16275 * This function is used to set the key mgmt type(PSK/8021x).
16276 *
16277 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016278static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070016279 u32 key_mgmt
16280 )
16281{
16282 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
16283 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053016284 /* Should be in ieee802_11_defs.h */
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053016285#ifndef WLAN_AKM_SUITE_8021X_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053016286#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053016287#endif
16288#ifndef WLAN_AKM_SUITE_PSK_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053016289#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053016290#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016291 /*set key mgmt type*/
16292 switch(key_mgmt)
16293 {
16294 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053016295 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053016296#ifdef WLAN_FEATURE_VOWIFI_11R
16297 case WLAN_AKM_SUITE_FT_PSK:
16298#endif
16299 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070016300 __func__);
16301 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
16302 break;
16303
16304 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053016305 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053016306#ifdef WLAN_FEATURE_VOWIFI_11R
16307 case WLAN_AKM_SUITE_FT_8021X:
16308#endif
16309 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070016310 __func__);
16311 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
16312 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016313#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070016314#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
16315#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
16316 case WLAN_AKM_SUITE_CCKM:
16317 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
16318 __func__);
16319 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
16320 break;
16321#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070016322#ifndef WLAN_AKM_SUITE_OSEN
16323#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
16324 case WLAN_AKM_SUITE_OSEN:
16325 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
16326 __func__);
16327 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
16328 break;
16329#endif
Abhinav Kumar4d44f632019-08-02 13:55:54 +053016330 case WLAN_AKM_SUITE_SAE:
16331 hddLog(LOG1, "setting key mgmt type to SAE");
16332 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
16333 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016334
Abhinav Kumar487e49e2019-07-22 14:46:18 +053016335 case WLAN_AKM_SUITE_OWE_1:
16336 hddLog(LOG1, "setting key mgmt type to OWE");
16337 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
16338 break;
16339
Jeff Johnson295189b2012-06-20 16:38:30 -070016340 default:
Abhinav Kumar487e49e2019-07-22 14:46:18 +053016341 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %x",
Jeff Johnson295189b2012-06-20 16:38:30 -070016342 __func__, key_mgmt);
16343 return -EINVAL;
16344
16345 }
16346 return 0;
16347}
16348
16349/*
16350 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016351 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070016352 * (NONE/WEP40/WEP104/TKIP/CCMP).
16353 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016354static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
16355 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070016356 bool ucast
16357 )
16358{
16359 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016360 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016361 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16362
16363 ENTER();
16364
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016365 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070016366 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053016367 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070016368 __func__, cipher);
16369 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
16370 }
16371 else
16372 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016373
Jeff Johnson295189b2012-06-20 16:38:30 -070016374 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016375 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070016376 {
16377 case IW_AUTH_CIPHER_NONE:
16378 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
16379 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016380
Jeff Johnson295189b2012-06-20 16:38:30 -070016381 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053016382 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070016383 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016384
Jeff Johnson295189b2012-06-20 16:38:30 -070016385 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053016386 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070016387 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016388
Jeff Johnson295189b2012-06-20 16:38:30 -070016389 case WLAN_CIPHER_SUITE_TKIP:
16390 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
16391 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016392
Jeff Johnson295189b2012-06-20 16:38:30 -070016393 case WLAN_CIPHER_SUITE_CCMP:
16394 encryptionType = eCSR_ENCRYPT_TYPE_AES;
16395 break;
16396#ifdef FEATURE_WLAN_WAPI
16397 case WLAN_CIPHER_SUITE_SMS4:
16398 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
16399 break;
16400#endif
16401
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016402#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070016403 case WLAN_CIPHER_SUITE_KRK:
16404 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
16405 break;
16406#endif
16407 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016408 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016409 __func__, cipher);
16410 return -EOPNOTSUPP;
16411 }
16412 }
16413
16414 if (ucast)
16415 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016416 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016417 __func__, encryptionType);
16418 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
16419 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016420 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070016421 encryptionType;
16422 }
16423 else
16424 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016425 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016426 __func__, encryptionType);
16427 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
16428 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
16429 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
16430 }
16431
16432 return 0;
16433}
16434
16435
16436/*
16437 * FUNCTION: wlan_hdd_cfg80211_set_ie
16438 * This function is used to parse WPA/RSN IE's.
16439 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016440int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016441#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16442 const u8 *ie,
16443#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016444 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016445#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016446 size_t ie_len
16447 )
16448{
16449 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016450#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16451 const u8 *genie = ie;
16452#else
Jeff Johnson295189b2012-06-20 16:38:30 -070016453 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016454#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016455 v_U16_t remLen = ie_len;
16456#ifdef FEATURE_WLAN_WAPI
16457 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
16458 u16 *tmp;
16459 v_U16_t akmsuiteCount;
16460 int *akmlist;
16461#endif
16462 ENTER();
16463
16464 /* clear previous assocAddIE */
16465 pWextState->assocAddIE.length = 0;
16466 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070016467 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016468
16469 while (remLen >= 2)
16470 {
16471 v_U16_t eLen = 0;
16472 v_U8_t elementId;
16473 elementId = *genie++;
16474 eLen = *genie++;
16475 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016476
Nachiket Kukade4aba5f02017-06-09 15:43:48 +053016477 /* Sanity check on eLen */
16478 if (eLen > remLen) {
16479 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid IE length[%d] for IE[0x%X]",
16480 __func__, eLen, elementId);
16481 VOS_ASSERT(0);
16482 return -EINVAL;
16483 }
16484
Arif Hussain6d2a3322013-11-17 19:50:10 -080016485 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070016486 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016487
16488 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070016489 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016490 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016491 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 -070016492 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016493 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016494 "%s: Invalid WPA IE", __func__);
16495 return -EINVAL;
16496 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016497 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070016498 {
16499 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016500 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070016501 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016502
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016503 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070016504 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016505 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
16506 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070016507 VOS_ASSERT(0);
16508 return -ENOMEM;
16509 }
16510 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
16511 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16512 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016513
Jeff Johnson295189b2012-06-20 16:38:30 -070016514 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
16515 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16516 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16517 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016518 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
16519 {
Nachiket Kukade3d72b7e2017-06-09 16:58:24 +053016520 if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) {
16521 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid WPA RSN IE length[%d]",
16522 __func__, eLen);
16523 VOS_ASSERT(0);
16524 return -EINVAL;
16525 }
16526
Jeff Johnson295189b2012-06-20 16:38:30 -070016527 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
16528 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
16529 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
16530 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
16531 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
16532 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016533 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053016534 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070016535 {
16536 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016537 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070016538 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016539
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016540 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070016541 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016542 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16543 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070016544 VOS_ASSERT(0);
16545 return -ENOMEM;
16546 }
16547 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
16548 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16549 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016550
Jeff Johnson295189b2012-06-20 16:38:30 -070016551 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16552 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16553 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016554#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016555 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
16556 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016557 /*Consider WFD IE, only for P2P Client */
16558 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
16559 {
16560 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016561 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070016562 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016563
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016564 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070016565 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016566 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16567 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070016568 VOS_ASSERT(0);
16569 return -ENOMEM;
16570 }
16571 // WFD IE is saved to Additional IE ; it should be accumulated to handle
16572 // WPS IE + P2P IE + WFD IE
16573 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16574 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016575
Jeff Johnson295189b2012-06-20 16:38:30 -070016576 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16577 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16578 }
16579#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016580 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016581 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016582 HS20_OUI_TYPE_SIZE)) )
16583 {
16584 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016585 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016586 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016587
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016588 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016589 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016590 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16591 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016592 VOS_ASSERT(0);
16593 return -ENOMEM;
16594 }
16595 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16596 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016597
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016598 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16599 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16600 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070016601 /* Appending OSEN Information Element in Assiciation Request */
16602 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
16603 OSEN_OUI_TYPE_SIZE)) )
16604 {
16605 v_U16_t curAddIELen = pWextState->assocAddIE.length;
16606 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
16607 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016608
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016609 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070016610 {
16611 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16612 "Need bigger buffer space");
16613 VOS_ASSERT(0);
16614 return -ENOMEM;
16615 }
16616 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16617 pWextState->assocAddIE.length += eLen + 2;
16618
16619 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
16620 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16621 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16622 }
16623
Abhishek Singh4322e622015-06-10 15:42:54 +053016624 /* Update only for WPA IE */
16625 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
16626 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070016627
16628 /* populating as ADDIE in beacon frames */
16629 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016630 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070016631 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
16632 {
16633 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
16634 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
16635 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
16636 {
16637 hddLog(LOGE,
16638 "Coldn't pass "
16639 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
16640 }
16641 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
16642 else
16643 hddLog(LOGE,
16644 "Could not pass on "
16645 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
16646
16647 /* IBSS mode doesn't contain params->proberesp_ies still
16648 beaconIE's need to be populated in probe response frames */
16649 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
16650 {
16651 u16 rem_probe_resp_ie_len = eLen + 2;
16652 u8 probe_rsp_ie_len[3] = {0};
16653 u8 counter = 0;
16654
16655 /* Check Probe Resp Length if it is greater then 255 then
16656 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
16657 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
16658 not able Store More then 255 bytes into One Variable */
16659
16660 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
16661 {
16662 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
16663 {
16664 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
16665 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
16666 }
16667 else
16668 {
16669 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
16670 rem_probe_resp_ie_len = 0;
16671 }
16672 }
16673
16674 rem_probe_resp_ie_len = 0;
16675
16676 if (probe_rsp_ie_len[0] > 0)
16677 {
16678 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
16679 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
16680 (tANI_U8*)(genie - 2),
16681 probe_rsp_ie_len[0], NULL,
16682 eANI_BOOLEAN_FALSE)
16683 == eHAL_STATUS_FAILURE)
16684 {
16685 hddLog(LOGE,
16686 "Could not pass"
16687 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
16688 }
16689 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
16690 }
16691
16692 if (probe_rsp_ie_len[1] > 0)
16693 {
16694 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
16695 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
16696 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
16697 probe_rsp_ie_len[1], NULL,
16698 eANI_BOOLEAN_FALSE)
16699 == eHAL_STATUS_FAILURE)
16700 {
16701 hddLog(LOGE,
16702 "Could not pass"
16703 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
16704 }
16705 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
16706 }
16707
16708 if (probe_rsp_ie_len[2] > 0)
16709 {
16710 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
16711 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
16712 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
16713 probe_rsp_ie_len[2], NULL,
16714 eANI_BOOLEAN_FALSE)
16715 == eHAL_STATUS_FAILURE)
16716 {
16717 hddLog(LOGE,
16718 "Could not pass"
16719 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
16720 }
16721 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
16722 }
16723
16724 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
16725 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
16726 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
16727 {
16728 hddLog(LOGE,
16729 "Could not pass"
16730 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
16731 }
16732 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070016733 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070016734 break;
16735 case DOT11F_EID_RSN:
Nachiket Kukade307d4892018-01-23 23:36:25 +053016736 if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) {
16737 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid WPA RSN IE length[%d], exceeds %d bytes",
16738 __func__, eLen, MAX_WPA_RSN_IE_LEN - 2);
16739 VOS_ASSERT(0);
16740 return -EINVAL;
16741 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016742 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
16743 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
16744 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
16745 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
16746 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
16747 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053016748
Abhishek Singhb16f3562016-01-20 11:08:32 +053016749 /* Appending extended capabilities with Interworking or
16750 * bsstransition bit set in Assoc Req.
Abhishek Singh15d95602015-03-24 15:52:57 +053016751 *
16752 * In assoc req this EXT Cap will only be taken into account if
Abhishek Singhb16f3562016-01-20 11:08:32 +053016753 * interworkingService or bsstransition bit is set to 1.
16754 * Driver is only interested in interworkingService and
16755 * bsstransition capability from supplicant.
16756 * If in future any other EXT Cap info is
Abhishek Singh15d95602015-03-24 15:52:57 +053016757 * required from supplicat, it needs to be handled while
16758 * sending Assoc Req in LIM.
16759 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016760 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016761 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016762 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016763 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016764 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016765
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016766 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016767 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016768 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16769 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016770 VOS_ASSERT(0);
16771 return -ENOMEM;
16772 }
16773 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16774 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016775
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016776 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16777 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16778 break;
16779 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016780#ifdef FEATURE_WLAN_WAPI
16781 case WLAN_EID_WAPI:
16782 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070016783 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070016784 pAdapter->wapi_info.nWapiMode);
16785 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016786 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070016787 akmsuiteCount = WPA_GET_LE16(tmp);
16788 tmp = tmp + 1;
16789 akmlist = (int *)(tmp);
16790 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
16791 {
16792 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
16793 }
16794 else
16795 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016796 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070016797 VOS_ASSERT(0);
16798 return -EINVAL;
16799 }
16800
16801 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
16802 {
16803 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016804 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016805 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016806 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016807 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016808 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016809 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016810 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016811 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
16812 }
16813 break;
16814#endif
Abhinav Kumar487e49e2019-07-22 14:46:18 +053016815 case SIR_MAC_REQUEST_EID_MAX:
16816 if (genie[0] == SIR_DH_PARAMETER_ELEMENT_EXT_EID)
16817 {
16818 v_U16_t curAddIELen = pWextState->assocAddIE.length;
16819 if (SIR_MAC_MAX_ADD_IE_LENGTH <
16820 (pWextState->assocAddIE.length + eLen))
16821 {
16822 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16823 "Need bigger buffer space");
16824 VOS_ASSERT(0);
16825 return -ENOMEM;
16826 }
16827 hddLog(VOS_TRACE_LEVEL_INFO, "Set DH EXT IE(len %d)",
16828 eLen + 2);
16829 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen,
16830 genie - 2, eLen + 2);
16831 pWextState->assocAddIE.length += eLen + 2;
16832 pWextState->roamProfile.pAddIEAssoc =
16833 pWextState->assocAddIE.addIEdata;
16834 pWextState->roamProfile.nAddIEAssocLength =
16835 pWextState->assocAddIE.length;
16836 }else {
16837 hddLog(VOS_TRACE_LEVEL_FATAL, "UNKNOWN EID: %X", genie[0]);
16838 }
16839 break;
16840
Jeff Johnson295189b2012-06-20 16:38:30 -070016841 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016842 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016843 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016844 /* when Unknown IE is received we should break and continue
16845 * to the next IE in the buffer instead we were returning
16846 * so changing this to break */
16847 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016848 }
16849 genie += eLen;
16850 remLen -= eLen;
16851 }
16852 EXIT();
16853 return 0;
16854}
16855
16856/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053016857 * FUNCTION: hdd_isWPAIEPresent
16858 * Parse the received IE to find the WPA IE
16859 *
16860 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016861static bool hdd_isWPAIEPresent(
16862#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
16863 const u8 *ie,
16864#else
16865 u8 *ie,
16866#endif
16867 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053016868{
16869 v_U8_t eLen = 0;
16870 v_U16_t remLen = ie_len;
16871 v_U8_t elementId = 0;
16872
16873 while (remLen >= 2)
16874 {
16875 elementId = *ie++;
16876 eLen = *ie++;
16877 remLen -= 2;
16878 if (eLen > remLen)
16879 {
16880 hddLog(VOS_TRACE_LEVEL_ERROR,
16881 "%s: IE length is wrong %d", __func__, eLen);
16882 return FALSE;
16883 }
16884 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
16885 {
16886 /* OUI - 0x00 0X50 0XF2
16887 WPA Information Element - 0x01
16888 WPA version - 0x01*/
16889 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
16890 return TRUE;
16891 }
16892 ie += eLen;
16893 remLen -= eLen;
16894 }
16895 return FALSE;
16896}
16897
16898/*
Jeff Johnson295189b2012-06-20 16:38:30 -070016899 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016900 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070016901 * parameters during connect operation.
16902 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016903int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070016904 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016905 )
Jeff Johnson295189b2012-06-20 16:38:30 -070016906{
16907 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016908 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016909 ENTER();
16910
16911 /*set wpa version*/
16912 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
16913
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016914 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070016915 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053016916 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070016917 {
16918 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
16919 }
16920 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
16921 {
16922 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
16923 }
16924 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016925
16926 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016927 pWextState->wpaVersion);
16928
16929 /*set authentication type*/
16930 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
16931
16932 if (0 > status)
16933 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016934 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016935 "%s: failed to set authentication type ", __func__);
16936 return status;
16937 }
16938
16939 /*set key mgmt type*/
16940 if (req->crypto.n_akm_suites)
16941 {
16942 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
16943 if (0 > status)
16944 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016945 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070016946 __func__);
16947 return status;
16948 }
16949 }
16950
16951 /*set pairwise cipher type*/
16952 if (req->crypto.n_ciphers_pairwise)
16953 {
16954 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
16955 req->crypto.ciphers_pairwise[0], true);
16956 if (0 > status)
16957 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016958 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016959 "%s: failed to set unicast cipher type", __func__);
16960 return status;
16961 }
16962 }
16963 else
16964 {
16965 /*Reset previous cipher suite to none*/
16966 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
16967 if (0 > status)
16968 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016969 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016970 "%s: failed to set unicast cipher type", __func__);
16971 return status;
16972 }
16973 }
16974
16975 /*set group cipher type*/
16976 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
16977 false);
16978
16979 if (0 > status)
16980 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016981 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070016982 __func__);
16983 return status;
16984 }
16985
Chet Lanctot186b5732013-03-18 10:26:30 -070016986#ifdef WLAN_FEATURE_11W
16987 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
16988#endif
16989
Jeff Johnson295189b2012-06-20 16:38:30 -070016990 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
16991 if (req->ie_len)
16992 {
16993 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
16994 if ( 0 > status)
16995 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016996 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070016997 __func__);
16998 return status;
16999 }
17000 }
17001
17002 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017003 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070017004 {
17005 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
17006 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
17007 )
17008 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017009 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070017010 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
17011 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017012 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070017013 __func__);
17014 return -EOPNOTSUPP;
17015 }
17016 else
17017 {
17018 u8 key_len = req->key_len;
17019 u8 key_idx = req->key_idx;
17020
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017021 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070017022 && (CSR_MAX_NUM_KEY > key_idx)
17023 )
17024 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017025 hddLog(VOS_TRACE_LEVEL_INFO,
17026 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070017027 __func__, key_idx, key_len);
17028 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017029 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070017030 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017031 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070017032 (u8)key_len;
17033 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
17034 }
17035 }
17036 }
17037 }
17038
17039 return status;
17040}
17041
17042/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017043 * FUNCTION: wlan_hdd_try_disconnect
17044 * This function is used to disconnect from previous
17045 * connection
17046 */
Agrawal Ashishc407f192017-01-23 17:18:35 +053017047int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017048{
17049 long ret = 0;
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017050 int status, result = 0;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017051 hdd_station_ctx_t *pHddStaCtx;
17052 eMib_dot11DesiredBssType connectedBssType;
Abhishek Singh19a7dd92015-12-30 16:31:51 +053017053 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017054
Abhishek Singh19a7dd92015-12-30 16:31:51 +053017055 ret = wlan_hdd_validate_context(pHddCtx);
17056 if (0 != ret)
17057 {
17058 return ret;
17059 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017060 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17061
17062 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
17063
17064 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
17065 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
Abhishek Singh630ff592016-01-07 18:15:53 +053017066 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) ||
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017067 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
17068 {
Abhishek Singh9f4df782017-03-15 17:29:10 +053017069 /* Indicate disconnect to SME so that in-progress connection or preauth
17070 * can be aborted
17071 */
17072 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
17073 pAdapter->sessionId);
Abhishek Singh19a7dd92015-12-30 16:31:51 +053017074 spin_lock_bh(&pAdapter->lock_for_active_session);
17075 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
17076 {
17077 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
17078 }
17079 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singhf7962582015-10-23 10:54:06 +053017080 hdd_connSetConnectionState(pHddStaCtx,
17081 eConnectionState_Disconnecting);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017082 /* Issue disconnect to CSR */
17083 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017084 status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017085 pAdapter->sessionId,
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017086 eCSR_DISCONNECT_REASON_UNSPECIFIED);
17087 if(eHAL_STATUS_CMD_NOT_QUEUED == status) {
17088 hddLog(LOG1,
17089 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
17090 } else if ( 0 != status ) {
17091 hddLog(LOGE,
17092 FL("csrRoamDisconnect failure, returned %d"),
17093 (int)status );
17094 result = -EINVAL;
17095 goto disconnected;
17096 }
17097 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017098 &pAdapter->disconnect_comp_var,
17099 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017100 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status)) {
17101 hddLog(LOGE,
17102 "%s: Failed to disconnect, timed out", __func__);
17103 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017104 }
17105 }
17106 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
17107 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017108 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017109 &pAdapter->disconnect_comp_var,
17110 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017111 if (!ret)
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017112 {
17113 hddLog(LOGE, FL("Failed to receive disconnect event"));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017114 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017115 }
17116 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053017117disconnected:
17118 hddLog(LOG1,
17119 FL("Set HDD connState to eConnectionState_NotConnected"));
17120 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
17121 return result;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017122}
17123
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053017124/**
17125 * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present
17126 * @adapter: Pointer to the HDD adapter
17127 * @req: Pointer to the structure cfg_connect_params receieved from user space
17128 *
Abhinav Kumar42c34902018-09-27 19:00:35 +053017129 * This function will start reassociation if prev_bssid is set and bssid/
17130 * bssid_hint, channel/channel_hint parameters are present in connect request.
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053017131 *
17132 * Return: success if reassociation is happening
17133 * Error code if reassociation is not permitted or not happening
17134 */
17135#ifdef CFG80211_CONNECT_PREV_BSSID
17136static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
17137 struct cfg80211_connect_params *req)
17138{
17139 int status = -EPERM;
Abhinav Kumar42c34902018-09-27 19:00:35 +053017140 const uint8_t *bssid = NULL;
17141 uint16_t channel = 0;
17142
17143 if (req->bssid)
17144 bssid = req->bssid;
17145 else if (req->bssid_hint)
17146 bssid = req->bssid_hint;
17147
17148 if (req->channel)
17149 channel = req->channel->hw_value;
17150 else if (req->channel_hint)
17151 channel = req->channel_hint->hw_value;
17152
17153 if (bssid && channel && req->prev_bssid) {
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053017154 hddLog(VOS_TRACE_LEVEL_INFO,
17155 FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR),
Abhinav Kumar42c34902018-09-27 19:00:35 +053017156 channel, MAC_ADDR_ARRAY(bssid));
17157 status = hdd_reassoc(adapter, bssid, channel,
17158 CONNECT_CMD_USERSPACE);
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053017159 }
17160 return status;
17161}
17162#else
17163static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
17164 struct cfg80211_connect_params *req)
17165{
17166 return -EPERM;
17167}
17168#endif
17169
Abhishek Singhe3beee22017-07-31 15:35:40 +053017170/**
17171 * wlan_hdd_check_ht20_ht40_ind() - check if Supplicant has indicated to
17172 * connect in HT20 mode
17173 * @hdd_ctx: hdd context
17174 * @adapter: Pointer to the HDD adapter
17175 * @req: Pointer to the structure cfg_connect_params receieved from user space
17176 *
17177 * This function will check if supplicant has indicated to to connect in HT20
17178 * mode. this is currently applicable only for 2.4Ghz mode only.
17179 * if feature is enabled and supplicant indicate HT20 set
17180 * force_24ghz_in_ht20 to true to force 2.4Ghz in HT20 else set it to false.
17181 *
17182 * Return: void
17183 */
17184#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
17185static void wlan_hdd_check_ht20_ht40_ind(hdd_context_t *hdd_ctx,
17186 hdd_adapter_t *adapter,
17187 struct cfg80211_connect_params *req)
17188{
17189 hdd_wext_state_t *wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
17190 tCsrRoamProfile *roam_profile;
17191
17192 roam_profile = &wext_state->roamProfile;
17193 roam_profile->force_24ghz_in_ht20 = false;
17194 if (hdd_ctx->cfg_ini->override_ht20_40_24g &&
17195 !(req->ht_capa.cap_info &
17196 IEEE80211_HT_CAP_SUP_WIDTH_20_40))
17197 roam_profile->force_24ghz_in_ht20 = true;
17198
17199 hddLog(LOG1, FL("req->ht_capa.cap_info %x override_ht20_40_24g %d"),
17200 req->ht_capa.cap_info, hdd_ctx->cfg_ini->override_ht20_40_24g);
17201}
17202#else
17203static inline void wlan_hdd_check_ht20_ht40_ind(hdd_context_t *hdd_ctx,
17204 hdd_adapter_t *adapter,
17205 struct cfg80211_connect_params *req)
17206{
17207 hdd_wext_state_t *wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
17208 tCsrRoamProfile *roam_profile;
17209
17210 roam_profile = &wext_state->roamProfile;
17211 roam_profile->force_24ghz_in_ht20 = false;
17212}
17213#endif
17214
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017215/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053017216 * FUNCTION: __wlan_hdd_cfg80211_connect
17217 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070017218 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017219static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017220 struct net_device *ndev,
17221 struct cfg80211_connect_params *req
17222 )
17223{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017224 int status;
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017225 u16 channel;
Edhar, Mahesh Kumar496c7f72016-03-18 12:47:44 +053017226#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
17227 defined(CFG80211_BSSID_HINT_BACKPORT)
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017228 const u8 *bssid_hint = req->bssid_hint;
17229#else
17230 const u8 *bssid_hint = NULL;
17231#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017232 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070017233 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053017234 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017235
17236 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017237
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017238 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17239 TRACE_CODE_HDD_CFG80211_CONNECT,
17240 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017241 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053017242 "%s: device_mode = %s (%d)", __func__,
17243 hdd_device_modetoString(pAdapter->device_mode),
17244 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070017245
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017246 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080017247 if (!pHddCtx)
17248 {
17249 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17250 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053017251 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080017252 }
17253
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017254 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017255 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070017256 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017257 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017258 }
17259
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053017260 if (wlan_hdd_check_and_stop_mon(pAdapter, true))
17261 return -EINVAL;
17262
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053017263 status = wlan_hdd_reassoc_bssid_hint(pAdapter, req);
17264 if (0 == status)
17265 return status;
17266
Agarwal Ashish51325b52014-06-16 16:50:49 +053017267
Jeff Johnson295189b2012-06-20 16:38:30 -070017268#ifdef WLAN_BTAMP_FEATURE
17269 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017270 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070017271 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017272 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070017273 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080017274 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070017275 }
17276#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017277
17278 //If Device Mode is Station Concurrent Sessions Exit BMps
17279 //P2P Mode will be taken care in Open/close adapter
17280 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053017281 (vos_concurrent_open_sessions_running())) {
17282 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
17283 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017284 }
17285
17286 /*Try disconnecting if already in connected state*/
17287 status = wlan_hdd_try_disconnect(pAdapter);
17288 if ( 0 > status)
17289 {
17290 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
17291 " connection"));
17292 return -EALREADY;
17293 }
Agrawal Ashish559530c2015-12-01 18:04:20 +053017294 /* Check for max concurrent connections after doing disconnect if any*/
17295 if (vos_max_concurrent_connections_reached()) {
17296 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
17297 return -ECONNREFUSED;
17298 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017299
Jeff Johnson295189b2012-06-20 16:38:30 -070017300 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017301 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070017302
17303 if ( 0 > status)
17304 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017305 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070017306 __func__);
17307 return status;
17308 }
Sravan Kumar Kairam589c5722016-01-27 20:28:53 +053017309
17310 if (pHddCtx->spoofMacAddr.isEnabled)
17311 {
17312 hddLog(VOS_TRACE_LEVEL_INFO,
17313 "%s: MAC Spoofing enabled ", __func__);
17314 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
17315 * to fill TxBds for probe request during SSID scan which may happen
17316 * as part of connect command
17317 */
17318 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
17319 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
17320 if (status != VOS_STATUS_SUCCESS)
17321 return -ECONNREFUSED;
17322 }
17323
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017324 if (req->channel)
17325 channel = req->channel->hw_value;
Mohit Khanna765234a2012-09-11 15:08:35 -070017326 else
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017327 channel = 0;
Kapil Gupta312028a2016-10-25 14:15:20 +053017328
17329 /* Abort if any scan is going on */
17330 status = wlan_hdd_scan_abort(pAdapter);
17331 if (0 != status)
17332 hddLog(VOS_TRACE_LEVEL_ERROR, FL("scan abort failed"));
17333
Abhishek Singhe3beee22017-07-31 15:35:40 +053017334 wlan_hdd_check_ht20_ht40_ind(pHddCtx, pAdapter, req);
17335
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017336 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
17337 req->ssid_len, req->bssid,
17338 bssid_hint, channel);
Jeff Johnson295189b2012-06-20 16:38:30 -070017339
Sushant Kaushikd7083982015-03-18 14:33:24 +053017340 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070017341 {
17342 //ReEnable BMPS if disabled
17343 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
17344 (NULL != pHddCtx))
17345 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053017346 if (pHddCtx->hdd_wlan_suspended)
17347 {
17348 hdd_set_pwrparams(pHddCtx);
17349 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017350 //ReEnable Bmps and Imps back
17351 hdd_enable_bmps_imps(pHddCtx);
17352 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053017353 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017354 return status;
17355 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017356 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017357 EXIT();
17358 return status;
17359}
17360
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017361static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
17362 struct net_device *ndev,
17363 struct cfg80211_connect_params *req)
17364{
17365 int ret;
17366 vos_ssr_protect(__func__);
17367 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
17368 vos_ssr_unprotect(__func__);
17369
17370 return ret;
17371}
Jeff Johnson295189b2012-06-20 16:38:30 -070017372
17373/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017374 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070017375 * This function is used to issue a disconnect request to SME
17376 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017377static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017378 struct net_device *dev,
17379 u16 reason
17380 )
17381{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017382 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017383 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017384 tCsrRoamProfile *pRoamProfile;
17385 hdd_station_ctx_t *pHddStaCtx;
17386 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017387#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017388 tANI_U8 staIdx;
17389#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017390
Jeff Johnson295189b2012-06-20 16:38:30 -070017391 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017392
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017393 if (!pAdapter) {
17394 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
17395 return -EINVAL;
17396 }
17397
17398 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17399 if (!pHddStaCtx) {
17400 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
17401 return -EINVAL;
17402 }
17403
17404 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17405 status = wlan_hdd_validate_context(pHddCtx);
17406 if (0 != status)
17407 {
17408 return status;
17409 }
17410
17411 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
17412
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017413 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17414 TRACE_CODE_HDD_CFG80211_DISCONNECT,
17415 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053017416 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
17417 __func__, hdd_device_modetoString(pAdapter->device_mode),
17418 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070017419
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017420 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
17421 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070017422
Jeff Johnson295189b2012-06-20 16:38:30 -070017423 if (NULL != pRoamProfile)
17424 {
17425 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053017426 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
17427 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070017428 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017429 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070017430 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017431 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070017432 switch(reason)
17433 {
17434 case WLAN_REASON_MIC_FAILURE:
17435 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
17436 break;
17437
17438 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
17439 case WLAN_REASON_DISASSOC_AP_BUSY:
17440 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
17441 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
17442 break;
17443
17444 case WLAN_REASON_PREV_AUTH_NOT_VALID:
17445 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053017446 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070017447 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
17448 break;
17449
Jeff Johnson295189b2012-06-20 16:38:30 -070017450 default:
17451 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
17452 break;
17453 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017454 pScanInfo = &pHddCtx->scan_info;
17455 if (pScanInfo->mScanPending)
17456 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053017457 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017458 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053017459 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053017460 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017461 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053017462 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017463#ifdef FEATURE_WLAN_TDLS
17464 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080017465 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017466 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080017467 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
17468 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017469 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017470 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080017471 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017473 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080017474 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017475 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017476 status = sme_DeleteTdlsPeerSta(
17477 WLAN_HDD_GET_HAL_CTX(pAdapter),
17478 pAdapter->sessionId,
17479 mac);
17480 if (status != eHAL_STATUS_SUCCESS) {
17481 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
17482 return -EPERM;
17483 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017484 }
17485 }
17486#endif
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053017487
17488 hddLog(LOG1, FL("Disconnecting with reasoncode:%u connState %d"),
17489 reasonCode,
17490 pHddStaCtx->conn_info.connState);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053017491 status = wlan_hdd_disconnect(pAdapter, reasonCode);
17492 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070017493 {
17494 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017495 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070017496 __func__, (int)status );
17497 return -EINVAL;
17498 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017499 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053017500 else
17501 {
17502 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
17503 "called while in %d state", __func__,
17504 pHddStaCtx->conn_info.connState);
17505 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017506 }
17507 else
17508 {
17509 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
17510 }
17511
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017512 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070017513 return status;
17514}
17515
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017516static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
17517 struct net_device *dev,
17518 u16 reason
17519 )
17520{
17521 int ret;
17522 vos_ssr_protect(__func__);
17523 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
17524 vos_ssr_unprotect(__func__);
17525
17526 return ret;
17527}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053017528
Jeff Johnson295189b2012-06-20 16:38:30 -070017529/*
17530 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017531 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070017532 * settings in IBSS mode.
17533 */
17534static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017535 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070017536 struct cfg80211_ibss_params *params
17537 )
17538{
17539 int status = 0;
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +053017540 tANI_U32 ret;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017541 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070017542 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
17543 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017544
Jeff Johnson295189b2012-06-20 16:38:30 -070017545 ENTER();
17546
17547 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070017548 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070017549
17550 if (params->ie_len && ( NULL != params->ie) )
17551 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017552 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
17553 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070017554 {
17555 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
17556 encryptionType = eCSR_ENCRYPT_TYPE_AES;
17557 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017558 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070017559 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070017560 tDot11fIEWPA dot11WPAIE;
17561 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017562 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070017563
Wilson Yang00256342013-10-10 23:13:38 -070017564 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017565 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
17566 params->ie_len, DOT11F_EID_WPA);
17567 if ( NULL != ie )
17568 {
17569 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
Hanumanth Reddy Pothulad6d2d2c2018-06-27 12:28:12 +053017570
17571 if (ie[1] < DOT11F_IE_WPA_MIN_LEN ||
17572 ie[1] > DOT11F_IE_WPA_MAX_LEN) {
17573 hddLog(LOGE, FL("invalid ie len:%d"), ie[1]);
17574 return -EINVAL;
17575 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017576 // Unpack the WPA IE
17577 //Skip past the EID byte and length byte - and four byte WiFi OUI
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +053017578 ret = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017579 &ie[2+4],
17580 ie[1] - 4,
17581 &dot11WPAIE);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +053017582 if (DOT11F_FAILED(ret))
17583 {
17584 hddLog(LOGE,
17585 FL("unpack failed status:(0x%08x)"),
17586 ret);
17587 return -EINVAL;
17588 }
17589
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017590 /*Extract the multicast cipher, the encType for unicast
17591 cipher for wpa-none is none*/
17592 encryptionType =
17593 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
17594 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017595 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017596
Jeff Johnson295189b2012-06-20 16:38:30 -070017597 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
17598
17599 if (0 > status)
17600 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017601 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070017602 __func__);
17603 return status;
17604 }
17605 }
17606
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017607 pWextState->roamProfile.AuthType.authType[0] =
17608 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070017609 eCSR_AUTH_TYPE_OPEN_SYSTEM;
Jeff Johnson295189b2012-06-20 16:38:30 -070017610 if (params->privacy)
17611 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017612 /* Security enabled IBSS, At this time there is no information available
17613 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070017614 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017615 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070017616 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017617 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070017618 *enable privacy bit in beacons */
17619
17620 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
17621 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070017622 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
17623 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070017624 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
17625 pWextState->roamProfile.EncryptionType.numEntries = 1;
17626 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070017627 return status;
17628}
17629
17630/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017631 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017632 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070017633 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017634static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017635 struct net_device *dev,
17636 struct cfg80211_ibss_params *params
17637 )
17638{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017639 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070017640 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
17641 tCsrRoamProfile *pRoamProfile;
17642 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017643 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17644 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017645 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070017646
17647 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017648
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017649 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17650 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
17651 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017652 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053017653 "%s: device_mode = %s (%d)", __func__,
17654 hdd_device_modetoString(pAdapter->device_mode),
17655 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070017656
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017657 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017658 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070017659 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017660 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017661 }
17662
17663 if (NULL == pWextState)
17664 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017665 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070017666 __func__);
17667 return -EIO;
17668 }
17669
Agarwal Ashish51325b52014-06-16 16:50:49 +053017670 if (vos_max_concurrent_connections_reached()) {
17671 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
17672 return -ECONNREFUSED;
17673 }
17674
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017675 /*Try disconnecting if already in connected state*/
17676 status = wlan_hdd_try_disconnect(pAdapter);
17677 if ( 0 > status)
17678 {
17679 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
17680 " IBSS connection"));
17681 return -EALREADY;
17682 }
17683
Jeff Johnson295189b2012-06-20 16:38:30 -070017684 pRoamProfile = &pWextState->roamProfile;
17685
17686 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
17687 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017688 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017689 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070017690 return -EINVAL;
17691 }
17692
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070017693 /* BSSID is provided by upper layers hence no need to AUTO generate */
17694 if (NULL != params->bssid) {
17695 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
17696 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
17697 hddLog (VOS_TRACE_LEVEL_ERROR,
17698 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
17699 return -EIO;
17700 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017701 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070017702 }
krunal sonie9002db2013-11-25 14:24:17 -080017703 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
17704 {
17705 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
17706 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
17707 {
17708 hddLog (VOS_TRACE_LEVEL_ERROR,
17709 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
17710 return -EIO;
17711 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017712
17713 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080017714 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017715 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080017716 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070017717
Jeff Johnson295189b2012-06-20 16:38:30 -070017718 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070017719 if (NULL !=
17720#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
17721 params->chandef.chan)
17722#else
17723 params->channel)
17724#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017725 {
17726 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017727 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
17728 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
17729 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17730 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070017731
17732 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017733 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070017734 ieee80211_frequency_to_channel(
17735#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
17736 params->chandef.chan->center_freq);
17737#else
17738 params->channel->center_freq);
17739#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017740
17741 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
17742 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070017743 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017744 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
17745 __func__);
17746 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070017747 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017748
17749 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070017750 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017751 if (channelNum == validChan[indx])
17752 {
17753 break;
17754 }
17755 }
17756 if (indx >= numChans)
17757 {
17758 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070017759 __func__, channelNum);
17760 return -EINVAL;
17761 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017762 /* Set the Operational Channel */
17763 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
17764 channelNum);
17765 pRoamProfile->ChannelInfo.numOfChannels = 1;
17766 pHddStaCtx->conn_info.operationChannel = channelNum;
17767 pRoamProfile->ChannelInfo.ChannelList =
17768 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070017769 }
17770
17771 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017772 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070017773 if (status < 0)
17774 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017775 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070017776 __func__);
17777 return status;
17778 }
17779
17780 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017781 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Abhishek Singh4d924682015-11-17 15:23:06 +053017782 params->ssid_len, (const u8 *)&bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017783 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070017784
17785 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070017786 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070017787
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017788 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017789 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017790}
17791
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017792static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
17793 struct net_device *dev,
17794 struct cfg80211_ibss_params *params
17795 )
17796{
17797 int ret = 0;
17798
17799 vos_ssr_protect(__func__);
17800 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
17801 vos_ssr_unprotect(__func__);
17802
17803 return ret;
17804}
17805
Jeff Johnson295189b2012-06-20 16:38:30 -070017806/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017807 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017808 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070017809 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017810static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017811 struct net_device *dev
17812 )
17813{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017814 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017815 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
17816 tCsrRoamProfile *pRoamProfile;
17817 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017818 int status;
Abhishek Singh69de3302016-11-11 16:44:32 +053017819 eHalStatus hal_status;
Abhishek Singh7cd040e2016-01-07 10:51:04 +053017820#ifdef WLAN_FEATURE_RMC
17821 tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN] = {0};
17822#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017823
17824 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017825
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017826 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17827 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
17828 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017829 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017830 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017831 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017832 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017833 }
17834
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053017835 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
17836 hdd_device_modetoString(pAdapter->device_mode),
17837 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070017838 if (NULL == pWextState)
17839 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017840 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070017841 __func__);
17842 return -EIO;
17843 }
17844
17845 pRoamProfile = &pWextState->roamProfile;
17846
17847 /* Issue disconnect only if interface type is set to IBSS */
17848 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
17849 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017850 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070017851 __func__);
17852 return -EINVAL;
17853 }
17854
Abhishek Singh7cd040e2016-01-07 10:51:04 +053017855#ifdef WLAN_FEATURE_RMC
17856 /* Clearing add IE of beacon */
17857 if (ccmCfgSetStr(pHddCtx->hHal,
17858 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0],
17859 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN,
17860 NULL, eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
17861 {
17862 hddLog (VOS_TRACE_LEVEL_ERROR,
17863 "%s: unable to clear PROBE_RSP_BCN_ADDNIE_DATA", __func__);
17864 return -EINVAL;
17865 }
17866 if (ccmCfgSetInt(pHddCtx->hHal,
17867 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0, NULL,
17868 eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
17869 {
17870 hddLog (VOS_TRACE_LEVEL_ERROR,
17871 "%s: unable to clear WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
17872 __func__);
17873 return -EINVAL;
17874 }
17875
17876 // Reset WNI_CFG_PROBE_RSP Flags
17877 wlan_hdd_reset_prob_rspies(pAdapter);
17878
17879 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
17880 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 0,NULL,
17881 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
17882 {
17883 hddLog (VOS_TRACE_LEVEL_ERROR,
17884 "%s: unable to clear WNI_CFG_PROBE_RSP_ADDNIE_FLAG",
17885 __func__);
17886 return -EINVAL;
17887 }
17888#endif
17889
Jeff Johnson295189b2012-06-20 16:38:30 -070017890 /* Issue Disconnect request */
17891 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singh69de3302016-11-11 16:44:32 +053017892 hal_status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
17893 pAdapter->sessionId,
17894 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
17895 if (!HAL_STATUS_SUCCESS(hal_status)) {
17896 hddLog(LOGE,
17897 FL("sme_RoamDisconnect failed hal_status(%d)"),
17898 hal_status);
17899 return -EAGAIN;
17900 }
17901 status = wait_for_completion_timeout(
17902 &pAdapter->disconnect_comp_var,
17903 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
17904 if (!status) {
17905 hddLog(LOGE,
17906 FL("wait on disconnect_comp_var failed"));
17907 return -ETIMEDOUT;
17908 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017909
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017910 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070017911 return 0;
17912}
17913
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017914static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
17915 struct net_device *dev
17916 )
17917{
17918 int ret = 0;
17919
17920 vos_ssr_protect(__func__);
17921 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
17922 vos_ssr_unprotect(__func__);
17923
17924 return ret;
17925}
17926
Jeff Johnson295189b2012-06-20 16:38:30 -070017927/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053017928 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070017929 * This function is used to set the phy parameters
17930 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
17931 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053017932static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017933 u32 changed)
17934{
17935 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
17936 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017937 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017938
17939 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017940
17941 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017942 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
17943 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017944
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017945 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017946 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017947 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017948 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017949 }
17950
Jeff Johnson295189b2012-06-20 16:38:30 -070017951 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
17952 {
17953 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
17954 WNI_CFG_RTS_THRESHOLD_STAMAX :
17955 wiphy->rts_threshold;
17956
17957 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017958 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070017959 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017960 hddLog(VOS_TRACE_LEVEL_ERROR,
17961 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070017962 __func__, rts_threshold);
17963 return -EINVAL;
17964 }
17965
17966 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
17967 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017968 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070017969 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017970 hddLog(VOS_TRACE_LEVEL_ERROR,
17971 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070017972 __func__, rts_threshold);
17973 return -EIO;
17974 }
17975
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017976 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070017977 rts_threshold);
17978 }
17979
17980 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
17981 {
17982 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
17983 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
17984 wiphy->frag_threshold;
17985
17986 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017987 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070017988 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017989 hddLog(VOS_TRACE_LEVEL_ERROR,
17990 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070017991 frag_threshold);
17992 return -EINVAL;
17993 }
17994
17995 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
17996 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017997 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070017998 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017999 hddLog(VOS_TRACE_LEVEL_ERROR,
18000 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018001 __func__, frag_threshold);
18002 return -EIO;
18003 }
18004
18005 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
18006 frag_threshold);
18007 }
18008
18009 if ((changed & WIPHY_PARAM_RETRY_SHORT)
18010 || (changed & WIPHY_PARAM_RETRY_LONG))
18011 {
18012 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
18013 wiphy->retry_short :
18014 wiphy->retry_long;
18015
18016 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
18017 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
18018 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018019 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018020 __func__, retry_value);
18021 return -EINVAL;
18022 }
18023
18024 if (changed & WIPHY_PARAM_RETRY_SHORT)
18025 {
18026 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
18027 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018028 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070018029 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018030 hddLog(VOS_TRACE_LEVEL_ERROR,
18031 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018032 __func__, retry_value);
18033 return -EIO;
18034 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018035 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018036 __func__, retry_value);
18037 }
18038 else if (changed & WIPHY_PARAM_RETRY_SHORT)
18039 {
18040 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
18041 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018042 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070018043 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018044 hddLog(VOS_TRACE_LEVEL_ERROR,
18045 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018046 __func__, retry_value);
18047 return -EIO;
18048 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018049 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070018050 __func__, retry_value);
18051 }
18052 }
18053
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018054 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070018055 return 0;
18056}
18057
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053018058static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
18059 u32 changed)
18060{
18061 int ret;
18062
18063 vos_ssr_protect(__func__);
18064 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
18065 vos_ssr_unprotect(__func__);
18066
18067 return ret;
18068}
18069
Jeff Johnson295189b2012-06-20 16:38:30 -070018070/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053018071 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070018072 * This function is used to set the txpower
18073 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053018074static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070018075#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18076 struct wireless_dev *wdev,
18077#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018078#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018079 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070018080#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018081 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070018082#endif
18083 int dbm)
18084{
18085 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018086 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070018087 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
18088 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018089 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070018090
18091 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018092
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018093 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18094 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
18095 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018096 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018097 if (0 != status)
18098 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018099 return status;
18100 }
18101
18102 hHal = pHddCtx->hHal;
18103
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018104 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
18105 dbm, ccmCfgSetCallback,
18106 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070018107 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018108 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070018109 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
18110 return -EIO;
18111 }
18112
18113 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
18114 dbm);
18115
18116 switch(type)
18117 {
18118 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
18119 /* Fall through */
18120 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
18121 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
18122 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018123 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
18124 __func__);
18125 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070018126 }
18127 break;
18128 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018129 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070018130 __func__);
18131 return -EOPNOTSUPP;
18132 break;
18133 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018134 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
18135 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070018136 return -EIO;
18137 }
18138
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018139 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070018140 return 0;
18141}
18142
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053018143static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
18144#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18145 struct wireless_dev *wdev,
18146#endif
18147#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
18148 enum tx_power_setting type,
18149#else
18150 enum nl80211_tx_power_setting type,
18151#endif
18152 int dbm)
18153{
18154 int ret;
18155 vos_ssr_protect(__func__);
18156 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
18157#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18158 wdev,
18159#endif
18160#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
18161 type,
18162#else
18163 type,
18164#endif
18165 dbm);
18166 vos_ssr_unprotect(__func__);
18167
18168 return ret;
18169}
18170
Jeff Johnson295189b2012-06-20 16:38:30 -070018171/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018172 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070018173 * This function is used to read the txpower
18174 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018175static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070018176#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18177 struct wireless_dev *wdev,
18178#endif
18179 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070018180{
18181
18182 hdd_adapter_t *pAdapter;
18183 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018184 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070018185
Jeff Johnsone7245742012-09-05 17:12:55 -070018186 ENTER();
18187
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018188 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018189 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018190 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018191 *dbm = 0;
18192 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018193 }
18194
Jeff Johnson295189b2012-06-20 16:38:30 -070018195 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
18196 if (NULL == pAdapter)
18197 {
18198 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
18199 return -ENOENT;
18200 }
18201
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018202 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18203 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
18204 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070018205 wlan_hdd_get_classAstats(pAdapter);
18206 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
18207
Jeff Johnsone7245742012-09-05 17:12:55 -070018208 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070018209 return 0;
18210}
18211
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018212static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
18213#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18214 struct wireless_dev *wdev,
18215#endif
18216 int *dbm)
18217{
18218 int ret;
18219
18220 vos_ssr_protect(__func__);
18221 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
18222#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18223 wdev,
18224#endif
18225 dbm);
18226 vos_ssr_unprotect(__func__);
18227
18228 return ret;
18229}
18230
Dustin Brown8c1d4092017-07-28 18:08:01 +053018231/*
18232 * wlan_hdd_fill_summary_stats() - populate station_info summary stats
18233 * @stats: summary stats to use as a source
18234 * @info: kernel station_info struct to use as a destination
18235 *
18236 * Return: None
18237 */
18238static void wlan_hdd_fill_summary_stats(tCsrSummaryStatsInfo *stats,
18239 struct station_info *info)
18240{
18241 int i;
18242
18243 info->rx_packets = stats->rx_frm_cnt;
18244 info->tx_packets = 0;
18245 info->tx_retries = 0;
18246 info->tx_failed = 0;
18247
18248 for (i = 0; i < 4; ++i) {
18249 info->tx_packets += stats->tx_frm_cnt[i];
18250 info->tx_retries += stats->multiple_retry_cnt[i];
18251 info->tx_failed += stats->fail_cnt[i];
18252 }
18253
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018254#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
18255 !defined(WITH_BACKPORTS)
Dustin Brown8c1d4092017-07-28 18:08:01 +053018256 info->filled |= STATION_INFO_TX_PACKETS |
18257 STATION_INFO_TX_RETRIES |
18258 STATION_INFO_TX_FAILED |
18259 STATION_INFO_RX_PACKETS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018260#else
18261 info->filled |= BIT(NL80211_STA_INFO_TX_PACKETS) |
18262 BIT(NL80211_STA_INFO_TX_RETRIES) |
18263 BIT(NL80211_STA_INFO_TX_FAILED) |
18264 BIT(NL80211_STA_INFO_RX_PACKETS);
18265#endif
Dustin Brown8c1d4092017-07-28 18:08:01 +053018266}
18267
18268/**
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018269 * wlan_hdd_sap_get_sta_rssi() - get RSSI of the SAP client
18270 * @adapter: sap adapter pointer
18271 * @staid: station id of the client
18272 * @rssi: rssi value to fill
18273 *
18274 * Return: None
18275 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053018276void
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018277wlan_hdd_sap_get_sta_rssi(hdd_adapter_t *adapter, uint8_t staid, s8 *rssi)
18278{
18279 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
18280
18281 WLANTL_GetSAPStaRSSi(pVosContext, staid, rssi);
18282}
18283
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018284#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
18285 !defined(WITH_BACKPORTS)
18286static inline void wlan_hdd_fill_station_info_signal(struct station_info
18287 *sinfo)
18288{
18289 sinfo->filled |= STATION_INFO_SIGNAL;
18290}
18291#else
18292static inline void wlan_hdd_fill_station_info_signal(struct station_info
18293 *sinfo)
18294{
18295 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
18296}
18297#endif
18298
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018299/**
Dustin Brown8c1d4092017-07-28 18:08:01 +053018300 * wlan_hdd_get_sap_stats() - get aggregate SAP stats
18301 * @adapter: sap adapter to get stats for
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018302 * @mac: mac address of the station
Dustin Brown8c1d4092017-07-28 18:08:01 +053018303 * @info: kernel station_info struct to populate
18304 *
18305 * Fetch the vdev-level aggregate stats for the given SAP adapter. This is to
18306 * support "station dump" and "station get" for SAP vdevs, even though they
18307 * aren't technically stations.
18308 *
18309 * Return: errno
18310 */
18311static int
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018312wlan_hdd_get_sap_stats(hdd_adapter_t *adapter,
18313#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18314 const u8* mac,
18315#else
18316 u8* mac,
18317#endif
18318 struct station_info *info)
Dustin Brown8c1d4092017-07-28 18:08:01 +053018319{
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018320 v_MACADDR_t *peerMacAddr;
18321 uint8_t staid;
Dustin Brown8c1d4092017-07-28 18:08:01 +053018322 VOS_STATUS status;
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018323 bool bc_mac_addr;
Dustin Brown8c1d4092017-07-28 18:08:01 +053018324
18325 status = wlan_hdd_get_station_stats(adapter);
18326 if (!VOS_IS_STATUS_SUCCESS(status)) {
18327 hddLog(VOS_TRACE_LEVEL_ERROR,
18328 "Failed to get SAP stats; status:%d", status);
18329 return 0;
18330 }
18331
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018332 peerMacAddr = (v_MACADDR_t *)mac;
18333 bc_mac_addr = vos_is_macaddr_broadcast(peerMacAddr);
18334 staid = hdd_sta_id_find_from_mac_addr(adapter, peerMacAddr);
18335 hddLog(VOS_TRACE_LEVEL_INFO, "Get SAP stats for sta id:%d", staid);
18336
18337 if (staid < WLAN_MAX_STA_COUNT && !bc_mac_addr) {
18338 wlan_hdd_sap_get_sta_rssi(adapter, staid, &info->signal);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018339 wlan_hdd_fill_station_info_signal(info);
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018340 }
18341
Dustin Brown8c1d4092017-07-28 18:08:01 +053018342 wlan_hdd_fill_summary_stats(&adapter->hdd_stats.summary_stat, info);
18343
18344 return 0;
18345}
18346
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018347static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053018348#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18349 const u8* mac,
18350#else
18351 u8* mac,
18352#endif
18353 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070018354{
18355 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
18356 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
c_hpothu44ff4e02014-05-08 00:13:57 +053018357 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070018358
18359 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
18360 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070018361
18362 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
18363 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
18364 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
18365 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
18366 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
18367 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
18368 tANI_U16 maxRate = 0;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053018369 int8_t snr = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018370 tANI_U16 myRate;
18371 tANI_U16 currentRate = 0;
18372 tANI_U8 maxSpeedMCS = 0;
18373 tANI_U8 maxMCSIdx = 0;
18374 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053018375 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070018376 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018377 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070018378
Leo Chang6f8870f2013-03-26 18:11:36 -070018379#ifdef WLAN_FEATURE_11AC
18380 tANI_U32 vht_mcs_map;
18381 eDataRate11ACMaxMcs vhtMaxMcs;
18382#endif /* WLAN_FEATURE_11AC */
18383
Jeff Johnsone7245742012-09-05 17:12:55 -070018384 ENTER();
18385
Dustin Brown8c1d4092017-07-28 18:08:01 +053018386 status = wlan_hdd_validate_context(pHddCtx);
18387 if (0 != status)
18388 {
18389 return status;
18390 }
18391
18392 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018393 return wlan_hdd_get_sap_stats(pAdapter, mac, sinfo);
Dustin Brown8c1d4092017-07-28 18:08:01 +053018394
Abhinav Kumarf70293b2019-09-19 12:33:43 +053018395 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -070018396 {
Abhinav Kumarf70293b2019-09-19 12:33:43 +053018397 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070018398 /*To keep GUI happy*/
18399 return 0;
18400 }
18401
Mukul Sharma811205f2014-07-09 21:07:30 +053018402 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
18403 {
18404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18405 "%s: Roaming in progress, so unable to proceed this request", __func__);
Sachin Ahuja81ab1812016-08-19 21:35:58 +053018406 /* return a cached value */
18407 sinfo->signal = pAdapter->rssi;
Mukul Sharma811205f2014-07-09 21:07:30 +053018408 return 0;
18409 }
18410
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053018411 wlan_hdd_get_station_stats(pAdapter);
18412 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070018413
Kiet Lam3b17fc82013-09-27 05:24:08 +053018414 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053018415 wlan_hdd_get_snr(pAdapter, &snr);
18416 pHddStaCtx->conn_info.signal = sinfo->signal;
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +053018417 pHddStaCtx->cache_conn_info.signal = sinfo->signal;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053018418 pHddStaCtx->conn_info.noise = pHddStaCtx->conn_info.signal - snr;
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +053018419 pHddStaCtx->cache_conn_info.noise = pHddStaCtx->conn_info.noise;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018420 wlan_hdd_fill_station_info_signal(sinfo);
Kiet Lam3b17fc82013-09-27 05:24:08 +053018421
c_hpothu09f19542014-05-30 21:53:31 +053018422 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053018423 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
18424 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053018425 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053018426 {
18427 rate_flags = pAdapter->maxRateFlags;
18428 }
c_hpothu44ff4e02014-05-08 00:13:57 +053018429
Jeff Johnson295189b2012-06-20 16:38:30 -070018430 //convert to the UI units of 100kbps
18431 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
18432
18433#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070018434 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 -070018435 sinfo->signal,
18436 pCfg->reportMaxLinkSpeed,
18437 myRate,
18438 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070018439 (int) pCfg->linkSpeedRssiMid,
18440 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070018441 (int) rate_flags,
18442 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070018443#endif //LINKSPEED_DEBUG_ENABLED
18444
Hanumanth Reddy Pothula596b8b32018-05-01 20:17:38 +053018445#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || defined(WITH_BACKPORTS)
18446 /* assume basic BW. anything else will override this later */
18447 sinfo->txrate.bw = RATE_INFO_BW_20;
18448#endif
18449
Jeff Johnson295189b2012-06-20 16:38:30 -070018450 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
18451 {
18452 // we do not want to necessarily report the current speed
18453 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
18454 {
18455 // report the max possible speed
18456 rssidx = 0;
18457 }
18458 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
18459 {
18460 // report the max possible speed with RSSI scaling
18461 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
18462 {
18463 // report the max possible speed
18464 rssidx = 0;
18465 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070018466 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070018467 {
18468 // report middle speed
18469 rssidx = 1;
18470 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070018471 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
18472 {
18473 // report middle speed
18474 rssidx = 2;
18475 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018476 else
18477 {
18478 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070018479 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070018480 }
18481 }
18482 else
18483 {
18484 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
18485 hddLog(VOS_TRACE_LEVEL_ERROR,
18486 "%s: Invalid value for reportMaxLinkSpeed: %u",
18487 __func__, pCfg->reportMaxLinkSpeed);
18488 rssidx = 0;
18489 }
18490
18491 maxRate = 0;
18492
18493 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053018494 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
18495 OperationalRates, &ORLeng))
18496 {
18497 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
18498 /*To keep GUI happy*/
18499 return 0;
18500 }
18501
Jeff Johnson295189b2012-06-20 16:38:30 -070018502 for (i = 0; i < ORLeng; i++)
18503 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018504 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070018505 {
18506 /* Validate Rate Set */
18507 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
18508 {
18509 currentRate = supported_data_rate[j].supported_rate[rssidx];
18510 break;
18511 }
18512 }
18513 /* Update MAX rate */
18514 maxRate = (currentRate > maxRate)?currentRate:maxRate;
18515 }
18516
18517 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053018518 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
18519 ExtendedRates, &ERLeng))
18520 {
18521 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
18522 /*To keep GUI happy*/
18523 return 0;
18524 }
18525
Jeff Johnson295189b2012-06-20 16:38:30 -070018526 for (i = 0; i < ERLeng; i++)
18527 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018528 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070018529 {
18530 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
18531 {
18532 currentRate = supported_data_rate[j].supported_rate[rssidx];
18533 break;
18534 }
18535 }
18536 /* Update MAX rate */
18537 maxRate = (currentRate > maxRate)?currentRate:maxRate;
18538 }
c_hpothu79aab322014-07-14 21:11:01 +053018539
Kiet Lamb69f8dc2013-11-15 15:34:27 +053018540 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053018541 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053018542 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053018543 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070018544 {
c_hpothu79aab322014-07-14 21:11:01 +053018545 if (rate_flags & eHAL_TX_RATE_VHT80)
18546 mode = 2;
18547 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
18548 mode = 1;
18549 else
18550 mode = 0;
18551
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053018552 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
18553 MCSRates, &MCSLeng))
18554 {
18555 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
18556 /*To keep GUI happy*/
18557 return 0;
18558 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018559 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070018560#ifdef WLAN_FEATURE_11AC
18561 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018562 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070018563 {
Leo Chang6f8870f2013-03-26 18:11:36 -070018564 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018565 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070018566 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070018567 {
Leo Chang6f8870f2013-03-26 18:11:36 -070018568 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070018569 }
Leo Chang6f8870f2013-03-26 18:11:36 -070018570 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070018571 {
Leo Chang6f8870f2013-03-26 18:11:36 -070018572 maxMCSIdx = 7;
18573 }
18574 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
18575 {
18576 maxMCSIdx = 8;
18577 }
18578 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
18579 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018580 //VHT20 is supporting 0~8
18581 if (rate_flags & eHAL_TX_RATE_VHT20)
18582 maxMCSIdx = 8;
18583 else
18584 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070018585 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018586
c_hpothu79aab322014-07-14 21:11:01 +053018587 if (0 != rssidx)/*check for scaled */
18588 {
18589 //get middle rate MCS index if rssi=1/2
18590 for (i=0; i <= maxMCSIdx; i++)
18591 {
18592 if (sinfo->signal <= rssiMcsTbl[mode][i])
18593 {
18594 maxMCSIdx = i;
18595 break;
18596 }
18597 }
18598 }
18599
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018600 if (rate_flags & eHAL_TX_RATE_VHT80)
18601 {
18602 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
18603 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
18604 }
18605 else if (rate_flags & eHAL_TX_RATE_VHT40)
18606 {
18607 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
18608 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
18609 }
18610 else if (rate_flags & eHAL_TX_RATE_VHT20)
18611 {
18612 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
18613 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
18614 }
18615
Leo Chang6f8870f2013-03-26 18:11:36 -070018616 maxSpeedMCS = 1;
18617 if (currentRate > maxRate)
18618 {
18619 maxRate = currentRate;
18620 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018621
Leo Chang6f8870f2013-03-26 18:11:36 -070018622 }
18623 else
18624#endif /* WLAN_FEATURE_11AC */
18625 {
18626 if (rate_flags & eHAL_TX_RATE_HT40)
18627 {
18628 rateFlag |= 1;
18629 }
18630 if (rate_flags & eHAL_TX_RATE_SGI)
18631 {
18632 rateFlag |= 2;
18633 }
18634
Girish Gowli01abcee2014-07-31 20:18:55 +053018635 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053018636 if (rssidx == 1 || rssidx == 2)
18637 {
18638 //get middle rate MCS index if rssi=1/2
18639 for (i=0; i <= 7; i++)
18640 {
18641 if (sinfo->signal <= rssiMcsTbl[mode][i])
18642 {
18643 temp = i+1;
18644 break;
18645 }
18646 }
18647 }
c_hpothu79aab322014-07-14 21:11:01 +053018648
18649 for (i = 0; i < MCSLeng; i++)
18650 {
Leo Chang6f8870f2013-03-26 18:11:36 -070018651 for (j = 0; j < temp; j++)
18652 {
18653 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
18654 {
18655 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053018656 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070018657 break;
18658 }
18659 }
18660 if ((j < temp) && (currentRate > maxRate))
18661 {
18662 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070018663 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018664 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053018665 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070018666 }
18667 }
18668
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018669 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
18670 {
18671 maxRate = myRate;
18672 maxSpeedMCS = 1;
18673 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
18674 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018675 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053018676 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070018677 {
18678 maxRate = myRate;
18679 if (rate_flags & eHAL_TX_RATE_LEGACY)
18680 {
18681 maxSpeedMCS = 0;
18682 }
18683 else
18684 {
18685 maxSpeedMCS = 1;
18686 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
18687 }
18688 }
18689
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018690 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070018691 {
18692 sinfo->txrate.legacy = maxRate;
18693#ifdef LINKSPEED_DEBUG_ENABLED
18694 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
18695#endif //LINKSPEED_DEBUG_ENABLED
18696 }
18697 else
18698 {
18699 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070018700#ifdef WLAN_FEATURE_11AC
18701 sinfo->txrate.nss = 1;
18702 if (rate_flags & eHAL_TX_RATE_VHT80)
18703 {
18704 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018705#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18706 defined(WITH_BACKPORTS)
18707 sinfo->txrate.bw = RATE_INFO_BW_80;
18708#else
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018709 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018710#endif
Leo Chang6f8870f2013-03-26 18:11:36 -070018711 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018712 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070018713 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018714 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018715#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18716 defined(WITH_BACKPORTS)
18717 sinfo->txrate.bw = RATE_INFO_BW_40;
18718#else
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018719 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018720#endif
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018721 }
18722 else if (rate_flags & eHAL_TX_RATE_VHT20)
18723 {
18724 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
18725 }
18726#endif /* WLAN_FEATURE_11AC */
18727 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
18728 {
18729 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
18730 if (rate_flags & eHAL_TX_RATE_HT40)
18731 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018732#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18733 defined(WITH_BACKPORTS)
18734 sinfo->txrate.bw = RATE_INFO_BW_40;
18735#else
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018736 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018737#endif
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018738 }
Leo Chang6f8870f2013-03-26 18:11:36 -070018739 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018740 if (rate_flags & eHAL_TX_RATE_SGI)
18741 {
18742 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
18743 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018744
Jeff Johnson295189b2012-06-20 16:38:30 -070018745#ifdef LINKSPEED_DEBUG_ENABLED
18746 pr_info("Reporting MCS rate %d flags %x\n",
18747 sinfo->txrate.mcs,
18748 sinfo->txrate.flags );
18749#endif //LINKSPEED_DEBUG_ENABLED
18750 }
18751 }
18752 else
18753 {
18754 // report current rate instead of max rate
18755
18756 if (rate_flags & eHAL_TX_RATE_LEGACY)
18757 {
18758 //provide to the UI in units of 100kbps
18759 sinfo->txrate.legacy = myRate;
18760#ifdef LINKSPEED_DEBUG_ENABLED
18761 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
18762#endif //LINKSPEED_DEBUG_ENABLED
18763 }
18764 else
18765 {
18766 //must be MCS
18767 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070018768#ifdef WLAN_FEATURE_11AC
18769 sinfo->txrate.nss = 1;
18770 if (rate_flags & eHAL_TX_RATE_VHT80)
18771 {
18772 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
18773 }
18774 else
18775#endif /* WLAN_FEATURE_11AC */
18776 {
18777 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
18778 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018779 if (rate_flags & eHAL_TX_RATE_SGI)
18780 {
18781 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
18782 }
18783 if (rate_flags & eHAL_TX_RATE_HT40)
18784 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018785#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18786 defined(WITH_BACKPORTS)
18787 sinfo->txrate.bw = RATE_INFO_BW_40;
18788#else
Jeff Johnson295189b2012-06-20 16:38:30 -070018789 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018790#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018791 }
Leo Chang6f8870f2013-03-26 18:11:36 -070018792#ifdef WLAN_FEATURE_11AC
18793 else if (rate_flags & eHAL_TX_RATE_VHT80)
18794 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018795#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18796 defined(WITH_BACKPORTS)
18797 sinfo->txrate.bw = RATE_INFO_BW_80;
18798#else
Leo Chang6f8870f2013-03-26 18:11:36 -070018799 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018800#endif
Leo Chang6f8870f2013-03-26 18:11:36 -070018801 }
18802#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070018803#ifdef LINKSPEED_DEBUG_ENABLED
18804 pr_info("Reporting actual MCS rate %d flags %x\n",
18805 sinfo->txrate.mcs,
18806 sinfo->txrate.flags );
18807#endif //LINKSPEED_DEBUG_ENABLED
18808 }
18809 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018810
18811#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
18812 !defined(WITH_BACKPORTS)
Jeff Johnson295189b2012-06-20 16:38:30 -070018813 sinfo->filled |= STATION_INFO_TX_BITRATE;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018814#else
18815 sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE);
18816#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018817
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018818 sinfo->tx_packets =
18819 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
18820 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
18821 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
18822 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
18823
18824 sinfo->tx_retries =
18825 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
18826 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
18827 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
18828 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
18829
18830 sinfo->tx_failed =
18831 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
18832 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
18833 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
18834 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
18835
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018836#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
18837 !defined(WITH_BACKPORTS)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018838 sinfo->filled |=
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018839 STATION_INFO_RX_PACKETS |
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018840 STATION_INFO_TX_PACKETS |
18841 STATION_INFO_TX_RETRIES |
18842 STATION_INFO_TX_FAILED;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018843#else
18844 sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS) |
18845 BIT(NL80211_STA_INFO_TX_PACKETS) |
18846 BIT(NL80211_STA_INFO_TX_RETRIES) |
18847 BIT(NL80211_STA_INFO_TX_FAILED);
18848#endif
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018849
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053018850 sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt;
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053018851
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053018852 vos_mem_copy(&pHddStaCtx->conn_info.txrate,
18853 &sinfo->txrate, sizeof(sinfo->txrate));
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +053018854 vos_mem_copy(&pHddStaCtx->cache_conn_info.txrate,
18855 &sinfo->txrate, sizeof(sinfo->txrate));
18856
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053018857 if (rate_flags & eHAL_TX_RATE_LEGACY)
18858 hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"),
18859 sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets,
18860 sinfo->rx_packets);
18861 else
18862 hddLog(LOG1,
18863 FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"),
18864 sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags,
18865 sinfo->tx_packets, sinfo->rx_packets);
18866
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018867 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18868 TRACE_CODE_HDD_CFG80211_GET_STA,
18869 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018870 EXIT();
18871 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018872}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053018873#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
18874static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
18875 const u8* mac, struct station_info *sinfo)
18876#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018877static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
18878 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053018879#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018880{
18881 int ret;
18882
18883 vos_ssr_protect(__func__);
18884 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
18885 vos_ssr_unprotect(__func__);
18886
18887 return ret;
18888}
18889
18890static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070018891 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070018892{
18893 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018894 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070018895 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018896 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070018897
Jeff Johnsone7245742012-09-05 17:12:55 -070018898 ENTER();
18899
Jeff Johnson295189b2012-06-20 16:38:30 -070018900 if (NULL == pAdapter)
18901 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080018902 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070018903 return -ENODEV;
18904 }
18905
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018906 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18907 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
18908 pAdapter->sessionId, timeout));
18909
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018910 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018911 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018912 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018913 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018914 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018915 }
18916
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018917 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
18918 (TRUE == pHddCtx->hdd_wlan_suspended) &&
18919 (pHddCtx->cfg_ini->fhostArpOffload) &&
18920 (eConnectionState_Associated ==
18921 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
18922 {
Amar Singhald53568e2013-09-26 11:03:45 -070018923
18924 hddLog(VOS_TRACE_LEVEL_INFO,
18925 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053018926 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018927 if (!VOS_IS_STATUS_SUCCESS(vos_status))
18928 {
18929 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080018930 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018931 __func__, vos_status);
18932 }
18933 }
18934
Jeff Johnson295189b2012-06-20 16:38:30 -070018935 /**The get power cmd from the supplicant gets updated by the nl only
18936 *on successful execution of the function call
18937 *we are oppositely mapped w.r.t mode in the driver
18938 **/
18939 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
18940
18941 if (VOS_STATUS_E_FAILURE == vos_status)
18942 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018943 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18944 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070018945 return -EINVAL;
18946 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018947 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070018948 return 0;
18949}
18950
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018951static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
18952 struct net_device *dev, bool mode, int timeout)
18953{
18954 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070018955
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018956 vos_ssr_protect(__func__);
18957 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
18958 vos_ssr_unprotect(__func__);
18959
18960 return ret;
18961}
Sushant Kaushik084f6592015-09-10 13:11:56 +053018962
Jeff Johnson295189b2012-06-20 16:38:30 -070018963#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018964static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
18965 struct net_device *netdev,
18966 u8 key_index)
18967{
18968 ENTER();
18969 return 0;
18970}
18971
Jeff Johnson295189b2012-06-20 16:38:30 -070018972static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018973 struct net_device *netdev,
18974 u8 key_index)
18975{
18976 int ret;
18977 vos_ssr_protect(__func__);
18978 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
18979 vos_ssr_unprotect(__func__);
18980 return ret;
18981}
18982#endif //LINUX_VERSION_CODE
18983
18984#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
18985static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
18986 struct net_device *dev,
18987 struct ieee80211_txq_params *params)
18988{
18989 ENTER();
18990 return 0;
18991}
18992#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
18993static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
18994 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070018995{
Jeff Johnsone7245742012-09-05 17:12:55 -070018996 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070018997 return 0;
18998}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018999#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070019000
19001#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
19002static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019003 struct net_device *dev,
19004 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070019005{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019006 int ret;
19007
19008 vos_ssr_protect(__func__);
19009 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
19010 vos_ssr_unprotect(__func__);
19011 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070019012}
19013#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
19014static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
19015 struct ieee80211_txq_params *params)
19016{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019017 int ret;
19018
19019 vos_ssr_protect(__func__);
19020 ret = __wlan_hdd_set_txq_params(wiphy, params);
19021 vos_ssr_unprotect(__func__);
19022 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070019023}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019024#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019025
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019026static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019027 struct net_device *dev,
19028 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070019029{
19030 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019031 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019032 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019033 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019034 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019035 v_CONTEXT_t pVosContext = NULL;
19036 ptSapContext pSapCtx = NULL;
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019037 hdd_hostapd_state_t *hostap_state;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019038
Jeff Johnsone7245742012-09-05 17:12:55 -070019039 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019040
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019041 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070019042 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019043 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070019044 return -EINVAL;
19045 }
19046
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019047 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19048 TRACE_CODE_HDD_CFG80211_DEL_STA,
19049 pAdapter->sessionId, pAdapter->device_mode));
19050
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019051 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19052 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019053 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019054 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019055 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019056 }
19057
Jeff Johnson295189b2012-06-20 16:38:30 -070019058 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070019059 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070019060 )
19061 {
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019062 hostap_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019063 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
19064 pSapCtx = VOS_GET_SAP_CB(pVosContext);
19065 if(pSapCtx == NULL){
19066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19067 FL("psapCtx is NULL"));
19068 return -ENOENT;
19069 }
Agrawal Ashish306b75f2017-01-11 19:16:25 +053019070 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
19071 {
19072 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
19073 "Change reason code to eSIR_MAC_DISASSOC_LEAVING_BSS_REASON in sap auth offload");
19074 pDelStaParams->reason_code = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
19075 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019076 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070019077 {
19078 v_U16_t i;
19079 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
19080 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019081 if ((pSapCtx->aStaInfo[i].isUsed) &&
19082 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070019083 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019084 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019085 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019086 ETHER_ADDR_LEN);
19087
Jeff Johnson295189b2012-06-20 16:38:30 -070019088 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080019089 "%s: Delete STA with MAC::"
19090 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019091 __func__,
19092 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019093 vos_event_reset(&hostap_state->sta_discon_event);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019094 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070019095 if (VOS_IS_STATUS_SUCCESS(vos_status))
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019096 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019097 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019098 vos_status =
19099 vos_wait_single_event(
19100 &hostap_state->sta_discon_event,
19101 WLAN_WAIT_TIME_DISCONNECT);
19102 if (!VOS_IS_STATUS_SUCCESS(vos_status))
19103 hddLog(LOGE,"!!%s: ERROR: Deauth wait expired!!",
19104 __func__);
19105 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019106 }
19107 }
19108 }
19109 else
19110 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019111
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019112 vos_status = hdd_softap_GetStaId(pAdapter,
19113 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019114 if (!VOS_IS_STATUS_SUCCESS(vos_status))
19115 {
19116 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080019117 "%s: Skip this DEL STA as this is not used::"
19118 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019119 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019120 return -ENOENT;
19121 }
19122
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019123 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019124 {
19125 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080019126 "%s: Skip this DEL STA as deauth is in progress::"
19127 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019128 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019129 return -ENOENT;
19130 }
19131
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019132 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019133
Jeff Johnson295189b2012-06-20 16:38:30 -070019134 hddLog(VOS_TRACE_LEVEL_INFO,
19135 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080019136 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070019137 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019138 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019139
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019140 vos_event_reset(&hostap_state->sta_discon_event);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019141 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019142 if (!VOS_IS_STATUS_SUCCESS(vos_status))
19143 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053019144 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019145 hddLog(VOS_TRACE_LEVEL_INFO,
19146 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080019147 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019148 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019149 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080019150 return -ENOENT;
19151 }
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +053019152 vos_status =
19153 vos_wait_single_event(&hostap_state->sta_discon_event,
19154 WLAN_WAIT_TIME_DISCONNECT);
19155 if (!VOS_IS_STATUS_SUCCESS(vos_status))
19156 hddLog(LOGE,"!!%s: ERROR: Deauth wait expired!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070019157 }
19158 }
19159
19160 EXIT();
19161
19162 return 0;
19163}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019164
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053019165#ifdef USE_CFG80211_DEL_STA_V2
Kapil Gupta137ef892016-12-13 19:38:00 +053019166int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019167 struct net_device *dev,
19168 struct station_del_parameters *param)
19169#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019170#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
Kapil Gupta137ef892016-12-13 19:38:00 +053019171int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019172 struct net_device *dev, const u8 *mac)
19173#else
Kapil Gupta137ef892016-12-13 19:38:00 +053019174int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019175 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019176#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019177#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019178{
19179 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019180 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070019181
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019182 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019183
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053019184#ifdef USE_CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019185 if (NULL == param) {
19186 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019187 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019188 return -EINVAL;
19189 }
19190
19191 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
19192 param->subtype, &delStaParams);
19193
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019194#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053019195 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019196 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019197#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019198 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
19199
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019200 vos_ssr_unprotect(__func__);
19201
19202 return ret;
19203}
19204
19205static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019206 struct net_device *dev,
19207#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
19208 const u8 *mac,
19209#else
19210 u8 *mac,
19211#endif
19212 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080019213{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019214 hdd_adapter_t *pAdapter;
19215 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080019216 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080019217#ifdef FEATURE_WLAN_TDLS
19218 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019219
Hoonki Lee11f7dda2013-02-14 16:55:44 -080019220 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019221
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019222 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19223 if (NULL == pAdapter)
19224 {
19225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19226 "%s: Adapter is NULL",__func__);
19227 return -EINVAL;
19228 }
19229 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19230 status = wlan_hdd_validate_context(pHddCtx);
19231 if (0 != status)
19232 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019233 return status;
19234 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019235
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019236 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19237 TRACE_CODE_HDD_CFG80211_ADD_STA,
19238 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019239 mask = params->sta_flags_mask;
19240
19241 set = params->sta_flags_set;
19242
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053019243 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019244 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
19245 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019246
19247 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
19248 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080019249 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019250 }
19251 }
19252#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019253 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080019254 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070019255}
19256
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019257#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
19258static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
19259 struct net_device *dev, const u8 *mac,
19260 struct station_parameters *params)
19261#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019262static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
19263 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019264#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019265{
19266 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019267
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019268 vos_ssr_protect(__func__);
19269 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
19270 vos_ssr_unprotect(__func__);
19271
19272 return ret;
19273}
Abhinav Kumar8c122592019-08-07 15:43:20 +053019274
19275#if defined(WLAN_FEATURE_SAE) && \
19276 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
19277/*
19278 * wlan_hdd_is_pmksa_valid: API to validate pmksa
19279 * @pmksa: pointer to cfg80211_pmksa structure
19280 *
19281 * Return: True if valid else false
19282 */
19283static inline bool wlan_hdd_is_pmksa_valid(struct cfg80211_pmksa *pmksa)
19284{
19285 if (pmksa->bssid){
19286 return true;
19287 }
19288 else
19289 {
19290 hddLog(LOGE, FL(" Either of bssid (%p) is NULL"), pmksa->bssid);
19291 return false;
19292 }
19293}
19294
19295/*
19296 * hdd_update_pmksa_info: API to update tPmkidCacheInfo from cfg80211_pmksa
19297 * @pmk_cache: pmksa from supplicant
19298 * @pmk_cache: pmk needs to be updated
19299 *
19300 * Return: None
19301 */
19302static void hdd_update_pmksa_info(tPmkidCacheInfo *pmk_cache,
19303 struct cfg80211_pmksa *pmksa, bool is_delete)
19304{
19305 if (pmksa->bssid) {
19306 hddLog(VOS_TRACE_LEVEL_DEBUG,"set PMKSA for " MAC_ADDRESS_STR,
19307 MAC_ADDR_ARRAY(pmksa->bssid));
19308 vos_mem_copy(pmk_cache->BSSID,
19309 pmksa->bssid, VOS_MAC_ADDR_SIZE);
19310 }
19311
19312 if (is_delete)
19313 return;
19314
19315 vos_mem_copy(pmk_cache->PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
19316 if (pmksa->pmk_len && (pmksa->pmk_len <= CSR_RSN_MAX_PMK_LEN)) {
19317 vos_mem_copy(pmk_cache->pmk, pmksa->pmk, pmksa->pmk_len);
19318 pmk_cache->pmk_len = pmksa->pmk_len;
19319 } else
19320 hddLog(VOS_TRACE_LEVEL_INFO, "pmk len is %zu", pmksa->pmk_len);
19321}
19322#else
19323/*
19324 * wlan_hdd_is_pmksa_valid: API to validate pmksa
19325 * @pmksa: pointer to cfg80211_pmksa structure
19326 *
19327 * Return: True if valid else false
19328 */
19329static inline bool wlan_hdd_is_pmksa_valid(struct cfg80211_pmksa *pmksa)
19330{
19331 if (!pmksa->bssid) {
19332 hddLog(LOGE,FL("both bssid is NULL %p"), pmksa->bssid);
19333 return false;
19334 }
19335 return true;
19336}
19337
19338/*
19339 * hdd_update_pmksa_info: API to update tPmkidCacheInfo from cfg80211_pmksa
19340 * @pmk_cache: pmksa from supplicant
19341 * @pmk_cache: pmk needs to be updated
19342 *
19343 * Return: None
19344 */
19345static void hdd_update_pmksa_info(tPmkidCacheInfo *pmk_cache,
19346 struct cfg80211_pmksa *pmksa, bool is_delete)
19347{
19348 hddLog(VOS_TRACE_LEVEL_INFO,"set PMKSA for " MAC_ADDRESS_STR,
19349 MAC_ADDR_ARRAY(pmksa->bssid));
19350 vos_mem_copy(pmk_cache->BSSID,
19351 pmksa->bssid, VOS_MAC_ADDR_SIZE);
19352
19353 if (is_delete)
19354 return;
19355
19356 vos_mem_copy(pmk_cache->PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
19357}
19358#endif
19359
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019360#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070019361
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019362static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070019363 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019364{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019365 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19366 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019367 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019368 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019369 hdd_context_t *pHddCtx;
Abhinav Kumar8c122592019-08-07 15:43:20 +053019370 tPmkidCacheInfo pmk_cache;
Jeff Johnsone7245742012-09-05 17:12:55 -070019371
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019372 ENTER();
19373
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019374 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019375 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019376 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019377 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019378 return -EINVAL;
19379 }
19380
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019381 if (!pmksa) {
19382 hddLog(LOGE, FL("pmksa is NULL"));
19383 return -EINVAL;
19384 }
19385
Abhinav Kumar8c122592019-08-07 15:43:20 +053019386 if (!pmksa->pmkid) {
19387 hddLog(LOGE, FL("pmksa->pmkid(%p) is NULL"), pmksa->pmkid);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019388 return -EINVAL;
19389 }
19390
Abhinav Kumar8c122592019-08-07 15:43:20 +053019391 if (!wlan_hdd_is_pmksa_valid(pmksa))
19392 return -EINVAL;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019393
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019394 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19395 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019396 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019397 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019398 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019399 }
19400
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019401 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019402 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19403
Abhinav Kumar8c122592019-08-07 15:43:20 +053019404 vos_mem_zero(&pmk_cache, sizeof(pmk_cache));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019405
Abhinav Kumar8c122592019-08-07 15:43:20 +053019406 hdd_update_pmksa_info(&pmk_cache, pmksa, false);
19407
19408
19409 /* Add to the PMKSA ID Cache in CSR
19410 * PMKSA cache will be having following
19411 * 1. pmkid id
19412 * 2. pmk 15733
19413 * 3. bssid or cache identifier
19414 */
19415 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
19416 &pmk_cache, 1, FALSE);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019417
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019418 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19419 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
19420 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019421
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019422 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019423 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019424}
19425
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019426static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
19427 struct cfg80211_pmksa *pmksa)
19428{
19429 int ret;
19430
19431 vos_ssr_protect(__func__);
19432 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
19433 vos_ssr_unprotect(__func__);
19434
19435 return ret;
19436}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019437
Wilson Yang6507c4e2013-10-01 20:11:19 -070019438
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019439static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070019440 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019441{
Wilson Yang6507c4e2013-10-01 20:11:19 -070019442 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19443 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019444 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080019445 int status = 0;
Abhinav Kumar8c122592019-08-07 15:43:20 +053019446 tPmkidCacheInfo pmk_cache;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019447
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019448 ENTER();
19449
Wilson Yang6507c4e2013-10-01 20:11:19 -070019450 /* Validate pAdapter */
19451 if (NULL == pAdapter)
19452 {
19453 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
19454 return -EINVAL;
19455 }
19456
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019457 if (!pmksa) {
19458 hddLog(LOGE, FL("pmksa is NULL"));
19459 return -EINVAL;
19460 }
19461
Abhinav Kumar8c122592019-08-07 15:43:20 +053019462 if (!wlan_hdd_is_pmksa_valid(pmksa))
19463 return -EINVAL;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019464
Kiet Lam98c46a12014-10-31 15:34:57 -070019465
Wilson Yang6507c4e2013-10-01 20:11:19 -070019466 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19467 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070019468 if (0 != status)
19469 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070019470 return status;
19471 }
19472
19473 /*Retrieve halHandle*/
19474 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19475
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019476 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19477 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
19478 pAdapter->sessionId, 0));
Abhinav Kumar8c122592019-08-07 15:43:20 +053019479
19480 vos_mem_zero(&pmk_cache, sizeof(pmk_cache));
19481
19482 hdd_update_pmksa_info(&pmk_cache, pmksa, true);
19483
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019484 /* Delete the PMKID CSR cache */
19485 if (eHAL_STATUS_SUCCESS !=
19486 sme_RoamDelPMKIDfromCache(halHandle,
Abhinav Kumar8c122592019-08-07 15:43:20 +053019487 pAdapter->sessionId, &pmk_cache, FALSE)) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019488 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
19489 MAC_ADDR_ARRAY(pmksa->bssid));
19490 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019491 }
19492
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019493 EXIT();
19494 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019495}
19496
Wilson Yang6507c4e2013-10-01 20:11:19 -070019497
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019498static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
19499 struct cfg80211_pmksa *pmksa)
19500{
19501 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019502
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019503 vos_ssr_protect(__func__);
19504 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
19505 vos_ssr_unprotect(__func__);
19506
19507 return ret;
19508
19509}
19510
19511static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019512{
Wilson Yang6507c4e2013-10-01 20:11:19 -070019513 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19514 tHalHandle halHandle;
19515 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080019516 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019517
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019518 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070019519
19520 /* Validate pAdapter */
19521 if (NULL == pAdapter)
19522 {
19523 hddLog(VOS_TRACE_LEVEL_ERROR,
19524 "%s: Invalid Adapter" ,__func__);
19525 return -EINVAL;
19526 }
19527
19528 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19529 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070019530 if (0 != status)
19531 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070019532 return status;
19533 }
19534
19535 /*Retrieve halHandle*/
19536 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19537
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019538 /* Flush the PMKID cache in CSR */
19539 if (eHAL_STATUS_SUCCESS !=
19540 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
19541 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
19542 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019543 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019544 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080019545 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019546}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019547
19548static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
19549{
19550 int ret;
19551
19552 vos_ssr_protect(__func__);
19553 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
19554 vos_ssr_unprotect(__func__);
19555
19556 return ret;
19557}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019558#endif
19559
Abhinav Kumar118efd02019-08-07 16:41:07 +053019560#if defined(WLAN_FEATURE_SAE) && \
19561 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
19562/**
19563 * __wlan_hdd_cfg80211_external_auth() - Handle external auth
19564 * @wiphy: Pointer to wireless phy
19565 * @dev: net device
19566 * @params: Pointer to external auth params
19567 *
19568 * Return: 0 on success, negative errno on failure
19569 */
19570static int
19571__wlan_hdd_cfg80211_external_auth(struct wiphy *wiphy, struct net_device *dev,
19572 struct cfg80211_external_auth_params *params)
19573{
19574 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
19575 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
19576 int ret;
19577
19578 if (hdd_get_conparam() == VOS_FTM_MODE) {
19579 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Command not allowed in FTM mode"));
19580 return -EPERM;
19581 }
19582
19583 ret = wlan_hdd_validate_context(hdd_ctx);
19584 if (ret)
19585 return ret;
19586
19587 hddLog(VOS_TRACE_LEVEL_DEBUG, FL("external_auth status: %d"),
19588 params->status);
19589
19590 sme_handle_sae_msg(hdd_ctx->hHal, adapter->sessionId, params->status);
19591
19592 return ret;
19593}
19594
19595/**
19596 * wlan_hdd_cfg80211_external_auth() - Handle external auth
19597 * @wiphy: Pointer to wireless phy
19598 * @dev: net device
19599 * @params: Pointer to external auth params
19600 *
19601 * Return: 0 on success, negative errno on failure
19602 */
19603static int
19604wlan_hdd_cfg80211_external_auth(struct wiphy *wiphy,
19605 struct net_device *dev,
19606 struct cfg80211_external_auth_params *params)
19607{
19608 int ret;
19609
19610 vos_ssr_protect(__func__);
19611 ret = __wlan_hdd_cfg80211_external_auth(wiphy, dev, params);
19612 vos_ssr_unprotect(__func__);
19613
19614 return ret;
19615}
19616#endif
19617
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019618#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019619static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
19620 struct net_device *dev,
19621 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019622{
19623 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19624 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019625 hdd_context_t *pHddCtx;
19626 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019627
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019628 ENTER();
19629
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019630 if (NULL == pAdapter)
19631 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080019632 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019633 return -ENODEV;
19634 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019635 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19636 ret = wlan_hdd_validate_context(pHddCtx);
19637 if (0 != ret)
19638 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019639 return ret;
19640 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019641 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019642 if (NULL == pHddStaCtx)
19643 {
19644 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
19645 return -EINVAL;
19646 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019647
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019648 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19649 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
19650 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019651 // Added for debug on reception of Re-assoc Req.
19652 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
19653 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080019654 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019655 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080019656 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019657 }
19658
19659#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Abhinav Kumar36177e12018-10-30 11:55:48 +053019660 hddLog(LOG1, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019661 ftie->ie_len);
19662#endif
19663
19664 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053019665 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
19666 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019667 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019668
19669 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019670 return 0;
19671}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019672
19673static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
19674 struct net_device *dev,
19675 struct cfg80211_update_ft_ies_params *ftie)
19676{
19677 int ret;
19678
19679 vos_ssr_protect(__func__);
19680 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
19681 vos_ssr_unprotect(__func__);
19682
19683 return ret;
19684}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019685#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019686
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019687#ifdef FEATURE_WLAN_SCAN_PNO
19688
19689void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
19690 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
19691{
19692 int ret;
19693 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
19694 hdd_context_t *pHddCtx;
19695
Nirav Shah80830bf2013-12-31 16:35:12 +053019696 ENTER();
19697
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019698 if (NULL == pAdapter)
19699 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053019700 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019701 "%s: HDD adapter is Null", __func__);
19702 return ;
19703 }
19704
19705 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19706 if (NULL == pHddCtx)
19707 {
19708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19709 "%s: HDD context is Null!!!", __func__);
19710 return ;
19711 }
19712
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019713 spin_lock(&pHddCtx->schedScan_lock);
19714 if (TRUE == pHddCtx->isWiphySuspended)
19715 {
19716 pHddCtx->isSchedScanUpdatePending = TRUE;
19717 spin_unlock(&pHddCtx->schedScan_lock);
19718 hddLog(VOS_TRACE_LEVEL_INFO,
19719 "%s: Update cfg80211 scan database after it resume", __func__);
19720 return ;
19721 }
19722 spin_unlock(&pHddCtx->schedScan_lock);
19723
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019724 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
19725
19726 if (0 > ret)
19727 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053019728 else
19729 {
19730 /* Acquire wakelock to handle the case where APP's tries to suspend
19731 * immediatly after the driver gets connect request(i.e after pno)
19732 * from supplicant, this result in app's is suspending and not able
19733 * to process the connect request to AP */
19734 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
19735 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019736 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19738 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019739}
19740
19741/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019742 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053019743 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019744 */
19745static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
19746{
19747 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
19748 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019749 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019750 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19751 int status = 0;
Agrawal Ashishcff31692016-12-16 17:17:50 +053019752
19753 if (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
19754 {
19755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19756 "%s: PNO is allowed only in STA interface", __func__);
19757 return eHAL_STATUS_FAILURE;
19758 }
19759
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019760 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
19761
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053019762 /* The current firmware design does not allow PNO during any
Agrawal Ashishcff31692016-12-16 17:17:50 +053019763 * active sessions. PNO is allowed only in case when sap session
19764 * is present and sapo auth offload feature enabled in firmare.
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053019765 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019766 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
19767 {
19768 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019769 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019770
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019771 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
19772 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
19773 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
19774 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
Agrawal Ashishcff31692016-12-16 17:17:50 +053019775 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode &&
19776 !pHddCtx->cfg_ini->enable_sap_auth_offload)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053019777 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019778 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019779 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019780 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019781 }
19782 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
19783 pAdapterNode = pNext;
19784 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019785 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019786}
19787
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019788void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
19789{
19790 hdd_adapter_t *pAdapter = callbackContext;
19791 hdd_context_t *pHddCtx;
19792
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019793 ENTER();
19794
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019795 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
19796 {
19797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19798 FL("Invalid adapter or adapter has invalid magic"));
19799 return;
19800 }
19801
19802 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19803 if (0 != wlan_hdd_validate_context(pHddCtx))
19804 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019805 return;
19806 }
19807
c_hpothub53c45d2014-08-18 16:53:14 +053019808 if (VOS_STATUS_SUCCESS != status)
19809 {
19810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019811 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053019812 pHddCtx->isPnoEnable = FALSE;
19813 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019814
19815 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
19816 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019817 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019818}
19819
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019820#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) || \
19821 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
19822/**
19823 * hdd_config_sched_scan_plan() - configures the sched scan plans
19824 * from the framework.
19825 * @pno_req: pointer to PNO scan request
19826 * @request: pointer to scan request from framework
19827 *
19828 * Return: None
19829 */
19830static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
19831 struct cfg80211_sched_scan_request *request,
19832 hdd_context_t *hdd_ctx)
19833{
19834 v_U32_t i = 0;
19835
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019836 pno_req->scanTimers.ucScanTimersCount = request->n_scan_plans;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019837 for (i = 0; i < request->n_scan_plans; i++)
19838 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019839 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
19840 request->scan_plans[i].iterations;
19841 pno_req->scanTimers.aTimerValues[i].uTimerValue =
19842 request->scan_plans[i].interval;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019843 }
19844}
19845#else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019846static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019847 struct cfg80211_sched_scan_request *request,
19848 hdd_context_t *hdd_ctx)
19849{
19850 v_U32_t i, temp_int;
19851 /* Driver gets only one time interval which is hardcoded in
19852 * supplicant for 10000ms. Taking power consumption into account 6
19853 * timers will be used, Timervalue is increased exponentially
19854 * i.e 10,20,40, 80,160,320 secs. And number of scan cycle for each
19855 * timer is configurable through INI param gPNOScanTimerRepeatValue.
19856 * If it is set to 0 only one timer will be used and PNO scan cycle
19857 * will be repeated after each interval specified by supplicant
19858 * till PNO is disabled.
19859 */
19860 if (0 == hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue)
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019861 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019862 HDD_PNO_SCAN_TIMERS_SET_ONE;
19863 else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019864 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019865 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
19866
19867 temp_int = (request->interval)/1000;
19868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19869 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
19870 temp_int, hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue);
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019871 for ( i = 0; i < pno_req->scanTimers.ucScanTimersCount; i++)
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019872 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019873 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019874 hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue;
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019875 pno_req->scanTimers.aTimerValues[i].uTimerValue = temp_int;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019876 temp_int *= 2;
19877 }
19878 //Repeat last timer until pno disabled.
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019879 pno_req->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019880}
19881#endif
19882
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019883/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053019884 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
19885 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019886 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053019887static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019888 struct net_device *dev, struct cfg80211_sched_scan_request *request)
19889{
19890 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019891 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019892 hdd_context_t *pHddCtx;
19893 tHalHandle hHal;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019894 v_U32_t i, indx, num_ch, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053019895 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
19896 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019897 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
19898 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019899 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053019900 hdd_config_t *pConfig = NULL;
19901 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019902
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019903 ENTER();
19904
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019905 if (NULL == pAdapter)
19906 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019908 "%s: HDD adapter is Null", __func__);
19909 return -ENODEV;
19910 }
19911
19912 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019913 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019914
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019915 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019916 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019917 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019918 }
19919
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053019920 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019921 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
19922 if (NULL == hHal)
19923 {
19924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19925 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019926 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019927 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019928 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19929 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
19930 pAdapter->sessionId, pAdapter->device_mode));
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053019931 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053019932 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053019933 {
19934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19935 "%s: aborting the existing scan is unsuccessfull", __func__);
19936 return -EBUSY;
19937 }
19938
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019939 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019940 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053019941 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019942 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019943 return -EBUSY;
19944 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019945
c_hpothu37f21312014-04-09 21:49:54 +053019946 if (TRUE == pHddCtx->isPnoEnable)
19947 {
19948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
19949 FL("already PNO is enabled"));
19950 return -EBUSY;
19951 }
c_hpothu225aa7c2014-10-22 17:45:13 +053019952
19953 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
19954 {
19955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19956 "%s: abort ROC failed ", __func__);
19957 return -EBUSY;
19958 }
19959
c_hpothu37f21312014-04-09 21:49:54 +053019960 pHddCtx->isPnoEnable = TRUE;
19961
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019962 pnoRequest.enable = 1; /*Enable PNO */
19963 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019964
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019965 if (( !pnoRequest.ucNetworksCount ) ||
19966 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019967 {
19968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053019969 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019970 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053019971 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019972 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019973 goto error;
19974 }
19975
19976 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
19977 {
19978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053019979 "%s: Incorrect number of channels %d",
19980 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019981 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019982 goto error;
19983 }
19984
19985 /* Framework provides one set of channels(all)
19986 * common for all saved profile */
19987 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
19988 channels_allowed, &num_channels_allowed))
19989 {
19990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19991 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019992 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019993 goto error;
19994 }
19995 /* Checking each channel against allowed channel list */
19996 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053019997 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019998 {
Nirav Shah80830bf2013-12-31 16:35:12 +053019999 char chList [(request->n_channels*5)+1];
20000 int len;
20001 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020002 {
Nirav Shah80830bf2013-12-31 16:35:12 +053020003 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020004 {
Nirav Shah80830bf2013-12-31 16:35:12 +053020005 if (request->channels[i]->hw_value == channels_allowed[indx])
20006 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053020007 if ((!pConfig->enableDFSPnoChnlScan) &&
20008 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
20009 {
20010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20011 "%s : Dropping DFS channel : %d",
20012 __func__,channels_allowed[indx]);
20013 num_ignore_dfs_ch++;
20014 break;
20015 }
20016
Nirav Shah80830bf2013-12-31 16:35:12 +053020017 valid_ch[num_ch++] = request->channels[i]->hw_value;
20018 len += snprintf(chList+len, 5, "%d ",
20019 request->channels[i]->hw_value);
20020 break ;
20021 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020022 }
20023 }
Nirav Shah80830bf2013-12-31 16:35:12 +053020024 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020025
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053020026 /*If all channels are DFS and dropped, then ignore the PNO request*/
20027 if (num_ignore_dfs_ch == request->n_channels)
20028 {
20029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20030 "%s : All requested channels are DFS channels", __func__);
20031 ret = -EINVAL;
20032 goto error;
20033 }
20034 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020035
20036 pnoRequest.aNetworks =
20037 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
20038 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020039 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020040 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
20041 FL("failed to allocate memory aNetworks %u"),
20042 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
20043 goto error;
20044 }
20045 vos_mem_zero(pnoRequest.aNetworks,
20046 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
20047
20048 /* Filling per profile params */
20049 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
20050 {
20051 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020052 request->match_sets[i].ssid.ssid_len;
20053
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020054 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
20055 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020056 {
20057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053020058 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020059 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020060 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020061 goto error;
20062 }
20063
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020064 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020065 request->match_sets[i].ssid.ssid,
20066 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053020067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20068 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020069 i, pnoRequest.aNetworks[i].ssId.ssId);
20070 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
20071 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
20072 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020073
20074 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020075 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
20076 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020077
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020078 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020079 }
20080
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053020081 for (i = 0; i < request->n_ssids; i++)
20082 {
20083 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020084 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053020085 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020086 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053020087 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020088 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053020089 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020090 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053020091 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020092 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053020093 break;
20094 }
20095 j++;
20096 }
20097 }
20098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20099 "Number of hidden networks being Configured = %d",
20100 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053020101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080020102 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020103
20104 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
20105 if (pnoRequest.p24GProbeTemplate == NULL)
20106 {
20107 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
20108 FL("failed to allocate memory p24GProbeTemplate %u"),
20109 SIR_PNO_MAX_PB_REQ_SIZE);
20110 goto error;
20111 }
20112
20113 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
20114 if (pnoRequest.p5GProbeTemplate == NULL)
20115 {
20116 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
20117 FL("failed to allocate memory p5GProbeTemplate %u"),
20118 SIR_PNO_MAX_PB_REQ_SIZE);
20119 goto error;
20120 }
20121
20122 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
20123 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
20124
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053020125 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
20126 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053020127 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020128 pnoRequest.us24GProbeTemplateLen = request->ie_len;
20129 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
20130 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053020131
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020132 pnoRequest.us5GProbeTemplateLen = request->ie_len;
20133 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
20134 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053020135 }
20136
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053020137 hdd_config_sched_scan_plan(&pnoRequest, request, pHddCtx);
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053020138
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020139 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020140
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020141 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020142 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
20143 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020144 pAdapter->pno_req_status = 0;
20145
Nirav Shah80830bf2013-12-31 16:35:12 +053020146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20147 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020148 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
20149 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053020150
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020151 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020152 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020153 hdd_cfg80211_sched_scan_done_callback, pAdapter);
20154 if (eHAL_STATUS_SUCCESS != status)
20155 {
20156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053020157 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020158 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020159 goto error;
20160 }
20161
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020162 ret = wait_for_completion_timeout(
20163 &pAdapter->pno_comp_var,
20164 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
20165 if (0 >= ret)
20166 {
20167 // Did not receive the response for PNO enable in time.
20168 // Assuming the PNO enable was success.
20169 // Returning error from here, because we timeout, results
20170 // in side effect of Wifi (Wifi Setting) not to work.
20171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20172 FL("Timed out waiting for PNO to be Enabled"));
20173 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020174 }
20175
20176 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053020177 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020178
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020179error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20181 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053020182 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020183 if (pnoRequest.aNetworks)
20184 vos_mem_free(pnoRequest.aNetworks);
20185 if (pnoRequest.p24GProbeTemplate)
20186 vos_mem_free(pnoRequest.p24GProbeTemplate);
20187 if (pnoRequest.p5GProbeTemplate)
20188 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020189
20190 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020191 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020192}
20193
20194/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053020195 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
20196 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020197 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053020198static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
20199 struct net_device *dev, struct cfg80211_sched_scan_request *request)
20200{
20201 int ret;
20202
20203 vos_ssr_protect(__func__);
20204 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
20205 vos_ssr_unprotect(__func__);
20206
20207 return ret;
20208}
20209
20210/*
20211 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
20212 * Function to disable PNO
20213 */
20214static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020215 struct net_device *dev)
20216{
20217 eHalStatus status = eHAL_STATUS_FAILURE;
20218 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
20219 hdd_context_t *pHddCtx;
20220 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020221 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020222 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020223
20224 ENTER();
20225
20226 if (NULL == pAdapter)
20227 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053020228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020229 "%s: HDD adapter is Null", __func__);
20230 return -ENODEV;
20231 }
20232
20233 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020234
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020235 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020236 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020237 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020238 "%s: HDD context is Null", __func__);
20239 return -ENODEV;
20240 }
20241
20242 /* The return 0 is intentional when isLogpInProgress and
20243 * isLoadUnloadInProgress. We did observe a crash due to a return of
20244 * failure in sched_scan_stop , especially for a case where the unload
20245 * of the happens at the same time. The function __cfg80211_stop_sched_scan
20246 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
20247 * success. If it returns a failure , then its next invocation due to the
20248 * clean up of the second interface will have the dev pointer corresponding
20249 * to the first one leading to a crash.
20250 */
20251 if (pHddCtx->isLogpInProgress)
20252 {
20253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20254 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053020255 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020256 return ret;
20257 }
20258
Mihir Shete18156292014-03-11 15:38:30 +053020259 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020260 {
20261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20262 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
20263 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020264 }
20265
20266 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
20267 if (NULL == hHal)
20268 {
20269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20270 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020271 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020272 }
20273
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020274 pnoRequest.enable = 0; /* Disable PNO */
20275 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020276
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053020277 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20278 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
20279 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053020280
20281 INIT_COMPLETION(pAdapter->pno_comp_var);
20282 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
20283 pnoRequest.callbackContext = pAdapter;
20284 pAdapter->pno_req_status = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053020285 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020286 pAdapter->sessionId,
20287 NULL, pAdapter);
20288 if (eHAL_STATUS_SUCCESS != status)
20289 {
20290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20291 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020292 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020293 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020294 }
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053020295 ret = wait_for_completion_timeout(
20296 &pAdapter->pno_comp_var,
20297 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
20298 if (0 >= ret)
20299 {
20300 // Did not receive the response for PNO disable in time.
20301 // Assuming the PNO disable was success.
20302 // Returning error from here, because we timeout, results
20303 // in side effect of Wifi (Wifi Setting) not to work.
Anurag Chouhan96b41cb2016-09-28 18:54:47 +053020304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053020305 FL("Timed out waiting for PNO to be disabled"));
20306 ret = 0;
20307 }
20308
20309 ret = pAdapter->pno_req_status;
20310 pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020311
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020312error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020313 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053020314 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020315
20316 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053020317 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020318}
20319
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053020320/*
20321 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
20322 * NL interface to disable PNO
20323 */
20324static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
20325 struct net_device *dev)
20326{
20327 int ret;
20328
20329 vos_ssr_protect(__func__);
20330 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
20331 vos_ssr_unprotect(__func__);
20332
20333 return ret;
20334}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020335#endif /*FEATURE_WLAN_SCAN_PNO*/
20336
20337
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020338#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053020339#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020340static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20341 struct net_device *dev,
20342 u8 *peer, u8 action_code,
20343 u8 dialog_token,
20344 u16 status_code, u32 peer_capability,
20345 const u8 *buf, size_t len)
20346#else /* TDLS_MGMT_VERSION2 */
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053020347#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || \
20348 defined(WITH_BACKPORTS)
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020349static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20350 struct net_device *dev,
20351 const u8 *peer, u8 action_code,
20352 u8 dialog_token, u16 status_code,
20353 u32 peer_capability, bool initiator,
20354 const u8 *buf, size_t len)
20355#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
20356static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20357 struct net_device *dev,
20358 const u8 *peer, u8 action_code,
20359 u8 dialog_token, u16 status_code,
20360 u32 peer_capability, const u8 *buf,
20361 size_t len)
20362#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
20363static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20364 struct net_device *dev,
20365 u8 *peer, u8 action_code,
20366 u8 dialog_token,
20367 u16 status_code, u32 peer_capability,
20368 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053020369#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020370static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20371 struct net_device *dev,
20372 u8 *peer, u8 action_code,
20373 u8 dialog_token,
20374 u16 status_code, const u8 *buf,
20375 size_t len)
20376#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053020377#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020378{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020379 hdd_adapter_t *pAdapter;
20380 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020381 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070020382 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080020383 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070020384 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020385 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053020386 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020387#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053020388 u32 peer_capability = 0;
20389#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053020390 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020391 hdd_station_ctx_t *pHddStaCtx = NULL;
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020392 tdlsCtx_t *pHddTdlsCtx;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053020393
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020394 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
20395 if (NULL == pAdapter)
20396 {
20397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20398 "%s: Adapter is NULL",__func__);
20399 return -EINVAL;
20400 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053020401 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20402 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
20403 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020404
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020405 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020406 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020407 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053020408 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020409 "Invalid arguments");
20410 return -EINVAL;
20411 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020412
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080020413 if (pHddCtx->isLogpInProgress)
20414 {
20415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20416 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053020417 wlan_hdd_tdls_set_link_status(pAdapter,
20418 peer,
20419 eTDLS_LINK_IDLE,
20420 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080020421 return -EBUSY;
20422 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020423
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020424 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
20425 {
20426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20427 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
20428 return -EAGAIN;
20429 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020430
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020431 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
20432 if (!pHddTdlsCtx) {
20433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20434 "%s: pHddTdlsCtx not valid.", __func__);
Hanumanth Reddy Pothula36dfa522018-03-12 16:42:08 +053020435 return -EINVAL;
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020436 }
20437
Hoonki Lee27511902013-03-14 18:19:06 -070020438 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020439 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053020440 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070020441 "%s: TDLS mode is disabled OR not enabled in FW."
20442 MAC_ADDRESS_STR " action %d declined.",
20443 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020444 return -ENOTSUPP;
20445 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080020446
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020447 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
20448
20449 if( NULL == pHddStaCtx )
20450 {
20451 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20452 "%s: HDD station context NULL ",__func__);
20453 return -EINVAL;
20454 }
20455
20456 /* STA should be connected and authenticated
20457 * before sending any TDLS frames
20458 */
20459 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
20460 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
20461 {
20462 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20463 "STA is not connected or unauthenticated. "
20464 "connState %u, uIsAuthenticated %u",
20465 pHddStaCtx->conn_info.connState,
20466 pHddStaCtx->conn_info.uIsAuthenticated);
20467 return -EAGAIN;
20468 }
20469
Hoonki Lee27511902013-03-14 18:19:06 -070020470 /* other than teardown frame, other mgmt frames are not sent if disabled */
20471 if (SIR_MAC_TDLS_TEARDOWN != action_code)
20472 {
20473 /* if tdls_mode is disabled to respond to peer's request */
20474 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
20475 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053020476 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070020477 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070020478 " TDLS mode is disabled. action %d declined.",
20479 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070020480
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020481 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070020482 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053020483
20484 if (vos_max_concurrent_connections_reached())
20485 {
20486 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
20487 return -EINVAL;
20488 }
Hoonki Lee27511902013-03-14 18:19:06 -070020489 }
20490
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020491 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
20492 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053020493 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020494 {
20495 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020496 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070020497 " TDLS setup is ongoing. action %d declined.",
20498 __func__, MAC_ADDR_ARRAY(peer), action_code);
20499 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020500 }
20501 }
20502
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020503 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
20504 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080020505 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053020506 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
20507 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080020508 {
20509 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
20510 we return error code at 'add_station()'. Hence we have this
20511 check again in addtion to add_station().
20512 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020513 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080020514 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020515 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20516 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053020517 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
20518 __func__, MAC_ADDR_ARRAY(peer), action_code,
20519 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053020520 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080020521 }
20522 else
20523 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020524 /* maximum reached. tweak to send error code to peer and return
20525 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080020526 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020527 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20528 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053020529 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
20530 __func__, MAC_ADDR_ARRAY(peer), status_code,
20531 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070020532 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020533 /* fall through to send setup resp with failure status
20534 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080020535 }
20536 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020537 else
20538 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020539 mutex_lock(&pHddCtx->tdls_lock);
20540 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070020541 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020542 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020543 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020544 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070020545 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
20546 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020547 return -EPERM;
20548 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020549 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020550 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080020551 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020552
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053020553 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053020554 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020555 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
20556 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020557
Hoonki Leea34dd892013-02-05 22:56:02 -080020558 /*Except teardown responder will not be used so just make 0*/
20559 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020560 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080020561 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070020562
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020563 mutex_lock(&pHddCtx->tdls_lock);
20564 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070020565
20566 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
20567 responder = pTdlsPeer->is_responder;
20568 else
Hoonki Leea34dd892013-02-05 22:56:02 -080020569 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070020570 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053020571 "%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 -070020572 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
20573 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020574 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070020575 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080020576 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020577 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020578 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020579
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053020580 /* Discard TDLS setup if peer is removed by user app */
20581 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
20582 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
20583 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
20584 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
20585
20586 mutex_lock(&pHddCtx->tdls_lock);
20587 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
20588 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
20589 mutex_unlock(&pHddCtx->tdls_lock);
20590 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
20591 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
20592 MAC_ADDR_ARRAY(peer), action_code);
20593 return -EINVAL;
20594 }
20595 mutex_unlock(&pHddCtx->tdls_lock);
20596 }
20597
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053020598 /* For explicit trigger of DIS_REQ come out of BMPS for
20599 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070020600 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Deepthi Gowrif78f1f72016-03-21 13:13:28 +053020601 (SIR_MAC_TDLS_SETUP_CNF== action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053020602 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
20603 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070020604 {
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020605 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053020606 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020607 "%s: Sending frame action_code %u.Disable BMPS", __func__,
20608 action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020609 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
20610 if (status != VOS_STATUS_SUCCESS) {
20611 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020612 } else {
20613 pHddTdlsCtx->is_tdls_disabled_bmps = true;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020614 }
Hoonki Lee14621352013-04-16 17:51:19 -070020615 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020616 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020617 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020618 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
20619 }
20620 }
Hoonki Lee14621352013-04-16 17:51:19 -070020621 }
20622
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020623 /* make sure doesn't call send_mgmt() while it is pending */
20624 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
20625 {
20626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080020627 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020628 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020629 ret = -EBUSY;
20630 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020631 }
20632
20633 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020634 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
20635
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020636 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
20637 pAdapter->sessionId, peer, action_code, dialog_token,
20638 status_code, peer_capability, (tANI_U8 *)buf, len,
20639 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020640
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020641 if (VOS_STATUS_SUCCESS != status)
20642 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20644 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020645 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020646 ret = -EINVAL;
20647 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020648 }
20649
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20651 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
20652 WAIT_TIME_TDLS_MGMT);
20653
Hoonki Leed37cbb32013-04-20 00:31:14 -070020654 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
20655 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
20656
20657 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020658 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070020659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070020660 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070020661 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020662 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080020663
20664 if (pHddCtx->isLogpInProgress)
20665 {
20666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20667 "%s: LOGP in Progress. Ignore!!!", __func__);
20668 return -EAGAIN;
20669 }
Abhishek Singh837adf22015-10-01 17:37:37 +053020670 if (rc <= 0)
20671 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
20672 WLAN_LOG_INDICATOR_HOST_DRIVER,
20673 WLAN_LOG_REASON_HDD_TIME_OUT,
20674 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080020675
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020676 ret = -EINVAL;
20677 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020678 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020679 else
20680 {
20681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20682 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
20683 __func__, rc, pAdapter->mgmtTxCompletionStatus);
20684 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020685
Gopichand Nakkala05922802013-03-14 12:23:19 -070020686 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070020687 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020688 ret = max_sta_failed;
20689 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070020690 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020691
Hoonki Leea34dd892013-02-05 22:56:02 -080020692 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
20693 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020694 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020695 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
20696 }
Hoonki Leea34dd892013-02-05 22:56:02 -080020697 }
20698 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
20699 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020700 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020701 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
20702 }
Hoonki Leea34dd892013-02-05 22:56:02 -080020703 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020704
20705 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020706
20707tx_failed:
20708 /* add_station will be called before sending TDLS_SETUP_REQ and
20709 * TDLS_SETUP_RSP and as part of add_station driver will enable
20710 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
20711 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
20712 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
20713 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
20714 */
20715
20716 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
20717 (SIR_MAC_TDLS_SETUP_RSP == action_code))
20718 wlan_hdd_tdls_check_bmps(pAdapter);
20719 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020720}
20721
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020722#if TDLS_MGMT_VERSION2
20723static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
20724 u8 *peer, u8 action_code, u8 dialog_token,
20725 u16 status_code, u32 peer_capability,
20726 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020727#else /* TDLS_MGMT_VERSION2 */
20728#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
20729static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20730 struct net_device *dev,
20731 const u8 *peer, u8 action_code,
20732 u8 dialog_token, u16 status_code,
20733 u32 peer_capability, bool initiator,
20734 const u8 *buf, size_t len)
20735#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
20736static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20737 struct net_device *dev,
20738 const u8 *peer, u8 action_code,
20739 u8 dialog_token, u16 status_code,
20740 u32 peer_capability, const u8 *buf,
20741 size_t len)
20742#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
20743static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20744 struct net_device *dev,
20745 u8 *peer, u8 action_code,
20746 u8 dialog_token,
20747 u16 status_code, u32 peer_capability,
20748 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020749#else
20750static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
20751 u8 *peer, u8 action_code, u8 dialog_token,
20752 u16 status_code, const u8 *buf, size_t len)
20753#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020754#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020755{
20756 int ret;
20757
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020758 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020759#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020760 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20761 dialog_token, status_code,
20762 peer_capability, buf, len);
20763#else /* TDLS_MGMT_VERSION2 */
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053020764#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || \
20765 defined(WITH_BACKPORTS)
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020766 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20767 dialog_token, status_code,
20768 peer_capability, initiator,
20769 buf, len);
20770#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
20771 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20772 dialog_token, status_code,
20773 peer_capability, buf, len);
20774#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
20775 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20776 dialog_token, status_code,
20777 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020778#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020779 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20780 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020781#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020782#endif
20783 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020784
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020785 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020786}
Atul Mittal115287b2014-07-08 13:26:33 +053020787
20788int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020789#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
20790 const u8 *peer,
20791#else
Atul Mittal115287b2014-07-08 13:26:33 +053020792 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020793#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020794 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053020795 cfg80211_exttdls_callback callback)
20796{
20797
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020798 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053020799 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053020800 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053020801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20802 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
20803 __func__, MAC_ADDR_ARRAY(peer));
20804
20805 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
20806 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
20807
20808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020809 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
20810 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
20811 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053020812 return -ENOTSUPP;
20813 }
20814
20815 /* To cater the requirement of establishing the TDLS link
20816 * irrespective of the data traffic , get an entry of TDLS peer.
20817 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053020818 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020819 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
20820 if (pTdlsPeer == NULL) {
20821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20822 "%s: peer " MAC_ADDRESS_STR " not existing",
20823 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053020824 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020825 return -EINVAL;
20826 }
20827
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053020828 /* check FW TDLS Off Channel capability */
20829 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053020830 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053020831 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020832 {
20833 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
20834 pTdlsPeer->peerParams.global_operating_class =
20835 tdls_peer_params->global_operating_class;
20836 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
20837 pTdlsPeer->peerParams.min_bandwidth_kbps =
20838 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053020839 /* check configured channel is valid, non dfs and
20840 * not current operating channel */
20841 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
20842 tdls_peer_params->channel)) &&
20843 (pHddStaCtx) &&
20844 (tdls_peer_params->channel !=
20845 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020846 {
20847 pTdlsPeer->isOffChannelConfigured = TRUE;
20848 }
20849 else
20850 {
20851 pTdlsPeer->isOffChannelConfigured = FALSE;
20852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20853 "%s: Configured Tdls Off Channel is not valid", __func__);
20854
20855 }
20856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053020857 "%s: tdls_off_channel %d isOffChannelConfigured %d "
20858 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020859 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053020860 pTdlsPeer->isOffChannelConfigured,
20861 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020862 }
20863 else
20864 {
20865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053020866 "%s: TDLS off channel FW capability %d, "
20867 "host capab %d or Invalid TDLS Peer Params", __func__,
20868 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
20869 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020870 }
20871
Atul Mittal115287b2014-07-08 13:26:33 +053020872 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
20873
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020874 mutex_unlock(&pHddCtx->tdls_lock);
20875
Atul Mittal115287b2014-07-08 13:26:33 +053020876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20877 " %s TDLS Add Force Peer Failed",
20878 __func__);
20879 return -EINVAL;
20880 }
20881 /*EXT TDLS*/
20882
20883 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020884 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20886 " %s TDLS set callback Failed",
20887 __func__);
20888 return -EINVAL;
20889 }
20890
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020891 mutex_unlock(&pHddCtx->tdls_lock);
20892
Atul Mittal115287b2014-07-08 13:26:33 +053020893 return(0);
20894
20895}
20896
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020897int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
20898#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
20899 const u8 *peer
20900#else
20901 u8 *peer
20902#endif
20903)
Atul Mittal115287b2014-07-08 13:26:33 +053020904{
20905
20906 hddTdlsPeer_t *pTdlsPeer;
20907 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053020908
Atul Mittal115287b2014-07-08 13:26:33 +053020909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20910 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
20911 __func__, MAC_ADDR_ARRAY(peer));
20912
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053020913 if (0 != wlan_hdd_validate_context(pHddCtx)) {
20914 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
20915 return -EINVAL;
20916 }
20917
Atul Mittal115287b2014-07-08 13:26:33 +053020918 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
20919 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
20920
20921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020922 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
20923 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
20924 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053020925 return -ENOTSUPP;
20926 }
20927
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020928 mutex_lock(&pHddCtx->tdls_lock);
20929 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053020930
20931 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020932 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020933 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053020934 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053020935 __func__, MAC_ADDR_ARRAY(peer));
20936 return -EINVAL;
20937 }
20938 else {
20939 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
20940 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053020941 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL,
20942 pTdlsPeer->peerMac);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020943 /* if channel switch is configured, reset
20944 the channel for this peer */
20945 if (TRUE == pTdlsPeer->isOffChannelConfigured)
20946 {
20947 pTdlsPeer->peerParams.channel = 0;
20948 pTdlsPeer->isOffChannelConfigured = FALSE;
20949 }
Atul Mittal115287b2014-07-08 13:26:33 +053020950 }
20951
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020952 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020953 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020954 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053020955 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020956 }
Atul Mittal115287b2014-07-08 13:26:33 +053020957
20958 /*EXT TDLS*/
20959
20960 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020961 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20963 " %s TDLS set callback Failed",
20964 __func__);
20965 return -EINVAL;
20966 }
Atul Mittal115287b2014-07-08 13:26:33 +053020967
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020968 mutex_unlock(&pHddCtx->tdls_lock);
20969
20970 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053020971}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053020972static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020973#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
20974 const u8 *peer,
20975#else
20976 u8 *peer,
20977#endif
20978 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020979{
20980 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
20981 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053020982 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020983 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053020984
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020985 ENTER();
20986
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053020987 if (!pAdapter) {
20988 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
20989 return -EINVAL;
20990 }
20991
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053020992 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20993 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
20994 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053020995 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020996 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020997 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070020998 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020999 return -EINVAL;
21000 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080021001
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021002 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021003 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080021004 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021005 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080021006 }
21007
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021008
21009 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080021010 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021011 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080021012 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021013 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
21014 "Cannot process TDLS commands",
21015 pHddCtx->cfg_ini->fEnableTDLSSupport,
21016 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021017 return -ENOTSUPP;
21018 }
21019
21020 switch (oper) {
21021 case NL80211_TDLS_ENABLE_LINK:
21022 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021023 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053021024 long ret;
Hanumantha Reddy Pothulada389492016-02-11 17:29:27 +053021025 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams = { {0}, 0,
21026 0, 0, 0, 0, 0, 0, {0}, 0, {0} };
Agarwal Ashish16020c42014-12-29 22:01:11 +053021027 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021028 tANI_U16 numCurrTdlsPeers = 0;
21029 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053021030 tANI_U8 suppChannelLen = 0;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021031 tSirMacAddr peerMac;
21032 int channel;
21033 tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021034
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21036 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
21037 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053021038
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021039 mutex_lock(&pHddCtx->tdls_lock);
21040 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053021041 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053021042 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021043 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021044 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
21045 " (oper %d) not exsting. ignored",
21046 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
21047 return -EINVAL;
21048 }
21049
21050 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21051 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
21052 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
21053 "NL80211_TDLS_ENABLE_LINK");
21054
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070021055 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
21056 {
21057 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
21058 MAC_ADDRESS_STR " failed",
21059 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021060 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070021061 return -EINVAL;
21062 }
21063
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053021064 /* before starting tdls connection, set tdls
21065 * off channel established status to default value */
21066 pTdlsPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021067
21068 mutex_unlock(&pHddCtx->tdls_lock);
21069
Deepthi Gowri2d85bbf2016-07-25 15:43:31 +053021070 wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021071 /* TDLS Off Channel, Disable tdls channel switch,
21072 when there are more than one tdls link */
21073 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053021074 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021075 {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021076 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021077 /* get connected peer and send disable tdls off chan */
21078 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021079 if ((connPeer) &&
21080 (connPeer->isOffChannelSupported == TRUE) &&
21081 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021082 {
21083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21084 "%s: More then one peer connected, Disable "
21085 "TDLS channel switch", __func__);
21086
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053021087 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021088 vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr));
21089 channel = connPeer->peerParams.channel;
21090
21091 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053021092
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021093 ret = sme_SendTdlsChanSwitchReq(
21094 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021095 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021096 peerMac,
21097 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021098 TDLS_OFF_CHANNEL_BW_OFFSET,
21099 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021100 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021101 hddLog(VOS_TRACE_LEVEL_ERROR,
21102 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021103 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021104 }
21105 else
21106 {
21107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21108 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021109 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021110 "isOffChannelConfigured %d",
21111 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021112 (connPeer ? (connPeer->isOffChannelSupported)
21113 : -1),
21114 (connPeer ? (connPeer->isOffChannelConfigured)
21115 : -1));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021116 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021117 }
21118 }
21119
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021120 mutex_lock(&pHddCtx->tdls_lock);
21121 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
21122 if ( NULL == pTdlsPeer ) {
21123 mutex_unlock(&pHddCtx->tdls_lock);
21124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21125 "%s: " MAC_ADDRESS_STR
21126 " (oper %d) peer got freed in other context. ignored",
21127 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
21128 return -EINVAL;
21129 }
21130 peer_status = pTdlsPeer->link_status;
21131 mutex_unlock(&pHddCtx->tdls_lock);
21132
21133 if (eTDLS_LINK_CONNECTED != peer_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021134 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053021135 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053021136
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053021137 if (0 != wlan_hdd_tdls_get_link_establish_params(
21138 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021139 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053021140 return -EINVAL;
21141 }
21142 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021143
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021144 ret = sme_SendTdlsLinkEstablishParams(
21145 WLAN_HDD_GET_HAL_CTX(pAdapter),
21146 pAdapter->sessionId, peer,
21147 &tdlsLinkEstablishParams);
21148 if (ret != VOS_STATUS_SUCCESS) {
21149 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
21150 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053021151 /* Send TDLS peer UAPSD capabilities to the firmware and
21152 * register with the TL on after the response for this operation
21153 * is received .
21154 */
21155 ret = wait_for_completion_interruptible_timeout(
21156 &pAdapter->tdls_link_establish_req_comp,
21157 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Masti, Narayanraddie1892a52015-12-15 15:01:01 +053021158
21159 mutex_lock(&pHddCtx->tdls_lock);
21160 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
21161 if ( NULL == pTdlsPeer ) {
21162 mutex_unlock(&pHddCtx->tdls_lock);
21163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21164 "%s %d: " MAC_ADDRESS_STR
21165 " (oper %d) peer got freed in other context. ignored",
21166 __func__, __LINE__, MAC_ADDR_ARRAY(peer),
21167 (int)oper);
21168 return -EINVAL;
21169 }
21170 peer_status = pTdlsPeer->link_status;
21171 mutex_unlock(&pHddCtx->tdls_lock);
21172
21173 if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING))
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053021174 {
21175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021176 FL("Link Establish Request Failed Status %ld"),
21177 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053021178 return -EINVAL;
21179 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021180 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053021181
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021182 mutex_lock(&pHddCtx->tdls_lock);
21183 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
21184 if ( NULL == pTdlsPeer ) {
21185 mutex_unlock(&pHddCtx->tdls_lock);
21186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21187 "%s: " MAC_ADDRESS_STR
21188 " (oper %d) peer got freed in other context. ignored",
21189 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
21190 return -EINVAL;
21191 }
21192
Atul Mittal115287b2014-07-08 13:26:33 +053021193 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
21194 eTDLS_LINK_CONNECTED,
21195 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053021196 staDesc.ucSTAId = pTdlsPeer->staId;
21197 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053021198
21199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21200 "%s: tdlsLinkEstablishParams of peer "
21201 MAC_ADDRESS_STR "uapsdQueues: %d"
21202 "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d"
21203 "isResponder: %d peerstaId: %d",
21204 __func__,
21205 MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac),
21206 tdlsLinkEstablishParams.uapsdQueues,
21207 tdlsLinkEstablishParams.qos,
21208 tdlsLinkEstablishParams.maxSp,
21209 tdlsLinkEstablishParams.isBufSta,
21210 tdlsLinkEstablishParams.isOffChannelSupported,
21211 tdlsLinkEstablishParams.isResponder,
21212 pTdlsPeer->staId);
21213
21214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21215 "%s: StaDesc ucSTAId: %d ucQosEnabled: %d",
21216 __func__,
21217 staDesc.ucSTAId,
21218 staDesc.ucQosEnabled);
21219
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021220 ret = WLANTL_UpdateTdlsSTAClient(
21221 pHddCtx->pvosContext,
21222 &staDesc);
21223 if (ret != VOS_STATUS_SUCCESS) {
21224 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
21225 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053021226
Gopichand Nakkala471708b2013-06-04 20:03:01 +053021227 /* Mark TDLS client Authenticated .*/
21228 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
21229 pTdlsPeer->staId,
21230 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070021231 if (VOS_STATUS_SUCCESS == status)
21232 {
Hoonki Lee14621352013-04-16 17:51:19 -070021233 if (pTdlsPeer->is_responder == 0)
21234 {
21235 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053021236 tdlsConnInfo_t *tdlsInfo;
21237
21238 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
21239
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053021240 if (!vos_timer_is_initialized(
21241 &pTdlsPeer->initiatorWaitTimeoutTimer))
21242 {
21243 /* Initialize initiator wait callback */
21244 vos_timer_init(
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053021245 &pTdlsPeer->initiatorWaitTimeoutTimer,
21246 VOS_TIMER_TYPE_SW,
21247 wlan_hdd_tdls_initiator_wait_cb,
21248 tdlsInfo);
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053021249 }
Hoonki Lee14621352013-04-16 17:51:19 -070021250 wlan_hdd_tdls_timer_restart(pAdapter,
21251 &pTdlsPeer->initiatorWaitTimeoutTimer,
21252 WAIT_TIME_TDLS_INITIATOR);
21253 /* suspend initiator TX until it receives direct packet from the
21254 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021255 ret = WLANTL_SuspendDataTx(
21256 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
21257 &staId, NULL);
21258 if (ret != VOS_STATUS_SUCCESS) {
21259 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
21260 }
Hoonki Lee14621352013-04-16 17:51:19 -070021261 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021262
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053021263 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021264 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053021265 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021266 suppChannelLen =
21267 tdlsLinkEstablishParams.supportedChannelsLen;
21268
21269 if ((suppChannelLen > 0) &&
21270 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
21271 {
21272 tANI_U8 suppPeerChannel = 0;
21273 int i = 0;
21274 for (i = 0U; i < suppChannelLen; i++)
21275 {
21276 suppPeerChannel =
21277 tdlsLinkEstablishParams.supportedChannels[i];
21278
21279 pTdlsPeer->isOffChannelSupported = FALSE;
21280 if (suppPeerChannel ==
21281 pTdlsPeer->peerParams.channel)
21282 {
21283 pTdlsPeer->isOffChannelSupported = TRUE;
21284 break;
21285 }
21286 }
21287 }
21288 else
21289 {
21290 pTdlsPeer->isOffChannelSupported = FALSE;
21291 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053021292 }
21293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21294 "%s: TDLS channel switch request for channel "
21295 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021296 "%d isOffChannelSupported %d", __func__,
21297 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053021298 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053021299 suppChannelLen,
21300 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053021301
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021302 /* TDLS Off Channel, Enable tdls channel switch,
21303 when their is only one tdls link and it supports */
21304 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
21305 if ((numCurrTdlsPeers == 1) &&
21306 (TRUE == pTdlsPeer->isOffChannelSupported) &&
21307 (TRUE == pTdlsPeer->isOffChannelConfigured))
21308 {
21309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21310 "%s: Send TDLS channel switch request for channel %d",
21311 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053021312
21313 pTdlsPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021314 vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr));
21315 channel = pTdlsPeer->peerParams.channel;
21316
21317 mutex_unlock(&pHddCtx->tdls_lock);
21318
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021319 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
21320 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021321 peerMac,
21322 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021323 TDLS_OFF_CHANNEL_BW_OFFSET,
21324 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021325 if (ret != VOS_STATUS_SUCCESS) {
21326 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
21327 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021328 }
21329 else
21330 {
21331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21332 "%s: TDLS channel switch request not sent"
21333 " numCurrTdlsPeers %d "
21334 "isOffChannelSupported %d "
21335 "isOffChannelConfigured %d",
21336 __func__, numCurrTdlsPeers,
21337 pTdlsPeer->isOffChannelSupported,
21338 pTdlsPeer->isOffChannelConfigured);
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021339 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021340 }
21341
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070021342 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021343 else
21344 mutex_unlock(&pHddCtx->tdls_lock);
21345
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021346 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021347
21348 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053021349 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
21350 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021351 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053021352 int ac;
21353 uint8 ucAc[4] = { WLANTL_AC_VO,
21354 WLANTL_AC_VI,
21355 WLANTL_AC_BK,
21356 WLANTL_AC_BE };
21357 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
21358 for(ac=0; ac < 4; ac++)
21359 {
21360 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
21361 pTdlsPeer->staId, ucAc[ac],
21362 tlTid[ac], tlTid[ac], 0, 0,
21363 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021364 if (status != VOS_STATUS_SUCCESS) {
21365 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
21366 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053021367 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021368 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021369 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021370
Bhargav Shah66896792015-10-01 18:17:37 +053021371 /* stop TCP delack timer if TDLS is enable */
21372 set_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
21373 hdd_manage_delack_timer(pHddCtx);
Abhishek Singh67fa6bc2016-01-05 15:57:19 +053021374 hdd_wlan_tdls_enable_link_event(peer,
21375 pTdlsPeer->isOffChannelSupported,
21376 pTdlsPeer->isOffChannelConfigured,
21377 pTdlsPeer->isOffChannelEstablished);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021378 }
21379 break;
21380 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080021381 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021382 tANI_U16 numCurrTdlsPeers = 0;
21383 hddTdlsPeer_t *connPeer = NULL;
21384
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21386 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
21387 __func__, MAC_ADDR_ARRAY(peer));
21388
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021389 mutex_lock(&pHddCtx->tdls_lock);
21390 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021391
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021392
Sunil Dutt41de4e22013-11-14 18:09:02 +053021393 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021394 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021395 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
21396 " (oper %d) not exsting. ignored",
21397 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
21398 return -EINVAL;
21399 }
21400
21401 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21402 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
21403 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
21404 "NL80211_TDLS_DISABLE_LINK");
21405
Hoonki Lee5305c3a2013-04-29 23:28:59 -070021406 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080021407 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021408 long status;
21409
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053021410 /* set tdls off channel status to false for this peer */
21411 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053021412 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
21413 eTDLS_LINK_TEARING,
21414 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
21415 eTDLS_LINK_UNSPECIFIED:
21416 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021417 mutex_unlock(&pHddCtx->tdls_lock);
21418
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021419 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
21420
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021421 status = sme_DeleteTdlsPeerSta(
21422 WLAN_HDD_GET_HAL_CTX(pAdapter),
21423 pAdapter->sessionId, peer );
21424 if (status != VOS_STATUS_SUCCESS) {
21425 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
21426 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021427
21428 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
21429 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021430
21431 mutex_lock(&pHddCtx->tdls_lock);
21432 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
21433 if ( NULL == pTdlsPeer ) {
21434 mutex_unlock(&pHddCtx->tdls_lock);
21435 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
21436 " peer was freed in other context",
21437 __func__, MAC_ADDR_ARRAY(peer));
21438 return -EINVAL;
21439 }
21440
Atul Mittal271a7652014-09-12 13:18:22 +053021441 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053021442 eTDLS_LINK_IDLE,
21443 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021444 mutex_unlock(&pHddCtx->tdls_lock);
21445
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021446 if (status <= 0)
21447 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21449 "%s: Del station failed status %ld",
21450 __func__, status);
21451 return -EPERM;
21452 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021453
21454 /* TDLS Off Channel, Enable tdls channel switch,
21455 when their is only one tdls link and it supports */
21456 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
21457 if (numCurrTdlsPeers == 1)
21458 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021459 tSirMacAddr peerMac;
21460 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053021461
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021462 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021463 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053021464
21465 if (connPeer == NULL) {
21466 mutex_unlock(&pHddCtx->tdls_lock);
21467 hddLog(VOS_TRACE_LEVEL_ERROR,
21468 "%s connPeer is NULL", __func__);
21469 return -EINVAL;
21470 }
21471
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021472 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
21473 channel = connPeer->peerParams.channel;
21474
21475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21476 "%s: TDLS channel switch "
21477 "isOffChannelSupported %d "
21478 "isOffChannelConfigured %d "
21479 "isOffChannelEstablished %d",
21480 __func__,
21481 (connPeer ? connPeer->isOffChannelSupported : -1),
21482 (connPeer ? connPeer->isOffChannelConfigured : -1),
21483 (connPeer ? connPeer->isOffChannelEstablished : -1));
21484
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021485 if ((connPeer) &&
21486 (connPeer->isOffChannelSupported == TRUE) &&
21487 (connPeer->isOffChannelConfigured == TRUE))
21488 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053021489 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021490 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021491 status = sme_SendTdlsChanSwitchReq(
21492 WLAN_HDD_GET_HAL_CTX(pAdapter),
21493 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021494 peerMac,
21495 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021496 TDLS_OFF_CHANNEL_BW_OFFSET,
21497 TDLS_CHANNEL_SWITCH_ENABLE);
21498 if (status != VOS_STATUS_SUCCESS) {
21499 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
21500 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021501 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021502 else
21503 mutex_unlock(&pHddCtx->tdls_lock);
21504 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021505 else
21506 {
21507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21508 "%s: TDLS channel switch request not sent "
21509 "numCurrTdlsPeers %d ",
21510 __func__, numCurrTdlsPeers);
21511 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080021512 }
21513 else
21514 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021515 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21517 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080021518 }
Bhargav Shah66896792015-10-01 18:17:37 +053021519 if (numCurrTdlsPeers == 0) {
21520 /* start TCP delack timer if TDLS is disable */
21521 clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
21522 hdd_manage_delack_timer(pHddCtx);
21523 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080021524 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021525 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021526 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053021527 {
Atul Mittal115287b2014-07-08 13:26:33 +053021528 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021529
Atul Mittal115287b2014-07-08 13:26:33 +053021530 if (0 != status)
21531 {
21532 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021533 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053021534 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053021535 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053021536 break;
21537 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021538 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053021539 {
Atul Mittal115287b2014-07-08 13:26:33 +053021540 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
21541 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021542 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053021543 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021544
Atul Mittal115287b2014-07-08 13:26:33 +053021545 if (0 != status)
21546 {
21547 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021548 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053021549 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053021550 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053021551 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053021552 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021553 case NL80211_TDLS_DISCOVERY_REQ:
21554 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053021555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021556 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053021557 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021558 return -ENOTSUPP;
21559 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053021560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21561 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021562 return -ENOTSUPP;
21563 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021564
21565 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021566 return 0;
21567}
Chilam NG571c65a2013-01-19 12:27:36 +053021568
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021569static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053021570#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
21571 const u8 *peer,
21572#else
21573 u8 *peer,
21574#endif
21575 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021576{
21577 int ret;
21578
21579 vos_ssr_protect(__func__);
21580 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
21581 vos_ssr_unprotect(__func__);
21582
21583 return ret;
21584}
21585
Chilam NG571c65a2013-01-19 12:27:36 +053021586int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
21587 struct net_device *dev, u8 *peer)
21588{
Arif Hussaina7c8e412013-11-20 11:06:42 -080021589 hddLog(VOS_TRACE_LEVEL_INFO,
21590 "tdls send discover req: "MAC_ADDRESS_STR,
21591 MAC_ADDR_ARRAY(peer));
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053021592#if TDLS_MGMT_VERSION2
21593 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21594 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
21595#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053021596#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
21597 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21598 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
21599#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
21600 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21601 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
21602#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
21603 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21604 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
21605#else
Chilam NG571c65a2013-01-19 12:27:36 +053021606 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21607 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053021608#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053021609#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053021610}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021611#endif
21612
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021613#ifdef WLAN_FEATURE_GTK_OFFLOAD
21614/*
21615 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
21616 * Callback rountine called upon receiving response for
21617 * get offload info
21618 */
21619void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
21620 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
21621{
21622
21623 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021624 tANI_U8 tempReplayCounter[8];
21625 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021626
21627 ENTER();
21628
21629 if (NULL == pAdapter)
21630 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053021631 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021632 "%s: HDD adapter is Null", __func__);
21633 return ;
21634 }
21635
21636 if (NULL == pGtkOffloadGetInfoRsp)
21637 {
21638 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21639 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
21640 return ;
21641 }
21642
21643 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
21644 {
21645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21646 "%s: wlan Failed to get replay counter value",
21647 __func__);
21648 return ;
21649 }
21650
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021651 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
21652 /* Update replay counter */
21653 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
21654 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
21655
21656 {
21657 /* changing from little to big endian since supplicant
21658 * works on big endian format
21659 */
21660 int i;
21661 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
21662
21663 for (i = 0; i < 8; i++)
21664 {
21665 tempReplayCounter[7-i] = (tANI_U8)p[i];
21666 }
21667 }
21668
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021669 /* Update replay counter to NL */
21670 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021671 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021672}
21673
21674/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021675 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021676 * This function is used to offload GTK rekeying job to the firmware.
21677 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021678int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021679 struct cfg80211_gtk_rekey_data *data)
21680{
21681 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
21682 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
21683 hdd_station_ctx_t *pHddStaCtx;
21684 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021685 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021686 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021687 eHalStatus status = eHAL_STATUS_FAILURE;
21688
21689 ENTER();
21690
21691 if (NULL == pAdapter)
21692 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053021693 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021694 "%s: HDD adapter is Null", __func__);
21695 return -ENODEV;
21696 }
21697
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053021698 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
21699 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
21700 pAdapter->sessionId, pAdapter->device_mode));
21701
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021702 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021703 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021704 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021705 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021706 }
21707
21708 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
21709 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
21710 if (NULL == hHal)
21711 {
21712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21713 "%s: HAL context is Null!!!", __func__);
21714 return -EAGAIN;
21715 }
21716
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021717 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
21718 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
21719 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
21720 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021721 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021722 {
21723 /* changing from big to little endian since driver
21724 * works on little endian format
21725 */
21726 tANI_U8 *p =
21727 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
21728 int i;
21729
21730 for (i = 0; i < 8; i++)
21731 {
21732 p[7-i] = data->replay_ctr[i];
21733 }
21734 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021735
21736 if (TRUE == pHddCtx->hdd_wlan_suspended)
21737 {
21738 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021739 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
21740 sizeof (tSirGtkOffloadParams));
21741 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021742 pAdapter->sessionId);
21743
21744 if (eHAL_STATUS_SUCCESS != status)
21745 {
21746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21747 "%s: sme_SetGTKOffload failed, returned %d",
21748 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053021749
21750 /* Need to clear any trace of key value in the memory.
21751 * Thus zero out the memory even though it is local
21752 * variable.
21753 */
21754 vos_mem_zero(&hddGtkOffloadReqParams,
21755 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021756 return status;
21757 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21759 "%s: sme_SetGTKOffload successfull", __func__);
21760 }
21761 else
21762 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21764 "%s: wlan not suspended GTKOffload request is stored",
21765 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021766 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021767
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053021768 /* Need to clear any trace of key value in the memory.
21769 * Thus zero out the memory even though it is local
21770 * variable.
21771 */
21772 vos_mem_zero(&hddGtkOffloadReqParams,
21773 sizeof(hddGtkOffloadReqParams));
21774
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021775 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021776 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021777}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021778
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021779int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
21780 struct cfg80211_gtk_rekey_data *data)
21781{
21782 int ret;
21783
21784 vos_ssr_protect(__func__);
21785 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
21786 vos_ssr_unprotect(__func__);
21787
21788 return ret;
21789}
21790#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021791/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053021792 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021793 * This function is used to set access control policy
21794 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053021795static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
21796 struct net_device *dev,
21797 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021798{
21799 int i;
21800 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
21801 hdd_hostapd_state_t *pHostapdState;
21802 tsap_Config_t *pConfig;
21803 v_CONTEXT_t pVosContext = NULL;
21804 hdd_context_t *pHddCtx;
21805 int status;
21806
21807 ENTER();
21808
21809 if (NULL == pAdapter)
21810 {
21811 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
21812 "%s: HDD adapter is Null", __func__);
21813 return -ENODEV;
21814 }
21815
21816 if (NULL == params)
21817 {
21818 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
21819 "%s: params is Null", __func__);
21820 return -EINVAL;
21821 }
21822
21823 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
21824 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021825 if (0 != status)
21826 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021827 return status;
21828 }
21829
21830 pVosContext = pHddCtx->pvosContext;
21831 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
21832
21833 if (NULL == pHostapdState)
21834 {
21835 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
21836 "%s: pHostapdState is Null", __func__);
21837 return -EINVAL;
21838 }
21839
21840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
21841 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053021842 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
21843 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
21844 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021845
21846 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
21847 {
21848 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
21849
21850 /* default value */
21851 pConfig->num_accept_mac = 0;
21852 pConfig->num_deny_mac = 0;
21853
21854 /**
21855 * access control policy
21856 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
21857 * listed in hostapd.deny file.
21858 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
21859 * listed in hostapd.accept file.
21860 */
21861 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
21862 {
21863 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
21864 }
21865 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
21866 {
21867 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
21868 }
21869 else
21870 {
21871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21872 "%s:Acl Policy : %d is not supported",
21873 __func__, params->acl_policy);
21874 return -ENOTSUPP;
21875 }
21876
21877 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
21878 {
21879 pConfig->num_accept_mac = params->n_acl_entries;
21880 for (i = 0; i < params->n_acl_entries; i++)
21881 {
21882 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21883 "** Add ACL MAC entry %i in WhiletList :"
21884 MAC_ADDRESS_STR, i,
21885 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
21886
21887 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
21888 sizeof(qcmacaddr));
21889 }
21890 }
21891 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
21892 {
21893 pConfig->num_deny_mac = params->n_acl_entries;
21894 for (i = 0; i < params->n_acl_entries; i++)
21895 {
21896 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21897 "** Add ACL MAC entry %i in BlackList :"
21898 MAC_ADDRESS_STR, i,
21899 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
21900
21901 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
21902 sizeof(qcmacaddr));
21903 }
21904 }
21905
21906 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
21907 {
21908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21909 "%s: SAP Set Mac Acl fail", __func__);
21910 return -EINVAL;
21911 }
21912 }
21913 else
21914 {
21915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053021916 "%s: Invalid device_mode = %s (%d)",
21917 __func__, hdd_device_modetoString(pAdapter->device_mode),
21918 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021919 return -EINVAL;
21920 }
21921
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021922 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021923 return 0;
21924}
21925
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053021926static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
21927 struct net_device *dev,
21928 const struct cfg80211_acl_data *params)
21929{
21930 int ret;
21931 vos_ssr_protect(__func__);
21932 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
21933 vos_ssr_unprotect(__func__);
21934
21935 return ret;
21936}
21937
Leo Chang9056f462013-08-01 19:21:11 -070021938#ifdef WLAN_NL80211_TESTMODE
21939#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070021940void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070021941(
21942 void *pAdapter,
21943 void *indCont
21944)
21945{
Leo Changd9df8aa2013-09-26 13:32:26 -070021946 tSirLPHBInd *lphbInd;
21947 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053021948 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070021949
21950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070021951 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070021952
c_hpothu73f35e62014-04-18 13:40:08 +053021953 if (pAdapter == NULL)
21954 {
21955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21956 "%s: pAdapter is NULL\n",__func__);
21957 return;
21958 }
21959
Leo Chang9056f462013-08-01 19:21:11 -070021960 if (NULL == indCont)
21961 {
21962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070021963 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070021964 return;
21965 }
21966
c_hpothu73f35e62014-04-18 13:40:08 +053021967 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070021968 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070021969 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053021970 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070021971 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070021972 GFP_ATOMIC);
21973 if (!skb)
21974 {
21975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21976 "LPHB timeout, NL buffer alloc fail");
21977 return;
21978 }
21979
Leo Changac3ba772013-10-07 09:47:04 -070021980 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070021981 {
21982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21983 "WLAN_HDD_TM_ATTR_CMD put fail");
21984 goto nla_put_failure;
21985 }
Leo Changac3ba772013-10-07 09:47:04 -070021986 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070021987 {
21988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21989 "WLAN_HDD_TM_ATTR_TYPE put fail");
21990 goto nla_put_failure;
21991 }
Leo Changac3ba772013-10-07 09:47:04 -070021992 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070021993 sizeof(tSirLPHBInd), lphbInd))
21994 {
21995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21996 "WLAN_HDD_TM_ATTR_DATA put fail");
21997 goto nla_put_failure;
21998 }
Leo Chang9056f462013-08-01 19:21:11 -070021999 cfg80211_testmode_event(skb, GFP_ATOMIC);
22000 return;
22001
22002nla_put_failure:
22003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22004 "NLA Put fail");
22005 kfree_skb(skb);
22006
22007 return;
22008}
22009#endif /* FEATURE_WLAN_LPHB */
22010
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053022011static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070022012{
22013 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
22014 int err = 0;
22015#ifdef FEATURE_WLAN_LPHB
22016 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070022017 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022018
22019 ENTER();
22020
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022021 err = wlan_hdd_validate_context(pHddCtx);
22022 if (0 != err)
22023 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022024 return err;
22025 }
Leo Chang9056f462013-08-01 19:21:11 -070022026#endif /* FEATURE_WLAN_LPHB */
22027
22028 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
22029 if (err)
22030 {
22031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22032 "%s Testmode INV ATTR", __func__);
22033 return err;
22034 }
22035
22036 if (!tb[WLAN_HDD_TM_ATTR_CMD])
22037 {
22038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22039 "%s Testmode INV CMD", __func__);
22040 return -EINVAL;
22041 }
22042
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053022043 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
22044 TRACE_CODE_HDD_CFG80211_TESTMODE,
22045 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070022046 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
22047 {
22048#ifdef FEATURE_WLAN_LPHB
22049 /* Low Power Heartbeat configuration request */
22050 case WLAN_HDD_TM_CMD_WLAN_HB:
22051 {
22052 int buf_len;
22053 void *buf;
22054 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080022055 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070022056
22057 if (!tb[WLAN_HDD_TM_ATTR_DATA])
22058 {
22059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22060 "%s Testmode INV DATA", __func__);
22061 return -EINVAL;
22062 }
22063
22064 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
22065 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080022066
Manjeet Singh3c577442017-02-10 19:03:38 +053022067 if (buf_len > sizeof(*hb_params)) {
22068 hddLog(LOGE, FL("buf_len=%d exceeded hb_params size limit"),
22069 buf_len);
22070 return -ERANGE;
22071 }
22072
Amar Singhal05852702014-02-04 14:40:00 -080022073 hb_params_temp =(tSirLPHBReq *)buf;
22074 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
22075 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
22076 return -EINVAL;
22077
Leo Chang9056f462013-08-01 19:21:11 -070022078 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
22079 if (NULL == hb_params)
22080 {
22081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22082 "%s Request Buffer Alloc Fail", __func__);
22083 return -EINVAL;
22084 }
22085
Ashish Kumar Dhanotiya3a8c0a72017-07-13 18:58:59 +053022086 vos_mem_zero(hb_params, sizeof(tSirLPHBReq));
Leo Chang9056f462013-08-01 19:21:11 -070022087 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070022088 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
22089 hb_params,
22090 wlan_hdd_cfg80211_lphb_ind_handler);
22091 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070022092 {
Leo Changd9df8aa2013-09-26 13:32:26 -070022093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22094 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070022095 vos_mem_free(hb_params);
22096 }
Leo Chang9056f462013-08-01 19:21:11 -070022097 return 0;
22098 }
22099#endif /* FEATURE_WLAN_LPHB */
22100 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053022101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
22102 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070022103 return -EOPNOTSUPP;
22104 }
22105
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022106 EXIT();
22107 return err;
Leo Chang9056f462013-08-01 19:21:11 -070022108}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053022109
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053022110static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
22111#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
22112 struct wireless_dev *wdev,
22113#endif
22114 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053022115{
22116 int ret;
22117
22118 vos_ssr_protect(__func__);
22119 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
22120 vos_ssr_unprotect(__func__);
22121
22122 return ret;
22123}
Leo Chang9056f462013-08-01 19:21:11 -070022124#endif /* CONFIG_NL80211_TESTMODE */
22125
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053022126extern void hdd_set_wlan_suspend_mode(bool suspend);
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053022127static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022128 struct net_device *dev,
22129 int idx, struct survey_info *survey)
22130{
22131 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
22132 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053022133 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022134 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053022135 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022136 v_S7_t snr,rssi;
22137 int status, i, j, filled = 0;
22138
22139 ENTER();
22140
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022141 if (NULL == pAdapter)
22142 {
22143 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
22144 "%s: HDD adapter is Null", __func__);
22145 return -ENODEV;
22146 }
22147
22148 if (NULL == wiphy)
22149 {
22150 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
22151 "%s: wiphy is Null", __func__);
22152 return -ENODEV;
22153 }
22154
22155 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
22156 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022157 if (0 != status)
22158 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022159 return status;
22160 }
22161
Mihir Sheted9072e02013-08-21 17:02:29 +053022162 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
22163
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022164 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053022165 0 != pAdapter->survey_idx ||
22166 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022167 {
22168 /* The survey dump ops when implemented completely is expected to
22169 * return a survey of all channels and the ops is called by the
22170 * kernel with incremental values of the argument 'idx' till it
22171 * returns -ENONET. But we can only support the survey for the
22172 * operating channel for now. survey_idx is used to track
22173 * that the ops is called only once and then return -ENONET for
22174 * the next iteration
22175 */
22176 pAdapter->survey_idx = 0;
22177 return -ENONET;
22178 }
22179
Mukul Sharma9d5233b2015-06-11 20:28:20 +053022180 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
22181 {
22182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22183 "%s: Roaming in progress, hence return ", __func__);
22184 return -ENONET;
22185 }
22186
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022187 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
22188
22189 wlan_hdd_get_snr(pAdapter, &snr);
22190 wlan_hdd_get_rssi(pAdapter, &rssi);
22191
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053022192 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
22193 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
22194 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022195 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
22196 hdd_wlan_get_freq(channel, &freq);
22197
22198
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053022199 for (i = 0; i < HDD_NUM_NL80211_BANDS; i++)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022200 {
22201 if (NULL == wiphy->bands[i])
22202 {
22203 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
22204 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
22205 continue;
22206 }
22207
22208 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
22209 {
22210 struct ieee80211_supported_band *band = wiphy->bands[i];
22211
22212 if (band->channels[j].center_freq == (v_U16_t)freq)
22213 {
22214 survey->channel = &band->channels[j];
22215 /* The Rx BDs contain SNR values in dB for the received frames
22216 * while the supplicant expects noise. So we calculate and
22217 * return the value of noise (dBm)
22218 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
22219 */
22220 survey->noise = rssi - snr;
22221 survey->filled = SURVEY_INFO_NOISE_DBM;
22222 filled = 1;
22223 }
22224 }
22225 }
22226
22227 if (filled)
22228 pAdapter->survey_idx = 1;
22229 else
22230 {
22231 pAdapter->survey_idx = 0;
22232 return -ENONET;
22233 }
22234
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022235 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022236 return 0;
22237}
22238
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053022239static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
22240 struct net_device *dev,
22241 int idx, struct survey_info *survey)
22242{
22243 int ret;
22244
22245 vos_ssr_protect(__func__);
22246 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
22247 vos_ssr_unprotect(__func__);
22248
22249 return ret;
22250}
22251
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022252/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022253 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022254 * this is called when cfg80211 driver resume
22255 * driver updates latest sched_scan scan result(if any) to cfg80211 database
22256 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022257int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022258{
22259 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
22260 hdd_adapter_t *pAdapter;
22261 hdd_adapter_list_node_t *pAdapterNode, *pNext;
22262 VOS_STATUS status = VOS_STATUS_SUCCESS;
22263
22264 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022265
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053022266 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022267 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022268 return 0;
22269 }
22270
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053022271 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
22272 NO_SESSION, pHddCtx->isWiphySuspended));
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053022273
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053022274 if (pHddCtx->is_ap_mode_wow_supported)
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053022275 {
22276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22277 "%s: Resume SoftAP", __func__);
22278 hdd_set_wlan_suspend_mode(false);
22279 }
22280
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022281 spin_lock(&pHddCtx->schedScan_lock);
22282 pHddCtx->isWiphySuspended = FALSE;
22283 if (TRUE != pHddCtx->isSchedScanUpdatePending)
22284 {
22285 spin_unlock(&pHddCtx->schedScan_lock);
22286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22287 "%s: Return resume is not due to PNO indication", __func__);
22288 return 0;
22289 }
22290 // Reset flag to avoid updatating cfg80211 data old results again
22291 pHddCtx->isSchedScanUpdatePending = FALSE;
22292 spin_unlock(&pHddCtx->schedScan_lock);
22293
22294 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
22295
22296 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
22297 {
22298 pAdapter = pAdapterNode->pAdapter;
22299 if ( (NULL != pAdapter) &&
22300 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
22301 {
22302 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053022303 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
22305 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053022306 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022307 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053022308 {
22309 /* Acquire wakelock to handle the case where APP's tries to
22310 * suspend immediately after updating the scan results. Whis
22311 * results in app's is in suspended state and not able to
22312 * process the connect request to AP
22313 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053022314 hdd_prevent_suspend_timeout(2000,
22315 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022316 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053022317 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022318
22319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22320 "%s : cfg80211 scan result database updated", __func__);
22321
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022322 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022323 return 0;
22324
22325 }
22326 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
22327 pAdapterNode = pNext;
22328 }
22329
22330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22331 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022332 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022333 return 0;
22334}
22335
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022336int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
22337{
22338 int ret;
22339
22340 vos_ssr_protect(__func__);
22341 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
22342 vos_ssr_unprotect(__func__);
22343
22344 return ret;
22345}
22346
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022347/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022348 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022349 * this is called when cfg80211 driver suspends
22350 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022351int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022352 struct cfg80211_wowlan *wow)
22353{
22354 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022355 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022356
22357 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022358
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022359 ret = wlan_hdd_validate_context(pHddCtx);
22360 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022361 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022362 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022363 }
22364
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053022365 if (pHddCtx->is_ap_mode_wow_supported) {
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053022366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22367 "%s: Suspend SoftAP", __func__);
22368 hdd_set_wlan_suspend_mode(true);
22369 }
22370
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022371
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053022372 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
22373 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
22374 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022375 pHddCtx->isWiphySuspended = TRUE;
22376
22377 EXIT();
22378
22379 return 0;
22380}
22381
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022382int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
22383 struct cfg80211_wowlan *wow)
22384{
22385 int ret;
22386
22387 vos_ssr_protect(__func__);
22388 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
22389 vos_ssr_unprotect(__func__);
22390
22391 return ret;
22392}
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022393
22394#ifdef FEATURE_OEM_DATA_SUPPORT
22395static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022396 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022397{
22398 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
22399
22400 ENTER();
22401
22402 if (wlan_hdd_validate_context(pHddCtx)) {
22403 return;
22404 }
22405 if (!pMsg)
22406 {
22407 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
22408 return;
22409 }
22410
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022411 send_oem_data_rsp_msg(evLen, pMsg);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022412
22413 EXIT();
22414 return;
22415
22416}
22417
22418void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022419 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022420{
22421 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
22422
22423 ENTER();
22424
22425 if (wlan_hdd_validate_context(pHddCtx)) {
22426 return;
22427 }
22428
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022429 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d) evLen %d"), evType, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022430
22431 switch(evType) {
22432 case SIR_HAL_START_OEM_DATA_RSP_IND_NEW:
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022433 wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022434 break;
22435 default:
22436 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
22437 break;
22438 }
22439 EXIT();
22440}
22441#endif
22442
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053022443#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
22444 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053022445/**
22446 * __wlan_hdd_cfg80211_abort_scan() - cfg80211 abort scan api
22447 * @wiphy: Pointer to wiphy
22448 * @wdev: Pointer to wireless device structure
22449 *
22450 * This function is used to abort an ongoing scan
22451 *
22452 * Return: None
22453 */
22454static void __wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
22455 struct wireless_dev *wdev)
22456{
22457 struct net_device *dev = wdev->netdev;
22458 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
22459 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
22460 int ret;
22461
22462 ENTER();
22463
22464 if (NULL == adapter) {
22465 hddLog(VOS_TRACE_LEVEL_FATAL, FL("HDD adapter is NULL"));
22466 return;
22467 }
22468
22469 ret = wlan_hdd_validate_context(hdd_ctx);
22470 if (0 != ret)
22471 return;
22472
22473 wlan_hdd_scan_abort(adapter);
22474
22475 return;
22476}
22477
22478/**
22479 * wlan_hdd_cfg80211_abort_scan - cfg80211 abort scan api
22480 * @wiphy: Pointer to wiphy
22481 * @wdev: Pointer to wireless device structure
22482 *
22483 * Return: None
22484 */
22485void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
22486 struct wireless_dev *wdev)
22487{
22488 vos_ssr_protect(__func__);
22489 __wlan_hdd_cfg80211_abort_scan(wiphy, wdev);
22490 vos_ssr_unprotect(__func__);
22491
22492 return;
22493}
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053022494#endif
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053022495
Abhishek Singh936c6932017-11-07 17:28:23 +053022496#ifdef CHANNEL_SWITCH_SUPPORTED
22497/**
22498 * __wlan_hdd_cfg80211_channel_switch()- function to switch
22499 * channel in SAP/GO
22500 * @wiphy: wiphy pointer
22501 * @dev: dev pointer.
22502 * @csa_params: Change channel params
22503 *
22504 * This function is called to switch channel in SAP/GO
22505 *
22506 * Return: 0 if success else return non zero
22507 */
22508static int __wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy,
22509 struct net_device *dev, struct cfg80211_csa_settings *csa_params)
22510{
22511 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
22512 hdd_context_t *hdd_ctx;
22513 uint8_t channel;
22514 int ret;
Abhishek Singh10e17cf2018-03-12 14:34:22 +053022515 ptSapContext sap_ctx;
Abhishek Singh936c6932017-11-07 17:28:23 +053022516 v_CONTEXT_t vos_ctx;
22517
22518 hddLog(LOGE, FL("Set Freq %d"), csa_params->chandef.chan->center_freq);
22519
22520 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
22521 ret = wlan_hdd_validate_context(hdd_ctx);
22522 if (ret)
22523 return ret;
22524
22525 vos_ctx = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
22526 if (!vos_ctx) {
22527 hddLog(LOGE, FL("Vos ctx is null"));
22528 return -EINVAL;
22529 }
22530
Abhishek Singh10e17cf2018-03-12 14:34:22 +053022531 if (WLAN_HDD_SOFTAP != adapter->device_mode)
Abhishek Singh936c6932017-11-07 17:28:23 +053022532 return -ENOTSUPP;
22533
Abhishek Singh10e17cf2018-03-12 14:34:22 +053022534 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
22535 if (!sap_ctx) {
22536 hddLog(LOGE, FL("sap_ctx is NULL"));
22537 return -EINVAL;
22538 }
22539
22540 ret = wlansap_chk_n_set_chan_change_in_progress(sap_ctx);
22541 if (ret)
22542 return ret;
22543
22544 INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp);
22545
Abhishek Singh936c6932017-11-07 17:28:23 +053022546 channel = vos_freq_to_chan(csa_params->chandef.chan->center_freq);
Abhishek Singhceb6fe22017-11-27 13:53:18 +053022547 ret = wlansap_set_channel_change(vos_ctx, channel, false);
Abhishek Singh936c6932017-11-07 17:28:23 +053022548
Abhishek Singh10e17cf2018-03-12 14:34:22 +053022549 if (ret) {
22550 wlansap_reset_chan_change_in_progress(sap_ctx);
22551 complete(&sap_ctx->ecsa_info.chan_switch_comp);
22552 }
22553
Abhishek Singh936c6932017-11-07 17:28:23 +053022554 return ret;
22555}
22556
22557/**
22558 * wlan_hdd_cfg80211_channel_switch()- function to switch
22559 * channel in SAP/GO
22560 * @wiphy: wiphy pointer
22561 * @dev: dev pointer.
22562 * @csa_params: Change channel params
22563 *
22564 * This function is called to switch channel in SAP/GO
22565 *
22566 * Return: 0 if success else return non zero
22567 */
22568static int wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy,
22569 struct net_device *dev, struct cfg80211_csa_settings *csa_params)
22570{
22571 int ret;
22572
22573 vos_ssr_protect(__func__);
22574 ret = __wlan_hdd_cfg80211_channel_switch(wiphy, dev, csa_params);
22575 vos_ssr_unprotect(__func__);
22576
22577 return ret;
22578}
22579#endif
22580
Jeff Johnson295189b2012-06-20 16:38:30 -070022581/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053022582static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070022583{
22584 .add_virtual_intf = wlan_hdd_add_virtual_intf,
22585 .del_virtual_intf = wlan_hdd_del_virtual_intf,
22586 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
22587 .change_station = wlan_hdd_change_station,
22588#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
22589 .add_beacon = wlan_hdd_cfg80211_add_beacon,
22590 .del_beacon = wlan_hdd_cfg80211_del_beacon,
22591 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070022592#else
22593 .start_ap = wlan_hdd_cfg80211_start_ap,
22594 .change_beacon = wlan_hdd_cfg80211_change_beacon,
22595 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070022596#endif
22597 .change_bss = wlan_hdd_cfg80211_change_bss,
22598 .add_key = wlan_hdd_cfg80211_add_key,
22599 .get_key = wlan_hdd_cfg80211_get_key,
22600 .del_key = wlan_hdd_cfg80211_del_key,
22601 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080022602#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070022603 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080022604#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070022605 .scan = wlan_hdd_cfg80211_scan,
22606 .connect = wlan_hdd_cfg80211_connect,
22607 .disconnect = wlan_hdd_cfg80211_disconnect,
22608 .join_ibss = wlan_hdd_cfg80211_join_ibss,
22609 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
22610 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
22611 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
22612 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070022613 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
22614 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053022615 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070022616#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
22617 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
22618 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
22619 .set_txq_params = wlan_hdd_set_txq_params,
22620#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070022621 .get_station = wlan_hdd_cfg80211_get_station,
22622 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
22623 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070022624 .add_station = wlan_hdd_cfg80211_add_station,
22625#ifdef FEATURE_WLAN_LFR
22626 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
22627 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
22628 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
22629#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070022630#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
22631 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
22632#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080022633#ifdef FEATURE_WLAN_TDLS
22634 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
22635 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
22636#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053022637#ifdef WLAN_FEATURE_GTK_OFFLOAD
22638 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
22639#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053022640#ifdef FEATURE_WLAN_SCAN_PNO
22641 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
22642 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
22643#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022644 .resume = wlan_hdd_cfg80211_resume_wlan,
22645 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053022646 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070022647#ifdef WLAN_NL80211_TESTMODE
22648 .testmode_cmd = wlan_hdd_cfg80211_testmode,
22649#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022650 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053022651#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
22652 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053022653 .abort_scan = wlan_hdd_cfg80211_abort_scan,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053022654#endif
Abhishek Singh936c6932017-11-07 17:28:23 +053022655#ifdef CHANNEL_SWITCH_SUPPORTED
22656 .channel_switch = wlan_hdd_cfg80211_channel_switch,
22657#endif
22658
Abhinav Kumar118efd02019-08-07 16:41:07 +053022659#if defined(WLAN_FEATURE_SAE) && \
22660 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
22661 .external_auth = wlan_hdd_cfg80211_external_auth,
22662#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070022663};
22664