blob: 4c615d2e40946f61b5d1ea06635daa04c62eee0e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Hanumanth Reddy Pothula14bc86d2018-01-02 20:02:02 +05302 * Copyright (c) 2012-2018 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
307 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
308 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
309 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
310 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
311 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
312 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
313};
314
Jeff Johnson295189b2012-06-20 16:38:30 -0700315static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
316{
Agrawal Ashish97dec502015-11-26 20:20:58 +0530317 .channels = NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +0530319 .band = HDD_NL80211_BAND_5GHZ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 .bitrates = a_mode_rates,
321 .n_bitrates = a_mode_rates_size,
322 .ht_cap.ht_supported = 1,
323 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
324 | IEEE80211_HT_CAP_GRN_FLD
325 | IEEE80211_HT_CAP_DSSSCCK40
326 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
327 | IEEE80211_HT_CAP_SGI_40
328 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
329 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
330 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
331 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
332 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
333 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
334};
335
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530336/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 TX/RX direction for each kind of interface */
338static const struct ieee80211_txrx_stypes
339wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
340 [NL80211_IFTYPE_STATION] = {
341 .tx = 0xffff,
342 .rx = BIT(SIR_MAC_MGMT_ACTION) |
343 BIT(SIR_MAC_MGMT_PROBE_REQ),
344 },
345 [NL80211_IFTYPE_AP] = {
346 .tx = 0xffff,
347 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
348 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
349 BIT(SIR_MAC_MGMT_PROBE_REQ) |
350 BIT(SIR_MAC_MGMT_DISASSOC) |
351 BIT(SIR_MAC_MGMT_AUTH) |
352 BIT(SIR_MAC_MGMT_DEAUTH) |
353 BIT(SIR_MAC_MGMT_ACTION),
354 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700355 [NL80211_IFTYPE_ADHOC] = {
356 .tx = 0xffff,
357 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
358 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
359 BIT(SIR_MAC_MGMT_PROBE_REQ) |
360 BIT(SIR_MAC_MGMT_DISASSOC) |
361 BIT(SIR_MAC_MGMT_AUTH) |
362 BIT(SIR_MAC_MGMT_DEAUTH) |
363 BIT(SIR_MAC_MGMT_ACTION),
364 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 [NL80211_IFTYPE_P2P_CLIENT] = {
366 .tx = 0xffff,
367 .rx = BIT(SIR_MAC_MGMT_ACTION) |
368 BIT(SIR_MAC_MGMT_PROBE_REQ),
369 },
370 [NL80211_IFTYPE_P2P_GO] = {
371 /* This is also same as for SoftAP */
372 .tx = 0xffff,
373 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
374 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
375 BIT(SIR_MAC_MGMT_PROBE_REQ) |
376 BIT(SIR_MAC_MGMT_DISASSOC) |
377 BIT(SIR_MAC_MGMT_AUTH) |
378 BIT(SIR_MAC_MGMT_DEAUTH) |
379 BIT(SIR_MAC_MGMT_ACTION),
380 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700381};
382
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800383#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800384static const struct ieee80211_iface_limit
385wlan_hdd_iface_limit[] = {
386 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800387 /* max = 3 ; Our driver create two interfaces during driver init
388 * wlan0 and p2p0 interfaces. p2p0 is considered as station
389 * interface until a group is formed. In JB architecture, once the
390 * group is formed, interface type of p2p0 is changed to P2P GO or
391 * Client.
392 * When supplicant remove the group, it first issue a set interface
393 * cmd to change the mode back to Station. In JB this works fine as
394 * we advertize two station type interface during driver init.
395 * Some vendors create separate interface for P2P GO/Client,
396 * after group formation(Third one). But while group remove
397 * supplicant first tries to change the mode(3rd interface) to STATION
398 * But as we advertized only two sta type interfaces nl80211 was
399 * returning error for the third one which was leading to failure in
400 * delete interface. Ideally while removing the group, supplicant
401 * should not try to change the 3rd interface mode to Station type.
402 * Till we get a fix in wpa_supplicant, we advertize max STA
403 * interface type to 3
404 */
405 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800406 .types = BIT(NL80211_IFTYPE_STATION),
407 },
408 {
409 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700410 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800411 },
412 {
413 .max = 1,
414 .types = BIT(NL80211_IFTYPE_P2P_GO) |
415 BIT(NL80211_IFTYPE_P2P_CLIENT),
416 },
417};
418
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +0530419/* interface limits for sta + monitor SCC */
420static const struct ieee80211_iface_limit
421wlan_hdd_iface_sta_mon_limit[] = {
422 {
423 .max = 1,
424 .types = BIT(NL80211_IFTYPE_STATION),
425 },
426 {
427 .max = 1, /* Monitor interface */
428 .types = BIT(NL80211_IFTYPE_MONITOR),
429 },
430};
431
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800432/* By default, only single channel concurrency is allowed */
433static struct ieee80211_iface_combination
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +0530434wlan_hdd_iface_combination[] = {
435 {
436 .limits = wlan_hdd_iface_limit,
437 .num_different_channels = 1,
438 /*
439 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
440 * and p2p0 interfaces during driver init
441 * Some vendors create separate interface for P2P operations.
442 * wlan0: STA interface
443 * p2p0: P2P Device interface, action frames goes
444 * through this interface.
445 * p2p-xx: P2P interface, After GO negotiation this interface is
446 * created for p2p operations(GO/CLIENT interface).
447 */
448 .max_interfaces = WLAN_MAX_INTERFACES,
449 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
450 .beacon_int_infra_match = false,
451 },
452 {
453 .limits = wlan_hdd_iface_sta_mon_limit,
454 .num_different_channels = 1,
455 .max_interfaces = WLAN_STA_AND_MON_INTERFACES,
456 .n_limits = ARRAY_SIZE(wlan_hdd_iface_sta_mon_limit),
457 .beacon_int_infra_match = false,
458 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800459};
460#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800461
Nachiket Kukade5b2e7332018-04-06 14:40:22 +0530462#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) || defined(WITH_BACKPORTS)
463static const struct wiphy_wowlan_support wowlan_support_cfg80211_init = {
Nachiket Kukade1e1b90e2018-05-10 15:26:13 +0530464 .flags = WIPHY_WOWLAN_ANY |
465 WIPHY_WOWLAN_MAGIC_PKT,
Nachiket Kukade5b2e7332018-04-06 14:40:22 +0530466 .n_patterns = WOWL_MAX_PTRNS_ALLOWED,
467 .pattern_min_len = 1,
468 .pattern_max_len = WOWL_PTRN_MAX_SIZE,
469};
470#endif
471
Jeff Johnson295189b2012-06-20 16:38:30 -0700472static struct cfg80211_ops wlan_hdd_cfg80211_ops;
473
474/* Data rate 100KBPS based on IE Index */
475struct index_data_rate_type
476{
477 v_U8_t beacon_rate_index;
478 v_U16_t supported_rate[4];
479};
480
481/* 11B, 11G Rate table include Basic rate and Extended rate
482 The IDX field is the rate index
483 The HI field is the rate when RSSI is strong or being ignored
484 (in this case we report actual rate)
485 The MID field is the rate when RSSI is moderate
486 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
487 The LO field is the rate when RSSI is low
488 (in this case we don't report rates, actual current rate used)
489 */
490static const struct
491{
492 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700493 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700494} supported_data_rate[] =
495{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700496/* IDX HI HM LM LO (RSSI-based index */
497 {2, { 10, 10, 10, 0}},
498 {4, { 20, 20, 10, 0}},
499 {11, { 55, 20, 10, 0}},
500 {12, { 60, 55, 20, 0}},
501 {18, { 90, 55, 20, 0}},
502 {22, {110, 55, 20, 0}},
503 {24, {120, 90, 60, 0}},
504 {36, {180, 120, 60, 0}},
505 {44, {220, 180, 60, 0}},
506 {48, {240, 180, 90, 0}},
507 {66, {330, 180, 90, 0}},
508 {72, {360, 240, 90, 0}},
509 {96, {480, 240, 120, 0}},
510 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700511};
512
513/* MCS Based rate table */
514static struct index_data_rate_type supported_mcs_rate[] =
515{
516/* MCS L20 L40 S20 S40 */
517 {0, {65, 135, 72, 150}},
518 {1, {130, 270, 144, 300}},
519 {2, {195, 405, 217, 450}},
520 {3, {260, 540, 289, 600}},
521 {4, {390, 810, 433, 900}},
522 {5, {520, 1080, 578, 1200}},
523 {6, {585, 1215, 650, 1350}},
524 {7, {650, 1350, 722, 1500}}
525};
526
Leo Chang6f8870f2013-03-26 18:11:36 -0700527#ifdef WLAN_FEATURE_11AC
528
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530529#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700530
531struct index_vht_data_rate_type
532{
533 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530534 v_U16_t supported_VHT80_rate[2];
535 v_U16_t supported_VHT40_rate[2];
536 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700537};
538
539typedef enum
540{
541 DATA_RATE_11AC_MAX_MCS_7,
542 DATA_RATE_11AC_MAX_MCS_8,
543 DATA_RATE_11AC_MAX_MCS_9,
544 DATA_RATE_11AC_MAX_MCS_NA
545} eDataRate11ACMaxMcs;
546
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530547/* SSID broadcast type */
548typedef enum eSSIDBcastType
549{
550 eBCAST_UNKNOWN = 0,
551 eBCAST_NORMAL = 1,
552 eBCAST_HIDDEN = 2,
553} tSSIDBcastType;
554
Leo Chang6f8870f2013-03-26 18:11:36 -0700555/* MCS Based VHT rate table */
556static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
557{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530558/* MCS L80 S80 L40 S40 L20 S40*/
559 {0, {293, 325}, {135, 150}, {65, 72}},
560 {1, {585, 650}, {270, 300}, {130, 144}},
561 {2, {878, 975}, {405, 450}, {195, 217}},
562 {3, {1170, 1300}, {540, 600}, {260, 289}},
563 {4, {1755, 1950}, {810, 900}, {390, 433}},
564 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
565 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
566 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
567 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
568 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700569};
570#endif /* WLAN_FEATURE_11AC */
571
c_hpothu79aab322014-07-14 21:11:01 +0530572/*array index points to MCS and array value points respective rssi*/
573static int rssiMcsTbl[][10] =
574{
575/*MCS 0 1 2 3 4 5 6 7 8 9*/
576 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
577 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
578 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
579};
580
Jeff Johnson295189b2012-06-20 16:38:30 -0700581extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530582#ifdef FEATURE_WLAN_SCAN_PNO
583static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
584#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700585
Leo Chang9056f462013-08-01 19:21:11 -0700586#ifdef WLAN_NL80211_TESTMODE
587enum wlan_hdd_tm_attr
588{
589 WLAN_HDD_TM_ATTR_INVALID = 0,
590 WLAN_HDD_TM_ATTR_CMD = 1,
591 WLAN_HDD_TM_ATTR_DATA = 2,
592 WLAN_HDD_TM_ATTR_TYPE = 3,
593 /* keep last */
594 WLAN_HDD_TM_ATTR_AFTER_LAST,
595 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
596};
597
598enum wlan_hdd_tm_cmd
599{
600 WLAN_HDD_TM_CMD_WLAN_HB = 1,
601};
602
603#define WLAN_HDD_TM_DATA_MAX_LEN 5000
604
605static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
606{
607 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
608 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
609 .len = WLAN_HDD_TM_DATA_MAX_LEN },
610};
611#endif /* WLAN_NL80211_TESTMODE */
612
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800613#ifdef FEATURE_WLAN_CH_AVOID
614/*
615 * FUNCTION: wlan_hdd_send_avoid_freq_event
616 * This is called when wlan driver needs to send vendor specific
617 * avoid frequency range event to userspace
618 */
619int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
620 tHddAvoidFreqList *pAvoidFreqList)
621{
622 struct sk_buff *vendor_event;
623
624 ENTER();
625
626 if (!pHddCtx)
627 {
628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
629 "%s: HDD context is null", __func__);
630 return -1;
631 }
632
633 if (!pAvoidFreqList)
634 {
635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
636 "%s: pAvoidFreqList is null", __func__);
637 return -1;
638 }
639
640 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530641#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
642 NULL,
643#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800644 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530645 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800646 GFP_KERNEL);
647 if (!vendor_event)
648 {
649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
650 "%s: cfg80211_vendor_event_alloc failed", __func__);
651 return -1;
652 }
653
654 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
655 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
656
657 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
658
659 EXIT();
660 return 0;
661}
662#endif /* FEATURE_WLAN_CH_AVOID */
663
Srinivas Dasari030bad32015-02-18 23:23:54 +0530664/*
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +0530665 * define short names for the global vendor params
666 * used by QCA_NL80211_VENDOR_SUBCMD_HANG
667 */
668#define HANG_REASON_INDEX QCA_NL80211_VENDOR_SUBCMD_HANG_REASON_INDEX
669
670/**
671 * hdd_convert_hang_reason() - Convert cds recovery reason to vendor specific
672 * hang reason
673 * @reason: cds recovery reason
674 *
675 * Return: Vendor specific reason code
676 */
677static enum qca_wlan_vendor_hang_reason
678hdd_convert_hang_reason(enum vos_hang_reason reason)
679{
680 unsigned int ret_val;
681
682 switch (reason) {
683 case VOS_GET_MSG_BUFF_FAILURE:
684 ret_val = QCA_WLAN_HANG_GET_MSG_BUFF_FAILURE;
685 break;
686 case VOS_ACTIVE_LIST_TIMEOUT:
687 ret_val = QCA_WLAN_HANG_ACTIVE_LIST_TIMEOUT;
688 break;
689 case VOS_SCAN_REQ_EXPIRED:
690 ret_val = QCA_WLAN_HANG_SCAN_REQ_EXPIRED;
691 break;
692 case VOS_TRANSMISSIONS_TIMEOUT:
693 ret_val = QCA_WLAN_HANG_TRANSMISSIONS_TIMEOUT;
694 break;
695 case VOS_DXE_FAILURE:
696 ret_val = QCA_WLAN_HANG_DXE_FAILURE;
697 break;
698 case VOS_WDI_FAILURE:
699 ret_val = QCA_WLAN_HANG_WDI_FAILURE;
700 break;
701 case VOS_REASON_UNSPECIFIED:
702 default:
703 ret_val = QCA_WLAN_HANG_REASON_UNSPECIFIED;
704 }
705 return ret_val;
706}
707
708/**
709 * wlan_hdd_send_hang_reason_event() - Send hang reason to the userspace
710 * @hdd_ctx: Pointer to hdd context
711 * @reason: cds recovery reason
712 *
713 * Return: 0 on success or failure reason
714 */
715int wlan_hdd_send_hang_reason_event(hdd_context_t *hdd_ctx,
716 enum vos_hang_reason reason)
717{
718 struct sk_buff *vendor_event;
719 enum qca_wlan_vendor_hang_reason hang_reason;
720
721 ENTER();
722
723 if (!hdd_ctx) {
724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
725 "HDD context is null");
726 return -EINVAL;
727 }
728
729 vendor_event = cfg80211_vendor_event_alloc(hdd_ctx->wiphy,
730#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
731 NULL,
732#endif
733 sizeof(unsigned int),
734 HANG_REASON_INDEX,
735 GFP_KERNEL);
736 if (!vendor_event) {
737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
738 "cfg80211_vendor_event_alloc failed");
739 return -ENOMEM;
740 }
741
742 hang_reason = hdd_convert_hang_reason(reason);
743
744 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_HANG_REASON,
745 (unsigned int) hang_reason)) {
746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
747 "QCA_WLAN_VENDOR_ATTR_HANG_REASON put fail");
748 kfree_skb(vendor_event);
749 return -EINVAL;
750 }
751
752 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
753
754 EXIT();
755 return 0;
756}
757#undef HANG_REASON_INDEX
758
759/*
Srinivas Dasari030bad32015-02-18 23:23:54 +0530760 * FUNCTION: __wlan_hdd_cfg80211_nan_request
761 * This is called when wlan driver needs to send vendor specific
762 * nan request event.
763 */
764static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
765 struct wireless_dev *wdev,
766 const void *data, int data_len)
767{
768 tNanRequestReq nan_req;
769 VOS_STATUS status;
770 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530771 struct net_device *dev = wdev->netdev;
772 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
773 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530774 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
775
776 if (0 == data_len)
777 {
778 hddLog(VOS_TRACE_LEVEL_ERROR,
779 FL("NAN - Invalid Request, length = 0"));
780 return ret_val;
781 }
782
783 if (NULL == data)
784 {
785 hddLog(VOS_TRACE_LEVEL_ERROR,
786 FL("NAN - Invalid Request, data is NULL"));
787 return ret_val;
788 }
789
790 status = wlan_hdd_validate_context(pHddCtx);
791 if (0 != status)
792 {
793 hddLog(VOS_TRACE_LEVEL_ERROR,
794 FL("HDD context is not valid"));
795 return -EINVAL;
796 }
797
798 hddLog(LOG1, FL("Received NAN command"));
799 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
800 (tANI_U8 *)data, data_len);
801
802 /* check the NAN Capability */
803 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
804 {
805 hddLog(VOS_TRACE_LEVEL_ERROR,
806 FL("NAN is not supported by Firmware"));
807 return -EINVAL;
808 }
809
810 nan_req.request_data_len = data_len;
811 nan_req.request_data = data;
812
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530813 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530814 if (VOS_STATUS_SUCCESS == status)
815 {
816 ret_val = 0;
817 }
818 return ret_val;
819}
820
821/*
822 * FUNCTION: wlan_hdd_cfg80211_nan_request
823 * Wrapper to protect the nan vendor command from ssr
824 */
825static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
826 struct wireless_dev *wdev,
827 const void *data, int data_len)
828{
829 int ret;
830
831 vos_ssr_protect(__func__);
832 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
833 vos_ssr_unprotect(__func__);
834
835 return ret;
836}
837
838/*
839 * FUNCTION: wlan_hdd_cfg80211_nan_callback
840 * This is a callback function and it gets called
841 * when we need to report nan response event to
842 * upper layers.
843 */
844static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
845{
846 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
847 struct sk_buff *vendor_event;
848 int status;
849 tSirNanEvent *data;
850
851 ENTER();
852 if (NULL == msg)
853 {
854 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
855 FL(" msg received here is null"));
856 return;
857 }
858 data = msg;
859
860 status = wlan_hdd_validate_context(pHddCtx);
861
862 if (0 != status)
863 {
864 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
865 FL("HDD context is not valid"));
866 return;
867 }
868
869 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530870#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
871 NULL,
872#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530873 data->event_data_len +
874 NLMSG_HDRLEN,
875 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
876 GFP_KERNEL);
877
878 if (!vendor_event)
879 {
880 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
881 FL("cfg80211_vendor_event_alloc failed"));
882 return;
883 }
884 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
885 data->event_data_len, data->event_data))
886 {
887 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
888 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
889 kfree_skb(vendor_event);
890 return;
891 }
892 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
893 EXIT();
894}
895
896/*
897 * FUNCTION: wlan_hdd_cfg80211_nan_init
898 * This function is called to register the callback to sme layer
899 */
900inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
901{
902 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
903}
904
Anurag Chouhanfcd20172017-07-19 17:25:19 +0530905/*
906 * define short names for the global vendor params
907 * used by __wlan_hdd_cfg80211_get_station_cmd()
908 */
909#define STATION_INVALID \
910 QCA_WLAN_VENDOR_ATTR_GET_STATION_INVALID
911#define STATION_INFO \
912 QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO
913#define STATION_ASSOC_FAIL_REASON \
914 QCA_WLAN_VENDOR_ATTR_GET_STATION_ASSOC_FAIL_REASON
Hanumanth Reddy Pothulaa35c4872017-12-14 20:47:59 +0530915#define STATION_REMOTE \
916 QCA_WLAN_VENDOR_ATTR_GET_STATION_REMOTE
Anurag Chouhanfcd20172017-07-19 17:25:19 +0530917#define STATION_MAX \
918 QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX
919
920static const struct nla_policy
921hdd_get_station_policy[STATION_MAX + 1] = {
922 [STATION_INFO] = {.type = NLA_FLAG},
923 [STATION_ASSOC_FAIL_REASON] = {.type = NLA_FLAG},
924};
925
926/**
927 * hdd_get_station_assoc_fail() - Handle get station assoc fail
928 * @hdd_ctx: HDD context within host driver
929 * @wdev: wireless device
930 *
931 * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION_ASSOC_FAIL.
932 * Validate cmd attributes and send the station info to upper layers.
933 *
934 * Return: Success(0) or reason code for failure
935 */
936static int hdd_get_station_assoc_fail(hdd_context_t *hdd_ctx,
937 hdd_adapter_t *adapter)
938{
939 struct sk_buff *skb = NULL;
940 uint32_t nl_buf_len;
941 hdd_station_ctx_t *hdd_sta_ctx;
942
943 nl_buf_len = NLMSG_HDRLEN;
944 nl_buf_len += sizeof(uint32_t);
945 skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len);
946
947 if (!skb) {
948 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"cfg80211_vendor_cmd_alloc_reply_skb failed");
949 return -ENOMEM;
950 }
951
952 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
953
954 if (nla_put_u32(skb, INFO_ASSOC_FAIL_REASON,
955 hdd_sta_ctx->conn_info.assoc_status_code)) {
956 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
957 goto fail;
958 }
959 return cfg80211_vendor_cmd_reply(skb);
960fail:
961 if (skb)
962 kfree_skb(skb);
963 return -EINVAL;
964}
965
966/**
967 * hdd_map_auth_type() - transform auth type specific to
968 * vendor command
969 * @auth_type: csr auth type
970 *
971 * Return: Success(0) or reason code for failure
972 */
973static int hdd_convert_auth_type(uint32_t auth_type)
974{
975 uint32_t ret_val;
976
977 switch (auth_type) {
978 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
979 ret_val = QCA_WLAN_AUTH_TYPE_OPEN;
980 break;
981 case eCSR_AUTH_TYPE_SHARED_KEY:
982 ret_val = QCA_WLAN_AUTH_TYPE_SHARED;
983 break;
984 case eCSR_AUTH_TYPE_WPA:
985 ret_val = QCA_WLAN_AUTH_TYPE_WPA;
986 break;
987 case eCSR_AUTH_TYPE_WPA_PSK:
988 ret_val = QCA_WLAN_AUTH_TYPE_WPA_PSK;
989 break;
990 case eCSR_AUTH_TYPE_AUTOSWITCH:
991 ret_val = QCA_WLAN_AUTH_TYPE_AUTOSWITCH;
992 break;
993 case eCSR_AUTH_TYPE_WPA_NONE:
994 ret_val = QCA_WLAN_AUTH_TYPE_WPA_NONE;
995 break;
996 case eCSR_AUTH_TYPE_RSN:
997 ret_val = QCA_WLAN_AUTH_TYPE_RSN;
998 break;
999 case eCSR_AUTH_TYPE_RSN_PSK:
1000 ret_val = QCA_WLAN_AUTH_TYPE_RSN_PSK;
1001 break;
1002 case eCSR_AUTH_TYPE_FT_RSN:
1003 ret_val = QCA_WLAN_AUTH_TYPE_FT;
1004 break;
1005 case eCSR_AUTH_TYPE_FT_RSN_PSK:
1006 ret_val = QCA_WLAN_AUTH_TYPE_FT_PSK;
1007 break;
1008 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
1009 ret_val = QCA_WLAN_AUTH_TYPE_WAI;
1010 break;
1011 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
1012 ret_val = QCA_WLAN_AUTH_TYPE_WAI_PSK;
1013 break;
1014#ifdef FEATURE_WLAN_ESE
1015 case eCSR_AUTH_TYPE_CCKM_WPA:
1016 ret_val = QCA_WLAN_AUTH_TYPE_CCKM_WPA;
1017 break;
1018 case eCSR_AUTH_TYPE_CCKM_RSN:
1019 ret_val = QCA_WLAN_AUTH_TYPE_CCKM_RSN;
1020 break;
1021#endif
1022 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
1023 ret_val = QCA_WLAN_AUTH_TYPE_SHA256_PSK;
1024 break;
1025 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
1026 ret_val = QCA_WLAN_AUTH_TYPE_SHA256;
1027 break;
1028 case eCSR_NUM_OF_SUPPORT_AUTH_TYPE:
1029 case eCSR_AUTH_TYPE_FAILED:
1030 case eCSR_AUTH_TYPE_NONE:
1031 default:
1032 ret_val = QCA_WLAN_AUTH_TYPE_INVALID;
1033 break;
1034 }
1035 return ret_val;
1036}
1037
1038/**
1039 * hdd_map_dot_11_mode() - transform dot11mode type specific to
1040 * vendor command
1041 * @dot11mode: dot11mode
1042 *
1043 * Return: Success(0) or reason code for failure
1044 */
1045static int hdd_convert_dot11mode(uint32_t dot11mode)
1046{
1047 uint32_t ret_val;
1048
1049 switch (dot11mode) {
1050 case eCSR_CFG_DOT11_MODE_11A:
1051 ret_val = QCA_WLAN_802_11_MODE_11A;
1052 break;
1053 case eCSR_CFG_DOT11_MODE_11B:
1054 ret_val = QCA_WLAN_802_11_MODE_11B;
1055 break;
1056 case eCSR_CFG_DOT11_MODE_11G:
1057 ret_val = QCA_WLAN_802_11_MODE_11G;
1058 break;
1059 case eCSR_CFG_DOT11_MODE_11N:
1060 ret_val = QCA_WLAN_802_11_MODE_11N;
1061 break;
1062 case eCSR_CFG_DOT11_MODE_11AC:
1063 ret_val = QCA_WLAN_802_11_MODE_11AC;
1064 break;
1065 case eCSR_CFG_DOT11_MODE_AUTO:
1066 case eCSR_CFG_DOT11_MODE_ABG:
1067 default:
1068 ret_val = QCA_WLAN_802_11_MODE_INVALID;
1069 }
1070 return ret_val;
1071}
1072
1073/**
1074 * hdd_add_tx_bitrate() - add tx bitrate attribute
1075 * @skb: pointer to sk buff
1076 * @hdd_sta_ctx: pointer to hdd station context
1077 * @idx: attribute index
1078 *
1079 * Return: Success(0) or reason code for failure
1080 */
1081static int32_t hdd_add_tx_bitrate(struct sk_buff *skb,
1082 hdd_station_ctx_t *hdd_sta_ctx,
1083 int idx)
1084{
1085 struct nlattr *nla_attr;
1086 uint32_t bitrate, bitrate_compat;
1087
1088 nla_attr = nla_nest_start(skb, idx);
1089 if (!nla_attr)
1090 goto fail;
1091 /* cfg80211_calculate_bitrate will return 0 for mcs >= 32 */
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301092 bitrate = cfg80211_calculate_bitrate(
1093 &hdd_sta_ctx->cache_conn_info.txrate);
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301094
1095 /* report 16-bit bitrate only if we can */
1096 bitrate_compat = bitrate < (1UL << 16) ? bitrate : 0;
1097 if (bitrate > 0 &&
1098 nla_put_u32(skb, NL80211_RATE_INFO_BITRATE32, bitrate)) {
1099 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1100 goto fail;
1101 }
1102 if (bitrate_compat > 0 &&
1103 nla_put_u16(skb, NL80211_RATE_INFO_BITRATE, bitrate_compat)) {
1104 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1105 goto fail;
1106 }
1107 if (nla_put_u8(skb, NL80211_RATE_INFO_VHT_NSS,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301108 hdd_sta_ctx->cache_conn_info.txrate.nss)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301109 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1110 goto fail;
1111 }
1112 nla_nest_end(skb, nla_attr);
1113 return 0;
1114fail:
1115 return -EINVAL;
1116}
1117
1118/**
1119 * hdd_add_sta_info() - add station info attribute
1120 * @skb: pointer to sk buff
1121 * @hdd_sta_ctx: pointer to hdd station context
1122 * @idx: attribute index
1123 *
1124 * Return: Success(0) or reason code for failure
1125 */
1126static int32_t hdd_add_sta_info(struct sk_buff *skb,
1127 hdd_station_ctx_t *hdd_sta_ctx, int idx)
1128{
1129 struct nlattr *nla_attr;
1130
1131 nla_attr = nla_nest_start(skb, idx);
1132 if (!nla_attr)
1133 goto fail;
1134 if (nla_put_u8(skb, NL80211_STA_INFO_SIGNAL,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301135 (hdd_sta_ctx->cache_conn_info.signal + 100))) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301136 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1137 goto fail;
1138 }
1139 if (hdd_add_tx_bitrate(skb, hdd_sta_ctx, NL80211_STA_INFO_TX_BITRATE))
1140 goto fail;
1141 nla_nest_end(skb, nla_attr);
1142 return 0;
1143fail:
1144 return -EINVAL;
1145}
1146
1147/**
1148 * hdd_add_survey_info() - add survey info attribute
1149 * @skb: pointer to sk buff
1150 * @hdd_sta_ctx: pointer to hdd station context
1151 * @idx: attribute index
1152 *
1153 * Return: Success(0) or reason code for failure
1154 */
1155static int32_t hdd_add_survey_info(struct sk_buff *skb,
1156 hdd_station_ctx_t *hdd_sta_ctx,
1157 int idx)
1158{
1159 struct nlattr *nla_attr;
1160
1161 nla_attr = nla_nest_start(skb, idx);
1162 if (!nla_attr)
1163 goto fail;
1164 if (nla_put_u32(skb, NL80211_SURVEY_INFO_FREQUENCY,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301165 hdd_sta_ctx->cache_conn_info.freq) ||
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301166 nla_put_u8(skb, NL80211_SURVEY_INFO_NOISE,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301167 (hdd_sta_ctx->cache_conn_info.noise + 100))) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301168 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1169 goto fail;
1170 }
1171 nla_nest_end(skb, nla_attr);
1172 return 0;
1173fail:
1174 return -EINVAL;
1175}
1176
1177/**
1178 * hdd_add_link_standard_info() - add link info attribute
1179 * @skb: pointer to sk buff
1180 * @hdd_sta_ctx: pointer to hdd station context
1181 * @idx: attribute index
1182 *
1183 * Return: Success(0) or reason code for failure
1184 */
1185static int32_t
1186hdd_add_link_standard_info(struct sk_buff *skb,
1187 hdd_station_ctx_t *hdd_sta_ctx, int idx)
1188{
1189 struct nlattr *nla_attr;
1190
1191 nla_attr = nla_nest_start(skb, idx);
1192 if (!nla_attr)
1193 goto fail;
1194 if (nla_put(skb,
1195 NL80211_ATTR_SSID,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301196 hdd_sta_ctx->cache_conn_info.SSID.SSID.length,
1197 hdd_sta_ctx->cache_conn_info.SSID.SSID.ssId)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301198 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1199 goto fail;
1200 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301201 if (nla_put(skb, NL80211_ATTR_MAC, VOS_MAC_ADDR_SIZE,
1202 hdd_sta_ctx->cache_conn_info.bssId))
1203 goto fail;
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301204 if (hdd_add_survey_info(skb, hdd_sta_ctx, NL80211_ATTR_SURVEY_INFO))
1205 goto fail;
1206 if (hdd_add_sta_info(skb, hdd_sta_ctx, NL80211_ATTR_STA_INFO))
1207 goto fail;
1208 nla_nest_end(skb, nla_attr);
1209 return 0;
1210fail:
1211 return -EINVAL;
1212}
1213
1214/**
1215 * hdd_add_ap_standard_info() - add ap info attribute
1216 * @skb: pointer to sk buff
1217 * @hdd_sta_ctx: pointer to hdd station context
1218 * @idx: attribute index
1219 *
1220 * Return: Success(0) or reason code for failure
1221 */
1222static int32_t
1223hdd_add_ap_standard_info(struct sk_buff *skb,
1224 hdd_station_ctx_t *hdd_sta_ctx, int idx)
1225{
1226 struct nlattr *nla_attr;
1227
1228 nla_attr = nla_nest_start(skb, idx);
1229 if (!nla_attr)
1230 goto fail;
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301231 if (hdd_sta_ctx->cache_conn_info.conn_flag.vht_present)
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301232 if (nla_put(skb, NL80211_ATTR_VHT_CAPABILITY,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301233 sizeof(hdd_sta_ctx->cache_conn_info.vht_caps),
1234 &hdd_sta_ctx->cache_conn_info.vht_caps)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301235 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1236 goto fail;
1237 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301238 if (hdd_sta_ctx->cache_conn_info.conn_flag.ht_present)
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301239 if (nla_put(skb, NL80211_ATTR_HT_CAPABILITY,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301240 sizeof(hdd_sta_ctx->cache_conn_info.ht_caps),
1241 &hdd_sta_ctx->cache_conn_info.ht_caps)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301242 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1243 goto fail;
1244 }
1245 nla_nest_end(skb, nla_attr);
1246 return 0;
1247fail:
1248 return -EINVAL;
1249}
1250
1251/**
1252 * hdd_get_station_info() - send BSS information to supplicant
1253 * @hdd_ctx: pointer to hdd context
1254 * @adapter: pointer to adapter
1255 *
1256 * Return: 0 if success else error status
1257 */
1258static int hdd_get_station_info(hdd_context_t *hdd_ctx,
1259 hdd_adapter_t *adapter)
1260{
1261 struct sk_buff *skb = NULL;
1262 uint8_t *tmp_hs20 = NULL;
1263 uint32_t nl_buf_len;
1264 hdd_station_ctx_t *hdd_sta_ctx;
1265
1266 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1267
1268 nl_buf_len = NLMSG_HDRLEN;
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301269
1270 nl_buf_len += sizeof(hdd_sta_ctx->cache_conn_info.SSID.SSID.length) +
1271 VOS_MAC_ADDR_SIZE +
1272 sizeof(hdd_sta_ctx->cache_conn_info.freq) +
1273 sizeof(hdd_sta_ctx->cache_conn_info.noise) +
1274 sizeof(hdd_sta_ctx->cache_conn_info.signal) +
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301275 (sizeof(uint32_t) * 2) +
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301276 sizeof(hdd_sta_ctx->cache_conn_info.txrate.nss) +
1277 sizeof(hdd_sta_ctx->cache_conn_info.roam_count) +
1278 sizeof(hdd_sta_ctx->cache_conn_info.authType) +
1279 sizeof(hdd_sta_ctx->cache_conn_info.dot11Mode);
1280 if (hdd_sta_ctx->cache_conn_info.conn_flag.vht_present)
1281 nl_buf_len += sizeof(hdd_sta_ctx->cache_conn_info.vht_caps);
1282 if (hdd_sta_ctx->cache_conn_info.conn_flag.ht_present)
1283 nl_buf_len += sizeof(hdd_sta_ctx->cache_conn_info.ht_caps);
1284 if (hdd_sta_ctx->cache_conn_info.conn_flag.hs20_present) {
1285 tmp_hs20 = (uint8_t *)&(hdd_sta_ctx->
1286 cache_conn_info.hs20vendor_ie);
1287 nl_buf_len +=
1288 (sizeof(hdd_sta_ctx->cache_conn_info.hs20vendor_ie) -
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301289 1);
1290 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301291 if (hdd_sta_ctx->cache_conn_info.conn_flag.ht_op_present)
1292 nl_buf_len += sizeof(hdd_sta_ctx->cache_conn_info.ht_operation);
1293 if (hdd_sta_ctx->cache_conn_info.conn_flag.vht_op_present)
1294 nl_buf_len +=
1295 sizeof(hdd_sta_ctx->cache_conn_info.vht_operation);
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301296
1297
1298 skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len);
1299 if (!skb) {
1300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: %d cfg80211_vendor_cmd_alloc_reply_skb failed",
1301 __func__, __LINE__);
1302 return -ENOMEM;
1303 }
1304
1305 if (hdd_add_link_standard_info(skb, hdd_sta_ctx,
1306 LINK_INFO_STANDARD_NL80211_ATTR)) {
1307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1308 goto fail;
1309 }
1310 if (hdd_add_ap_standard_info(skb, hdd_sta_ctx,
1311 AP_INFO_STANDARD_NL80211_ATTR)) {
1312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1313 goto fail;
1314 }
1315 if (nla_put_u32(skb, INFO_ROAM_COUNT,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301316 hdd_sta_ctx->cache_conn_info.roam_count) ||
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301317 nla_put_u32(skb, INFO_AKM,
1318 hdd_convert_auth_type(
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301319 hdd_sta_ctx->cache_conn_info.authType)) ||
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301320 nla_put_u32(skb, WLAN802_11_MODE,
1321 hdd_convert_dot11mode(
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301322 hdd_sta_ctx->cache_conn_info.dot11Mode))) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1324 goto fail;
1325 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301326 if (hdd_sta_ctx->cache_conn_info.conn_flag.ht_op_present)
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301327 if (nla_put(skb, HT_OPERATION,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301328 (sizeof(hdd_sta_ctx->cache_conn_info.ht_operation)),
1329 &hdd_sta_ctx->cache_conn_info.ht_operation)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1331 goto fail;
1332 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301333 if (hdd_sta_ctx->cache_conn_info.conn_flag.vht_op_present)
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301334 if (nla_put(skb, VHT_OPERATION,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301335 (sizeof(hdd_sta_ctx->
1336 cache_conn_info.vht_operation)),
1337 &hdd_sta_ctx->cache_conn_info.vht_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.hs20_present)
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301342 if (nla_put(skb, AP_INFO_HS20_INDICATION,
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +05301343 (sizeof(hdd_sta_ctx->cache_conn_info.hs20vendor_ie)
1344 - 1), tmp_hs20 + 1)) {
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"put fail");
1346 goto fail;
1347 }
1348
1349 return cfg80211_vendor_cmd_reply(skb);
1350fail:
1351 if (skb)
1352 kfree_skb(skb);
1353 return -EINVAL;
1354}
1355
1356/**
Hanumanth Reddy Pothulaa35c4872017-12-14 20:47:59 +05301357 * hdd_add_survey_info_sap_get_len - get data length used in
1358 * hdd_add_survey_info_sap()
1359 *
1360 * This function calculates the data length used in hdd_add_survey_info_sap()
1361 *
1362 * Return: total data length used in hdd_add_survey_info_sap()
1363 */
1364static uint32_t hdd_add_survey_info_sap_get_len(void)
1365{
1366 return ((NLA_HDRLEN) + (sizeof(uint32_t) + NLA_HDRLEN));
1367}
1368
1369/**
1370 * hdd_add_survey_info - add survey info attribute
1371 * @skb: pointer to response skb buffer
1372 * @stainfo: station information
1373 * @idx: attribute type index for nla_next_start()
1374 *
1375 * This function adds survey info attribute to response skb buffer
1376 *
1377 * Return : 0 on success and errno on failure
1378 */
1379static int32_t hdd_add_survey_info_sap(struct sk_buff *skb,
1380 struct hdd_cache_sta_info *stainfo,
1381 int idx)
1382{
1383 struct nlattr *nla_attr;
1384
1385 nla_attr = nla_nest_start(skb, idx);
1386 if (!nla_attr)
1387 goto fail;
1388 if (nla_put_u32(skb, NL80211_SURVEY_INFO_FREQUENCY,
1389 stainfo->freq)) {
1390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1391 FL("put fail"));
1392 goto fail;
1393 }
1394 nla_nest_end(skb, nla_attr);
1395 return 0;
1396fail:
1397 return -EINVAL;
1398}
1399
1400/**
1401 * hdd_add_tx_bitrate_sap_get_len - get data length used in
1402 * hdd_add_tx_bitrate_sap()
1403 *
1404 * This function calculates the data length used in hdd_add_tx_bitrate_sap()
1405 *
1406 * Return: total data length used in hdd_add_tx_bitrate_sap()
1407 */
1408static uint32_t hdd_add_tx_bitrate_sap_get_len(void)
1409{
1410 return ((NLA_HDRLEN) + (sizeof(uint8_t) + NLA_HDRLEN));
1411}
1412
1413/**
1414 * hdd_add_tx_bitrate_sap - add vht nss info attribute
1415 * @skb: pointer to response skb buffer
1416 * @stainfo: station information
1417 * @idx: attribute type index for nla_next_start()
1418 *
1419 * This function adds vht nss attribute to response skb buffer
1420 *
1421 * Return : 0 on success and errno on failure
1422 */
1423static int hdd_add_tx_bitrate_sap(struct sk_buff *skb,
1424 struct hdd_cache_sta_info *stainfo,
1425 int idx)
1426{
1427 struct nlattr *nla_attr;
1428
1429 nla_attr = nla_nest_start(skb, idx);
1430 if (!nla_attr)
1431 goto fail;
1432
1433 if (nla_put_u8(skb, NL80211_RATE_INFO_VHT_NSS,
1434 stainfo->nss)) {
1435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1436 FL("put fail"));
1437 goto fail;
1438 }
1439 nla_nest_end(skb, nla_attr);
1440 return 0;
1441fail:
1442 return -EINVAL;
1443}
1444
1445/**
1446 * hdd_add_sta_info_sap_get_len - get data length used in
1447 * hdd_add_sta_info_sap()
1448 *
1449 * This function calculates the data length used in hdd_add_sta_info_sap()
1450 *
1451 * Return: total data length used in hdd_add_sta_info_sap()
1452 */
1453static uint32_t hdd_add_sta_info_sap_get_len(void)
1454{
1455 return ((NLA_HDRLEN) + (sizeof(uint8_t) + NLA_HDRLEN) +
1456 hdd_add_tx_bitrate_sap_get_len());
1457}
1458
1459/**
1460 * hdd_add_sta_info_sap - add sta signal info attribute
1461 * @skb: pointer to response skb buffer
1462 * @rssi: peer rssi value
1463 * @stainfo: station information
1464 * @idx: attribute type index for nla_next_start()
1465 *
1466 * This function adds sta signal attribute to response skb buffer
1467 *
1468 * Return : 0 on success and errno on failure
1469 */
1470static int32_t hdd_add_sta_info_sap(struct sk_buff *skb, int8_t rssi,
1471 struct hdd_cache_sta_info *stainfo, int idx)
1472{
1473 struct nlattr *nla_attr;
1474
1475 nla_attr = nla_nest_start(skb, idx);
1476 if (!nla_attr)
1477 goto fail;
1478
Hanumanth Reddy Pothula14bc86d2018-01-02 20:02:02 +05301479 /* upperlayer expects positive rssi value */
1480 if (nla_put_u8(skb, NL80211_STA_INFO_SIGNAL, (rssi + 96))) {
Hanumanth Reddy Pothulaa35c4872017-12-14 20:47:59 +05301481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1482 FL("put fail"));
1483 goto fail;
1484 }
1485 if (hdd_add_tx_bitrate_sap(skb, stainfo, NL80211_STA_INFO_TX_BITRATE)) {
1486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1487 FL("put fail"));
1488 goto fail;
1489 }
1490
1491 nla_nest_end(skb, nla_attr);
1492 return 0;
1493fail:
1494 return -EINVAL;
1495}
1496
1497/**
1498 * hdd_add_link_standard_info_sap_get_len - get data length used in
1499 * hdd_add_link_standard_info_sap()
1500 *
1501 * This function calculates the data length used in
1502 * hdd_add_link_standard_info_sap()
1503 *
1504 * Return: total data length used in hdd_add_link_standard_info_sap()
1505 */
1506static uint32_t hdd_add_link_standard_info_sap_get_len(void)
1507{
1508 return ((NLA_HDRLEN) +
1509 hdd_add_survey_info_sap_get_len() +
1510 hdd_add_sta_info_sap_get_len() +
1511 (sizeof(uint32_t) + NLA_HDRLEN));
1512}
1513
1514/**
1515 * hdd_add_link_standard_info_sap - add add link info attribut
1516 * @skb: pointer to response skb buffer
1517 * @stainfo: station information
1518 * @idx: attribute type index for nla_next_start()
1519 *
1520 * This function adds link info attribut to response skb buffer
1521 *
1522 * Return : 0 on success and errno on failure
1523 */
1524static int hdd_add_link_standard_info_sap(struct sk_buff *skb, int8_t rssi,
1525 struct hdd_cache_sta_info *stainfo,
1526 int idx)
1527{
1528 struct nlattr *nla_attr;
1529
1530 nla_attr = nla_nest_start(skb, idx);
1531 if (!nla_attr)
1532 goto fail;
1533 if (hdd_add_survey_info_sap(skb, stainfo, NL80211_ATTR_SURVEY_INFO))
1534 goto fail;
1535 if (hdd_add_sta_info_sap(skb, rssi, stainfo, NL80211_ATTR_STA_INFO))
1536 goto fail;
1537
1538 if (nla_put_u32(skb, NL80211_ATTR_REASON_CODE, stainfo->reason_code)) {
1539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1540 FL("put fail"));
1541 goto fail;
1542 }
1543
1544 nla_nest_end(skb, nla_attr);
1545 return 0;
1546fail:
1547 return -EINVAL;
1548}
1549
1550/**
1551 * hdd_add_ap_standard_info_sap_get_len - get data length used in
1552 * hdd_add_ap_standard_info_sap()
1553 * @stainfo: station information
1554 *
1555 * This function calculates the data length used in
1556 * hdd_add_ap_standard_info_sap()
1557 *
1558 * Return: total data length used in hdd_add_ap_standard_info_sap()
1559 */
1560static uint32_t hdd_add_ap_standard_info_sap_get_len(
1561 struct hdd_cache_sta_info *stainfo)
1562{
1563 uint32_t len;
1564
1565 len = NLA_HDRLEN;
1566 if (stainfo->vht_present)
1567 len += (sizeof(stainfo->vht_caps) + NLA_HDRLEN);
1568 if (stainfo->ht_present)
1569 len += (sizeof(stainfo->ht_caps) + NLA_HDRLEN);
1570
1571 return len;
1572}
1573
1574/**
1575 * hdd_add_ap_standard_info_sap - add HT and VHT info attributes
1576 * @skb: pointer to response skb buffer
1577 * @stainfo: station information
1578 * @idx: attribute type index for nla_next_start()
1579 *
1580 * This function adds HT and VHT info attributes to response skb buffer
1581 *
1582 * Return : 0 on success and errno on failure
1583 */
1584static int hdd_add_ap_standard_info_sap(struct sk_buff *skb,
1585 struct hdd_cache_sta_info *stainfo,
1586 int idx)
1587{
1588 struct nlattr *nla_attr;
1589
1590 nla_attr = nla_nest_start(skb, idx);
1591 if (!nla_attr)
1592 goto fail;
1593
1594 if (stainfo->vht_present) {
1595 if (nla_put(skb, NL80211_ATTR_VHT_CAPABILITY,
1596 sizeof(stainfo->vht_caps),
1597 &stainfo->vht_caps)) {
1598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1599 FL("put fail"));
1600 goto fail;
1601 }
1602 }
1603 if (stainfo->ht_present) {
1604 if (nla_put(skb, NL80211_ATTR_HT_CAPABILITY,
1605 sizeof(stainfo->ht_caps),
1606 &stainfo->ht_caps)) {
1607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1608 FL("put fail"));
1609 goto fail;
1610 }
1611 }
1612 nla_nest_end(skb, nla_attr);
1613 return 0;
1614fail:
1615 return -EINVAL;
1616}
1617
1618/**
1619 * hdd_decode_ch_width - decode channel band width based
1620 * @ch_width: encoded enum value holding channel band width
1621 *
1622 * This function decodes channel band width from the given encoded enum value.
1623 *
1624 * Returns: decoded channel band width.
1625 */
1626static uint8_t hdd_decode_ch_width(tSirMacHTChannelWidth ch_width)
1627{
1628 switch (ch_width) {
1629 case 0:
1630 return 20;
1631 case 1:
1632 return 40;
1633 case 2:
1634 return 80;
1635 default:
1636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1637 "invalid enum: %d", ch_width);
1638 return 20;
1639 }
1640}
1641
1642/**
1643 * hdd_get_cached_station_remote() - get cached(deleted) peer's info
1644 * @hdd_ctx: hdd context
1645 * @adapter: hostapd interface
1646 * @mac_addr: mac address of requested peer
1647 *
1648 * This function collect and indicate the cached(deleted) peer's info
1649 *
1650 * Return: 0 on success, otherwise error value
1651 */
1652static int hdd_get_cached_station_remote(hdd_context_t *hdd_ctx,
1653 hdd_adapter_t *adapter,
1654 v_MACADDR_t mac_addr)
1655{
1656 struct hdd_cache_sta_info *stainfo;
1657 struct sk_buff *skb = NULL;
1658 uint32_t nl_buf_len;
1659 uint8_t cw;
1660 ptSapContext sap_ctx;
1661 v_CONTEXT_t vos_ctx = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
1662
1663 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
1664 if(sap_ctx == NULL){
1665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1666 FL("psapCtx is NULL"));
1667 return -ENOENT;
1668 }
1669
1670 stainfo = hdd_get_cache_stainfo(sap_ctx->cache_sta_info,
1671 mac_addr.bytes);
1672 if (!stainfo) {
1673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1674 "peer " MAC_ADDRESS_STR " not found",
1675 MAC_ADDR_ARRAY(mac_addr.bytes));
1676 return -EINVAL;
1677 }
1678 if (sap_ctx->aStaInfo[stainfo->ucSTAId].isUsed == TRUE) {
1679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1680 "peer " MAC_ADDRESS_STR " is in connected state",
1681 MAC_ADDR_ARRAY(mac_addr.bytes));
1682 return -EINVAL;
1683 }
1684
1685
1686 nl_buf_len = NLMSG_HDRLEN + hdd_add_link_standard_info_sap_get_len() +
1687 hdd_add_ap_standard_info_sap_get_len(stainfo) +
1688 (sizeof(stainfo->dot11_mode) + NLA_HDRLEN) +
1689 (sizeof(cw) + NLA_HDRLEN) +
1690 (sizeof(stainfo->rx_rate) + NLA_HDRLEN);
1691
1692 skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len);
1693 if (!skb) {
1694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "cfg80211_vendor_cmd_alloc_reply_skb failed");
1695 return -ENOMEM;
1696 }
1697
1698 if (hdd_add_link_standard_info_sap(skb, stainfo->rssi, stainfo,
1699 LINK_INFO_STANDARD_NL80211_ATTR)) {
1700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "link standard put fail");
1701 goto fail;
1702 }
1703
1704 if (hdd_add_ap_standard_info_sap(skb, stainfo,
1705 AP_INFO_STANDARD_NL80211_ATTR)) {
1706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ap standard put fail");
1707 goto fail;
1708 }
1709
1710 /* upper layer expects decoded channel BW */
1711 cw = hdd_decode_ch_width(stainfo->ch_width);
1712 if (nla_put_u32(skb, REMOTE_SUPPORTED_MODE, stainfo->dot11_mode) ||
1713 nla_put_u8(skb, REMOTE_CH_WIDTH, cw)) {
1714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "remote ch put fail");
1715 goto fail;
1716 }
Hanumanth Reddy Pothula504fe152018-01-02 20:41:03 +05301717 if (nla_put_u32(skb, REMOTE_LAST_RX_RATE, (stainfo->rx_rate * 100))) {
Hanumanth Reddy Pothulaa35c4872017-12-14 20:47:59 +05301718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "rx rate put fail");
1719 goto fail;
1720 }
1721
1722 vos_mem_zero(stainfo, sizeof(*stainfo));
1723
1724 return cfg80211_vendor_cmd_reply(skb);
1725fail:
1726 if (skb)
1727 kfree_skb(skb);
1728
1729 return -EINVAL;
1730}
1731
1732/**
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301733 * __hdd_cfg80211_get_station_cmd() - Handle get station vendor cmd
1734 * @wiphy: corestack handler
1735 * @wdev: wireless device
1736 * @data: data
1737 * @data_len: data length
1738 *
1739 * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION.
1740 * Validate cmd attributes and send the station info to upper layers.
1741 *
1742 * Return: Success(0) or reason code for failure
1743 */
1744static int32_t
1745__hdd_cfg80211_get_station_cmd(struct wiphy *wiphy,
1746 struct wireless_dev *wdev,
1747 const void *data,
1748 int data_len)
1749{
1750 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
1751 struct net_device *dev = wdev->netdev;
1752 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1753 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX + 1];
1754 int32_t status;
1755
1756 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"Enter");
1757 if (VOS_FTM_MODE == hdd_get_conparam()) {
1758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"Command not allowed in FTM mode");
1759 status = -EPERM;
1760 goto out;
1761 }
1762
1763 status = wlan_hdd_validate_context(hdd_ctx);
1764 if (0 != status)
1765 goto out;
1766
1767
1768 status = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX,
1769 data, data_len, NULL);
1770 if (status) {
1771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"Invalid ATTR");
1772 goto out;
1773 }
1774
1775 /* Parse and fetch Command Type*/
1776 if (tb[STATION_INFO]) {
1777 status = hdd_get_station_info(hdd_ctx, adapter);
1778 } else if (tb[STATION_ASSOC_FAIL_REASON]) {
1779 status = hdd_get_station_assoc_fail(hdd_ctx, adapter);
Hanumanth Reddy Pothulaa35c4872017-12-14 20:47:59 +05301780 } else if (tb[STATION_REMOTE]) {
1781 v_MACADDR_t mac_addr;
1782
1783 if (adapter->device_mode != WLAN_HDD_SOFTAP &&
1784 adapter->device_mode != WLAN_HDD_P2P_GO) {
1785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"invalid device_mode:%d",
1786 adapter->device_mode);
1787 status = -EINVAL;
1788 goto out;
1789 }
1790
1791 nla_memcpy(mac_addr.bytes, tb[STATION_REMOTE],
1792 VOS_MAC_ADDRESS_LEN);
1793
1794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "STATION_REMOTE "MAC_ADDRESS_STR"",
1795 MAC_ADDR_ARRAY(mac_addr.bytes));
1796
1797 status = hdd_get_cached_station_remote(hdd_ctx, adapter,
1798 mac_addr);
Anurag Chouhanfcd20172017-07-19 17:25:19 +05301799 } else {
1800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"get station info cmd type failed");
1801 status = -EINVAL;
1802 goto out;
1803 }
1804 EXIT();
1805out:
1806 return status;
1807}
1808
1809/**
1810 * wlan_hdd_cfg80211_get_station_cmd() - Handle get station vendor cmd
1811 * @wiphy: corestack handler
1812 * @wdev: wireless device
1813 * @data: data
1814 * @data_len: data length
1815 *
1816 * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION.
1817 * Validate cmd attributes and send the station info to upper layers.
1818 *
1819 * Return: Success(0) or reason code for failure
1820 */
1821static int32_t
1822hdd_cfg80211_get_station_cmd(struct wiphy *wiphy,
1823 struct wireless_dev *wdev,
1824 const void *data,
1825 int data_len)
1826{
1827 int ret;
1828
1829 vos_ssr_protect(__func__);
1830 ret = __hdd_cfg80211_get_station_cmd(wiphy, wdev, data, data_len);
1831 vos_ssr_unprotect(__func__);
1832
1833 return ret;
1834}
1835
1836/*
1837 * undef short names defined for get station command
1838 * used by __wlan_hdd_cfg80211_get_station_cmd()
1839 */
1840#undef STATION_INVALID
1841#undef STATION_INFO
1842#undef STATION_ASSOC_FAIL_REASON
1843#undef STATION_MAX
Srinivas Dasari030bad32015-02-18 23:23:54 +05301844
Sunil Duttc69bccb2014-05-26 21:30:20 +05301845#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1846
1847static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
1848 struct sk_buff *vendor_event)
1849{
1850 if (nla_put_u8(vendor_event,
1851 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
1852 stats->rate.preamble) ||
1853 nla_put_u8(vendor_event,
1854 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
1855 stats->rate.nss) ||
1856 nla_put_u8(vendor_event,
1857 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
1858 stats->rate.bw) ||
1859 nla_put_u8(vendor_event,
1860 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
1861 stats->rate.rateMcsIdx) ||
1862 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
1863 stats->rate.bitrate ) ||
1864 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
1865 stats->txMpdu ) ||
1866 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
1867 stats->rxMpdu ) ||
1868 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
1869 stats->mpduLost ) ||
1870 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
1871 stats->retries) ||
1872 nla_put_u32(vendor_event,
1873 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
1874 stats->retriesShort ) ||
1875 nla_put_u32(vendor_event,
1876 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
1877 stats->retriesLong))
1878 {
1879 hddLog(VOS_TRACE_LEVEL_ERROR,
1880 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1881 return FALSE;
1882 }
1883 return TRUE;
1884}
1885
1886static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
1887 struct sk_buff *vendor_event)
1888{
1889 u32 i = 0;
1890 struct nlattr *rateInfo;
1891 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
1892 stats->type) ||
1893 nla_put(vendor_event,
1894 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
1895 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
1896 nla_put_u32(vendor_event,
1897 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
1898 stats->capabilities) ||
1899 nla_put_u32(vendor_event,
1900 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
1901 stats->numRate))
1902 {
1903 hddLog(VOS_TRACE_LEVEL_ERROR,
1904 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1905 goto error;
1906 }
1907
1908 rateInfo = nla_nest_start(vendor_event,
1909 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301910 if(!rateInfo)
1911 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301912 for (i = 0; i < stats->numRate; i++)
1913 {
1914 struct nlattr *rates;
1915 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
1916 stats->rateStats +
1917 (i * sizeof(tSirWifiRateStat)));
1918 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301919 if(!rates)
1920 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301921
1922 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
1923 {
1924 hddLog(VOS_TRACE_LEVEL_ERROR,
1925 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1926 return FALSE;
1927 }
1928 nla_nest_end(vendor_event, rates);
1929 }
1930 nla_nest_end(vendor_event, rateInfo);
1931
1932 return TRUE;
1933error:
1934 return FALSE;
1935}
1936
1937static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
1938 struct sk_buff *vendor_event)
1939{
1940 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
1941 stats->ac ) ||
1942 nla_put_u32(vendor_event,
1943 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
1944 stats->txMpdu ) ||
1945 nla_put_u32(vendor_event,
1946 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
1947 stats->rxMpdu ) ||
1948 nla_put_u32(vendor_event,
1949 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
1950 stats->txMcast ) ||
1951 nla_put_u32(vendor_event,
1952 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
1953 stats->rxMcast ) ||
1954 nla_put_u32(vendor_event,
1955 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
1956 stats->rxAmpdu ) ||
1957 nla_put_u32(vendor_event,
1958 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
1959 stats->txAmpdu ) ||
1960 nla_put_u32(vendor_event,
1961 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
1962 stats->mpduLost )||
1963 nla_put_u32(vendor_event,
1964 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
1965 stats->retries ) ||
1966 nla_put_u32(vendor_event,
1967 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
1968 stats->retriesShort ) ||
1969 nla_put_u32(vendor_event,
1970 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
1971 stats->retriesLong ) ||
1972 nla_put_u32(vendor_event,
1973 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
1974 stats->contentionTimeMin ) ||
1975 nla_put_u32(vendor_event,
1976 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
1977 stats->contentionTimeMax ) ||
1978 nla_put_u32(vendor_event,
1979 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
1980 stats->contentionTimeAvg ) ||
1981 nla_put_u32(vendor_event,
1982 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
1983 stats->contentionNumSamples ))
1984 {
1985 hddLog(VOS_TRACE_LEVEL_ERROR,
1986 FL("QCA_WLAN_VENDOR_ATTR put fail") );
1987 return FALSE;
1988 }
1989 return TRUE;
1990}
1991
1992static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
1993 struct sk_buff *vendor_event)
1994{
Dino Myclec8f3f332014-07-21 16:48:27 +05301995 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301996 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
1997 nla_put(vendor_event,
1998 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
1999 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
2000 nla_put_u32(vendor_event,
2001 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
2002 stats->state ) ||
2003 nla_put_u32(vendor_event,
2004 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
2005 stats->roaming ) ||
2006 nla_put_u32(vendor_event,
2007 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
2008 stats->capabilities ) ||
2009 nla_put(vendor_event,
2010 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
2011 strlen(stats->ssid), stats->ssid) ||
2012 nla_put(vendor_event,
2013 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
2014 WNI_CFG_BSSID_LEN, stats->bssid) ||
2015 nla_put(vendor_event,
2016 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
2017 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
2018 nla_put(vendor_event,
2019 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
2020 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
2021 )
2022 {
2023 hddLog(VOS_TRACE_LEVEL_ERROR,
2024 FL("QCA_WLAN_VENDOR_ATTR put fail") );
2025 return FALSE;
2026 }
2027 return TRUE;
2028}
2029
Dino Mycle3b9536d2014-07-09 22:05:24 +05302030static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
2031 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302032 struct sk_buff *vendor_event)
2033{
2034 int i = 0;
2035 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302036 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2037 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05302038 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302039
Sunil Duttc69bccb2014-05-26 21:30:20 +05302040 if (FALSE == put_wifi_interface_info(
2041 &pWifiIfaceStat->info,
2042 vendor_event))
2043 {
2044 hddLog(VOS_TRACE_LEVEL_ERROR,
2045 FL("QCA_WLAN_VENDOR_ATTR put fail") );
2046 return FALSE;
2047
2048 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05302049 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
2050 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
2051 if (NULL == pWifiIfaceStatTL)
2052 {
2053 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
2054 return FALSE;
2055 }
2056
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05302057 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
2058 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
2059 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
2060 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
2061
2062 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
2063 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
2064 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
2065 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302066
2067 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
2068 {
2069 if (VOS_STATUS_SUCCESS ==
2070 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2071 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
2072 {
2073 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
2074 * obtained from TL structure
2075 */
2076
2077 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
2078 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302079 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
2080
Srinivas Dasari98947432014-11-07 19:41:24 +05302081 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
2082 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
2083 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
2084 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
2085 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
2086 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
2087 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
2088 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302089
Srinivas Dasari98947432014-11-07 19:41:24 +05302090 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
2091 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
2092 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
2093 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
2094 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
2095 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
2096 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
2097 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302098
Srinivas Dasari98947432014-11-07 19:41:24 +05302099 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
2100 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
2101 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
2102 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
2103 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
2104 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
2105 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
2106 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05302107 }
2108 else
2109 {
2110 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
2111 }
2112
Dino Mycle3b9536d2014-07-09 22:05:24 +05302113 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
2114 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
2115 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
2116 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
2117 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
2118 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
2119 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
2120 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
2121 }
2122 else
2123 {
2124 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
2125 }
2126
2127
Sunil Duttc69bccb2014-05-26 21:30:20 +05302128
2129 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302130 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
2131 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
2132 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302133 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
2134 pWifiIfaceStat->beaconRx) ||
2135 nla_put_u32(vendor_event,
2136 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
2137 pWifiIfaceStat->mgmtRx) ||
2138 nla_put_u32(vendor_event,
2139 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
2140 pWifiIfaceStat->mgmtActionRx) ||
2141 nla_put_u32(vendor_event,
2142 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
2143 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05302144 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302145 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
2146 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05302147 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302148 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
2149 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05302150 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302151 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
2152 pWifiIfaceStat->rssiAck))
2153 {
2154 hddLog(VOS_TRACE_LEVEL_ERROR,
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05302155 FL("QCA_WLAN_VENDOR_ATTR put fail"));
2156 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302157 return FALSE;
2158 }
2159
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05302160#ifdef FEATURE_EXT_LL_STAT
2161 /*
2162 * Ensure when EXT_LL_STAT is supported by both host and fwr,
2163 * then host should send Leaky AP stats to upper layer,
2164 * otherwise no need to send these stats.
2165 */
2166 if(sme_IsFeatureSupportedByFW(EXT_LL_STAT) &&
2167 sme_IsFeatureSupportedByDriver(EXT_LL_STAT)
2168 )
2169 {
2170 hddLog(VOS_TRACE_LEVEL_INFO,
2171 FL("EXT_LL_STAT is supported by fwr and host %u %u %u %llu"),
2172 pWifiIfaceStat->leakyApStat.is_leaky_ap,
2173 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked,
2174 pWifiIfaceStat->leakyApStat.rx_leak_window,
2175 pWifiIfaceStat->leakyApStat.avg_bcn_spread);
2176 if (nla_put_u32(vendor_event,
2177 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_DETECTED,
2178 pWifiIfaceStat->leakyApStat.is_leaky_ap) ||
2179 nla_put_u32(vendor_event,
2180 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_AVG_NUM_FRAMES_LEAKED,
2181 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked) ||
2182 nla_put_u32(vendor_event,
2183 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_GUARD_TIME,
2184 pWifiIfaceStat->leakyApStat.rx_leak_window) ||
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302185 hdd_wlan_nla_put_u64(vendor_event,
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05302186 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_AVERAGE_TSF_OFFSET,
2187 pWifiIfaceStat->leakyApStat.avg_bcn_spread))
2188 {
2189 hddLog(VOS_TRACE_LEVEL_ERROR,
2190 FL("EXT_LL_STAT put fail"));
2191 vos_mem_free(pWifiIfaceStatTL);
2192 return FALSE;
2193 }
2194 }
2195#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +05302196 wmmInfo = nla_nest_start(vendor_event,
2197 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302198 if(!wmmInfo)
2199 {
2200 vos_mem_free(pWifiIfaceStatTL);
2201 return FALSE;
2202 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302203 for (i = 0; i < WIFI_AC_MAX; i++)
2204 {
2205 struct nlattr *wmmStats;
2206 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302207 if(!wmmStats)
2208 {
2209 vos_mem_free(pWifiIfaceStatTL);
2210 return FALSE;
2211 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302212 if (FALSE == put_wifi_wmm_ac_stat(
2213 &pWifiIfaceStat->AccessclassStats[i],
2214 vendor_event))
2215 {
2216 hddLog(VOS_TRACE_LEVEL_ERROR,
2217 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05302218 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302219 return FALSE;
2220 }
2221
2222 nla_nest_end(vendor_event, wmmStats);
2223 }
2224 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05302225 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302226 return TRUE;
2227}
2228
2229static tSirWifiInterfaceMode
2230 hdd_map_device_to_ll_iface_mode ( int deviceMode )
2231{
2232 switch (deviceMode)
2233 {
2234 case WLAN_HDD_INFRA_STATION:
2235 return WIFI_INTERFACE_STA;
2236 case WLAN_HDD_SOFTAP:
2237 return WIFI_INTERFACE_SOFTAP;
2238 case WLAN_HDD_P2P_CLIENT:
2239 return WIFI_INTERFACE_P2P_CLIENT;
2240 case WLAN_HDD_P2P_GO:
2241 return WIFI_INTERFACE_P2P_GO;
2242 case WLAN_HDD_IBSS:
2243 return WIFI_INTERFACE_IBSS;
2244 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05302245 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302246 }
2247}
2248
2249static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
2250 tpSirWifiInterfaceInfo pInfo)
2251{
2252 v_U8_t *staMac = NULL;
2253 hdd_station_ctx_t *pHddStaCtx;
2254 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2255 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2256
2257 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
2258
2259 vos_mem_copy(pInfo->macAddr,
2260 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
2261
2262 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
2263 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
2264 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
2265 {
2266 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2267 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
2268 {
2269 pInfo->state = WIFI_DISCONNECTED;
2270 }
2271 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
2272 {
2273 hddLog(VOS_TRACE_LEVEL_ERROR,
2274 "%s: Session ID %d, Connection is in progress", __func__,
2275 pAdapter->sessionId);
2276 pInfo->state = WIFI_ASSOCIATING;
2277 }
2278 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
2279 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
2280 {
2281 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
2282 hddLog(VOS_TRACE_LEVEL_ERROR,
2283 "%s: client " MAC_ADDRESS_STR
2284 " is in the middle of WPS/EAPOL exchange.", __func__,
2285 MAC_ADDR_ARRAY(staMac));
2286 pInfo->state = WIFI_AUTHENTICATING;
2287 }
2288 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
2289 {
2290 pInfo->state = WIFI_ASSOCIATED;
2291 vos_mem_copy(pInfo->bssid,
2292 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
2293 vos_mem_copy(pInfo->ssid,
2294 pHddStaCtx->conn_info.SSID.SSID.ssId,
2295 pHddStaCtx->conn_info.SSID.SSID.length);
2296 //NULL Terminate the string.
2297 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
2298 }
2299 }
2300 vos_mem_copy(pInfo->countryStr,
2301 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
2302
2303 vos_mem_copy(pInfo->apCountryStr,
2304 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
2305
2306 return TRUE;
2307}
2308
2309/*
2310 * hdd_link_layer_process_peer_stats () - This function is called after
2311 * receiving Link Layer Peer statistics from FW.This function converts
2312 * the firmware data to the NL data and sends the same to the kernel/upper
2313 * layers.
2314 */
2315static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
2316 v_VOID_t *pData)
2317{
2318 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302319 tpSirWifiPeerStat pWifiPeerStat;
2320 tpSirWifiPeerInfo pWifiPeerInfo;
2321 struct nlattr *peerInfo;
2322 struct sk_buff *vendor_event;
2323 int status, i;
2324
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302325 ENTER();
2326
Sunil Duttc69bccb2014-05-26 21:30:20 +05302327 status = wlan_hdd_validate_context(pHddCtx);
2328 if (0 != status)
2329 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302330 return;
2331 }
2332
2333 pWifiPeerStat = (tpSirWifiPeerStat) pData;
2334
2335 hddLog(VOS_TRACE_LEVEL_INFO,
2336 "LL_STATS_PEER_ALL : numPeers %u",
2337 pWifiPeerStat->numPeers);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302338 /*
2339 * Allocate a size of 4096 for the peer stats comprising
2340 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
2341 * sizeof (tSirWifiRateStat).Each field is put with an
2342 * NL attribute.The size of 4096 is considered assuming
2343 * that number of rates shall not exceed beyond 50 with
2344 * the sizeof (tSirWifiRateStat) being 32.
2345 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302346 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
2347 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302348 if (!vendor_event)
2349 {
2350 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302351 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05302352 __func__);
2353 return;
2354 }
2355 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302356 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
2357 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
2358 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302359 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
2360 pWifiPeerStat->numPeers))
2361 {
2362 hddLog(VOS_TRACE_LEVEL_ERROR,
2363 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
2364 kfree_skb(vendor_event);
2365 return;
2366 }
2367
2368 peerInfo = nla_nest_start(vendor_event,
2369 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302370 if(!peerInfo)
2371 {
2372 hddLog(VOS_TRACE_LEVEL_ERROR,
2373 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
2374 __func__);
2375 kfree_skb(vendor_event);
2376 return;
2377 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302378
2379 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
2380 pWifiPeerStat->peerInfo);
2381
2382 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
2383 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302384 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302385 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302386
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302387 if(!peers)
2388 {
2389 hddLog(VOS_TRACE_LEVEL_ERROR,
2390 "%s: peer stats put fail",
2391 __func__);
2392 kfree_skb(vendor_event);
2393 return;
2394 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302395 if (FALSE == put_wifi_peer_info(
2396 pWifiPeerInfo, vendor_event))
2397 {
2398 hddLog(VOS_TRACE_LEVEL_ERROR,
2399 "%s: put_wifi_peer_info put fail", __func__);
2400 kfree_skb(vendor_event);
2401 return;
2402 }
2403
2404 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
2405 pWifiPeerStat->peerInfo +
2406 (i * sizeof(tSirWifiPeerInfo)) +
2407 (numRate * sizeof (tSirWifiRateStat)));
2408 nla_nest_end(vendor_event, peers);
2409 }
2410 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302411 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302412 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302413}
2414
2415/*
2416 * hdd_link_layer_process_iface_stats () - This function is called after
2417 * receiving Link Layer Interface statistics from FW.This function converts
2418 * the firmware data to the NL data and sends the same to the kernel/upper
2419 * layers.
2420 */
2421static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
2422 v_VOID_t *pData)
2423{
2424 tpSirWifiIfaceStat pWifiIfaceStat;
2425 struct sk_buff *vendor_event;
2426 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2427 int status;
2428
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302429 ENTER();
2430
Sunil Duttc69bccb2014-05-26 21:30:20 +05302431 status = wlan_hdd_validate_context(pHddCtx);
2432 if (0 != status)
2433 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302434 return;
2435 }
2436 /*
2437 * Allocate a size of 4096 for the interface stats comprising
2438 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
2439 * assuming that all these fit with in the limit.Please take
2440 * a call on the limit based on the data requirements on
2441 * interface statistics.
2442 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302443 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
2444 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302445 if (!vendor_event)
2446 {
2447 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302448 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05302449 return;
2450 }
2451
2452 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
2453
Dino Mycle3b9536d2014-07-09 22:05:24 +05302454
2455 if (FALSE == hdd_get_interface_info( pAdapter,
2456 &pWifiIfaceStat->info))
2457 {
2458 hddLog(VOS_TRACE_LEVEL_ERROR,
2459 FL("hdd_get_interface_info get fail") );
2460 kfree_skb(vendor_event);
2461 return;
2462 }
2463
2464 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
2465 vendor_event))
2466 {
2467 hddLog(VOS_TRACE_LEVEL_ERROR,
2468 FL("put_wifi_iface_stats fail") );
2469 kfree_skb(vendor_event);
2470 return;
2471 }
2472
Sunil Duttc69bccb2014-05-26 21:30:20 +05302473 hddLog(VOS_TRACE_LEVEL_INFO,
2474 "WMI_LINK_STATS_IFACE Data");
2475
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302476 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302477
2478 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302479}
2480
2481/*
2482 * hdd_link_layer_process_radio_stats () - This function is called after
2483 * receiving Link Layer Radio statistics from FW.This function converts
2484 * the firmware data to the NL data and sends the same to the kernel/upper
2485 * layers.
2486 */
2487static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
2488 v_VOID_t *pData)
2489{
2490 int status, i;
2491 tpSirWifiRadioStat pWifiRadioStat;
2492 tpSirWifiChannelStats pWifiChannelStats;
2493 struct sk_buff *vendor_event;
2494 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2495 struct nlattr *chList;
2496
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302497 ENTER();
2498
Sunil Duttc69bccb2014-05-26 21:30:20 +05302499 status = wlan_hdd_validate_context(pHddCtx);
2500 if (0 != status)
2501 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302502 return;
2503 }
2504 pWifiRadioStat = (tpSirWifiRadioStat) pData;
2505
2506 hddLog(VOS_TRACE_LEVEL_INFO,
2507 "LL_STATS_RADIO"
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05302508 " number of radios = %u"
Sunil Duttc69bccb2014-05-26 21:30:20 +05302509 " radio is %d onTime is %u "
2510 " txTime is %u rxTime is %u "
2511 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05302512 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05302513 " onTimePnoScan is %u onTimeHs20 is %u "
2514 " numChannels is %u",
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05302515 NUM_RADIOS,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302516 pWifiRadioStat->radio, pWifiRadioStat->onTime,
2517 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
2518 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302519 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302520 pWifiRadioStat->onTimeRoamScan,
2521 pWifiRadioStat->onTimePnoScan,
2522 pWifiRadioStat->onTimeHs20,
2523 pWifiRadioStat->numChannels);
2524 /*
2525 * Allocate a size of 4096 for the Radio stats comprising
2526 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
2527 * (tSirWifiChannelStats).Each channel data is put with an
2528 * NL attribute.The size of 4096 is considered assuming that
2529 * number of channels shall not exceed beyond 60 with the
2530 * sizeof (tSirWifiChannelStats) being 24 bytes.
2531 */
2532
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302533 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
2534 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302535 if (!vendor_event)
2536 {
2537 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302538 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05302539 return;
2540 }
2541
2542 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302543 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
2544 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
2545 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302546 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
2547 pWifiRadioStat->radio) ||
2548 nla_put_u32(vendor_event,
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05302549 QCA_WLAN_VENDOR_ATTR_LL_STATS_NUM_RADIOS,
2550 NUM_RADIOS) ||
2551 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302552 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
2553 pWifiRadioStat->onTime) ||
2554 nla_put_u32(vendor_event,
2555 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
2556 pWifiRadioStat->txTime) ||
2557 nla_put_u32(vendor_event,
2558 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
2559 pWifiRadioStat->rxTime) ||
2560 nla_put_u32(vendor_event,
2561 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
2562 pWifiRadioStat->onTimeScan) ||
2563 nla_put_u32(vendor_event,
2564 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
2565 pWifiRadioStat->onTimeNbd) ||
2566 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302567 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
2568 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05302569 nla_put_u32(vendor_event,
2570 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
2571 pWifiRadioStat->onTimeRoamScan) ||
2572 nla_put_u32(vendor_event,
2573 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
2574 pWifiRadioStat->onTimePnoScan) ||
2575 nla_put_u32(vendor_event,
2576 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
2577 pWifiRadioStat->onTimeHs20) ||
2578 nla_put_u32(vendor_event,
2579 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
2580 pWifiRadioStat->numChannels))
2581 {
2582 hddLog(VOS_TRACE_LEVEL_ERROR,
2583 FL("QCA_WLAN_VENDOR_ATTR put fail"));
2584 kfree_skb(vendor_event);
2585 return ;
2586 }
2587
2588 chList = nla_nest_start(vendor_event,
2589 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302590 if(!chList)
2591 {
2592 hddLog(VOS_TRACE_LEVEL_ERROR,
2593 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
2594 __func__);
2595 kfree_skb(vendor_event);
2596 return;
2597 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302598 for (i = 0; i < pWifiRadioStat->numChannels; i++)
2599 {
2600 struct nlattr *chInfo;
2601
2602 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
2603 pWifiRadioStat->channels +
2604 (i * sizeof(tSirWifiChannelStats)));
2605
Sunil Duttc69bccb2014-05-26 21:30:20 +05302606 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05302607 if(!chInfo)
2608 {
2609 hddLog(VOS_TRACE_LEVEL_ERROR,
2610 "%s: failed to put chInfo",
2611 __func__);
2612 kfree_skb(vendor_event);
2613 return;
2614 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302615
2616 if (nla_put_u32(vendor_event,
2617 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
2618 pWifiChannelStats->channel.width) ||
2619 nla_put_u32(vendor_event,
2620 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
2621 pWifiChannelStats->channel.centerFreq) ||
2622 nla_put_u32(vendor_event,
2623 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
2624 pWifiChannelStats->channel.centerFreq0) ||
2625 nla_put_u32(vendor_event,
2626 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
2627 pWifiChannelStats->channel.centerFreq1) ||
2628 nla_put_u32(vendor_event,
2629 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
2630 pWifiChannelStats->onTime) ||
2631 nla_put_u32(vendor_event,
2632 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
2633 pWifiChannelStats->ccaBusyTime))
2634 {
2635 hddLog(VOS_TRACE_LEVEL_ERROR,
2636 FL("cfg80211_vendor_event_alloc failed") );
2637 kfree_skb(vendor_event);
2638 return ;
2639 }
2640 nla_nest_end(vendor_event, chInfo);
2641 }
2642 nla_nest_end(vendor_event, chList);
2643
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302644 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302645
2646 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302647 return;
2648}
2649
2650/*
2651 * hdd_link_layer_stats_ind_callback () - This function is called after
2652 * receiving Link Layer indications from FW.This callback converts the firmware
2653 * data to the NL data and send the same to the kernel/upper layers.
2654 */
2655static void hdd_link_layer_stats_ind_callback ( void *pCtx,
2656 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05302657 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302658{
Dino Mycled3d50022014-07-07 12:58:25 +05302659 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
2660 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302661 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05302662 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302663 int status;
2664
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302665 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302666
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302667 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302668 if (0 != status)
2669 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302670 return;
2671 }
2672
Dino Mycled3d50022014-07-07 12:58:25 +05302673 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
2674 if (NULL == pAdapter)
2675 {
2676 hddLog(VOS_TRACE_LEVEL_ERROR,
2677 FL(" MAC address %pM does not exist with host"),
2678 macAddr);
2679 return;
2680 }
2681
Sunil Duttc69bccb2014-05-26 21:30:20 +05302682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302683 "%s: Interface: %s LLStats indType: %d", __func__,
2684 pAdapter->dev->name, indType);
2685
Sunil Duttc69bccb2014-05-26 21:30:20 +05302686 switch (indType)
2687 {
2688 case SIR_HAL_LL_STATS_RESULTS_RSP:
2689 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302690 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302691 "LL_STATS RESP paramID = 0x%x, ifaceId = %u MAC: %pM "
2692 "respId = %u, moreResultToFollow = %u",
2693 linkLayerStatsResults->paramId, linkLayerStatsResults->ifaceId,
2694 macAddr, linkLayerStatsResults->respId,
2695 linkLayerStatsResults->moreResultToFollow);
2696
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302697 spin_lock(&hdd_context_lock);
2698 context = &pHddCtx->ll_stats_context;
2699 /* validate response received from target */
2700 if ((context->request_id != linkLayerStatsResults->respId) ||
2701 !(context->request_bitmap & linkLayerStatsResults->paramId))
2702 {
2703 spin_unlock(&hdd_context_lock);
2704 hddLog(LOGE,
2705 FL("Error : Request id %d response id %d request bitmap 0x%x"
2706 "response bitmap 0x%x"),
2707 context->request_id, linkLayerStatsResults->respId,
2708 context->request_bitmap, linkLayerStatsResults->paramId);
2709 return;
2710 }
2711 spin_unlock(&hdd_context_lock);
2712
Sunil Duttc69bccb2014-05-26 21:30:20 +05302713 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
2714 {
2715 hdd_link_layer_process_radio_stats(pAdapter,
2716 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302717 spin_lock(&hdd_context_lock);
2718 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
2719 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302720 }
2721 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
2722 {
2723 hdd_link_layer_process_iface_stats(pAdapter,
2724 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302725 spin_lock(&hdd_context_lock);
2726 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
2727 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302728 }
2729 else if ( linkLayerStatsResults->paramId &
2730 WMI_LINK_STATS_ALL_PEER )
2731 {
2732 hdd_link_layer_process_peer_stats(pAdapter,
2733 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302734 spin_lock(&hdd_context_lock);
2735 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
2736 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302737 } /* WMI_LINK_STATS_ALL_PEER */
2738 else
2739 {
2740 hddLog(VOS_TRACE_LEVEL_ERROR,
2741 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
2742 }
2743
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302744 spin_lock(&hdd_context_lock);
2745 /* complete response event if all requests are completed */
2746 if (0 == context->request_bitmap)
2747 complete(&context->response_event);
2748 spin_unlock(&hdd_context_lock);
2749
Sunil Duttc69bccb2014-05-26 21:30:20 +05302750 break;
2751 }
2752 default:
2753 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
2754 break;
2755 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302756
2757 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302758 return;
2759}
2760
2761const struct
2762nla_policy
2763qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
2764{
2765 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
2766 { .type = NLA_U32 },
2767 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
2768 { .type = NLA_U32 },
2769};
2770
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302771static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
2772 struct wireless_dev *wdev,
2773 const void *data,
2774 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302775{
2776 int status;
2777 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302778 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302779 struct net_device *dev = wdev->netdev;
2780 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2781 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2782
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302783 ENTER();
2784
Sunil Duttc69bccb2014-05-26 21:30:20 +05302785 status = wlan_hdd_validate_context(pHddCtx);
2786 if (0 != status)
2787 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302788 return -EINVAL;
2789 }
2790
2791 if (NULL == pAdapter)
2792 {
2793 hddLog(VOS_TRACE_LEVEL_ERROR,
2794 FL("HDD adapter is Null"));
2795 return -ENODEV;
2796 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302797 /* check the LLStats Capability */
2798 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2799 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2800 {
Anurag Chouhan65ea6dc2016-10-25 19:59:14 +05302801 hddLog(VOS_TRACE_LEVEL_WARN,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302802 FL("Link Layer Statistics not supported by Firmware"));
2803 return -EINVAL;
2804 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302805
2806 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
2807 (struct nlattr *)data,
2808 data_len, qca_wlan_vendor_ll_set_policy))
2809 {
2810 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2811 return -EINVAL;
2812 }
2813 if (!tb_vendor
2814 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
2815 {
2816 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
2817 return -EINVAL;
2818 }
2819 if (!tb_vendor[
2820 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
2821 {
2822 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
2823 return -EINVAL;
2824 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302825 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302826 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302827
Dino Mycledf0a5d92014-07-04 09:41:55 +05302828 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302829 nla_get_u32(
2830 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
2831
Dino Mycledf0a5d92014-07-04 09:41:55 +05302832 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302833 nla_get_u32(
2834 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
2835
Dino Mycled3d50022014-07-07 12:58:25 +05302836 vos_mem_copy(linkLayerStatsSetReq.macAddr,
2837 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302838
2839
2840 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302841 "LL_STATS_SET reqId = %d, MAC = %pM, mpduSizeThreshold = %d "
2842 "Statistics Gathering = %d ",
2843 linkLayerStatsSetReq.reqId, linkLayerStatsSetReq.macAddr,
2844 linkLayerStatsSetReq.mpduSizeThreshold,
2845 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302846
2847 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
2848 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05302849 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302850 {
2851 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2852 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302853 return -EINVAL;
2854
2855 }
Srinivas Dasari98947432014-11-07 19:41:24 +05302856
Sunil Duttc69bccb2014-05-26 21:30:20 +05302857 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302858 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302859 {
2860 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2861 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302862 return -EINVAL;
2863 }
2864
2865 pAdapter->isLinkLayerStatsSet = 1;
2866
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302867 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302868 return 0;
2869}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302870static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
2871 struct wireless_dev *wdev,
2872 const void *data,
2873 int data_len)
2874{
2875 int ret = 0;
2876
2877 vos_ssr_protect(__func__);
2878 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
2879 vos_ssr_unprotect(__func__);
2880
2881 return ret;
2882}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302883
2884const struct
2885nla_policy
2886qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
2887{
2888 /* Unsigned 32bit value provided by the caller issuing the GET stats
2889 * command. When reporting
2890 * the stats results, the driver uses the same value to indicate
2891 * which GET request the results
2892 * correspond to.
2893 */
2894 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
2895
2896 /* Unsigned 32bit value . bit mask to identify what statistics are
2897 requested for retrieval */
2898 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
2899};
2900
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302901static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2902 struct wireless_dev *wdev,
2903 const void *data,
2904 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302905{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302906 unsigned long rc;
2907 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302908 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2909 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302910 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302911 struct net_device *dev = wdev->netdev;
2912 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05302913 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302914 int status;
2915
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302916 ENTER();
2917
Sunil Duttc69bccb2014-05-26 21:30:20 +05302918 status = wlan_hdd_validate_context(pHddCtx);
2919 if (0 != status)
2920 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302921 return -EINVAL ;
2922 }
2923
2924 if (NULL == pAdapter)
2925 {
2926 hddLog(VOS_TRACE_LEVEL_FATAL,
2927 "%s: HDD adapter is Null", __func__);
2928 return -ENODEV;
2929 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05302930
2931 if (pHddStaCtx == NULL)
2932 {
2933 hddLog(VOS_TRACE_LEVEL_FATAL,
2934 "%s: HddStaCtx is Null", __func__);
2935 return -ENODEV;
2936 }
2937
Dino Mycledf0a5d92014-07-04 09:41:55 +05302938 /* check the LLStats Capability */
2939 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2940 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2941 {
2942 hddLog(VOS_TRACE_LEVEL_ERROR,
2943 FL("Link Layer Statistics not supported by Firmware"));
2944 return -EINVAL;
2945 }
2946
Sunil Duttc69bccb2014-05-26 21:30:20 +05302947
2948 if (!pAdapter->isLinkLayerStatsSet)
2949 {
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05302950 hddLog(VOS_TRACE_LEVEL_ERROR,
Sunil Duttc69bccb2014-05-26 21:30:20 +05302951 "%s: isLinkLayerStatsSet : %d",
2952 __func__, pAdapter->isLinkLayerStatsSet);
2953 return -EINVAL;
2954 }
2955
Mukul Sharma10313ba2015-07-29 19:14:39 +05302956 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
2957 {
2958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2959 "%s: Roaming in progress, so unable to proceed this request", __func__);
2960 return -EBUSY;
2961 }
2962
Sunil Duttc69bccb2014-05-26 21:30:20 +05302963 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2964 (struct nlattr *)data,
2965 data_len, qca_wlan_vendor_ll_get_policy))
2966 {
2967 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2968 return -EINVAL;
2969 }
2970
2971 if (!tb_vendor
2972 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2973 {
2974 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2975 return -EINVAL;
2976 }
2977
2978 if (!tb_vendor
2979 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2980 {
2981 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2982 return -EINVAL;
2983 }
2984
Sunil Duttc69bccb2014-05-26 21:30:20 +05302985
Dino Mycledf0a5d92014-07-04 09:41:55 +05302986 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302987 nla_get_u32( tb_vendor[
2988 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302989 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302990 nla_get_u32( tb_vendor[
2991 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2992
Dino Mycled3d50022014-07-07 12:58:25 +05302993 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2994 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302995
2996 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302997 "LL_STATS_GET reqId = %d, MAC = %pM, paramIdMask = %d",
2998 linkLayerStatsGetReq.reqId, linkLayerStatsGetReq.macAddr,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302999 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05303000
mukul sharma4bd8d2e2015-08-13 20:33:25 +05303001 spin_lock(&hdd_context_lock);
3002 context = &pHddCtx->ll_stats_context;
3003 context->request_id = linkLayerStatsGetReq.reqId;
3004 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
3005 INIT_COMPLETION(context->response_event);
3006 spin_unlock(&hdd_context_lock);
3007
Sunil Duttc69bccb2014-05-26 21:30:20 +05303008 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05303009 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05303010 {
3011 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
3012 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05303013 return -EINVAL;
3014 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303015
mukul sharma4bd8d2e2015-08-13 20:33:25 +05303016 rc = wait_for_completion_timeout(&context->response_event,
3017 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
3018 if (!rc)
3019 {
3020 hddLog(LOGE,
3021 FL("Target response timed out request id %d request bitmap 0x%x"),
3022 context->request_id, context->request_bitmap);
3023 return -ETIMEDOUT;
3024 }
3025
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303026 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05303027 return 0;
3028}
3029
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303030static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
3031 struct wireless_dev *wdev,
3032 const void *data,
3033 int data_len)
3034{
3035 int ret = 0;
3036
3037 vos_ssr_protect(__func__);
3038 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
3039 vos_ssr_unprotect(__func__);
3040
3041 return ret;
3042}
3043
Sunil Duttc69bccb2014-05-26 21:30:20 +05303044const struct
3045nla_policy
3046qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
3047{
3048 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
3049 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
3050 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
3051 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
3052};
3053
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303054static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
3055 struct wireless_dev *wdev,
3056 const void *data,
3057 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05303058{
3059 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3060 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05303061 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05303062 struct net_device *dev = wdev->netdev;
3063 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3064 u32 statsClearReqMask;
3065 u8 stopReq;
3066 int status;
3067
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303068 ENTER();
3069
Sunil Duttc69bccb2014-05-26 21:30:20 +05303070 status = wlan_hdd_validate_context(pHddCtx);
3071 if (0 != status)
3072 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05303073 return -EINVAL;
3074 }
3075
3076 if (NULL == pAdapter)
3077 {
3078 hddLog(VOS_TRACE_LEVEL_FATAL,
3079 "%s: HDD adapter is Null", __func__);
3080 return -ENODEV;
3081 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05303082 /* check the LLStats Capability */
3083 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
3084 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
3085 {
3086 hddLog(VOS_TRACE_LEVEL_ERROR,
3087 FL("Enable LLStats Capability"));
3088 return -EINVAL;
3089 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05303090
3091 if (!pAdapter->isLinkLayerStatsSet)
3092 {
3093 hddLog(VOS_TRACE_LEVEL_FATAL,
3094 "%s: isLinkLayerStatsSet : %d",
3095 __func__, pAdapter->isLinkLayerStatsSet);
3096 return -EINVAL;
3097 }
3098
3099 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
3100 (struct nlattr *)data,
3101 data_len, qca_wlan_vendor_ll_clr_policy))
3102 {
3103 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
3104 return -EINVAL;
3105 }
3106
3107 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
3108
3109 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
3110 {
3111 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
3112 return -EINVAL;
3113
3114 }
3115
Sunil Duttc69bccb2014-05-26 21:30:20 +05303116
Dino Mycledf0a5d92014-07-04 09:41:55 +05303117 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05303118 nla_get_u32(
3119 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
3120
Dino Mycledf0a5d92014-07-04 09:41:55 +05303121 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05303122 nla_get_u8(
3123 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
3124
3125 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05303126 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05303127
Dino Mycled3d50022014-07-07 12:58:25 +05303128 vos_mem_copy(linkLayerStatsClearReq.macAddr,
3129 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05303130
3131 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05303132 "LL_STATS_CLEAR reqId = %d, MAC = %pM,"
3133 "statsClearReqMask = 0x%X, stopReq = %d",
3134 linkLayerStatsClearReq.reqId,
3135 linkLayerStatsClearReq.macAddr,
3136 linkLayerStatsClearReq.statsClearReqMask,
Dino Mycledf0a5d92014-07-04 09:41:55 +05303137 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05303138
3139 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05303140 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05303141 {
3142 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05303143 hdd_station_ctx_t *pHddStaCtx;
3144
3145 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3146 if (VOS_STATUS_SUCCESS !=
3147 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
3148 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
3149 {
3150 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
3151 "WLANTL_ClearInterfaceStats Failed", __func__);
3152 return -EINVAL;
3153 }
3154 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
3155 (statsClearReqMask & WIFI_STATS_IFACE)) {
3156 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
3157 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
3158 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
3159 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
3160 }
3161
Sunil Duttc69bccb2014-05-26 21:30:20 +05303162 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
3163 2 * sizeof(u32) +
3164 NLMSG_HDRLEN);
3165
3166 if (temp_skbuff != NULL)
3167 {
3168
3169 if (nla_put_u32(temp_skbuff,
3170 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
3171 statsClearReqMask) ||
3172 nla_put_u32(temp_skbuff,
3173 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
3174 stopReq))
3175 {
3176 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
3177 kfree_skb(temp_skbuff);
3178 return -EINVAL;
3179 }
3180 /* If the ask is to stop the stats collection as part of clear
3181 * (stopReq = 1) , ensure that no further requests of get
3182 * go to the firmware by having isLinkLayerStatsSet set to 0.
3183 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05303184 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05303185 * case the firmware is just asked to clear the statistics.
3186 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05303187 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05303188 pAdapter->isLinkLayerStatsSet = 0;
3189 return cfg80211_vendor_cmd_reply(temp_skbuff);
3190 }
3191 return -ENOMEM;
3192 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303193
3194 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05303195 return -EINVAL;
3196}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303197static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
3198 struct wireless_dev *wdev,
3199 const void *data,
3200 int data_len)
3201{
3202 int ret = 0;
3203
3204 vos_ssr_protect(__func__);
3205 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
3206 vos_ssr_unprotect(__func__);
3207
3208 return ret;
3209
3210
3211}
Sunil Duttc69bccb2014-05-26 21:30:20 +05303212#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
3213
Dino Mycle6fb96c12014-06-10 11:52:40 +05303214#ifdef WLAN_FEATURE_EXTSCAN
3215static const struct nla_policy
3216wlan_hdd_extscan_config_policy
3217 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
3218{
3219 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
3220 { .type = NLA_U32 },
3221 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
3222 { .type = NLA_U32 },
SaidiReddy Yenugaf2145922017-05-26 18:19:31 +05303223 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS] =
3224 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05303225 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
3226 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
3227 { .type = NLA_U32 },
3228 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
3229 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
3230
3231 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
3232 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
3233 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
3234 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
3235 { .type = NLA_U8 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303236 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD] =
3237 { .type = NLA_U32 },
3238 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT] =
3239 { .type = NLA_U32 },
3240 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT] =
3241 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05303242 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
3243 { .type = NLA_U32 },
3244 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
3245 { .type = NLA_U32 },
3246 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
3247 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303248 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT] =
3249 { .type = NLA_U8 },
3250 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05303251 { .type = NLA_U8 },
3252 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
3253 { .type = NLA_U8 },
3254 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
3255 { .type = NLA_U8 },
3256
3257 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
3258 { .type = NLA_U32 },
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05303259 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] = {
3260 .type = NLA_UNSPEC,
3261 .len = HDD_MAC_ADDR_LEN},
Dino Mycle6fb96c12014-06-10 11:52:40 +05303262 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
3263 { .type = NLA_S32 },
3264 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
3265 { .type = NLA_S32 },
3266 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
3267 { .type = NLA_U32 },
3268 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
3269 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303270 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE] =
3271 { .type = NLA_U32 },
3272 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID] =
3273 { .type = NLA_BINARY,
3274 .len = IEEE80211_MAX_SSID_LEN + 1 },
3275 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05303276 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303277 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID] =
3278 { .type = NLA_U32 },
3279 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND] =
3280 { .type = NLA_U8 },
3281 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW] =
3282 { .type = NLA_S32 },
3283 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH] =
3284 { .type = NLA_S32 },
3285 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS] =
3286 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05303287};
3288
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303289/**
3290 * wlan_hdd_cfg80211_extscan_get_capabilities_rsp() - response from target
3291 * @ctx: hdd global context
3292 * @data: capabilities data
3293 *
3294 * Return: none
3295 */
3296static void
3297wlan_hdd_cfg80211_extscan_get_capabilities_rsp(void *ctx, void *pMsg)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303298{
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303299 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303300 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303301 tSirEXTScanCapabilitiesEvent *data =
3302 (tSirEXTScanCapabilitiesEvent *) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303303
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303304 ENTER();
3305
3306 if (wlan_hdd_validate_context(pHddCtx))
3307 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303308 return;
3309 }
3310
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303311 if (!pMsg)
3312 {
3313 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3314 return;
3315 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303316
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303317 vos_spin_lock_acquire(&hdd_context_lock);
3318
3319 context = &pHddCtx->ext_scan_context;
3320 /* validate response received from target*/
3321 if (context->request_id != data->requestId)
3322 {
3323 vos_spin_lock_release(&hdd_context_lock);
3324 hddLog(LOGE,
3325 FL("Target response id did not match: request_id %d resposne_id %d"),
3326 context->request_id, data->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303327 return;
3328 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303329 else
3330 {
3331 context->capability_response = *data;
3332 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303333 }
3334
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303335 vos_spin_lock_release(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303336
Dino Mycle6fb96c12014-06-10 11:52:40 +05303337 return;
3338}
3339
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303340/*
3341 * define short names for the global vendor params
3342 * used by wlan_hdd_send_ext_scan_capability()
3343 */
3344#define PARAM_REQUEST_ID \
3345 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
3346#define PARAM_STATUS \
3347 QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS
3348#define MAX_SCAN_CACHE_SIZE \
3349 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE
3350#define MAX_SCAN_BUCKETS \
3351 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS
3352#define MAX_AP_CACHE_PER_SCAN \
3353 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN
3354#define MAX_RSSI_SAMPLE_SIZE \
3355 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE
3356#define MAX_SCAN_RPT_THRHOLD \
3357 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD
3358#define MAX_HOTLIST_BSSIDS \
3359 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS
3360#define MAX_BSSID_HISTORY_ENTRIES \
3361 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES
3362#define MAX_HOTLIST_SSIDS \
3363 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303364#define MAX_SIGNIFICANT_WIFI_CHANGE_APS \
3365 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303366
3367static int wlan_hdd_send_ext_scan_capability(void *ctx)
3368{
3369 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3370 struct sk_buff *skb = NULL;
3371 int ret;
3372 tSirEXTScanCapabilitiesEvent *data;
3373 tANI_U32 nl_buf_len;
3374
3375 ret = wlan_hdd_validate_context(pHddCtx);
3376 if (0 != ret)
3377 {
3378 return ret;
3379 }
3380
3381 data = &(pHddCtx->ext_scan_context.capability_response);
3382
3383 nl_buf_len = NLMSG_HDRLEN;
3384 nl_buf_len += (sizeof(data->requestId) + NLA_HDRLEN) +
3385 (sizeof(data->status) + NLA_HDRLEN) +
3386 (sizeof(data->scanCacheSize) + NLA_HDRLEN) +
3387 (sizeof(data->scanBuckets) + NLA_HDRLEN) +
3388 (sizeof(data->maxApPerScan) + NLA_HDRLEN) +
3389 (sizeof(data->maxRssiSampleSize) + NLA_HDRLEN) +
3390 (sizeof(data->maxScanReportingThreshold) + NLA_HDRLEN) +
3391 (sizeof(data->maxHotlistAPs) + NLA_HDRLEN) +
3392 (sizeof(data->maxBsidHistoryEntries) + NLA_HDRLEN) +
3393 (sizeof(data->maxHotlistSSIDs) + NLA_HDRLEN);
3394
3395 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, nl_buf_len);
3396
3397 if (!skb)
3398 {
3399 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
3400 return -ENOMEM;
3401 }
3402
3403 hddLog(LOG1, "Req Id (%u) Status (%u)", data->requestId, data->status);
3404 hddLog(LOG1, "Scan cache size (%u) Scan buckets (%u) Max AP per scan (%u)",
3405 data->scanCacheSize, data->scanBuckets, data->maxApPerScan);
3406 hddLog(LOG1, "max_rssi_sample_size (%u) max_scan_reporting_threshold (%u)",
3407 data->maxRssiSampleSize, data->maxScanReportingThreshold);
3408 hddLog(LOG1, "max_hotlist_bssids (%u) max_bssid_history_entries (%u)"
3409 "max_hotlist_ssids (%u)", data->maxHotlistAPs,
3410 data->maxBsidHistoryEntries, data->maxHotlistSSIDs);
3411
3412 if (nla_put_u32(skb, PARAM_REQUEST_ID, data->requestId) ||
3413 nla_put_u32(skb, PARAM_STATUS, data->status) ||
3414 nla_put_u32(skb, MAX_SCAN_CACHE_SIZE, data->scanCacheSize) ||
3415 nla_put_u32(skb, MAX_SCAN_BUCKETS, data->scanBuckets) ||
3416 nla_put_u32(skb, MAX_AP_CACHE_PER_SCAN,
3417 data->maxApPerScan) ||
3418 nla_put_u32(skb, MAX_RSSI_SAMPLE_SIZE,
3419 data->maxRssiSampleSize) ||
3420 nla_put_u32(skb, MAX_SCAN_RPT_THRHOLD,
3421 data->maxScanReportingThreshold) ||
3422 nla_put_u32(skb, MAX_HOTLIST_BSSIDS, data->maxHotlistAPs) ||
3423 nla_put_u32(skb, MAX_BSSID_HISTORY_ENTRIES,
3424 data->maxBsidHistoryEntries) ||
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303425 nla_put_u32(skb, MAX_HOTLIST_SSIDS, data->maxHotlistSSIDs) ||
3426 nla_put_u32(skb, MAX_SIGNIFICANT_WIFI_CHANGE_APS, 0))
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303427 {
3428 hddLog(LOGE, FL("nla put fail"));
3429 goto nla_put_failure;
3430 }
3431
3432 cfg80211_vendor_cmd_reply(skb);
3433 return 0;
3434
3435nla_put_failure:
3436 kfree_skb(skb);
3437 return -EINVAL;;
3438}
3439
3440/*
3441 * done with short names for the global vendor params
3442 * used by wlan_hdd_send_ext_scan_capability()
3443 */
3444#undef PARAM_REQUEST_ID
3445#undef PARAM_STATUS
3446#undef MAX_SCAN_CACHE_SIZE
3447#undef MAX_SCAN_BUCKETS
3448#undef MAX_AP_CACHE_PER_SCAN
3449#undef MAX_RSSI_SAMPLE_SIZE
3450#undef MAX_SCAN_RPT_THRHOLD
3451#undef MAX_HOTLIST_BSSIDS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303452#undef MAX_BSSID_HISTORY_ENTRIES
3453#undef MAX_HOTLIST_SSIDS
Dino Mycle6fb96c12014-06-10 11:52:40 +05303454
3455static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
3456{
3457 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
3458 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303459 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303460 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303461
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303462 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303463
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303464 if (wlan_hdd_validate_context(pHddCtx))
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303465 return;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303466
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303467 if (!pMsg)
3468 {
3469 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303470 return;
3471 }
3472
Dino Mycle6fb96c12014-06-10 11:52:40 +05303473 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3474 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
3475
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303476 context = &pHddCtx->ext_scan_context;
3477 spin_lock(&hdd_context_lock);
3478 if (context->request_id == pData->requestId) {
3479 context->response_status = pData->status ? -EINVAL : 0;
3480 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303481 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303482 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303483
3484 /*
3485 * Store the Request ID for comparing with the requestID obtained
3486 * in other requests.HDD shall return a failure is the extscan_stop
3487 * request is issued with a different requestId as that of the
3488 * extscan_start request. Also, This requestId shall be used while
3489 * indicating the full scan results to the upper layers.
3490 * The requestId is stored with the assumption that the firmware
3491 * shall return the ext scan start request's requestId in ext scan
3492 * start response.
3493 */
3494 if (pData->status == 0)
3495 pMac->sme.extScanStartReqId = pData->requestId;
3496
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303497 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303498 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303499}
3500
3501
3502static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
3503{
3504 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
3505 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05303506 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303507
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303508 ENTER();
3509
3510 if (wlan_hdd_validate_context(pHddCtx)){
3511 return;
3512 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05303513
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303514 if (!pMsg)
3515 {
3516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303517 return;
3518 }
3519
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05303520 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
3521 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303522
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05303523 context = &pHddCtx->ext_scan_context;
3524 spin_lock(&hdd_context_lock);
3525 if (context->request_id == pData->requestId) {
3526 context->response_status = pData->status ? -EINVAL : 0;
3527 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303528 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05303529 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303530
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303531 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303532 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303533}
3534
Dino Mycle6fb96c12014-06-10 11:52:40 +05303535static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
3536 void *pMsg)
3537{
3538 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303539 tpSirEXTScanSetBssidHotListRspParams pData =
3540 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303541 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303542
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303543 ENTER();
3544
3545 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05303546 return;
3547 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303548
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303549 if (!pMsg)
3550 {
3551 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3552 return;
3553 }
3554
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303555 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
3556 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303557
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303558 context = &pHddCtx->ext_scan_context;
3559 spin_lock(&hdd_context_lock);
3560 if (context->request_id == pData->requestId) {
3561 context->response_status = pData->status ? -EINVAL : 0;
3562 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303563 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303564 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303565
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303566 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303567 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303568}
3569
3570static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
3571 void *pMsg)
3572{
3573 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303574 tpSirEXTScanResetBssidHotlistRspParams pData =
3575 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05303576 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303577
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303578 ENTER();
3579
3580 if (wlan_hdd_validate_context(pHddCtx)) {
3581 return;
3582 }
3583 if (!pMsg)
3584 {
3585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303586 return;
3587 }
3588
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05303589 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
3590 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303591
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05303592 context = &pHddCtx->ext_scan_context;
3593 spin_lock(&hdd_context_lock);
3594 if (context->request_id == pData->requestId) {
3595 context->response_status = pData->status ? -EINVAL : 0;
3596 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303597 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05303598 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303599
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303600 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303601 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303602}
3603
Dino Mycle6fb96c12014-06-10 11:52:40 +05303604static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
3605 void *pMsg)
3606{
3607 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3608 struct sk_buff *skb = NULL;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303609 tANI_U32 i = 0, j, resultsPerEvent, scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303610 tANI_S32 totalResults;
3611 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303612 tpSirWifiScanResult pSirWifiScanResult, head_ptr;
3613 struct hdd_ext_scan_context *context;
3614 bool ignore_cached_results = false;
3615 tExtscanCachedScanResult *result;
3616 struct nlattr *nla_results;
3617 tANI_U16 ieLength= 0;
3618 tANI_U8 *ie = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303619
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303620 ENTER();
3621
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303622 if (wlan_hdd_validate_context(pHddCtx))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303623 return;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303624
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303625 if (!pMsg)
3626 {
3627 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3628 return;
3629 }
3630
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303631 spin_lock(&hdd_context_lock);
3632 context = &pHddCtx->ext_scan_context;
3633 ignore_cached_results = context->ignore_cached_results;
3634 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303635
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303636 if (ignore_cached_results) {
3637 hddLog(LOGE,
3638 FL("Ignore the cached results received after timeout"));
3639 return;
3640 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303641
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303642 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u More Data %u No of scan ids %u",
3643 pData->requestId, pData->moreData, pData->scanResultSize);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303644
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303645 result = (tExtscanCachedScanResult *)&(pData->result);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303646
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303647 for (scan_id_index = 0; scan_id_index < pData->scanResultSize;
3648 scan_id_index++) {
3649 result+= scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303650
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303651 totalResults = result->num_results;
3652 hddLog(VOS_TRACE_LEVEL_INFO, "scan_id %u flags %u Num results %u",
3653 result->scan_id, result->flags, totalResults);
3654 i = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303655
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303656 do{
3657 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
3658 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
3659 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303660
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303661 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
3662 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN);
3663
3664 if (!skb) {
3665 hddLog(VOS_TRACE_LEVEL_ERROR,
3666 FL("cfg80211_vendor_event_alloc failed"));
3667 return;
3668 }
3669
3670 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
3671
3672 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3673 pData->requestId) ||
3674 nla_put_u32(skb,
3675 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3676 resultsPerEvent)) {
3677 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3678 goto fail;
3679 }
3680 if (nla_put_u8(skb,
3681 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3682 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303683 {
3684 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3685 goto fail;
3686 }
3687
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303688 if (nla_put_u32(skb,
3689 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
3690 result->scan_id)) {
3691 hddLog(LOGE, FL("put fail"));
3692 goto fail;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303693 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303694
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303695 nla_results = nla_nest_start(skb,
3696 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST);
3697 if (!nla_results)
3698 goto fail;
3699
3700 if (resultsPerEvent) {
3701 struct nlattr *aps;
3702 struct nlattr *nla_result;
3703
3704 nla_result = nla_nest_start(skb, scan_id_index);
3705 if(!nla_result)
3706 goto fail;
3707
3708 if (nla_put_u32(skb,
3709 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
3710 result->scan_id) ||
3711 nla_put_u32(skb,
3712 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_FLAGS,
3713 result->flags) ||
3714 nla_put_u32(skb,
3715 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3716 totalResults)) {
3717 hddLog(LOGE, FL("put fail"));
3718 goto fail;
3719 }
3720
3721 aps = nla_nest_start(skb,
3722 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3723 if (!aps)
3724 {
3725 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3726 goto fail;
3727 }
3728
3729 head_ptr = (tpSirWifiScanResult) &(result->ap);
3730
3731 for (j = 0; j < resultsPerEvent; j++, i++) {
3732 struct nlattr *ap;
3733 pSirWifiScanResult = head_ptr + i;
3734
3735 /*
Srinivas Dasari91727c12016-03-23 17:59:06 +05303736 * Firmware returns timestamp from extscan_start till
3737 * BSSID was cached (in micro seconds). Add this with
3738 * time gap between system boot up to extscan_start
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303739 * to derive the time since boot when the
3740 * BSSID was cached.
3741 */
Srinivas Dasari91727c12016-03-23 17:59:06 +05303742 pSirWifiScanResult->ts +=
3743 pHddCtx->extscan_start_time_since_boot;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303744 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
3745 "Ssid (%s)"
3746 "Bssid: %pM "
3747 "Channel (%u)"
3748 "Rssi (%d)"
3749 "RTT (%u)"
3750 "RTT_SD (%u)"
3751 "Beacon Period %u"
3752 "Capability 0x%x "
3753 "Ie length %d",
3754 i,
3755 pSirWifiScanResult->ts,
3756 pSirWifiScanResult->ssid,
3757 pSirWifiScanResult->bssid,
3758 pSirWifiScanResult->channel,
3759 pSirWifiScanResult->rssi,
3760 pSirWifiScanResult->rtt,
3761 pSirWifiScanResult->rtt_sd,
3762 pSirWifiScanResult->beaconPeriod,
3763 pSirWifiScanResult->capability,
3764 ieLength);
3765
3766 ap = nla_nest_start(skb, j + 1);
3767 if (!ap)
3768 {
3769 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3770 goto fail;
3771 }
3772
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05303773 if (hdd_wlan_nla_put_u64(skb,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303774 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3775 pSirWifiScanResult->ts) )
3776 {
3777 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3778 goto fail;
3779 }
3780 if (nla_put(skb,
3781 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3782 sizeof(pSirWifiScanResult->ssid),
3783 pSirWifiScanResult->ssid) )
3784 {
3785 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3786 goto fail;
3787 }
3788 if (nla_put(skb,
3789 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3790 sizeof(pSirWifiScanResult->bssid),
3791 pSirWifiScanResult->bssid) )
3792 {
3793 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3794 goto fail;
3795 }
3796 if (nla_put_u32(skb,
3797 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3798 pSirWifiScanResult->channel) )
3799 {
3800 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3801 goto fail;
3802 }
3803 if (nla_put_s32(skb,
3804 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3805 pSirWifiScanResult->rssi) )
3806 {
3807 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3808 goto fail;
3809 }
3810 if (nla_put_u32(skb,
3811 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3812 pSirWifiScanResult->rtt) )
3813 {
3814 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3815 goto fail;
3816 }
3817 if (nla_put_u32(skb,
3818 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3819 pSirWifiScanResult->rtt_sd))
3820 {
3821 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3822 goto fail;
3823 }
3824 if (nla_put_u32(skb,
3825 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3826 pSirWifiScanResult->beaconPeriod))
3827 {
3828 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3829 goto fail;
3830 }
3831 if (nla_put_u32(skb,
3832 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3833 pSirWifiScanResult->capability))
3834 {
3835 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3836 goto fail;
3837 }
3838 if (nla_put_u32(skb,
3839 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3840 ieLength))
3841 {
3842 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3843 goto fail;
3844 }
3845
3846 if (ieLength)
3847 if (nla_put(skb,
3848 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3849 ieLength, ie)) {
3850 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3851 goto fail;
3852 }
3853
3854 nla_nest_end(skb, ap);
3855 }
3856 nla_nest_end(skb, aps);
3857 nla_nest_end(skb, nla_result);
3858 }
3859
3860 nla_nest_end(skb, nla_results);
3861
3862 cfg80211_vendor_cmd_reply(skb);
3863
3864 } while (totalResults > 0);
3865 }
3866
3867 if (!pData->moreData) {
3868 spin_lock(&hdd_context_lock);
3869 context->response_status = 0;
3870 complete(&context->response_event);
3871 spin_unlock(&hdd_context_lock);
3872 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303873
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303874 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303875 return;
3876fail:
3877 kfree_skb(skb);
3878 return;
3879}
3880
3881static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
3882 void *pMsg)
3883{
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303884 tpSirEXTScanHotlistMatch pData = (tpSirEXTScanHotlistMatch) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303885 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3886 struct sk_buff *skb = NULL;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303887 tANI_U32 i, index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303888
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303889 ENTER();
3890
3891 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303892 hddLog(LOGE,
3893 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303894 return;
3895 }
3896 if (!pMsg)
3897 {
3898 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303899 return;
3900 }
3901
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303902 if (pData->bss_found)
3903 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX;
3904 else
3905 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX;
3906
Dino Mycle6fb96c12014-06-10 11:52:40 +05303907 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303908#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3909 NULL,
3910#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303911 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303912 index, GFP_KERNEL);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303913
3914 if (!skb) {
3915 hddLog(VOS_TRACE_LEVEL_ERROR,
3916 FL("cfg80211_vendor_event_alloc failed"));
3917 return;
3918 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303919
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303920 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3921 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numHotlistBss);
3922 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
3923 hddLog(VOS_TRACE_LEVEL_INFO, "ap_found %u", pData->bss_found);
3924
3925 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303926 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
3927 "Ssid (%s) "
3928 "Bssid (" MAC_ADDRESS_STR ") "
3929 "Channel (%u) "
3930 "Rssi (%d) "
3931 "RTT (%u) "
3932 "RTT_SD (%u) ",
3933 i,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303934 pData->bssHotlist[i].ts,
3935 pData->bssHotlist[i].ssid,
3936 MAC_ADDR_ARRAY(pData->bssHotlist[i].bssid),
3937 pData->bssHotlist[i].channel,
3938 pData->bssHotlist[i].rssi,
3939 pData->bssHotlist[i].rtt,
3940 pData->bssHotlist[i].rtt_sd);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303941 }
3942
3943 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3944 pData->requestId) ||
3945 nla_put_u32(skb,
3946 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303947 pData->numHotlistBss)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303948 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3949 goto fail;
3950 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303951 if (pData->numHotlistBss) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303952 struct nlattr *aps;
3953
3954 aps = nla_nest_start(skb,
3955 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3956 if (!aps)
3957 goto fail;
3958
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303959 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303960 struct nlattr *ap;
3961
3962 ap = nla_nest_start(skb, i + 1);
3963 if (!ap)
3964 goto fail;
3965
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05303966 if (hdd_wlan_nla_put_u64(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303967 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303968 pData->bssHotlist[i].ts) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303969 nla_put(skb,
3970 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303971 sizeof(pData->bssHotlist[i].ssid),
3972 pData->bssHotlist[i].ssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303973 nla_put(skb,
3974 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303975 sizeof(pData->bssHotlist[i].bssid),
3976 pData->bssHotlist[i].bssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303977 nla_put_u32(skb,
3978 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303979 pData->bssHotlist[i].channel) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303980 nla_put_s32(skb,
3981 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303982 pData->bssHotlist[i].rssi) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303983 nla_put_u32(skb,
3984 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303985 pData->bssHotlist[i].rtt) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05303986 nla_put_u32(skb,
3987 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303988 pData->bssHotlist[i].rtt_sd))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303989 goto fail;
3990
3991 nla_nest_end(skb, ap);
3992 }
3993 nla_nest_end(skb, aps);
3994
3995 if (nla_put_u8(skb,
3996 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3997 pData->moreData))
3998 goto fail;
3999 }
4000
4001 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304002 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304003 return;
4004
4005fail:
4006 kfree_skb(skb);
4007 return;
4008
4009}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304010
4011static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
4012 void *pMsg)
4013{
4014 struct sk_buff *skb;
4015 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
4016 tpSirWifiFullScanResultEvent pData =
4017 (tpSirWifiFullScanResultEvent) (pMsg);
4018
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304019 ENTER();
4020
4021 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304022 hddLog(LOGE,
4023 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304024 return;
4025 }
4026 if (!pMsg)
4027 {
4028 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304029 return;
4030 }
4031
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304032 /*
4033 * If the full scan result including IE data exceeds NL 4K size
4034 * limitation, drop that beacon/probe rsp frame.
4035 */
4036 if ((sizeof(*pData) + pData->ieLength) >= EXTSCAN_EVENT_BUF_SIZE) {
4037 hddLog(LOGE, FL("Frame exceeded NL size limilation, drop it!"));
4038 return;
4039 }
4040
Dino Mycle6fb96c12014-06-10 11:52:40 +05304041 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304042#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4043 NULL,
4044#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05304045 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4046 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
4047 GFP_KERNEL);
4048
4049 if (!skb) {
4050 hddLog(VOS_TRACE_LEVEL_ERROR,
4051 FL("cfg80211_vendor_event_alloc failed"));
4052 return;
4053 }
4054
Dino Mycle6fb96c12014-06-10 11:52:40 +05304055 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
4056 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
4057 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
4058 "Ssid (%s)"
4059 "Bssid (" MAC_ADDRESS_STR ")"
4060 "Channel (%u)"
4061 "Rssi (%d)"
4062 "RTT (%u)"
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304063 "RTT_SD (%u)"
4064 "Bcn Period %d"
4065 "Capability 0x%X "),
Dino Mycle6fb96c12014-06-10 11:52:40 +05304066 pData->ap.ts,
4067 pData->ap.ssid,
4068 MAC_ADDR_ARRAY(pData->ap.bssid),
4069 pData->ap.channel,
4070 pData->ap.rssi,
4071 pData->ap.rtt,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304072 pData->ap.rtt_sd,
4073 pData->ap.beaconPeriod,
4074 pData->ap.capability);
4075
Dino Mycle6fb96c12014-06-10 11:52:40 +05304076 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
4077 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
4078 pData->requestId) ||
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05304079 hdd_wlan_nla_put_u64(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304080 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
4081 pData->ap.ts) ||
4082 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
4083 sizeof(pData->ap.ssid),
4084 pData->ap.ssid) ||
4085 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
4086 WNI_CFG_BSSID_LEN,
4087 pData->ap.bssid) ||
4088 nla_put_u32(skb,
4089 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
4090 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05304091 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304092 pData->ap.rssi) ||
4093 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
4094 pData->ap.rtt) ||
4095 nla_put_u32(skb,
4096 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
4097 pData->ap.rtt_sd) ||
4098 nla_put_u16(skb,
4099 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
4100 pData->ap.beaconPeriod) ||
4101 nla_put_u16(skb,
4102 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
4103 pData->ap.capability) ||
4104 nla_put_u32(skb,
4105 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304106 pData->ieLength) ||
4107 nla_put_u8(skb,
4108 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
4109 pData->moreData))
Dino Mycle6fb96c12014-06-10 11:52:40 +05304110 {
4111 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4112 goto nla_put_failure;
4113 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304114
4115 if (pData->ieLength) {
4116 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
4117 pData->ieLength,
4118 pData->ie))
4119 {
4120 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4121 goto nla_put_failure;
4122 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05304123 }
4124
4125 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304126 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304127 return;
4128
4129nla_put_failure:
4130 kfree_skb(skb);
4131 return;
4132}
4133
4134static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
4135 void *pMsg)
4136{
4137 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
4138 struct sk_buff *skb = NULL;
4139 tpSirEXTScanResultsAvailableIndParams pData =
4140 (tpSirEXTScanResultsAvailableIndParams) pMsg;
4141
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304142 ENTER();
4143
4144 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304145 hddLog(LOGE,
4146 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304147 return;
4148 }
4149 if (!pMsg)
4150 {
4151 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304152 return;
4153 }
4154
4155 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304156#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4157 NULL,
4158#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05304159 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4160 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
4161 GFP_KERNEL);
4162
4163 if (!skb) {
4164 hddLog(VOS_TRACE_LEVEL_ERROR,
4165 FL("cfg80211_vendor_event_alloc failed"));
4166 return;
4167 }
4168
Dino Mycle6fb96c12014-06-10 11:52:40 +05304169 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
4170 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
4171 pData->numResultsAvailable);
4172 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
4173 pData->requestId) ||
4174 nla_put_u32(skb,
4175 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
4176 pData->numResultsAvailable)) {
4177 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4178 goto nla_put_failure;
4179 }
4180
4181 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304182 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304183 return;
4184
4185nla_put_failure:
4186 kfree_skb(skb);
4187 return;
4188}
4189
4190static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
4191{
4192 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
4193 struct sk_buff *skb = NULL;
4194 tpSirEXTScanProgressIndParams pData =
4195 (tpSirEXTScanProgressIndParams) pMsg;
4196
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304197 ENTER();
4198
4199 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304200 hddLog(LOGE,
4201 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304202 return;
4203 }
4204 if (!pMsg)
4205 {
4206 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304207 return;
4208 }
4209
4210 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304211#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4212 NULL,
4213#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05304214 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4215 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
4216 GFP_KERNEL);
4217
4218 if (!skb) {
4219 hddLog(VOS_TRACE_LEVEL_ERROR,
4220 FL("cfg80211_vendor_event_alloc failed"));
4221 return;
4222 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304223 hddLog(VOS_TRACE_LEVEL_INFO, FL("Request Id (%u) "), pData->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304224 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
4225 pData->extScanEventType);
4226 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
4227 pData->status);
4228
4229 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
4230 pData->extScanEventType) ||
4231 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05304232 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
4233 pData->requestId) ||
4234 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304235 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
4236 pData->status)) {
4237 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4238 goto nla_put_failure;
4239 }
4240
4241 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304242 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304243 return;
4244
4245nla_put_failure:
4246 kfree_skb(skb);
4247 return;
4248}
4249
4250void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
4251 void *pMsg)
4252{
4253 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
4254
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304255 ENTER();
4256
Dino Mycle6fb96c12014-06-10 11:52:40 +05304257 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304258 return;
4259 }
4260
4261 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
4262
4263
4264 switch(evType) {
4265 case SIR_HAL_EXTSCAN_START_RSP:
4266 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
4267 break;
4268
4269 case SIR_HAL_EXTSCAN_STOP_RSP:
4270 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
4271 break;
4272 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
4273 /* There is no need to send this response to upper layer
4274 Just log the message */
4275 hddLog(VOS_TRACE_LEVEL_INFO,
4276 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
4277 break;
4278 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
4279 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
4280 break;
4281
4282 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
4283 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
4284 break;
4285
Dino Mycle6fb96c12014-06-10 11:52:40 +05304286 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05304287 wlan_hdd_cfg80211_extscan_get_capabilities_rsp(ctx, pMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304288 break;
4289 case SIR_HAL_EXTSCAN_PROGRESS_IND:
4290 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
4291 break;
4292 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
4293 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
4294 break;
4295 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
4296 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
4297 break;
4298 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
4299 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
4300 break;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304301 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
4302 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
4303 break;
4304 default:
4305 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
4306 break;
4307 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304308 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304309}
4310
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304311static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
4312 struct wireless_dev *wdev,
4313 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304314{
Dino Myclee8843b32014-07-04 14:21:45 +05304315 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304316 struct net_device *dev = wdev->netdev;
4317 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4318 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4319 struct nlattr
4320 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4321 eHalStatus status;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05304322 struct hdd_ext_scan_context *context;
4323 unsigned long rc;
4324 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304325
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304326 ENTER();
4327
Dino Mycle6fb96c12014-06-10 11:52:40 +05304328 status = wlan_hdd_validate_context(pHddCtx);
4329 if (0 != status)
4330 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304331 return -EINVAL;
4332 }
Dino Myclee8843b32014-07-04 14:21:45 +05304333 /* check the EXTScan Capability */
4334 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304335 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4336 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304337 {
4338 hddLog(VOS_TRACE_LEVEL_ERROR,
4339 FL("EXTScan not enabled/supported by Firmware"));
4340 return -EINVAL;
4341 }
4342
Dino Mycle6fb96c12014-06-10 11:52:40 +05304343 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4344 data, dataLen,
4345 wlan_hdd_extscan_config_policy)) {
4346 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4347 return -EINVAL;
4348 }
4349
4350 /* Parse and fetch request Id */
4351 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4352 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4353 return -EINVAL;
4354 }
4355
Dino Myclee8843b32014-07-04 14:21:45 +05304356 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304357 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304358 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304359
Dino Myclee8843b32014-07-04 14:21:45 +05304360 reqMsg.sessionId = pAdapter->sessionId;
4361 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304362
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05304363 vos_spin_lock_acquire(&hdd_context_lock);
4364 context = &pHddCtx->ext_scan_context;
4365 context->request_id = reqMsg.requestId;
4366 INIT_COMPLETION(context->response_event);
4367 vos_spin_lock_release(&hdd_context_lock);
4368
Dino Myclee8843b32014-07-04 14:21:45 +05304369 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304370 if (!HAL_STATUS_SUCCESS(status)) {
4371 hddLog(VOS_TRACE_LEVEL_ERROR,
4372 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304373 return -EINVAL;
4374 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05304375
4376 rc = wait_for_completion_timeout(&context->response_event,
4377 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4378 if (!rc) {
4379 hddLog(LOGE, FL("Target response timed out"));
4380 return -ETIMEDOUT;
4381 }
4382
4383 ret = wlan_hdd_send_ext_scan_capability(pHddCtx);
4384 if (ret)
4385 hddLog(LOGE, FL("Failed to send ext scan capability to user space"));
4386
4387 return ret;
4388
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304389 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304390 return 0;
4391}
4392
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304393static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
4394 struct wireless_dev *wdev,
4395 const void *data, int dataLen)
4396{
4397 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304398
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304399 vos_ssr_protect(__func__);
4400 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
4401 vos_ssr_unprotect(__func__);
4402
4403 return ret;
4404}
4405
4406static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
4407 struct wireless_dev *wdev,
4408 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304409{
Dino Myclee8843b32014-07-04 14:21:45 +05304410 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304411 struct net_device *dev = wdev->netdev;
4412 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4413 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4414 struct nlattr
4415 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4416 eHalStatus status;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304417 struct hdd_ext_scan_context *context;
4418 unsigned long rc;
4419 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304420
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304421 ENTER();
4422
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304423 if (VOS_FTM_MODE == hdd_get_conparam()) {
4424 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4425 return -EINVAL;
4426 }
4427
Dino Mycle6fb96c12014-06-10 11:52:40 +05304428 status = wlan_hdd_validate_context(pHddCtx);
4429 if (0 != status)
4430 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304431 return -EINVAL;
4432 }
Dino Myclee8843b32014-07-04 14:21:45 +05304433 /* check the EXTScan Capability */
4434 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304435 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4436 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304437 {
4438 hddLog(VOS_TRACE_LEVEL_ERROR,
4439 FL("EXTScan not enabled/supported by Firmware"));
4440 return -EINVAL;
4441 }
4442
Dino Mycle6fb96c12014-06-10 11:52:40 +05304443 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4444 data, dataLen,
4445 wlan_hdd_extscan_config_policy)) {
4446 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4447 return -EINVAL;
4448 }
4449 /* Parse and fetch request Id */
4450 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4451 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4452 return -EINVAL;
4453 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05304454
Dino Myclee8843b32014-07-04 14:21:45 +05304455 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304456 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4457
Dino Myclee8843b32014-07-04 14:21:45 +05304458 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304459
Dino Myclee8843b32014-07-04 14:21:45 +05304460 reqMsg.sessionId = pAdapter->sessionId;
4461 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304462
4463 /* Parse and fetch flush parameter */
4464 if (!tb
4465 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
4466 {
4467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
4468 goto failed;
4469 }
Dino Myclee8843b32014-07-04 14:21:45 +05304470 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304471 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
4472
Dino Myclee8843b32014-07-04 14:21:45 +05304473 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304474
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304475 spin_lock(&hdd_context_lock);
4476 context = &pHddCtx->ext_scan_context;
4477 context->request_id = reqMsg.requestId;
4478 context->ignore_cached_results = false;
4479 INIT_COMPLETION(context->response_event);
4480 spin_unlock(&hdd_context_lock);
4481
Dino Myclee8843b32014-07-04 14:21:45 +05304482 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304483 if (!HAL_STATUS_SUCCESS(status)) {
4484 hddLog(VOS_TRACE_LEVEL_ERROR,
4485 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304486 return -EINVAL;
4487 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304488
4489 rc = wait_for_completion_timeout(&context->response_event,
4490 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4491 if (!rc) {
4492 hddLog(LOGE, FL("Target response timed out"));
4493 retval = -ETIMEDOUT;
4494 spin_lock(&hdd_context_lock);
4495 context->ignore_cached_results = true;
4496 spin_unlock(&hdd_context_lock);
4497 } else {
4498 spin_lock(&hdd_context_lock);
4499 retval = context->response_status;
4500 spin_unlock(&hdd_context_lock);
4501 }
4502
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304503 EXIT();
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05304504 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304505
4506failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05304507 return -EINVAL;
4508}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304509static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
4510 struct wireless_dev *wdev,
4511 const void *data, int dataLen)
4512{
4513 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304514
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304515 vos_ssr_protect(__func__);
4516 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
4517 vos_ssr_unprotect(__func__);
4518
4519 return ret;
4520}
4521
4522static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304523 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05304524 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304525{
4526 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
4527 struct net_device *dev = wdev->netdev;
4528 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4529 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4530 struct nlattr
4531 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4532 struct nlattr
4533 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4534 struct nlattr *apTh;
4535 eHalStatus status;
4536 tANI_U8 i = 0;
4537 int rem;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304538 struct hdd_ext_scan_context *context;
4539 tANI_U32 request_id;
4540 unsigned long rc;
4541 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304542
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304543 ENTER();
4544
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304545 if (VOS_FTM_MODE == hdd_get_conparam()) {
4546 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4547 return -EINVAL;
4548 }
4549
Dino Mycle6fb96c12014-06-10 11:52:40 +05304550 status = wlan_hdd_validate_context(pHddCtx);
4551 if (0 != status)
4552 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304553 return -EINVAL;
4554 }
Dino Myclee8843b32014-07-04 14:21:45 +05304555 /* check the EXTScan Capability */
4556 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304557 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4558 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304559 {
4560 hddLog(VOS_TRACE_LEVEL_ERROR,
4561 FL("EXTScan not enabled/supported by Firmware"));
4562 return -EINVAL;
4563 }
4564
Dino Mycle6fb96c12014-06-10 11:52:40 +05304565 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4566 data, dataLen,
4567 wlan_hdd_extscan_config_policy)) {
4568 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4569 return -EINVAL;
4570 }
4571
4572 /* Parse and fetch request Id */
4573 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4574 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4575 return -EINVAL;
4576 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05304577 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
4578 vos_mem_malloc(sizeof(*pReqMsg));
4579 if (!pReqMsg) {
4580 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4581 return -ENOMEM;
4582 }
4583
Dino Myclee8843b32014-07-04 14:21:45 +05304584
Dino Mycle6fb96c12014-06-10 11:52:40 +05304585 pReqMsg->requestId = nla_get_u32(
4586 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4587 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4588
4589 /* Parse and fetch number of APs */
4590 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
4591 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
4592 goto fail;
4593 }
4594
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304595 /* Parse and fetch lost ap sample size */
4596 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]) {
4597 hddLog(LOGE, FL("attr lost ap sample size failed"));
4598 goto fail;
4599 }
4600
4601 pReqMsg->lostBssidSampleSize = nla_get_u32(
4602 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]);
4603 hddLog(LOG1, FL("Lost ap sample size %d"), pReqMsg->lostBssidSampleSize);
4604
Dino Mycle6fb96c12014-06-10 11:52:40 +05304605 pReqMsg->sessionId = pAdapter->sessionId;
4606 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4607
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304608 pReqMsg->numBssid = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304609 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05304610 if (pReqMsg->numBssid > WLAN_EXTSCAN_MAX_HOTLIST_APS) {
4611 hddLog(LOGE, FL("Number of AP: %u exceeds max: %u"),
4612 pReqMsg->numBssid, WLAN_EXTSCAN_MAX_HOTLIST_APS);
4613 goto fail;
4614 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304615 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304616
4617 nla_for_each_nested(apTh,
4618 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05304619 if (i == pReqMsg->numBssid) {
4620 hddLog(LOGW, FL("Ignoring excess AP"));
4621 break;
4622 }
4623
Dino Mycle6fb96c12014-06-10 11:52:40 +05304624 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4625 nla_data(apTh), nla_len(apTh),
4626 NULL)) {
4627 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4628 goto fail;
4629 }
4630
4631 /* Parse and fetch MAC address */
4632 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
4633 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
4634 goto fail;
4635 }
4636 memcpy(pReqMsg->ap[i].bssid, nla_data(
4637 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
4638 sizeof(tSirMacAddr));
4639 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
4640
4641 /* Parse and fetch low RSSI */
4642 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
4643 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
4644 goto fail;
4645 }
4646 pReqMsg->ap[i].low = nla_get_s32(
4647 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
4648 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
4649
4650 /* Parse and fetch high RSSI */
4651 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
4652 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
4653 goto fail;
4654 }
4655 pReqMsg->ap[i].high = nla_get_s32(
4656 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
4657 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
4658 pReqMsg->ap[i].high);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304659 i++;
4660 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304661
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05304662 if (i < pReqMsg->numBssid) {
4663 hddLog(LOGW, FL("Number of AP %u less than expected %u"),
4664 i, pReqMsg->numBssid);
4665 pReqMsg->numBssid = i;
4666 }
4667
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304668 context = &pHddCtx->ext_scan_context;
4669 spin_lock(&hdd_context_lock);
4670 INIT_COMPLETION(context->response_event);
4671 context->request_id = request_id = pReqMsg->requestId;
4672 spin_unlock(&hdd_context_lock);
4673
Dino Mycle6fb96c12014-06-10 11:52:40 +05304674 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
4675 if (!HAL_STATUS_SUCCESS(status)) {
4676 hddLog(VOS_TRACE_LEVEL_ERROR,
4677 FL("sme_SetBssHotlist failed(err=%d)"), status);
4678 vos_mem_free(pReqMsg);
4679 return -EINVAL;
4680 }
4681
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304682 /* request was sent -- wait for the response */
4683 rc = wait_for_completion_timeout(&context->response_event,
4684 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4685
4686 if (!rc) {
4687 hddLog(LOGE, FL("sme_SetBssHotlist timed out"));
4688 retval = -ETIMEDOUT;
4689 } else {
4690 spin_lock(&hdd_context_lock);
4691 if (context->request_id == request_id)
4692 retval = context->response_status;
4693 else
4694 retval = -EINVAL;
4695 spin_unlock(&hdd_context_lock);
4696 }
4697
Dino Myclee8843b32014-07-04 14:21:45 +05304698 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304699 EXIT();
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05304700 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304701
4702fail:
4703 vos_mem_free(pReqMsg);
4704 return -EINVAL;
4705}
4706
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304707static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
4708 struct wireless_dev *wdev,
4709 const void *data, int dataLen)
4710{
4711 int ret = 0;
4712
4713 vos_ssr_protect(__func__);
4714 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
4715 dataLen);
4716 vos_ssr_unprotect(__func__);
4717
4718 return ret;
4719}
4720
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304721static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304722 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304723 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304724{
Agrawal Ashish16abf782016-08-18 22:42:59 +05304725 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4726 struct net_device *dev = wdev->netdev;
4727 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4728 uint32_t chan_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4729 uint8_t num_channels = 0;
4730 uint8_t num_chan_new = 0;
4731 uint8_t buf[256] = {0};
Dino Mycle6fb96c12014-06-10 11:52:40 +05304732 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304733 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304734 tWifiBand wifiBand;
4735 eHalStatus status;
4736 struct sk_buff *replySkb;
Agrawal Ashish16abf782016-08-18 22:42:59 +05304737 tANI_U8 i,j,k;
4738 int ret,len = 0;;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304739
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304740 ENTER();
4741
Dino Mycle6fb96c12014-06-10 11:52:40 +05304742 status = wlan_hdd_validate_context(pHddCtx);
4743 if (0 != status)
4744 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304745 return -EINVAL;
4746 }
Dino Myclee8843b32014-07-04 14:21:45 +05304747
Dino Mycle6fb96c12014-06-10 11:52:40 +05304748 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4749 data, dataLen,
4750 wlan_hdd_extscan_config_policy)) {
4751 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4752 return -EINVAL;
4753 }
4754
4755 /* Parse and fetch request Id */
4756 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4757 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4758 return -EINVAL;
4759 }
4760 requestId = nla_get_u32(
4761 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4762 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
4763
4764 /* Parse and fetch wifi band */
4765 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
4766 {
4767 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4768 return -EINVAL;
4769 }
4770 wifiBand = nla_get_u32(
4771 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
4772 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
4773
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304774 /* Parse and fetch max channels */
4775 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
4776 {
4777 hddLog(LOGE, FL("attr max channels failed"));
4778 return -EINVAL;
4779 }
4780 maxChannels = nla_get_u32(
4781 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
4782 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
4783
Dino Mycle6fb96c12014-06-10 11:52:40 +05304784 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
Agrawal Ashish16abf782016-08-18 22:42:59 +05304785 wifiBand, chan_list,
4786 &num_channels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304787 if (eHAL_STATUS_SUCCESS != status) {
4788 hddLog(VOS_TRACE_LEVEL_ERROR,
4789 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4790 return -EINVAL;
4791 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304792
Agrawal Ashish16abf782016-08-18 22:42:59 +05304793 num_channels = VOS_MIN(num_channels, maxChannels);
4794 num_chan_new = num_channels;
4795 /* remove the indoor only channels if iface is SAP */
4796 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
4797 {
4798 num_chan_new = 0;
4799 for (i = 0; i < num_channels; i++)
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05304800 for (j = 0; j < HDD_NUM_NL80211_BANDS; j++) {
Agrawal Ashish16abf782016-08-18 22:42:59 +05304801 if (wiphy->bands[j] == NULL)
4802 continue;
4803 for (k = 0; k < wiphy->bands[j]->n_channels; k++) {
4804 if ((chan_list[i] ==
4805 wiphy->bands[j]->channels[k].center_freq) &&
4806 (!(wiphy->bands[j]->channels[k].flags &
4807 IEEE80211_CHAN_INDOOR_ONLY))) {
4808 chan_list[num_chan_new] = chan_list[i];
4809 num_chan_new++;
4810 }
4811 }
4812 }
4813 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304814
Agrawal Ashish16abf782016-08-18 22:42:59 +05304815 hddLog(LOG1, FL("Number of channels: %d"), num_chan_new);
4816 for (i = 0; i < num_chan_new; i++)
4817 len += scnprintf(buf + len, sizeof(buf) - len, "%u ", chan_list[i]);
4818 hddLog(LOG1, "Channels: %s", buf);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304819
4820 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
Agrawal Ashish16abf782016-08-18 22:42:59 +05304821 sizeof(u32) * num_chan_new +
Dino Mycle6fb96c12014-06-10 11:52:40 +05304822 NLMSG_HDRLEN);
4823
4824 if (!replySkb) {
4825 hddLog(VOS_TRACE_LEVEL_ERROR,
4826 FL("valid channels: buffer alloc fail"));
4827 return -EINVAL;
4828 }
4829 if (nla_put_u32(replySkb,
4830 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05304831 num_chan_new) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05304832 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05304833 sizeof(u32) * num_chan_new, chan_list)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304834
4835 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4836 kfree_skb(replySkb);
4837 return -EINVAL;
4838 }
4839
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304840 ret = cfg80211_vendor_cmd_reply(replySkb);
4841
4842 EXIT();
4843 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304844}
4845
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304846static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4847 struct wireless_dev *wdev,
4848 const void *data, int dataLen)
4849{
4850 int ret = 0;
4851
4852 vos_ssr_protect(__func__);
4853 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4854 dataLen);
4855 vos_ssr_unprotect(__func__);
4856
4857 return ret;
4858}
4859
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304860static int hdd_extscan_start_fill_bucket_channel_spec(
4861 hdd_context_t *pHddCtx,
4862 tpSirEXTScanStartReqParams pReqMsg,
4863 struct nlattr **tb)
4864{
4865 struct nlattr *bucket[
4866 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4867 struct nlattr *channel[
4868 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4869 struct nlattr *buckets;
4870 struct nlattr *channels;
4871 int rem1, rem2;
4872 eHalStatus status;
4873 tANI_U8 bktIndex, j, numChannels;
Ashish Kumar Dhanotiyacb407902017-08-14 19:57:32 +05304874 uint32_t expected_buckets;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304875 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4876 tANI_U32 passive_max_chn_time, active_max_chn_time;
4877
Ashish Kumar Dhanotiyacb407902017-08-14 19:57:32 +05304878 expected_buckets = pReqMsg->numBuckets;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304879 bktIndex = 0;
4880
4881 nla_for_each_nested(buckets,
4882 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
Ashish Kumar Dhanotiyacb407902017-08-14 19:57:32 +05304883 if (bktIndex >= expected_buckets) {
4884 hddLog(LOGW, FL("ignoring excess buckets"));
4885 break;
4886 }
4887
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304888 if (nla_parse(bucket,
Ashish Kumar Dhanotiya9c93f562017-06-20 12:13:33 +05304889 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4890 nla_data(buckets), nla_len(buckets),
4891 wlan_hdd_extscan_config_policy)) {
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304892 hddLog(LOGE, FL("nla_parse failed"));
4893 return -EINVAL;
4894 }
4895
4896 /* Parse and fetch bucket spec */
4897 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4898 hddLog(LOGE, FL("attr bucket index failed"));
4899 return -EINVAL;
4900 }
4901 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
4902 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4903 hddLog(LOG1, FL("Bucket spec Index %d"),
4904 pReqMsg->buckets[bktIndex].bucket);
4905
4906 /* Parse and fetch wifi band */
4907 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4908 hddLog(LOGE, FL("attr wifi band failed"));
4909 return -EINVAL;
4910 }
4911 pReqMsg->buckets[bktIndex].band = nla_get_u8(
4912 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4913 hddLog(LOG1, FL("Wifi band %d"),
4914 pReqMsg->buckets[bktIndex].band);
4915
4916 /* Parse and fetch period */
4917 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4918 hddLog(LOGE, FL("attr period failed"));
4919 return -EINVAL;
4920 }
4921 pReqMsg->buckets[bktIndex].period = nla_get_u32(
4922 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4923 hddLog(LOG1, FL("period %d"),
4924 pReqMsg->buckets[bktIndex].period);
4925
4926 /* Parse and fetch report events */
4927 if (!bucket[
4928 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4929 hddLog(LOGE, FL("attr report events failed"));
4930 return -EINVAL;
4931 }
4932 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
4933 bucket[
4934 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4935 hddLog(LOG1, FL("report events %d"),
4936 pReqMsg->buckets[bktIndex].reportEvents);
4937
4938 /* Parse and fetch max period */
4939 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
4940 hddLog(LOGE, FL("attr max period failed"));
4941 return -EINVAL;
4942 }
4943 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
4944 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
4945 hddLog(LOG1, FL("max period %u"),
4946 pReqMsg->buckets[bktIndex].max_period);
4947
4948 /* Parse and fetch exponent */
4949 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
4950 hddLog(LOGE, FL("attr exponent failed"));
4951 return -EINVAL;
4952 }
4953 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
4954 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
4955 hddLog(LOG1, FL("exponent %u"),
4956 pReqMsg->buckets[bktIndex].exponent);
4957
4958 /* Parse and fetch step count */
4959 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
4960 hddLog(LOGE, FL("attr step count failed"));
4961 return -EINVAL;
4962 }
4963 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
4964 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
4965 hddLog(LOG1, FL("Step count %u"),
4966 pReqMsg->buckets[bktIndex].step_count);
4967
4968 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
4969 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
4970
4971 /* Framework shall pass the channel list if the input WiFi band is
4972 * WIFI_BAND_UNSPECIFIED.
4973 * If the input WiFi band is specified (any value other than
4974 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
4975 */
4976 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
4977 numChannels = 0;
4978 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
4979 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
4980 pReqMsg->buckets[bktIndex].band,
4981 chanList, &numChannels);
4982 if (!HAL_STATUS_SUCCESS(status)) {
4983 hddLog(LOGE,
4984 FL("sme_GetValidChannelsByBand failed (err=%d)"),
4985 status);
4986 return -EINVAL;
4987 }
4988
4989 pReqMsg->buckets[bktIndex].numChannels =
4990 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
4991 hddLog(LOG1, FL("Num channels %d"),
4992 pReqMsg->buckets[bktIndex].numChannels);
4993
4994 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
4995 j++) {
4996 pReqMsg->buckets[bktIndex].channels[j].channel =
4997 chanList[j];
4998 pReqMsg->buckets[bktIndex].channels[j].
4999 chnlClass = 0;
5000 if (CSR_IS_CHANNEL_DFS(
5001 vos_freq_to_chan(chanList[j]))) {
5002 pReqMsg->buckets[bktIndex].channels[j].
5003 passive = 1;
5004 pReqMsg->buckets[bktIndex].channels[j].
5005 dwellTimeMs = passive_max_chn_time;
5006 } else {
5007 pReqMsg->buckets[bktIndex].channels[j].
5008 passive = 0;
5009 pReqMsg->buckets[bktIndex].channels[j].
5010 dwellTimeMs = active_max_chn_time;
5011 }
5012
5013 hddLog(LOG1,
5014 "Channel %u Passive %u Dwell time %u ms",
5015 pReqMsg->buckets[bktIndex].channels[j].channel,
5016 pReqMsg->buckets[bktIndex].channels[j].passive,
5017 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
5018 }
5019
5020 bktIndex++;
5021 continue;
5022 }
5023
5024 /* Parse and fetch number of channels */
5025 if (!bucket[
5026 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
5027 hddLog(LOGE, FL("attr num channels failed"));
5028 return -EINVAL;
5029 }
5030
5031 pReqMsg->buckets[bktIndex].numChannels =
5032 nla_get_u32(bucket[
5033 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
5034 hddLog(LOG1, FL("num channels %d"),
5035 pReqMsg->buckets[bktIndex].numChannels);
5036
5037 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
5038 hddLog(LOGE, FL("attr channel spec failed"));
5039 return -EINVAL;
5040 }
5041
5042 j = 0;
5043 nla_for_each_nested(channels,
5044 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
5045 if (nla_parse(channel,
5046 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
5047 nla_data(channels), nla_len(channels),
5048 wlan_hdd_extscan_config_policy)) {
5049 hddLog(LOGE, FL("nla_parse failed"));
5050 return -EINVAL;
5051 }
5052
5053 /* Parse and fetch channel */
5054 if (!channel[
5055 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
5056 hddLog(LOGE, FL("attr channel failed"));
5057 return -EINVAL;
5058 }
5059 pReqMsg->buckets[bktIndex].channels[j].channel =
5060 nla_get_u32(channel[
5061 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
5062 hddLog(LOG1, FL("channel %u"),
5063 pReqMsg->buckets[bktIndex].channels[j].channel);
5064
5065 /* Parse and fetch dwell time */
5066 if (!channel[
5067 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
5068 hddLog(LOGE, FL("attr dwelltime failed"));
5069 return -EINVAL;
5070 }
5071 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
5072 nla_get_u32(channel[
5073 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
5074
5075 hddLog(LOG1, FL("Dwell time (%u ms)"),
5076 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
5077
5078
5079 /* Parse and fetch channel spec passive */
5080 if (!channel[
5081 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
5082 hddLog(LOGE,
5083 FL("attr channel spec passive failed"));
5084 return -EINVAL;
5085 }
5086 pReqMsg->buckets[bktIndex].channels[j].passive =
5087 nla_get_u8(channel[
5088 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
5089 hddLog(LOG1, FL("Chnl spec passive %u"),
5090 pReqMsg->buckets[bktIndex].channels[j].passive);
5091
5092 j++;
5093 }
5094
5095 bktIndex++;
5096 }
5097
5098 return 0;
5099}
5100
5101
5102/*
5103 * define short names for the global vendor params
5104 * used by wlan_hdd_cfg80211_extscan_start()
5105 */
5106#define PARAM_MAX \
5107QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
5108#define PARAM_REQUEST_ID \
5109QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
5110#define PARAM_BASE_PERIOD \
5111QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
5112#define PARAM_MAX_AP_PER_SCAN \
5113QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
5114#define PARAM_RPT_THRHLD_PERCENT \
5115QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
5116#define PARAM_RPT_THRHLD_NUM_SCANS \
5117QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
5118#define PARAM_NUM_BUCKETS \
5119QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
5120
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305121static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05305122 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305123 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05305124{
Dino Myclee8843b32014-07-04 14:21:45 +05305125 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305126 struct net_device *dev = wdev->netdev;
5127 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5128 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5129 struct nlattr *tb[PARAM_MAX + 1];
5130 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305131 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305132 tANI_U32 request_id;
5133 struct hdd_ext_scan_context *context;
5134 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305135
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305136 ENTER();
5137
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305138 if (VOS_FTM_MODE == hdd_get_conparam()) {
5139 hddLog(LOGE, FL("Command not allowed in FTM mode"));
5140 return -EINVAL;
5141 }
5142
Dino Mycle6fb96c12014-06-10 11:52:40 +05305143 status = wlan_hdd_validate_context(pHddCtx);
5144 if (0 != status)
5145 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05305146 return -EINVAL;
5147 }
Dino Myclee8843b32014-07-04 14:21:45 +05305148 /* check the EXTScan Capability */
5149 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05305150 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
5151 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05305152 {
5153 hddLog(VOS_TRACE_LEVEL_ERROR,
5154 FL("EXTScan not enabled/supported by Firmware"));
5155 return -EINVAL;
5156 }
5157
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305158 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05305159 data, dataLen,
5160 wlan_hdd_extscan_config_policy)) {
5161 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5162 return -EINVAL;
5163 }
5164
5165 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305166 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05305167 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
5168 return -EINVAL;
5169 }
5170
Dino Myclee8843b32014-07-04 14:21:45 +05305171 pReqMsg = (tpSirEXTScanStartReqParams)
5172 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05305173 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05305174 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
5175 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305176 }
5177
5178 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305179 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305180 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
5181
5182 pReqMsg->sessionId = pAdapter->sessionId;
5183 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
5184
5185 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305186 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05305187 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
5188 goto fail;
5189 }
5190 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305191 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305192 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
5193 pReqMsg->basePeriod);
5194
5195 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305196 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05305197 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
5198 goto fail;
5199 }
5200 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305201 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305202 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
5203 pReqMsg->maxAPperScan);
5204
5205 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305206 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05305207 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
5208 goto fail;
5209 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305210 pReqMsg->reportThresholdPercent = nla_get_u8(
5211 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305212 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305213 pReqMsg->reportThresholdPercent);
5214
5215 /* Parse and fetch report threshold num scans */
5216 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
5217 hddLog(LOGE, FL("attr report_threshold num scans failed"));
5218 goto fail;
5219 }
5220 pReqMsg->reportThresholdNumScans = nla_get_u8(
5221 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
5222 hddLog(LOG1, FL("Report Threshold num scans %d"),
5223 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305224
5225 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305226 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05305227 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
5228 goto fail;
5229 }
5230 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305231 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305232 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
5233 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
5234 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
5235 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
5236 }
5237 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
5238 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305239
Dino Mycle6fb96c12014-06-10 11:52:40 +05305240 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
5241 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
5242 goto fail;
5243 }
5244
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305245 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305246
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305247 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
5248 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05305249
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305250 context = &pHddCtx->ext_scan_context;
5251 spin_lock(&hdd_context_lock);
5252 INIT_COMPLETION(context->response_event);
5253 context->request_id = request_id = pReqMsg->requestId;
5254 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05305255
Dino Mycle6fb96c12014-06-10 11:52:40 +05305256 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
5257 if (!HAL_STATUS_SUCCESS(status)) {
5258 hddLog(VOS_TRACE_LEVEL_ERROR,
5259 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305260 goto fail;
5261 }
5262
Srinivas Dasari91727c12016-03-23 17:59:06 +05305263 pHddCtx->extscan_start_time_since_boot = vos_get_monotonic_boottime();
5264
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305265 /* request was sent -- wait for the response */
5266 rc = wait_for_completion_timeout(&context->response_event,
5267 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
5268
5269 if (!rc) {
5270 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
5271 retval = -ETIMEDOUT;
5272 } else {
5273 spin_lock(&hdd_context_lock);
5274 if (context->request_id == request_id)
5275 retval = context->response_status;
5276 else
5277 retval = -EINVAL;
5278 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305279 }
5280
Dino Myclee8843b32014-07-04 14:21:45 +05305281 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305282 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305283 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305284
5285fail:
5286 vos_mem_free(pReqMsg);
5287 return -EINVAL;
5288}
5289
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05305290/*
5291 * done with short names for the global vendor params
5292 * used by wlan_hdd_cfg80211_extscan_start()
5293 */
5294#undef PARAM_MAX
5295#undef PARAM_REQUEST_ID
5296#undef PARAM_BASE_PERIOD
5297#undef PARAMS_MAX_AP_PER_SCAN
5298#undef PARAMS_RPT_THRHLD_PERCENT
5299#undef PARAMS_RPT_THRHLD_NUM_SCANS
5300#undef PARAMS_NUM_BUCKETS
5301
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305302static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
5303 struct wireless_dev *wdev,
5304 const void *data, int dataLen)
5305{
5306 int ret = 0;
5307
5308 vos_ssr_protect(__func__);
5309 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
5310 vos_ssr_unprotect(__func__);
5311
5312 return ret;
5313}
5314
5315static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05305316 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305317 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05305318{
Dino Myclee8843b32014-07-04 14:21:45 +05305319 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305320 struct net_device *dev = wdev->netdev;
5321 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5322 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5323 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
5324 eHalStatus status;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05305325 int retval;
5326 unsigned long rc;
5327 struct hdd_ext_scan_context *context;
5328 tANI_U32 request_id;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305329
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305330 ENTER();
5331
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05305332 if (VOS_FTM_MODE == hdd_get_conparam()) {
5333 hddLog(LOGE, FL("Command not allowed in FTM mode"));
5334 return -EINVAL;
5335 }
5336
Dino Mycle6fb96c12014-06-10 11:52:40 +05305337 status = wlan_hdd_validate_context(pHddCtx);
5338 if (0 != status)
5339 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05305340 return -EINVAL;
5341 }
Dino Myclee8843b32014-07-04 14:21:45 +05305342 /* check the EXTScan Capability */
5343 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05305344 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
5345 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05305346 {
5347 hddLog(VOS_TRACE_LEVEL_ERROR,
5348 FL("EXTScan not enabled/supported by Firmware"));
5349 return -EINVAL;
5350 }
5351
Dino Mycle6fb96c12014-06-10 11:52:40 +05305352 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
5353 data, dataLen,
5354 wlan_hdd_extscan_config_policy)) {
5355 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5356 return -EINVAL;
5357 }
5358
5359 /* Parse and fetch request Id */
5360 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
5361 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
5362 return -EINVAL;
5363 }
5364
Dino Myclee8843b32014-07-04 14:21:45 +05305365 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05305366 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05305367 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305368
Dino Myclee8843b32014-07-04 14:21:45 +05305369 reqMsg.sessionId = pAdapter->sessionId;
5370 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305371
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05305372 context = &pHddCtx->ext_scan_context;
5373 spin_lock(&hdd_context_lock);
5374 INIT_COMPLETION(context->response_event);
Sravanti Palakonda7539fb92016-02-26 17:49:21 +05305375 context->request_id = request_id = reqMsg.requestId;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05305376 spin_unlock(&hdd_context_lock);
5377
Dino Myclee8843b32014-07-04 14:21:45 +05305378 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305379 if (!HAL_STATUS_SUCCESS(status)) {
5380 hddLog(VOS_TRACE_LEVEL_ERROR,
5381 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305382 return -EINVAL;
5383 }
5384
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05305385 /* request was sent -- wait for the response */
5386 rc = wait_for_completion_timeout(&context->response_event,
5387 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
5388
5389 if (!rc) {
5390 hddLog(LOGE, FL("sme_ExtScanStop timed out"));
5391 retval = -ETIMEDOUT;
5392 } else {
5393 spin_lock(&hdd_context_lock);
5394 if (context->request_id == request_id)
5395 retval = context->response_status;
5396 else
5397 retval = -EINVAL;
5398 spin_unlock(&hdd_context_lock);
5399 }
5400
5401 return retval;
5402
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305403 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05305404 return 0;
5405}
5406
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305407static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
5408 struct wireless_dev *wdev,
5409 const void *data, int dataLen)
5410{
5411 int ret = 0;
5412
5413 vos_ssr_protect(__func__);
5414 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
5415 vos_ssr_unprotect(__func__);
5416
5417 return ret;
5418}
5419
5420static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05305421 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305422 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05305423{
Dino Myclee8843b32014-07-04 14:21:45 +05305424 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305425 struct net_device *dev = wdev->netdev;
5426 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5427 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5428 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
5429 eHalStatus status;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05305430 struct hdd_ext_scan_context *context;
5431 tANI_U32 request_id;
5432 unsigned long rc;
5433 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305434
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305435 ENTER();
5436
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05305437 if (VOS_FTM_MODE == hdd_get_conparam()) {
5438 hddLog(LOGE, FL("Command not allowed in FTM mode"));
5439 return -EINVAL;
5440 }
5441
Dino Mycle6fb96c12014-06-10 11:52:40 +05305442 status = wlan_hdd_validate_context(pHddCtx);
5443 if (0 != status)
5444 {
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05305445 hddLog(LOGE, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05305446 return -EINVAL;
5447 }
Dino Myclee8843b32014-07-04 14:21:45 +05305448 /* check the EXTScan Capability */
5449 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05305450 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
5451 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05305452 {
5453 hddLog(VOS_TRACE_LEVEL_ERROR,
5454 FL("EXTScan not enabled/supported by Firmware"));
5455 return -EINVAL;
5456 }
5457
Dino Mycle6fb96c12014-06-10 11:52:40 +05305458 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
5459 data, dataLen,
5460 wlan_hdd_extscan_config_policy)) {
5461 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5462 return -EINVAL;
5463 }
5464
5465 /* Parse and fetch request Id */
5466 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
5467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
5468 return -EINVAL;
5469 }
5470
Dino Myclee8843b32014-07-04 14:21:45 +05305471 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05305472 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05305473 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305474
Dino Myclee8843b32014-07-04 14:21:45 +05305475 reqMsg.sessionId = pAdapter->sessionId;
5476 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305477
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05305478 context = &pHddCtx->ext_scan_context;
5479 spin_lock(&hdd_context_lock);
5480 INIT_COMPLETION(context->response_event);
5481 context->request_id = request_id = reqMsg.requestId;
5482 spin_unlock(&hdd_context_lock);
5483
Dino Myclee8843b32014-07-04 14:21:45 +05305484 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305485 if (!HAL_STATUS_SUCCESS(status)) {
5486 hddLog(VOS_TRACE_LEVEL_ERROR,
5487 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05305488 return -EINVAL;
5489 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05305490
5491 /* request was sent -- wait for the response */
5492 rc = wait_for_completion_timeout(&context->response_event,
5493 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
5494 if (!rc) {
5495 hddLog(LOGE, FL("sme_ResetBssHotlist timed out"));
5496 retval = -ETIMEDOUT;
5497 } else {
5498 spin_lock(&hdd_context_lock);
5499 if (context->request_id == request_id)
5500 retval = context->response_status;
5501 else
5502 retval = -EINVAL;
5503 spin_unlock(&hdd_context_lock);
5504 }
5505
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305506 EXIT();
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05305507 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305508}
5509
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305510static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
5511 struct wireless_dev *wdev,
5512 const void *data, int dataLen)
5513{
5514 int ret = 0;
5515
5516 vos_ssr_protect(__func__);
5517 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
5518 vos_ssr_unprotect(__func__);
5519
5520 return ret;
5521}
Dino Mycle6fb96c12014-06-10 11:52:40 +05305522#endif /* WLAN_FEATURE_EXTSCAN */
5523
Atul Mittal115287b2014-07-08 13:26:33 +05305524/*EXT TDLS*/
5525static const struct nla_policy
5526wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
5527{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305528 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {
5529 .type = NLA_UNSPEC,
5530 .len = HDD_MAC_ADDR_LEN},
Atul Mittal115287b2014-07-08 13:26:33 +05305531 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
5532 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
5533 {.type = NLA_S32 },
5534 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
5535 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
5536
5537};
5538
5539static const struct nla_policy
5540wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
5541{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305542 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {
5543 .type = NLA_UNSPEC,
5544 .len = HDD_MAC_ADDR_LEN},
Atul Mittal115287b2014-07-08 13:26:33 +05305545
5546};
5547
5548static const struct nla_policy
5549wlan_hdd_tdls_config_state_change_policy[
5550 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
5551{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305552 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {
5553 .type = NLA_UNSPEC,
5554 .len = HDD_MAC_ADDR_LEN},
Atul Mittal115287b2014-07-08 13:26:33 +05305555 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
5556 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305557 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
5558 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
5559 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305560
5561};
5562
5563static const struct nla_policy
5564wlan_hdd_tdls_config_get_status_policy[
5565 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
5566{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305567 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {
5568 .type = NLA_UNSPEC,
5569 .len = HDD_MAC_ADDR_LEN},
Atul Mittal115287b2014-07-08 13:26:33 +05305570 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
5571 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305572 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
5573 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
5574 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305575
5576};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305577
5578static const struct nla_policy
5579wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
5580{
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05305581 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {
5582 .type = NLA_UNSPEC,
5583 .len = VOS_MAC_ADDR_FIRST_3_BYTES},
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305584};
5585
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305586static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305587 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305588 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305589 int data_len)
5590{
5591
5592 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5593 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
5594
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305595 ENTER();
5596
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305597 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305598 return -EINVAL;
5599 }
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +05305600 if (0 == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05305601 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305602 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05305603 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305604 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05305605 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305606 return -ENOTSUPP;
5607 }
5608
5609 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
5610 data, data_len, wlan_hdd_mac_config)) {
5611 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5612 return -EINVAL;
5613 }
5614
5615 /* Parse and fetch mac address */
5616 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
5617 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5618 return -EINVAL;
5619 }
5620
5621 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
5622 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5623 VOS_MAC_ADDR_LAST_3_BYTES);
5624
Siddharth Bhal76972212014-10-15 16:22:51 +05305625 pHddCtx->spoofMacAddr.isEnabled = TRUE;
5626
5627 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305628 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5629 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05305630 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
5631 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
5632 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
5633 {
5634 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
5635 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
5636 VOS_MAC_ADDRESS_LEN);
5637 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305638 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305639
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +05305640 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
5641 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305642
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305643 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305644 return 0;
5645}
5646
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305647static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
5648 struct wireless_dev *wdev,
5649 const void *data,
5650 int data_len)
5651{
5652 int ret = 0;
5653
5654 vos_ssr_protect(__func__);
5655 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
5656 vos_ssr_unprotect(__func__);
5657
5658 return ret;
5659}
5660
5661static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305662 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305663 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305664 int data_len)
5665{
5666 u8 peer[6] = {0};
5667 struct net_device *dev = wdev->netdev;
5668 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5669 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5670 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
5671 eHalStatus ret;
5672 tANI_S32 state;
5673 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305674 tANI_S32 global_operating_class = 0;
5675 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05305676 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305677 int retVal;
5678
5679 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305680
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305681 if (!pAdapter) {
5682 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5683 return -EINVAL;
5684 }
5685
Atul Mittal115287b2014-07-08 13:26:33 +05305686 ret = wlan_hdd_validate_context(pHddCtx);
5687 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305688 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305689 return -EINVAL;
5690 }
5691 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305692 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305693 return -ENOTSUPP;
5694 }
5695 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
5696 data, data_len,
5697 wlan_hdd_tdls_config_get_status_policy)) {
5698 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5699 return -EINVAL;
5700 }
5701
5702 /* Parse and fetch mac address */
5703 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
5704 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5705 return -EINVAL;
5706 }
5707
5708 memcpy(peer, nla_data(
5709 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
5710 sizeof(peer));
5711 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5712
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05305713 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05305714
Atul Mittal115287b2014-07-08 13:26:33 +05305715 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305716 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05305717 NLMSG_HDRLEN);
5718
5719 if (!skb) {
5720 hddLog(VOS_TRACE_LEVEL_ERROR,
5721 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5722 return -EINVAL;
5723 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305724 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 +05305725 reason,
5726 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305727 global_operating_class,
5728 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05305729 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305730 if (nla_put_s32(skb,
5731 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
5732 state) ||
5733 nla_put_s32(skb,
5734 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
5735 reason) ||
5736 nla_put_s32(skb,
5737 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
5738 global_operating_class) ||
5739 nla_put_s32(skb,
5740 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
5741 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05305742
5743 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5744 goto nla_put_failure;
5745 }
5746
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305747 retVal = cfg80211_vendor_cmd_reply(skb);
5748 EXIT();
5749 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05305750
5751nla_put_failure:
5752 kfree_skb(skb);
5753 return -EINVAL;
5754}
5755
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305756static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
5757 struct wireless_dev *wdev,
5758 const void *data,
5759 int data_len)
5760{
5761 int ret = 0;
5762
5763 vos_ssr_protect(__func__);
5764 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
5765 vos_ssr_unprotect(__func__);
5766
5767 return ret;
5768}
5769
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05305770static int wlan_hdd_cfg80211_exttdls_callback(
5771#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
5772 const tANI_U8* mac,
5773#else
5774 tANI_U8* mac,
5775#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305776 tANI_S32 state,
5777 tANI_S32 reason,
5778 void *ctx)
5779{
5780 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05305781 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305782 tANI_S32 global_operating_class = 0;
5783 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305784 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05305785
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305786 ENTER();
5787
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305788 if (!pAdapter) {
5789 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5790 return -EINVAL;
5791 }
5792
5793 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05305794 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305795 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305796 return -EINVAL;
5797 }
5798
5799 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305800 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305801 return -ENOTSUPP;
5802 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05305803 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
5804#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
5805 NULL,
5806#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305807 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
5808 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
5809 GFP_KERNEL);
5810
5811 if (!skb) {
5812 hddLog(VOS_TRACE_LEVEL_ERROR,
5813 FL("cfg80211_vendor_event_alloc failed"));
5814 return -EINVAL;
5815 }
5816 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305817 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
5818 reason,
5819 state,
5820 global_operating_class,
5821 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05305822 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
5823 MAC_ADDR_ARRAY(mac));
5824
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305825 if (nla_put(skb,
5826 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
5827 VOS_MAC_ADDR_SIZE, mac) ||
5828 nla_put_s32(skb,
5829 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
5830 state) ||
5831 nla_put_s32(skb,
5832 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
5833 reason) ||
5834 nla_put_s32(skb,
5835 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
5836 channel) ||
5837 nla_put_s32(skb,
5838 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
5839 global_operating_class)
5840 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05305841 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5842 goto nla_put_failure;
5843 }
5844
5845 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305846 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05305847 return (0);
5848
5849nla_put_failure:
5850 kfree_skb(skb);
5851 return -EINVAL;
5852}
5853
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305854static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305855 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305856 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305857 int data_len)
5858{
5859 u8 peer[6] = {0};
5860 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305861 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5862 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
5863 eHalStatus status;
5864 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305865 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305866 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305867
5868 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305869
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305870 if (!dev) {
5871 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5872 return -EINVAL;
5873 }
5874
5875 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5876 if (!pAdapter) {
5877 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5878 return -EINVAL;
5879 }
5880
Atul Mittal115287b2014-07-08 13:26:33 +05305881 status = wlan_hdd_validate_context(pHddCtx);
5882 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305883 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305884 return -EINVAL;
5885 }
5886 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305887 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305888 return -ENOTSUPP;
5889 }
5890 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
5891 data, data_len,
5892 wlan_hdd_tdls_config_enable_policy)) {
5893 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5894 return -EINVAL;
5895 }
5896
5897 /* Parse and fetch mac address */
5898 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
5899 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5900 return -EINVAL;
5901 }
5902
5903 memcpy(peer, nla_data(
5904 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
5905 sizeof(peer));
5906 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5907
5908 /* Parse and fetch channel */
5909 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
5910 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
5911 return -EINVAL;
5912 }
5913 pReqMsg.channel = nla_get_s32(
5914 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
5915 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
5916
5917 /* Parse and fetch global operating class */
5918 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
5919 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
5920 return -EINVAL;
5921 }
5922 pReqMsg.global_operating_class = nla_get_s32(
5923 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
5924 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
5925 pReqMsg.global_operating_class);
5926
5927 /* Parse and fetch latency ms */
5928 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
5929 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
5930 return -EINVAL;
5931 }
5932 pReqMsg.max_latency_ms = nla_get_s32(
5933 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
5934 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
5935 pReqMsg.max_latency_ms);
5936
5937 /* Parse and fetch required bandwidth kbps */
5938 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
5939 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
5940 return -EINVAL;
5941 }
5942
5943 pReqMsg.min_bandwidth_kbps = nla_get_s32(
5944 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
5945 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
5946 pReqMsg.min_bandwidth_kbps);
5947
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305948 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05305949 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05305950 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305951 wlan_hdd_cfg80211_exttdls_callback);
5952
5953 EXIT();
5954 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305955}
5956
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305957static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
5958 struct wireless_dev *wdev,
5959 const void *data,
5960 int data_len)
5961{
5962 int ret = 0;
5963
5964 vos_ssr_protect(__func__);
5965 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
5966 vos_ssr_unprotect(__func__);
5967
5968 return ret;
5969}
5970
5971static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305972 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305973 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305974 int data_len)
5975{
5976 u8 peer[6] = {0};
5977 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305978 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5979 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
5980 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305981 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305982 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305983
5984 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305985
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305986 if (!dev) {
5987 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5988 return -EINVAL;
5989 }
5990
5991 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5992 if (!pAdapter) {
5993 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
5994 return -EINVAL;
5995 }
5996
Atul Mittal115287b2014-07-08 13:26:33 +05305997 status = wlan_hdd_validate_context(pHddCtx);
5998 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305999 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05306000 return -EINVAL;
6001 }
6002 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05306003 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05306004 return -ENOTSUPP;
6005 }
6006 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
6007 data, data_len,
6008 wlan_hdd_tdls_config_disable_policy)) {
6009 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6010 return -EINVAL;
6011 }
6012 /* Parse and fetch mac address */
6013 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
6014 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
6015 return -EINVAL;
6016 }
6017
6018 memcpy(peer, nla_data(
6019 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
6020 sizeof(peer));
6021 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
6022
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306023 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
6024
6025 EXIT();
6026 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05306027}
6028
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306029static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
6030 struct wireless_dev *wdev,
6031 const void *data,
6032 int data_len)
6033{
6034 int ret = 0;
6035
6036 vos_ssr_protect(__func__);
6037 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
6038 vos_ssr_unprotect(__func__);
6039
6040 return ret;
6041}
6042
Dasari Srinivas7875a302014-09-26 17:50:57 +05306043static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306044__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05306045 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306046 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05306047{
6048 struct net_device *dev = wdev->netdev;
6049 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6050 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6051 struct sk_buff *skb = NULL;
6052 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306053 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05306054
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306055 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306056
6057 ret = wlan_hdd_validate_context(pHddCtx);
6058 if (0 != ret)
6059 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306060 return ret;
6061 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05306062 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
6063 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
6064 fset |= WIFI_FEATURE_INFRA;
6065 }
6066
6067 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
6068 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
6069 fset |= WIFI_FEATURE_INFRA_5G;
6070 }
6071
6072#ifdef WLAN_FEATURE_P2P
6073 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
6074 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
6075 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
6076 fset |= WIFI_FEATURE_P2P;
6077 }
6078#endif
6079
6080 /* Soft-AP is supported currently by default */
6081 fset |= WIFI_FEATURE_SOFT_AP;
6082
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05306083 /* HOTSPOT is a supplicant feature, enable it by default */
6084 fset |= WIFI_FEATURE_HOTSPOT;
6085
Dasari Srinivas7875a302014-09-26 17:50:57 +05306086#ifdef WLAN_FEATURE_EXTSCAN
6087 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05306088 sme_IsFeatureSupportedByFW(EXTENDED_SCAN) &&
6089 sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)) {
6090 hddLog(LOG1, FL("Enhanced EXTScan is supported by firmware"));
Dasari Srinivas7875a302014-09-26 17:50:57 +05306091 fset |= WIFI_FEATURE_EXTSCAN;
6092 }
6093#endif
6094
Dasari Srinivas7875a302014-09-26 17:50:57 +05306095 if (sme_IsFeatureSupportedByFW(NAN)) {
6096 hddLog(LOG1, FL("NAN is supported by firmware"));
6097 fset |= WIFI_FEATURE_NAN;
6098 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05306099
6100 /* D2D RTT is not supported currently by default */
Sourav Mohapatradf8b23c2017-11-17 17:50:31 +05306101 if (sme_IsFeatureSupportedByFW(RTT) &&
6102 pHddCtx->cfg_ini->enable_rtt_support) {
6103 hddLog(LOG1, FL("RTT is supported by firmware and framework"));
Dasari Srinivas7875a302014-09-26 17:50:57 +05306104 fset |= WIFI_FEATURE_D2AP_RTT;
6105 }
6106
Padma, Santhosh Kumaraac4c4d2015-12-08 16:07:47 +05306107 if (sme_IsFeatureSupportedByFW(RTT3)) {
6108 hddLog(LOG1, FL("RTT3 is supported by firmware"));
6109 fset |= WIFI_FEATURE_RTT3;
6110 }
6111
Dasari Srinivas7875a302014-09-26 17:50:57 +05306112#ifdef FEATURE_WLAN_BATCH_SCAN
6113 if (fset & WIFI_FEATURE_EXTSCAN) {
6114 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
6115 fset &= ~WIFI_FEATURE_BATCH_SCAN;
6116 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
6117 hddLog(LOG1, FL("Batch scan is supported by firmware"));
6118 fset |= WIFI_FEATURE_BATCH_SCAN;
6119 }
6120#endif
6121
6122#ifdef FEATURE_WLAN_SCAN_PNO
6123 if (pHddCtx->cfg_ini->configPNOScanSupport &&
6124 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
6125 hddLog(LOG1, FL("PNO is supported by firmware"));
6126 fset |= WIFI_FEATURE_PNO;
6127 }
6128#endif
6129
6130 /* STA+STA is supported currently by default */
6131 fset |= WIFI_FEATURE_ADDITIONAL_STA;
6132
6133#ifdef FEATURE_WLAN_TDLS
6134 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
6135 sme_IsFeatureSupportedByFW(TDLS)) {
6136 hddLog(LOG1, FL("TDLS is supported by firmware"));
6137 fset |= WIFI_FEATURE_TDLS;
6138 }
6139
6140 /* TDLS_OFFCHANNEL is not supported currently by default */
6141#endif
6142
6143#ifdef WLAN_AP_STA_CONCURRENCY
6144 /* AP+STA concurrency is supported currently by default */
6145 fset |= WIFI_FEATURE_AP_STA;
6146#endif
6147
Mukul Sharma5add0532015-08-17 15:57:47 +05306148#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Ajit Vaishya8353cfb2017-11-10 16:22:36 +05306149 if ((TRUE == pHddCtx->cfg_ini->fEnableLLStats) &&
6150 (TRUE == sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS))) {
Mukul Sharma5add0532015-08-17 15:57:47 +05306151 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
6152 hddLog(LOG1, FL("Link layer stats is supported by driver"));
Ajit Vaishya8353cfb2017-11-10 16:22:36 +05306153 }
Mukul Sharma5add0532015-08-17 15:57:47 +05306154#endif
6155
Dasari Srinivas7875a302014-09-26 17:50:57 +05306156 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
6157 NLMSG_HDRLEN);
6158
6159 if (!skb) {
6160 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6161 return -EINVAL;
6162 }
6163 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
6164
6165 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
6166 hddLog(LOGE, FL("nla put fail"));
6167 goto nla_put_failure;
6168 }
6169
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306170 ret = cfg80211_vendor_cmd_reply(skb);
6171 EXIT();
6172 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05306173
6174nla_put_failure:
6175 kfree_skb(skb);
6176 return -EINVAL;
6177}
6178
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306179static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306180wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
6181 struct wireless_dev *wdev,
6182 const void *data, int data_len)
6183{
6184 int ret = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306185 vos_ssr_protect(__func__);
6186 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
6187 vos_ssr_unprotect(__func__);
6188
6189 return ret;
6190}
6191
Sachin Ahujac08f72a2015-09-22 15:25:47 +05306192
6193static const struct
6194nla_policy
6195qca_wlan_vendor_wifi_logger_get_ring_data_policy
6196[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = {
6197 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]
6198 = {.type = NLA_U32 },
6199};
6200
6201static int
6202 __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
6203 struct wireless_dev *wdev,
6204 const void *data,
6205 int data_len)
6206{
6207 int ret;
6208 VOS_STATUS status;
6209 uint32_t ring_id;
6210 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6211 struct nlattr *tb
6212 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1];
6213
6214 ENTER();
6215
6216 ret = wlan_hdd_validate_context(hdd_ctx);
6217 if (0 != ret) {
6218 return ret;
6219 }
6220
6221 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX,
6222 data, data_len,
6223 qca_wlan_vendor_wifi_logger_get_ring_data_policy)) {
6224 hddLog(LOGE, FL("Invalid attribute"));
6225 return -EINVAL;
6226 }
6227
6228 /* Parse and fetch ring id */
6229 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) {
6230 hddLog(LOGE, FL("attr ATTR failed"));
6231 return -EINVAL;
6232 }
6233
6234 ring_id = nla_get_u32(
6235 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]);
6236
6237 hddLog(LOG1, FL("Bug report triggered by framework"));
6238
6239 status = vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
6240 WLAN_LOG_INDICATOR_FRAMEWORK,
6241 WLAN_LOG_REASON_CODE_FRAMEWORK,
Abhishek Singh837adf22015-10-01 17:37:37 +05306242 TRUE, TRUE
Sachin Ahujac08f72a2015-09-22 15:25:47 +05306243 );
6244 if (VOS_STATUS_SUCCESS != status) {
6245 hddLog(LOGE, FL("Failed to trigger bug report"));
6246
6247 return -EINVAL;
6248 }
6249
6250 return 0;
6251
6252
6253}
6254
6255
6256static int
6257 wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
6258 struct wireless_dev *wdev,
6259 const void *data,
6260 int data_len)
6261{
6262 int ret = 0;
6263
6264 vos_ssr_protect(__func__);
6265 ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy,
6266 wdev, data, data_len);
6267 vos_ssr_unprotect(__func__);
6268
6269 return ret;
6270
6271}
6272
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05306273#define MAX_CONCURRENT_MATRIX \
6274 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX
6275#define MATRIX_CONFIG_PARAM_SET_SIZE_MAX \
6276 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX
6277static const struct nla_policy
6278wlan_hdd_get_concurrency_matrix_policy[MAX_CONCURRENT_MATRIX + 1] = {
6279 [MATRIX_CONFIG_PARAM_SET_SIZE_MAX] = {.type = NLA_U32},
6280};
Sachin Ahujac08f72a2015-09-22 15:25:47 +05306281
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306282static int
6283__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306284 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306285 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306286{
6287 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
6288 uint8_t i, feature_sets, max_feature_sets;
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05306289 struct nlattr *tb[MAX_CONCURRENT_MATRIX + 1];
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306290 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306291 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6292 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306293
6294 ENTER();
6295
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306296 ret = wlan_hdd_validate_context(pHddCtx);
6297 if (0 != ret)
6298 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306299 return ret;
6300 }
6301
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05306302 if (nla_parse(tb, MAX_CONCURRENT_MATRIX, data, data_len,
6303 wlan_hdd_get_concurrency_matrix_policy)) {
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306304 hddLog(LOGE, FL("Invalid ATTR"));
6305 return -EINVAL;
6306 }
6307
6308 /* Parse and fetch max feature set */
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05306309 if (!tb[MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306310 hddLog(LOGE, FL("Attr max feature set size failed"));
6311 return -EINVAL;
6312 }
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05306313 max_feature_sets = nla_get_u32(tb[MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306314 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
6315
6316 /* Fill feature combination matrix */
6317 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306318 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
6319 WIFI_FEATURE_P2P;
6320
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306321 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
6322 WIFI_FEATURE_SOFT_AP;
6323
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306324 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
6325 WIFI_FEATURE_SOFT_AP;
6326
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306327 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
6328 WIFI_FEATURE_SOFT_AP |
6329 WIFI_FEATURE_P2P;
6330
6331 /* Add more feature combinations here */
6332
6333 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
6334 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
6335 hddLog(LOG1, "Feature set matrix");
6336 for (i = 0; i < feature_sets; i++)
6337 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
6338
6339 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
6340 sizeof(u32) * feature_sets +
6341 NLMSG_HDRLEN);
6342
6343 if (reply_skb) {
6344 if (nla_put_u32(reply_skb,
6345 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
6346 feature_sets) ||
6347 nla_put(reply_skb,
6348 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
6349 sizeof(u32) * feature_sets, feature_set_matrix)) {
6350 hddLog(LOGE, FL("nla put fail"));
6351 kfree_skb(reply_skb);
6352 return -EINVAL;
6353 }
6354
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306355 ret = cfg80211_vendor_cmd_reply(reply_skb);
6356 EXIT();
6357 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306358 }
6359 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
6360 return -ENOMEM;
6361
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05306362}
6363
Rajeev Kumar Sirasanagandla4c00e0d2017-06-13 12:04:09 +05306364#undef MAX_CONCURRENT_MATRIX
6365#undef MATRIX_CONFIG_PARAM_SET_SIZE_MAX
6366
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306367static int
6368wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
6369 struct wireless_dev *wdev,
6370 const void *data, int data_len)
6371{
6372 int ret = 0;
6373
6374 vos_ssr_protect(__func__);
6375 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
6376 data_len);
6377 vos_ssr_unprotect(__func__);
6378
6379 return ret;
6380}
6381
c_manjeecfd1efb2015-09-25 19:32:34 +05306382
6383static int
6384__wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
6385 struct wireless_dev *wdev,
6386 const void *data, int data_len)
6387{
6388 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6389 int ret;
6390 ENTER();
6391
6392 ret = wlan_hdd_validate_context(pHddCtx);
6393 if (0 != ret)
6394 {
6395 return ret;
6396 }
6397
6398 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
6399 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
6400 {
6401 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
Ajit Vaishyac5ba8482017-11-16 14:10:37 +05306402 return -EOPNOTSUPP;
c_manjeecfd1efb2015-09-25 19:32:34 +05306403 }
6404 /*call common API for FW mem dump req*/
6405 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
6406
Abhishek Singhc783fa72015-12-09 18:07:34 +05306407 if (!ret)
c_manjee04b4c5c2015-10-13 18:35:01 +05306408 {
6409 /*indicate to userspace the status of fw mem dump */
6410 wlan_indicate_mem_dump_complete(true);
6411 }
6412 else
6413 {
6414 /*else send failure to userspace */
6415 wlan_indicate_mem_dump_complete(false);
6416 }
c_manjeecfd1efb2015-09-25 19:32:34 +05306417 EXIT();
6418 return ret;
6419}
6420
6421/**
6422 * wlan_hdd_cfg80211_get_fw_mem_dump() - Get FW memory dump
6423 * @wiphy: pointer to wireless wiphy structure.
6424 * @wdev: pointer to wireless_dev structure.
6425 * @data: Pointer to the NL data.
6426 * @data_len:Length of @data
6427 *
6428 * This is called when wlan driver needs to get the firmware memory dump
6429 * via vendor specific command.
6430 *
6431 * Return: 0 on success, error number otherwise.
6432 */
6433
6434static int
6435wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
6436 struct wireless_dev *wdev,
6437 const void *data, int data_len)
Sushant Kaushik8e644982015-09-23 12:18:54 +05306438{
6439 int ret = 0;
6440 vos_ssr_protect(__func__);
6441 ret = __wlan_hdd_cfg80211_get_fw_mem_dump(wiphy, wdev, data,
6442 data_len);
6443 vos_ssr_unprotect(__func__);
6444 return ret;
6445}
c_manjeecfd1efb2015-09-25 19:32:34 +05306446
Sushant Kaushik8e644982015-09-23 12:18:54 +05306447static const struct
6448nla_policy
6449qca_wlan_vendor_wifi_logger_start_policy
6450[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = {
6451 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]
6452 = {.type = NLA_U32 },
6453 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]
6454 = {.type = NLA_U32 },
6455 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]
6456 = {.type = NLA_U32 },
6457};
6458
6459/**
6460 * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable
6461 * or disable the collection of packet statistics from the firmware
6462 * @wiphy: WIPHY structure pointer
6463 * @wdev: Wireless device structure pointer
6464 * @data: Pointer to the data received
6465 * @data_len: Length of the data received
6466 *
6467 * This function is used to enable or disable the collection of packet
6468 * statistics from the firmware
6469 *
6470 * Return: 0 on success and errno on failure
6471 */
6472static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
6473 struct wireless_dev *wdev,
6474 const void *data,
6475 int data_len)
6476{
6477 eHalStatus status;
6478 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6479 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1];
6480 tAniWifiStartLog start_log;
6481
6482 status = wlan_hdd_validate_context(hdd_ctx);
6483 if (0 != status) {
6484 return -EINVAL;
6485 }
6486
6487 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX,
6488 data, data_len,
6489 qca_wlan_vendor_wifi_logger_start_policy)) {
6490 hddLog(LOGE, FL("Invalid attribute"));
6491 return -EINVAL;
6492 }
6493
6494 /* Parse and fetch ring id */
6495 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) {
6496 hddLog(LOGE, FL("attr ATTR failed"));
6497 return -EINVAL;
6498 }
6499 start_log.ringId = nla_get_u32(
6500 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]);
6501 hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId);
6502
6503 /* Parse and fetch verbose level */
6504 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) {
6505 hddLog(LOGE, FL("attr verbose_level failed"));
6506 return -EINVAL;
6507 }
6508 start_log.verboseLevel = nla_get_u32(
6509 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]);
6510 hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel);
6511
6512 /* Parse and fetch flag */
6513 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) {
6514 hddLog(LOGE, FL("attr flag failed"));
6515 return -EINVAL;
6516 }
6517 start_log.flag = nla_get_u32(
6518 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]);
6519 hddLog(LOG1, FL("flag=%d"), start_log.flag);
6520
6521 if ((RING_ID_PER_PACKET_STATS == start_log.ringId) &&
Sushant Kaushik33200572015-08-05 16:46:20 +05306522 (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable ||
6523 !vos_isPktStatsEnabled()))
6524
Sushant Kaushik8e644982015-09-23 12:18:54 +05306525 {
6526 hddLog(LOGE, FL("per pkt stats not enabled"));
6527 return -EINVAL;
6528 }
Sushant Kaushik8e644982015-09-23 12:18:54 +05306529
Sushant Kaushik33200572015-08-05 16:46:20 +05306530 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
Sushant Kaushik8e644982015-09-23 12:18:54 +05306531 return 0;
6532}
6533
6534/**
6535 * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable
6536 * or disable the collection of packet statistics from the firmware
6537 * @wiphy: WIPHY structure pointer
6538 * @wdev: Wireless device structure pointer
6539 * @data: Pointer to the data received
6540 * @data_len: Length of the data received
6541 *
6542 * This function is used to enable or disable the collection of packet
6543 * statistics from the firmware
6544 *
6545 * Return: 0 on success and errno on failure
6546 */
6547static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
6548 struct wireless_dev *wdev,
6549 const void *data,
6550 int data_len)
c_manjeecfd1efb2015-09-25 19:32:34 +05306551{
6552 int ret = 0;
6553
6554 vos_ssr_protect(__func__);
Sushant Kaushik8e644982015-09-23 12:18:54 +05306555
6556 ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy,
6557 wdev, data, data_len);
c_manjeecfd1efb2015-09-25 19:32:34 +05306558 vos_ssr_unprotect(__func__);
6559
6560 return ret;
c_manjeecfd1efb2015-09-25 19:32:34 +05306561}
6562
6563
Agarwal Ashish738843c2014-09-25 12:27:56 +05306564static const struct nla_policy
6565wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
6566 +1] =
6567{
6568 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
6569};
6570
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306571static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306572 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306573 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306574 int data_len)
6575{
6576 struct net_device *dev = wdev->netdev;
6577 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6578 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6579 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6580 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
6581 eHalStatus status;
6582 u32 dfsFlag = 0;
6583
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306584 ENTER();
6585
Agarwal Ashish738843c2014-09-25 12:27:56 +05306586 status = wlan_hdd_validate_context(pHddCtx);
6587 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05306588 return -EINVAL;
6589 }
6590 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
6591 data, data_len,
6592 wlan_hdd_set_no_dfs_flag_config_policy)) {
6593 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6594 return -EINVAL;
6595 }
6596
6597 /* Parse and fetch required bandwidth kbps */
6598 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
6599 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
6600 return -EINVAL;
6601 }
6602
6603 dfsFlag = nla_get_u32(
6604 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
6605 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
6606 dfsFlag);
6607
6608 pHddCtx->disable_dfs_flag = dfsFlag;
6609
6610 sme_disable_dfs_channel(hHal, dfsFlag);
6611 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306612
6613 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05306614 return 0;
6615}
Atul Mittal115287b2014-07-08 13:26:33 +05306616
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306617static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
6618 struct wireless_dev *wdev,
6619 const void *data,
6620 int data_len)
6621{
6622 int ret = 0;
6623
6624 vos_ssr_protect(__func__);
6625 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
6626 vos_ssr_unprotect(__func__);
6627
6628 return ret;
6629
6630}
6631
Mukul Sharma2a271632014-10-13 14:59:01 +05306632const struct
6633nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
6634{
6635 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05306636 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = {
6637 .type = NLA_UNSPEC,
6638 .len = HDD_MAC_ADDR_LEN},
Mukul Sharma2a271632014-10-13 14:59:01 +05306639};
6640
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306641static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05306642 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05306643{
6644
6645 u8 bssid[6] = {0};
6646 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6647 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6648 eHalStatus status = eHAL_STATUS_SUCCESS;
6649 v_U32_t isFwrRoamEnabled = FALSE;
6650 int ret;
6651
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306652 ENTER();
6653
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306654 ret = wlan_hdd_validate_context(pHddCtx);
6655 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306656 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05306657 }
6658
6659 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
6660 data, data_len,
6661 qca_wlan_vendor_attr);
6662 if (ret){
6663 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6664 return -EINVAL;
6665 }
6666
6667 /* Parse and fetch Enable flag */
6668 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
6669 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
6670 return -EINVAL;
6671 }
6672
6673 isFwrRoamEnabled = nla_get_u32(
6674 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
6675
6676 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
6677
6678 /* Parse and fetch bssid */
6679 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6680 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
6681 return -EINVAL;
6682 }
6683
6684 memcpy(bssid, nla_data(
6685 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6686 sizeof(bssid));
6687 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
6688
6689 //Update roaming
6690 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306691 if (!HAL_STATUS_SUCCESS(status)) {
6692 hddLog(LOGE,
6693 FL("sme_ConfigFwrRoaming failed (err=%d)"), status);
6694 return -EINVAL;
6695 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306696 EXIT();
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306697 return 0;
Mukul Sharma2a271632014-10-13 14:59:01 +05306698}
6699
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306700static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
6701 struct wireless_dev *wdev, const void *data, int data_len)
6702{
6703 int ret = 0;
6704
6705 vos_ssr_protect(__func__);
6706 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
6707 vos_ssr_unprotect(__func__);
6708
6709 return ret;
6710}
6711
Sushant Kaushik847890c2015-09-28 16:05:17 +05306712static const struct
6713nla_policy
6714qca_wlan_vendor_get_wifi_info_policy[
6715 QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = {
6716 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
6717 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
6718};
6719
6720
6721/**
6722 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6723 * @wiphy: pointer to wireless wiphy structure.
6724 * @wdev: pointer to wireless_dev structure.
6725 * @data: Pointer to the data to be passed via vendor interface
6726 * @data_len:Length of the data to be passed
6727 *
6728 * This is called when wlan driver needs to send wifi driver related info
6729 * (driver/fw version) to the user space application upon request.
6730 *
6731 * Return: Return the Success or Failure code.
6732 */
6733static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6734 struct wireless_dev *wdev,
6735 const void *data, int data_len)
6736{
6737 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6738 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
6739 tSirVersionString version;
6740 uint32 version_len;
6741 uint8 attr;
6742 int status;
6743 struct sk_buff *reply_skb = NULL;
6744
6745 if (VOS_FTM_MODE == hdd_get_conparam()) {
6746 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6747 return -EINVAL;
6748 }
6749
6750 status = wlan_hdd_validate_context(hdd_ctx);
6751 if (0 != status) {
6752 hddLog(LOGE, FL("HDD context is not valid"));
6753 return -EINVAL;
6754 }
6755
6756 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
6757 data_len, qca_wlan_vendor_get_wifi_info_policy)) {
6758 hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
6759 return -EINVAL;
6760 }
6761
6762 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
6763 hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"),
6764 QWLAN_VERSIONSTR);
6765 strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
6766 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
6767 } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
6768 hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"),
6769 hdd_ctx->fw_Version);
6770 strlcpy(version, hdd_ctx->fw_Version, sizeof(version));
6771 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
6772 } else {
6773 hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
6774 return -EINVAL;
6775 }
6776
6777 version_len = strlen(version);
6778 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6779 version_len + NLA_HDRLEN + NLMSG_HDRLEN);
6780 if (!reply_skb) {
6781 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6782 return -ENOMEM;
6783 }
6784
6785 if (nla_put(reply_skb, attr, version_len, version)) {
6786 hddLog(LOGE, FL("nla put fail"));
6787 kfree_skb(reply_skb);
6788 return -EINVAL;
6789 }
6790
6791 return cfg80211_vendor_cmd_reply(reply_skb);
6792}
6793
6794/**
6795 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6796 * @wiphy: pointer to wireless wiphy structure.
6797 * @wdev: pointer to wireless_dev structure.
6798 * @data: Pointer to the data to be passed via vendor interface
6799 * @data_len:Length of the data to be passed
6800 * @data_len: Length of the data received
6801 *
6802 * This function is used to enable or disable the collection of packet
6803 * statistics from the firmware
6804 *
6805 * Return: 0 on success and errno on failure
6806 */
6807
6808static int
6809wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6810 struct wireless_dev *wdev,
6811 const void *data, int data_len)
6812
6813
6814{
6815 int ret = 0;
6816
6817 vos_ssr_protect(__func__);
6818 ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy,
6819 wdev, data, data_len);
6820 vos_ssr_unprotect(__func__);
6821
6822 return ret;
6823}
6824
6825
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306826/*
6827 * define short names for the global vendor params
6828 * used by __wlan_hdd_cfg80211_monitor_rssi()
6829 */
6830#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX
6831#define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID
6832#define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL
6833#define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI
6834#define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI
6835
6836/**---------------------------------------------------------------------------
6837
6838 \brief hdd_rssi_monitor_start_done - callback to be executed when rssi
6839 monitor start is completed successfully.
6840
6841 \return - None
6842
6843 --------------------------------------------------------------------------*/
6844void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6845{
6846 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6847
6848 if (NULL == pHddCtx)
6849 {
6850 hddLog(VOS_TRACE_LEVEL_ERROR,
6851 "%s: HDD context is NULL",__func__);
6852 return;
6853 }
6854
6855 if (VOS_STATUS_SUCCESS == status)
6856 {
6857 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful"));
6858 }
6859 else
6860 {
6861 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful"));
6862 }
6863
6864 return;
6865}
6866
6867/**---------------------------------------------------------------------------
6868
6869 \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor
6870 stop is completed successfully.
6871
6872 \return - None
6873
6874 --------------------------------------------------------------------------*/
6875void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6876{
6877 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6878
6879 if (NULL == pHddCtx)
6880 {
6881 hddLog(VOS_TRACE_LEVEL_ERROR,
6882 "%s: HDD context is NULL",__func__);
6883 return;
6884 }
6885
6886 if (VOS_STATUS_SUCCESS == status)
6887 {
6888 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful"));
6889 }
6890 else
6891 {
6892 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful"));
6893 }
6894
6895 return;
6896}
6897
6898/**
6899 * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi
6900 * @wiphy: Pointer to wireless phy
6901 * @wdev: Pointer to wireless device
6902 * @data: Pointer to data
6903 * @data_len: Data length
6904 *
6905 * Return: 0 on success, negative errno on failure
6906 */
6907
6908static int
6909__wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy,
6910 struct wireless_dev *wdev,
6911 const void *data,
6912 int data_len)
6913{
6914 struct net_device *dev = wdev->netdev;
6915 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6916 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6917 hdd_station_ctx_t *pHddStaCtx;
6918 struct nlattr *tb[PARAM_MAX + 1];
6919 tpSirRssiMonitorReq pReq;
6920 eHalStatus status;
6921 int ret;
6922 uint32_t control;
6923 static const struct nla_policy policy[PARAM_MAX + 1] = {
6924 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6925 [PARAM_CONTROL] = { .type = NLA_U32 },
6926 [PARAM_MIN_RSSI] = { .type = NLA_S8 },
6927 [PARAM_MAX_RSSI] = { .type = NLA_S8 },
6928 };
6929
6930 ENTER();
6931
6932 ret = wlan_hdd_validate_context(hdd_ctx);
6933 if (0 != ret) {
6934 return -EINVAL;
6935 }
6936
6937 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6938 hddLog(LOGE, FL("Not in Connected state!"));
6939 return -ENOTSUPP;
6940 }
6941
6942 if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) {
6943 hddLog(LOGE, FL("Invalid ATTR"));
6944 return -EINVAL;
6945 }
6946
6947 if (!tb[PARAM_REQUEST_ID]) {
6948 hddLog(LOGE, FL("attr request id failed"));
6949 return -EINVAL;
6950 }
6951
6952 if (!tb[PARAM_CONTROL]) {
6953 hddLog(LOGE, FL("attr control failed"));
6954 return -EINVAL;
6955 }
6956
6957 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6958
6959 pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq));
6960 if(NULL == pReq)
6961 {
6962 hddLog(LOGE,
6963 FL("vos_mem_alloc failed "));
6964 return eHAL_STATUS_FAILED_ALLOC;
6965 }
6966 vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0);
6967
6968 pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
6969 pReq->sessionId = pAdapter->sessionId;
6970 pReq->rssiMonitorCbContext = hdd_ctx;
6971 control = nla_get_u32(tb[PARAM_CONTROL]);
6972 vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6973
6974 hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"),
6975 pReq->requestId, pReq->sessionId, control);
6976
6977 if (control == QCA_WLAN_RSSI_MONITORING_START) {
6978 if (!tb[PARAM_MIN_RSSI]) {
6979 hddLog(LOGE, FL("attr min rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306980 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306981 }
6982
6983 if (!tb[PARAM_MAX_RSSI]) {
6984 hddLog(LOGE, FL("attr max rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306985 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306986 }
6987
6988 pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]);
6989 pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]);
6990 pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done;
6991
6992 if (!(pReq->minRssi < pReq->maxRssi)) {
6993 hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"),
6994 pReq->minRssi, pReq->maxRssi);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306995 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306996 }
6997 hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"),
6998 pReq->minRssi, pReq->maxRssi);
6999 status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq);
7000
7001 }
7002 else if (control == QCA_WLAN_RSSI_MONITORING_STOP) {
7003 pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done;
7004 status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq);
7005 }
7006 else {
7007 hddLog(LOGE, FL("Invalid control cmd: %d"), control);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05307008 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307009 }
7010
7011 if (!HAL_STATUS_SUCCESS(status)) {
7012 hddLog(LOGE,
7013 FL("sme_set_rssi_monitoring failed(err=%d)"), status);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05307014 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307015 }
7016
7017 return 0;
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05307018fail:
7019 vos_mem_free(pReq);
7020 return -EINVAL;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307021}
7022
7023/*
7024 * done with short names for the global vendor params
7025 * used by __wlan_hdd_cfg80211_monitor_rssi()
7026 */
7027#undef PARAM_MAX
7028#undef PARAM_CONTROL
7029#undef PARAM_REQUEST_ID
7030#undef PARAM_MAX_RSSI
7031#undef PARAM_MIN_RSSI
7032
7033/**
7034 * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
7035 * @wiphy: wiphy structure pointer
7036 * @wdev: Wireless device structure pointer
7037 * @data: Pointer to the data received
7038 * @data_len: Length of @data
7039 *
7040 * Return: 0 on success; errno on failure
7041 */
7042static int
7043wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
7044 const void *data, int data_len)
7045{
7046 int ret;
7047
7048 vos_ssr_protect(__func__);
7049 ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len);
7050 vos_ssr_unprotect(__func__);
7051
7052 return ret;
7053}
7054
7055/**
7056 * hdd_rssi_threshold_breached_cb() - rssi breached NL event
7057 * @hddctx: HDD context
7058 * @data: rssi breached event data
7059 *
7060 * This function reads the rssi breached event %data and fill in the skb with
7061 * NL attributes and send up the NL event.
7062 * This callback execute in atomic context and must not invoke any
7063 * blocking calls.
7064 *
7065 * Return: none
7066 */
7067void hdd_rssi_threshold_breached_cb(void *hddctx,
7068 struct rssi_breach_event *data)
7069{
7070 hdd_context_t *pHddCtx = (hdd_context_t *)hddctx;
7071 int status;
7072 struct sk_buff *skb;
7073
7074 ENTER();
7075 status = wlan_hdd_validate_context(pHddCtx);
7076
7077 if (0 != status) {
7078 return;
7079 }
7080
7081 if (!data) {
7082 hddLog(LOGE, FL("data is null"));
7083 return;
7084 }
7085
7086 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
7087#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
7088 NULL,
7089#endif
7090 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
7091 QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
7092 GFP_KERNEL);
7093
7094 if (!skb) {
7095 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
7096 return;
7097 }
7098
7099 hddLog(LOG1, "Req Id: %u Current rssi: %d",
7100 data->request_id, data->curr_rssi);
7101 hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR,
7102 MAC_ADDR_ARRAY(data->curr_bssid.bytes));
7103
7104 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID,
7105 data->request_id) ||
7106 nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID,
7107 sizeof(data->curr_bssid), data->curr_bssid.bytes) ||
7108 nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI,
7109 data->curr_rssi)) {
7110 hddLog(LOGE, FL("nla put fail"));
7111 goto fail;
7112 }
7113
7114 cfg80211_vendor_event(skb, GFP_KERNEL);
7115 return;
7116
7117fail:
7118 kfree_skb(skb);
7119 return;
7120}
7121
7122
7123
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307124/**
7125 * __wlan_hdd_cfg80211_setband() - set band
7126 * @wiphy: Pointer to wireless phy
7127 * @wdev: Pointer to wireless device
7128 * @data: Pointer to data
7129 * @data_len: Data length
7130 *
7131 * Return: 0 on success, negative errno on failure
7132 */
7133static int
7134__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
7135 struct wireless_dev *wdev,
7136 const void *data,
7137 int data_len)
7138{
7139 struct net_device *dev = wdev->netdev;
7140 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7141 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
7142 int ret;
7143 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
7144 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
7145
7146 ENTER();
7147
7148 ret = wlan_hdd_validate_context(hdd_ctx);
7149 if (0 != ret) {
7150 hddLog(LOGE, FL("HDD context is not valid"));
7151 return ret;
7152 }
7153
7154 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7155 policy)) {
7156 hddLog(LOGE, FL("Invalid ATTR"));
7157 return -EINVAL;
7158 }
7159
7160 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
7161 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
7162 return -EINVAL;
7163 }
7164
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05307165 hdd_ctx->isSetBandByNL = TRUE;
7166 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307167 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05307168 hdd_ctx->isSetBandByNL = FALSE;
7169
7170 EXIT();
7171 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307172}
7173
7174/**
7175 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
7176 * @wiphy: wiphy structure pointer
7177 * @wdev: Wireless device structure pointer
7178 * @data: Pointer to the data received
7179 * @data_len: Length of @data
7180 *
7181 * Return: 0 on success; errno on failure
7182 */
7183static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
7184 struct wireless_dev *wdev,
7185 const void *data,
7186 int data_len)
7187{
7188 int ret = 0;
7189
7190 vos_ssr_protect(__func__);
7191 ret = __wlan_hdd_cfg80211_setband(wiphy,
7192 wdev, data, data_len);
7193 vos_ssr_unprotect(__func__);
7194
7195 return ret;
7196}
7197
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307198#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
7199/**
7200 * hdd_map_req_id_to_pattern_id() - map request id to pattern id
7201 * @hdd_ctx: HDD context
7202 * @request_id: [input] request id
7203 * @pattern_id: [output] pattern id
7204 *
7205 * This function loops through request id to pattern id array
7206 * if the slot is available, store the request id and return pattern id
7207 * if entry exists, return the pattern id
7208 *
7209 * Return: 0 on success and errno on failure
7210 */
7211static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
7212 uint32_t request_id,
7213 uint8_t *pattern_id)
7214{
7215 uint32_t i;
7216
7217 mutex_lock(&hdd_ctx->op_ctx.op_lock);
7218 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
7219 {
7220 if (hdd_ctx->op_ctx.op_table[i].request_id == 0)
7221 {
7222 hdd_ctx->op_ctx.op_table[i].request_id = request_id;
7223 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
7224 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7225 return 0;
7226 } else if (hdd_ctx->op_ctx.op_table[i].request_id ==
7227 request_id) {
7228 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
7229 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7230 return 0;
7231 }
7232 }
7233 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7234 return -EINVAL;
7235}
7236
7237/**
7238 * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id
7239 * @hdd_ctx: HDD context
7240 * @request_id: [input] request id
7241 * @pattern_id: [output] pattern id
7242 *
7243 * This function loops through request id to pattern id array
7244 * reset request id to 0 (slot available again) and
7245 * return pattern id
7246 *
7247 * Return: 0 on success and errno on failure
7248 */
7249static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
7250 uint32_t request_id,
7251 uint8_t *pattern_id)
7252{
7253 uint32_t i;
7254
7255 mutex_lock(&hdd_ctx->op_ctx.op_lock);
7256 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
7257 {
7258 if (hdd_ctx->op_ctx.op_table[i].request_id == request_id)
7259 {
7260 hdd_ctx->op_ctx.op_table[i].request_id = 0;
7261 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
7262 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7263 return 0;
7264 }
7265 }
7266 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
7267 return -EINVAL;
7268}
7269
7270
7271/*
7272 * define short names for the global vendor params
7273 * used by __wlan_hdd_cfg80211_offloaded_packets()
7274 */
7275#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX
7276#define PARAM_REQUEST_ID \
7277 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID
7278#define PARAM_CONTROL \
7279 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL
7280#define PARAM_IP_PACKET \
7281 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA
7282#define PARAM_SRC_MAC_ADDR \
7283 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR
7284#define PARAM_DST_MAC_ADDR \
7285 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR
7286#define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD
7287
7288/**
7289 * wlan_hdd_add_tx_ptrn() - add tx pattern
7290 * @adapter: adapter pointer
7291 * @hdd_ctx: hdd context
7292 * @tb: nl attributes
7293 *
7294 * This function reads the NL attributes and forms a AddTxPtrn message
7295 * posts it to SME.
7296 *
7297 */
7298static int
7299wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
7300 struct nlattr **tb)
7301{
7302 struct sSirAddPeriodicTxPtrn *add_req;
7303 eHalStatus status;
7304 uint32_t request_id, ret, len;
7305 uint8_t pattern_id = 0;
7306 v_MACADDR_t dst_addr;
7307 uint16_t eth_type = htons(ETH_P_IP);
7308
7309 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
7310 {
7311 hddLog(LOGE, FL("Not in Connected state!"));
7312 return -ENOTSUPP;
7313 }
7314
7315 add_req = vos_mem_malloc(sizeof(*add_req));
7316 if (!add_req)
7317 {
7318 hddLog(LOGE, FL("memory allocation failed"));
7319 return -ENOMEM;
7320 }
7321
7322 /* Parse and fetch request Id */
7323 if (!tb[PARAM_REQUEST_ID])
7324 {
7325 hddLog(LOGE, FL("attr request id failed"));
7326 goto fail;
7327 }
7328
7329 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
7330 hddLog(LOG1, FL("Request Id: %u"), request_id);
7331 if (request_id == 0)
7332 {
7333 hddLog(LOGE, FL("request_id cannot be zero"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05307334 goto fail;
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307335 }
7336
7337 if (!tb[PARAM_PERIOD])
7338 {
7339 hddLog(LOGE, FL("attr period failed"));
7340 goto fail;
7341 }
7342 add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]);
7343 hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs);
7344 if (add_req->usPtrnIntervalMs == 0)
7345 {
7346 hddLog(LOGE, FL("Invalid interval zero, return failure"));
7347 goto fail;
7348 }
7349
7350 if (!tb[PARAM_SRC_MAC_ADDR])
7351 {
7352 hddLog(LOGE, FL("attr source mac address failed"));
7353 goto fail;
7354 }
7355 nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR],
7356 VOS_MAC_ADDR_SIZE);
7357 hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR,
7358 MAC_ADDR_ARRAY(add_req->macAddress));
7359
7360 if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes,
7361 VOS_MAC_ADDR_SIZE))
7362 {
7363 hddLog(LOGE,
7364 FL("input src mac address and connected ap bssid are different"));
7365 goto fail;
7366 }
7367
7368 if (!tb[PARAM_DST_MAC_ADDR])
7369 {
7370 hddLog(LOGE, FL("attr dst mac address failed"));
7371 goto fail;
7372 }
7373 nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE);
7374 hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR,
7375 MAC_ADDR_ARRAY(dst_addr.bytes));
7376
7377 if (!tb[PARAM_IP_PACKET])
7378 {
7379 hddLog(LOGE, FL("attr ip packet failed"));
7380 goto fail;
7381 }
7382 add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]);
7383 hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize);
7384
7385 if (add_req->ucPtrnSize < 0 ||
7386 add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE -
7387 HDD_ETH_HEADER_LEN))
7388 {
7389 hddLog(LOGE, FL("Invalid IP packet len: %d"),
7390 add_req->ucPtrnSize);
7391 goto fail;
7392 }
7393
7394 len = 0;
7395 vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE);
7396 len += VOS_MAC_ADDR_SIZE;
7397 vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress,
7398 VOS_MAC_ADDR_SIZE);
7399 len += VOS_MAC_ADDR_SIZE;
7400 vos_mem_copy(&add_req->ucPattern[len], &eth_type, 2);
7401 len += 2;
7402
7403 /*
7404 * This is the IP packet, add 14 bytes Ethernet (802.3) header
7405 * ------------------------------------------------------------
7406 * | 14 bytes Ethernet (802.3) header | IP header and payload |
7407 * ------------------------------------------------------------
7408 */
7409 vos_mem_copy(&add_req->ucPattern[len],
7410 nla_data(tb[PARAM_IP_PACKET]),
7411 add_req->ucPtrnSize);
7412 add_req->ucPtrnSize += len;
7413
7414 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7415 add_req->ucPattern, add_req->ucPtrnSize);
7416
7417 ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
7418 if (ret)
7419 {
7420 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
7421 goto fail;
7422 }
7423 add_req->ucPtrnId = pattern_id;
7424 hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId);
7425
7426 status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req);
7427 if (!HAL_STATUS_SUCCESS(status))
7428 {
7429 hddLog(LOGE,
7430 FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status);
7431 goto fail;
7432 }
7433
7434 EXIT();
7435 vos_mem_free(add_req);
7436 return 0;
7437
7438fail:
7439 vos_mem_free(add_req);
7440 return -EINVAL;
7441}
7442
7443/**
7444 * wlan_hdd_del_tx_ptrn() - delete tx pattern
7445 * @adapter: adapter pointer
7446 * @hdd_ctx: hdd context
7447 * @tb: nl attributes
7448 *
7449 * This function reads the NL attributes and forms a DelTxPtrn message
7450 * posts it to SME.
7451 *
7452 */
7453static int
7454wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
7455 struct nlattr **tb)
7456{
7457 struct sSirDelPeriodicTxPtrn *del_req;
7458 eHalStatus status;
7459 uint32_t request_id, ret;
7460 uint8_t pattern_id = 0;
7461
7462 /* Parse and fetch request Id */
7463 if (!tb[PARAM_REQUEST_ID])
7464 {
7465 hddLog(LOGE, FL("attr request id failed"));
7466 return -EINVAL;
7467 }
7468 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
7469 if (request_id == 0)
7470 {
7471 hddLog(LOGE, FL("request_id cannot be zero"));
7472 return -EINVAL;
7473 }
7474
7475 ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
7476 if (ret)
7477 {
7478 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
7479 return -EINVAL;
7480 }
7481
7482 del_req = vos_mem_malloc(sizeof(*del_req));
7483 if (!del_req)
7484 {
7485 hddLog(LOGE, FL("memory allocation failed"));
7486 return -ENOMEM;
7487 }
7488
7489 vos_mem_set(del_req, sizeof(*del_req), 0);
7490 vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes,
7491 VOS_MAC_ADDR_SIZE);
7492 hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress));
7493 del_req->ucPatternIdBitmap |= (0x1 << pattern_id);
7494 hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"),
7495 request_id, pattern_id, del_req->ucPatternIdBitmap);
7496
7497 status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req);
7498 if (!HAL_STATUS_SUCCESS(status))
7499 {
7500 hddLog(LOGE,
7501 FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status);
7502 goto fail;
7503 }
7504
7505 EXIT();
7506 vos_mem_free(del_req);
7507 return 0;
7508
7509fail:
7510 vos_mem_free(del_req);
7511 return -EINVAL;
7512}
7513
7514
7515/**
7516 * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets
7517 * @wiphy: Pointer to wireless phy
7518 * @wdev: Pointer to wireless device
7519 * @data: Pointer to data
7520 * @data_len: Data length
7521 *
7522 * Return: 0 on success, negative errno on failure
7523 */
7524static int
7525__wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7526 struct wireless_dev *wdev,
7527 const void *data,
7528 int data_len)
7529{
7530 struct net_device *dev = wdev->netdev;
7531 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7532 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7533 struct nlattr *tb[PARAM_MAX + 1];
7534 uint8_t control;
7535 int ret;
7536 static const struct nla_policy policy[PARAM_MAX + 1] =
7537 {
7538 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
7539 [PARAM_CONTROL] = { .type = NLA_U32 },
7540 [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY,
7541 .len = VOS_MAC_ADDR_SIZE },
7542 [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY,
7543 .len = VOS_MAC_ADDR_SIZE },
7544 [PARAM_PERIOD] = { .type = NLA_U32 },
7545 };
7546
7547 ENTER();
7548
7549 ret = wlan_hdd_validate_context(hdd_ctx);
7550 if (0 != ret)
7551 {
7552 hddLog(LOGE, FL("HDD context is not valid"));
7553 return ret;
7554 }
7555
7556 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
7557 {
7558 hddLog(LOGE,
7559 FL("Periodic Tx Pattern Offload feature is not supported in FW!"));
7560 return -ENOTSUPP;
7561 }
7562
7563 if (nla_parse(tb, PARAM_MAX, data, data_len, policy))
7564 {
7565 hddLog(LOGE, FL("Invalid ATTR"));
7566 return -EINVAL;
7567 }
7568
7569 if (!tb[PARAM_CONTROL])
7570 {
7571 hddLog(LOGE, FL("attr control failed"));
7572 return -EINVAL;
7573 }
7574 control = nla_get_u32(tb[PARAM_CONTROL]);
7575 hddLog(LOG1, FL("Control: %d"), control);
7576
7577 if (control == WLAN_START_OFFLOADED_PACKETS)
7578 return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb);
7579 else if (control == WLAN_STOP_OFFLOADED_PACKETS)
7580 return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb);
7581 else
7582 {
7583 hddLog(LOGE, FL("Invalid control: %d"), control);
7584 return -EINVAL;
7585 }
7586}
7587
7588/*
7589 * done with short names for the global vendor params
7590 * used by __wlan_hdd_cfg80211_offloaded_packets()
7591 */
7592#undef PARAM_MAX
7593#undef PARAM_REQUEST_ID
7594#undef PARAM_CONTROL
7595#undef PARAM_IP_PACKET
7596#undef PARAM_SRC_MAC_ADDR
7597#undef PARAM_DST_MAC_ADDR
7598#undef PARAM_PERIOD
7599
7600/**
7601 * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets
7602 * @wiphy: wiphy structure pointer
7603 * @wdev: Wireless device structure pointer
7604 * @data: Pointer to the data received
7605 * @data_len: Length of @data
7606 *
7607 * Return: 0 on success; errno on failure
7608 */
7609static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7610 struct wireless_dev *wdev,
7611 const void *data,
7612 int data_len)
7613{
7614 int ret = 0;
7615
7616 vos_ssr_protect(__func__);
7617 ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy,
7618 wdev, data, data_len);
7619 vos_ssr_unprotect(__func__);
7620
7621 return ret;
7622}
7623#endif
7624
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307625static const struct
7626nla_policy
7627qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = {
Jeff Johnsonda8c3a72017-06-23 15:59:08 +05307628 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = {
7629 .type = NLA_BINARY,
7630 .len = HDD_MAC_ADDR_LEN},
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307631};
7632
7633/**
7634 * wlan_hdd_cfg80211_get_link_properties() - This function is used to
7635 * get link properties like nss, rate flags and operating frequency for
7636 * the connection with the given peer.
7637 * @wiphy: WIPHY structure pointer
7638 * @wdev: Wireless device structure pointer
7639 * @data: Pointer to the data received
7640 * @data_len: Length of the data received
7641 *
7642 * This function return the above link properties on success.
7643 *
7644 * Return: 0 on success and errno on failure
7645 */
7646static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
7647 struct wireless_dev *wdev,
7648 const void *data,
7649 int data_len)
7650{
7651 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7652 struct net_device *dev = wdev->netdev;
7653 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7654 hdd_station_ctx_t *hdd_sta_ctx;
7655 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1];
7656 uint8_t peer_mac[VOS_MAC_ADDR_SIZE];
7657 uint32_t sta_id;
7658 struct sk_buff *reply_skb;
7659 uint32_t rate_flags = 0;
7660 uint8_t nss;
7661 uint8_t final_rate_flags = 0;
7662 uint32_t freq;
7663 v_CONTEXT_t pVosContext = NULL;
7664 ptSapContext pSapCtx = NULL;
7665
7666 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
7667 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
7668 return -EINVAL;
7669 }
7670
7671 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7672 qca_wlan_vendor_attr_policy)) {
7673 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute"));
7674 return -EINVAL;
7675 }
7676
7677 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
7678 hddLog(VOS_TRACE_LEVEL_ERROR,
7679 FL("Attribute peerMac not provided for mode=%d"),
7680 adapter->device_mode);
7681 return -EINVAL;
7682 }
7683
Ashish Kumar Dhanotiyaddaf0482017-06-23 15:22:42 +05307684 if (nla_len(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) < sizeof(peer_mac)) {
7685 hddLog(VOS_TRACE_LEVEL_ERROR,
7686 FL("Attribute peerMac is invalid=%d"),
7687 adapter->device_mode);
7688 return -EINVAL;
7689 }
7690
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307691 memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
7692 sizeof(peer_mac));
7693 hddLog(VOS_TRACE_LEVEL_INFO,
7694 FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"),
7695 MAC_ADDR_ARRAY(peer_mac), adapter->device_mode);
7696
7697 if (adapter->device_mode == WLAN_HDD_INFRA_STATION ||
7698 adapter->device_mode == WLAN_HDD_P2P_CLIENT) {
7699 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
7700 if ((hdd_sta_ctx->conn_info.connState !=
7701 eConnectionState_Associated) ||
7702 !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac,
7703 VOS_MAC_ADDRESS_LEN)) {
7704 hddLog(VOS_TRACE_LEVEL_ERROR,
7705 FL("Not Associated to mac "MAC_ADDRESS_STR),
7706 MAC_ADDR_ARRAY(peer_mac));
7707 return -EINVAL;
7708 }
7709
7710 nss = 1; //pronto supports only one spatial stream
7711 freq = vos_chan_to_freq(
7712 hdd_sta_ctx->conn_info.operationChannel);
7713 rate_flags = hdd_sta_ctx->conn_info.rate_flags;
7714
7715 } else if (adapter->device_mode == WLAN_HDD_P2P_GO ||
7716 adapter->device_mode == WLAN_HDD_SOFTAP) {
7717
7718 pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext;
7719 pSapCtx = VOS_GET_SAP_CB(pVosContext);
7720 if(pSapCtx == NULL){
7721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7722 FL("psapCtx is NULL"));
7723 return -ENOENT;
7724 }
7725
7726
7727 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
7728 if (pSapCtx->aStaInfo[sta_id].isUsed &&
7729 !vos_is_macaddr_broadcast(
7730 &pSapCtx->aStaInfo[sta_id].macAddrSTA) &&
7731 vos_mem_compare(
7732 &pSapCtx->aStaInfo[sta_id].macAddrSTA,
7733 peer_mac, VOS_MAC_ADDRESS_LEN))
7734 break;
7735 }
7736
7737 if (WLAN_MAX_STA_COUNT == sta_id) {
7738 hddLog(VOS_TRACE_LEVEL_ERROR,
7739 FL("No active peer with mac="MAC_ADDRESS_STR),
7740 MAC_ADDR_ARRAY(peer_mac));
7741 return -EINVAL;
7742 }
7743
7744 nss = 1; //pronto supports only one spatial stream
7745 freq = vos_chan_to_freq(
7746 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel);
7747 rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags;
7748 } else {
7749 hddLog(VOS_TRACE_LEVEL_ERROR,
7750 FL("Not Associated! with mac"MAC_ADDRESS_STR),
7751 MAC_ADDR_ARRAY(peer_mac));
7752 return -EINVAL;
7753 }
7754
7755 if (!(rate_flags & eHAL_TX_RATE_LEGACY)) {
7756 if (rate_flags & eHAL_TX_RATE_VHT80) {
7757 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307758#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
7759 !defined(WITH_BACKPORTS)
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307760 final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307761#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307762 } else if (rate_flags & eHAL_TX_RATE_VHT40) {
7763 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307764#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
7765 !defined(WITH_BACKPORTS)
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307766 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307767#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307768 } else if (rate_flags & eHAL_TX_RATE_VHT20) {
7769 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7770 } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) {
7771 final_rate_flags |= RATE_INFO_FLAGS_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307772#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
7773 !defined(WITH_BACKPORTS)
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307774 if (rate_flags & eHAL_TX_RATE_HT40)
7775 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05307776#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307777 }
7778
7779 if (rate_flags & eHAL_TX_RATE_SGI) {
7780 if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS))
7781 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7782 final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI;
7783 }
7784 }
7785
7786 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7787 sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN);
7788
7789 if (NULL == reply_skb) {
7790 hddLog(VOS_TRACE_LEVEL_ERROR,
7791 FL("getLinkProperties: skb alloc failed"));
7792 return -EINVAL;
7793 }
7794
7795 if (nla_put_u8(reply_skb,
7796 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS,
7797 nss) ||
7798 nla_put_u8(reply_skb,
7799 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS,
7800 final_rate_flags) ||
7801 nla_put_u32(reply_skb,
7802 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ,
7803 freq)) {
7804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed"));
7805 kfree_skb(reply_skb);
7806 return -EINVAL;
7807 }
7808
7809 return cfg80211_vendor_cmd_reply(reply_skb);
7810}
7811
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307812#define BEACON_MISS_THRESH_2_4 \
7813 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24
7814#define BEACON_MISS_THRESH_5_0 \
7815 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307816#define PARAM_WIFICONFIG_MAX QCA_WLAN_VENDOR_ATTR_CONFIG_MAX
7817#define PARAM_MODULATED_DTIM QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM
7818#define PARAM_STATS_AVG_FACTOR QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR
7819#define PARAM_GUARD_TIME QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307820#define PARAM_BCNMISS_PENALTY_PARAM_COUNT \
7821 QCA_WLAN_VENDOR_ATTR_CONFIG_PENALIZE_AFTER_NCONS_BEACON_MISS
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05307822#define PARAM_FORCE_RSN_IE \
7823 QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE
Ashish Kumar Dhanotiyaf59c7762018-04-10 17:54:25 +05307824/*
7825 * hdd_set_qpower() - Process the qpower command and invoke the SME api
7826 * @hdd_ctx: hdd context
7827 * @enable: Value received in the command, 1 for disable and 2 for enable
7828 *
7829 * Return: void
7830 */
7831static void hdd_set_qpower(hdd_context_t *hdd_ctx, uint8_t enable)
7832{
7833 if (!hdd_ctx) {
7834 hddLog(LOGE, "hdd_ctx NULL");
7835 return;
7836 }
7837
7838 sme_set_qpower(hdd_ctx->hHal, enable);
7839}
7840
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307841/**
7842 * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7843 * vendor command
7844 *
7845 * @wiphy: wiphy device pointer
7846 * @wdev: wireless device pointer
7847 * @data: Vendor command data buffer
7848 * @data_len: Buffer length
7849 *
7850 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7851 *
7852 * Return: EOK or other error codes.
7853 */
7854
7855static int __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7856 struct wireless_dev *wdev,
7857 const void *data,
7858 int data_len)
7859{
7860 struct net_device *dev = wdev->netdev;
7861 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7862 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7863 hdd_station_ctx_t *pHddStaCtx;
7864 struct nlattr *tb[PARAM_WIFICONFIG_MAX + 1];
7865 tpSetWifiConfigParams pReq;
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307866 tModifyRoamParamsReqParams modifyRoamParamsReq;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307867 eHalStatus status;
7868 int ret_val;
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307869 uint8_t hb_thresh_val;
Ashish Kumar Dhanotiyaf59c7762018-04-10 17:54:25 +05307870 uint8_t qpower;
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307871
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307872 static const struct nla_policy policy[PARAM_WIFICONFIG_MAX + 1] = {
7873 [PARAM_STATS_AVG_FACTOR] = { .type = NLA_U16 },
7874 [PARAM_MODULATED_DTIM] = { .type = NLA_U32 },
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307875 [PARAM_GUARD_TIME] = { .type = NLA_U32},
7876 [PARAM_BCNMISS_PENALTY_PARAM_COUNT] =
7877 { .type = NLA_U32},
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307878 [BEACON_MISS_THRESH_2_4] = { .type = NLA_U8 },
7879 [BEACON_MISS_THRESH_5_0] = { .type = NLA_U8 },
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05307880 [PARAM_FORCE_RSN_IE] = {.type = NLA_U8 },
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307881 };
7882
7883 ENTER();
7884
7885 if (VOS_FTM_MODE == hdd_get_conparam()) {
7886 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7887 return -EINVAL;
7888 }
7889
7890 ret_val = wlan_hdd_validate_context(pHddCtx);
7891 if (ret_val) {
7892 return ret_val;
7893 }
7894
7895 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7896
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307897 if (nla_parse(tb, PARAM_WIFICONFIG_MAX, data, data_len, policy)) {
7898 hddLog(LOGE, FL("Invalid ATTR"));
7899 return -EINVAL;
7900 }
7901
7902 /* check the Wifi Capability */
7903 if ( (TRUE != pHddCtx->cfg_ini->fEnableWifiConfig) &&
7904 (TRUE != sme_IsFeatureSupportedByFW(WIFI_CONFIG)))
7905 {
7906 hddLog(VOS_TRACE_LEVEL_ERROR,
7907 FL("WIFICONFIG not supported by Firmware"));
7908 return -EINVAL;
7909 }
7910
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307911 if (tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]) {
7912 modifyRoamParamsReq.param = WIFI_CONFIG_SET_BCNMISS_PENALTY_COUNT;
7913 modifyRoamParamsReq.value =
7914 nla_get_u32(tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]);
7915
7916 if (eHAL_STATUS_SUCCESS !=
7917 sme_setBcnMissPenaltyCount(pHddCtx->hHal,&modifyRoamParamsReq))
7918 {
7919 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed", __func__);
7920 ret_val = -EINVAL;
7921 }
7922 return ret_val;
7923 }
7924
7925 /* Moved this down in order to provide provision to set beacon
7926 * miss penalty count irrespective of connection state.
7927 */
7928 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
7929 hddLog(LOGE, FL("Not in Connected state!"));
7930 return -ENOTSUPP;
7931 }
7932
7933 pReq = vos_mem_malloc(sizeof(tSetWifiConfigParams));
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307934
7935 if (!pReq) {
7936 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7937 "%s: Not able to allocate memory for tSetWifiConfigParams",
7938 __func__);
7939 return eHAL_STATUS_E_MALLOC_FAILED;
7940 }
7941
7942 vos_mem_set(pReq, sizeof(tSetWifiConfigParams), 0);
7943
7944 pReq->sessionId = pAdapter->sessionId;
7945 vos_mem_copy( &pReq->bssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
7946
7947 if (tb[PARAM_MODULATED_DTIM]) {
7948 pReq->paramValue = nla_get_u32(
7949 tb[PARAM_MODULATED_DTIM]);
7950 hddLog(LOG1, FL("Modulated DTIM: pReq->paramValue:%d "),
7951 pReq->paramValue);
Arun Khandavalli876886f2015-11-23 11:42:27 +05307952 pHddCtx->cfg_ini->enableDynamicDTIM = pReq->paramValue;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307953 hdd_set_pwrparams(pHddCtx);
7954 if (BMPS == pmcGetPmcState(pHddCtx->hHal)) {
7955 hddLog( LOG1, FL("WifiConfig: Requesting FullPower!"));
7956
7957 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
7958 iw_full_power_cbfn, pAdapter,
7959 eSME_FULL_PWR_NEEDED_BY_HDD);
7960 }
7961 else
7962 {
7963 hddLog( LOG1, FL("WifiConfig Not in BMPS state"));
7964 }
7965 }
7966
7967 if (tb[PARAM_STATS_AVG_FACTOR]) {
7968 pReq->paramType = WIFI_CONFIG_SET_AVG_STATS_FACTOR;
7969 pReq->paramValue = nla_get_u16(
7970 tb[PARAM_STATS_AVG_FACTOR]);
7971 hddLog(LOG1, FL("AVG_STATS_FACTOR pReq->paramType:%d,pReq->paramValue:%d "),
7972 pReq->paramType, pReq->paramValue);
7973 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7974
7975 if (eHAL_STATUS_SUCCESS != status)
7976 {
7977 vos_mem_free(pReq);
7978 pReq = NULL;
7979 ret_val = -EPERM;
7980 return ret_val;
7981 }
7982 }
7983
7984
7985 if (tb[PARAM_GUARD_TIME]) {
7986 pReq->paramType = WIFI_CONFIG_SET_GUARD_TIME;
7987 pReq->paramValue = nla_get_u32(
7988 tb[PARAM_GUARD_TIME]);
7989 hddLog(LOG1, FL("GUARD_TIME pReq->paramType:%d,pReq->paramValue:%d "),
7990 pReq->paramType, pReq->paramValue);
7991 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7992
7993 if (eHAL_STATUS_SUCCESS != status)
7994 {
7995 vos_mem_free(pReq);
7996 pReq = NULL;
7997 ret_val = -EPERM;
7998 return ret_val;
7999 }
8000
8001 }
8002
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05308003 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]) {
8004 hb_thresh_val = nla_get_u8(
8005 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]);
8006
8007 hddLog(LOG1, "WLAN set heartbeat threshold for 2.4Ghz %d",
8008 hb_thresh_val);
8009 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
8010 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
8011 NULL, eANI_BOOLEAN_FALSE);
8012
8013 status = sme_update_hb_threshold(
8014 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
8015 WNI_CFG_HEART_BEAT_THRESHOLD,
8016 hb_thresh_val, eCSR_BAND_24);
8017 if (eHAL_STATUS_SUCCESS != status) {
8018 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
8019 vos_mem_free(pReq);
8020 pReq = NULL;
8021 return -EPERM;
8022 }
8023 }
8024
8025 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]) {
8026 hb_thresh_val = nla_get_u8(
8027 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]);
8028
8029 hddLog(LOG1, "WLAN set heartbeat threshold for 5Ghz %d",
8030 hb_thresh_val);
8031 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
8032 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
8033 NULL, eANI_BOOLEAN_FALSE);
8034
8035 status = sme_update_hb_threshold(
8036 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
8037 WNI_CFG_HEART_BEAT_THRESHOLD,
8038 hb_thresh_val, eCSR_BAND_5G);
8039 if (eHAL_STATUS_SUCCESS != status) {
8040 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
8041 vos_mem_free(pReq);
8042 pReq = NULL;
8043 return -EPERM;
8044 }
8045 }
8046
Ashish Kumar Dhanotiyaf59c7762018-04-10 17:54:25 +05308047 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER]) {
8048 qpower = nla_get_u8(
8049 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER]);
8050
8051 if(qpower > 1) {
8052 hddLog(LOGE, "Invalid QPOWER value %d", qpower);
8053 vos_mem_free(pReq);
8054 pReq = NULL;
8055 return -EINVAL;
8056 }
8057 /* FW is expacting qpower as 1 for Disable and 2 for enable */
8058 qpower++;
8059 hdd_set_qpower(pHddCtx, qpower);
8060 }
8061
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05308062 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE] &&
8063 pHddCtx->cfg_ini->force_rsne_override) {
8064 uint8_t force_rsne_override;
8065
8066 force_rsne_override =
8067 nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE]);
8068 if (force_rsne_override > 1) {
8069 hddLog(LOGE, "Invalid test_mode %d", force_rsne_override);
8070 ret_val = -EINVAL;
8071 }
8072 pHddCtx->force_rsne_override = force_rsne_override;
8073 hddLog(LOG1, "force_rsne_override - %d",
8074 pHddCtx->force_rsne_override);
8075 }
8076
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05308077 EXIT();
8078 return ret_val;
8079}
8080
8081/**
8082 * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
8083 * vendor command
8084 *
8085 * @wiphy: wiphy device pointer
8086 * @wdev: wireless device pointer
8087 * @data: Vendor command data buffer
8088 * @data_len: Buffer length
8089 *
8090 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
8091 *
8092 * Return: EOK or other error codes.
8093 */
8094static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
8095 struct wireless_dev *wdev,
8096 const void *data,
8097 int data_len)
8098{
8099 int ret;
8100
8101 vos_ssr_protect(__func__);
8102 ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev,
8103 data, data_len);
8104 vos_ssr_unprotect(__func__);
8105
8106 return ret;
8107}
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308108
8109/*
8110 * define short names for the global vendor params
8111 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
8112 */
8113#define STATS_SET_INVALID \
8114 QCA_ATTR_NUD_STATS_SET_INVALID
8115#define STATS_SET_START \
8116 QCA_ATTR_NUD_STATS_SET_START
8117#define STATS_GW_IPV4 \
8118 QCA_ATTR_NUD_STATS_GW_IPV4
8119#define STATS_SET_MAX \
8120 QCA_ATTR_NUD_STATS_SET_MAX
8121
8122const struct nla_policy
8123qca_wlan_vendor_set_nud_stats[STATS_SET_MAX +1] =
8124{
8125 [STATS_SET_START] = {.type = NLA_FLAG },
8126 [STATS_GW_IPV4] = {.type = NLA_U32 },
8127};
8128
8129/**
8130 * hdd_set_nud_stats_cb() - hdd callback api to get status
8131 * @data: pointer to adapter
8132 * @rsp: status
8133 *
8134 * Return: None
8135 */
8136static void hdd_set_nud_stats_cb(void *data, VOS_STATUS rsp)
8137{
8138
8139 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
8140
8141 if (NULL == adapter)
8142 return;
8143
8144 if (VOS_STATUS_SUCCESS == rsp) {
8145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8146 "%s success received STATS_SET_START", __func__);
8147 } else {
8148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8149 "%s STATS_SET_START Failed!!", __func__);
8150 }
8151 return;
8152}
8153
8154/**
8155 * __wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
8156 * @wiphy: pointer to wireless wiphy structure.
8157 * @wdev: pointer to wireless_dev structure.
8158 * @data: pointer to apfind configuration data.
8159 * @data_len: the length in byte of apfind data.
8160 *
8161 * This is called when wlan driver needs to send arp stats to
8162 * firmware.
8163 *
8164 * Return: An error code or 0 on success.
8165 */
8166static int __wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
8167 struct wireless_dev *wdev,
8168 const void *data, int data_len)
8169{
8170 struct nlattr *tb[STATS_SET_MAX + 1];
8171 struct net_device *dev = wdev->netdev;
8172 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8173 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308174 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308175 setArpStatsParams arp_stats_params;
8176 int err = 0;
8177
8178 ENTER();
8179
8180 err = wlan_hdd_validate_context(hdd_ctx);
8181 if (0 != err)
8182 return err;
8183
8184 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
8185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8186 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
8187 return -EINVAL;
8188 }
8189
8190 err = nla_parse(tb, STATS_SET_MAX, data, data_len,
8191 qca_wlan_vendor_set_nud_stats);
8192 if (err)
8193 {
8194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8195 "%s STATS_SET_START ATTR", __func__);
8196 return err;
8197 }
8198
8199 if (tb[STATS_SET_START])
8200 {
8201 if (!tb[STATS_GW_IPV4]) {
8202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8203 "%s STATS_SET_START CMD", __func__);
8204 return -EINVAL;
8205 }
8206 arp_stats_params.flag = true;
8207 arp_stats_params.ip_addr = nla_get_u32(tb[STATS_GW_IPV4]);
8208 } else {
8209 arp_stats_params.flag = false;
8210 }
Anurag Chouhan630c5562017-03-23 14:51:47 +05308211 if (arp_stats_params.flag)
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8213 "%s STATS_SET_START Cleared!!", __func__);
Anurag Chouhan630c5562017-03-23 14:51:47 +05308214 vos_mem_zero(&adapter->hdd_stats.hddArpStats,
8215 sizeof(adapter->hdd_stats.hddArpStats));
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308216
8217 arp_stats_params.pkt_type = 1; // ARP packet type
8218
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308219 if (arp_stats_params.flag) {
8220 hdd_ctx->track_arp_ip = arp_stats_params.ip_addr;
8221 WLANTL_SetARPFWDatapath(pVosContext, true);
8222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8223 "%s Set FW in data path for ARP with tgt IP :%d",
8224 __func__, hdd_ctx->track_arp_ip);
8225 }
8226 else {
8227 WLANTL_SetARPFWDatapath(pVosContext, false);
8228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8229 "%s Remove FW from data path", __func__);
8230 }
8231
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308232 arp_stats_params.rsp_cb_fn = hdd_set_nud_stats_cb;
8233 arp_stats_params.data_ctx = adapter;
8234
8235 if (eHAL_STATUS_SUCCESS !=
8236 sme_set_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
8237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8238 "%s STATS_SET_START CMD Failed!!", __func__);
8239 return -EINVAL;
8240 }
8241
8242 EXIT();
8243
8244 return err;
8245}
8246
8247/**
8248 * wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
8249 * @wiphy: pointer to wireless wiphy structure.
8250 * @wdev: pointer to wireless_dev structure.
8251 * @data: pointer to apfind configuration data.
8252 * @data_len: the length in byte of apfind data.
8253 *
8254 * This is called when wlan driver needs to send arp stats to
8255 * firmware.
8256 *
8257 * Return: An error code or 0 on success.
8258 */
8259static int wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
8260 struct wireless_dev *wdev,
8261 const void *data, int data_len)
8262{
8263 int ret;
8264
8265 vos_ssr_protect(__func__);
8266 ret = __wlan_hdd_cfg80211_set_nud_stats(wiphy, wdev, data, data_len);
8267 vos_ssr_unprotect(__func__);
8268
8269 return ret;
8270}
8271#undef STATS_SET_INVALID
8272#undef STATS_SET_START
8273#undef STATS_GW_IPV4
8274#undef STATS_SET_MAX
8275
8276/*
8277 * define short names for the global vendor params
8278 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
8279 */
8280#define STATS_GET_INVALID \
8281 QCA_ATTR_NUD_STATS_SET_INVALID
8282#define COUNT_FROM_NETDEV \
8283 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
8284#define COUNT_TO_LOWER_MAC \
8285 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
8286#define RX_COUNT_BY_LOWER_MAC \
8287 QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
8288#define COUNT_TX_SUCCESS \
8289 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
8290#define RSP_RX_COUNT_BY_LOWER_MAC \
8291 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
8292#define RSP_RX_COUNT_BY_UPPER_MAC \
8293 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
8294#define RSP_COUNT_TO_NETDEV \
8295 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
8296#define RSP_COUNT_OUT_OF_ORDER_DROP \
8297 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
8298#define AP_LINK_ACTIVE \
8299 QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
8300#define AP_LINK_DAD \
8301 QCA_ATTR_NUD_STATS_AP_LINK_DAD
8302#define STATS_GET_MAX \
8303 QCA_ATTR_NUD_STATS_GET_MAX
8304
8305const struct nla_policy
8306qca_wlan_vendor_get_nud_stats[STATS_GET_MAX +1] =
8307{
8308 [COUNT_FROM_NETDEV] = {.type = NLA_U16 },
8309 [COUNT_TO_LOWER_MAC] = {.type = NLA_U16 },
8310 [RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
8311 [COUNT_TX_SUCCESS] = {.type = NLA_U16 },
8312 [RSP_RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
8313 [RSP_RX_COUNT_BY_UPPER_MAC] = {.type = NLA_U16 },
8314 [RSP_COUNT_TO_NETDEV] = {.type = NLA_U16 },
8315 [RSP_COUNT_OUT_OF_ORDER_DROP] = {.type = NLA_U16 },
8316 [AP_LINK_ACTIVE] = {.type = NLA_FLAG },
8317 [AP_LINK_DAD] = {.type = NLA_FLAG },
8318};
8319
8320static void hdd_get_nud_stats_cb(void *data, rsp_stats *rsp)
8321{
8322
8323 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
Hanumanth Reddy Pothula8f528c72018-02-26 16:49:25 +05308324 hdd_context_t *hdd_ctx;
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308325 struct hdd_nud_stats_context *context;
8326 int status;
8327
8328 ENTER();
8329
8330 if (NULL == adapter)
8331 return;
8332
Hanumanth Reddy Pothula8f528c72018-02-26 16:49:25 +05308333 if (!rsp) {
8334 hddLog(LOGE, FL("data is null"));
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308335 return;
8336 }
8337
Hanumanth Reddy Pothula8f528c72018-02-26 16:49:25 +05308338 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
8339 status = wlan_hdd_validate_context(hdd_ctx);
8340 if (0 != status) {
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308341 return;
8342 }
8343
8344 adapter->hdd_stats.hddArpStats.tx_fw_cnt = rsp->tx_fw_cnt;
8345 adapter->hdd_stats.hddArpStats.rx_fw_cnt = rsp->rx_fw_cnt;
8346 adapter->hdd_stats.hddArpStats.tx_ack_cnt = rsp->tx_ack_cnt;
8347 adapter->dad |= rsp->dad;
8348
8349 spin_lock(&hdd_context_lock);
8350 context = &hdd_ctx->nud_stats_context;
8351 complete(&context->response_event);
8352 spin_unlock(&hdd_context_lock);
8353
8354 return;
8355}
8356static int __wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
8357 struct wireless_dev *wdev,
8358 const void *data, int data_len)
8359{
8360 int err = 0;
8361 unsigned long rc;
8362 struct hdd_nud_stats_context *context;
8363 struct net_device *dev = wdev->netdev;
8364 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8365 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
8366 getArpStatsParams arp_stats_params;
8367 struct sk_buff *skb;
8368
8369 ENTER();
8370
8371 err = wlan_hdd_validate_context(hdd_ctx);
8372 if (0 != err)
8373 return err;
8374
8375 arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE;
8376 arp_stats_params.get_rsp_cb_fn = hdd_get_nud_stats_cb;
8377 arp_stats_params.data_ctx = adapter;
8378
8379 spin_lock(&hdd_context_lock);
8380 context = &hdd_ctx->nud_stats_context;
8381 INIT_COMPLETION(context->response_event);
8382 spin_unlock(&hdd_context_lock);
8383
8384 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
8385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8386 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
8387 return -EINVAL;
8388 }
8389
8390 if (eHAL_STATUS_SUCCESS !=
8391 sme_get_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
8392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8393 "%s STATS_SET_START CMD Failed!!", __func__);
8394 return -EINVAL;
8395 }
8396
8397 rc = wait_for_completion_timeout(&context->response_event,
8398 msecs_to_jiffies(WLAN_WAIT_TIME_NUD_STATS));
8399 if (!rc)
8400 {
8401 hddLog(LOGE,
8402 FL("Target response timed out request "));
8403 return -ETIMEDOUT;
8404 }
8405
8406 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
8407 WLAN_NUD_STATS_LEN);
8408 if (!skb)
8409 {
8410 hddLog(VOS_TRACE_LEVEL_ERROR,
8411 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
8412 __func__);
8413 return -ENOMEM;
8414 }
8415
8416 if (nla_put_u16(skb, COUNT_FROM_NETDEV,
8417 adapter->hdd_stats.hddArpStats.txCount) ||
8418 nla_put_u16(skb, COUNT_TO_LOWER_MAC,
8419 adapter->hdd_stats.hddArpStats.tx_host_fw_sent) ||
8420 nla_put_u16(skb, RX_COUNT_BY_LOWER_MAC,
8421 adapter->hdd_stats.hddArpStats.tx_fw_cnt) ||
8422 nla_put_u16(skb, COUNT_TX_SUCCESS,
8423 adapter->hdd_stats.hddArpStats.tx_ack_cnt) ||
8424 nla_put_u16(skb, RSP_RX_COUNT_BY_LOWER_MAC,
8425 adapter->hdd_stats.hddArpStats.rx_fw_cnt) ||
8426 nla_put_u16(skb, RSP_RX_COUNT_BY_UPPER_MAC,
8427 adapter->hdd_stats.hddArpStats.rxCount) ||
8428 nla_put_u16(skb, RSP_COUNT_TO_NETDEV,
8429 adapter->hdd_stats.hddArpStats.rxDelivered) ||
8430 nla_put_u16(skb, RSP_COUNT_OUT_OF_ORDER_DROP,
8431 adapter->hdd_stats.hddArpStats.rx_host_drop_reorder)) {
8432 hddLog(LOGE, FL("nla put fail"));
8433 kfree_skb(skb);
8434 return -EINVAL;
8435 }
8436 if (adapter->con_status)
8437 nla_put_flag(skb, AP_LINK_ACTIVE);
8438 if (adapter->dad)
8439 nla_put_flag(skb, AP_LINK_DAD);
8440
8441 cfg80211_vendor_cmd_reply(skb);
8442 return err;
8443}
8444
8445static int wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
8446 struct wireless_dev *wdev,
8447 const void *data, int data_len)
8448{
8449 int ret;
8450
8451 vos_ssr_protect(__func__);
8452 ret = __wlan_hdd_cfg80211_get_nud_stats(wiphy, wdev, data, data_len);
8453 vos_ssr_unprotect(__func__);
8454
8455 return ret;
8456}
8457
8458#undef QCA_ATTR_NUD_STATS_SET_INVALID
8459#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
8460#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
8461#undef QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
8462#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
8463#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
8464#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
8465#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
8466#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
8467#undef QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
8468#undef QCA_ATTR_NUD_STATS_GET_MAX
8469
8470
8471
Kapil Guptaee33bf12016-12-20 18:27:37 +05308472#ifdef WLAN_FEATURE_APFIND
8473/**
8474 * __wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
8475 * @wiphy: pointer to wireless wiphy structure.
8476 * @wdev: pointer to wireless_dev structure.
8477 * @data: pointer to apfind configuration data.
8478 * @data_len: the length in byte of apfind data.
8479 *
8480 * This is called when wlan driver needs to send APFIND configurations to
8481 * firmware.
8482 *
8483 * Return: An error code or 0 on success.
8484 */
8485static int __wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
8486 struct wireless_dev *wdev,
8487 const void *data, int data_len)
8488{
8489 struct sme_ap_find_request_req apfind_req;
8490 VOS_STATUS status;
8491 int ret_val;
8492 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
8493
8494 ENTER();
8495
8496 ret_val = wlan_hdd_validate_context(hdd_ctx);
8497 if (ret_val)
8498 return ret_val;
8499
8500 if (VOS_FTM_MODE == hdd_get_conparam()) {
8501 hddLog(LOGE, FL("Command not allowed in FTM mode"));
8502 return -EPERM;
8503 }
8504
8505 apfind_req.request_data_len = data_len;
8506 apfind_req.request_data = data;
8507
8508 status = sme_apfind_set_cmd(&apfind_req);
8509 if (VOS_STATUS_SUCCESS != status) {
8510 ret_val = -EIO;
8511 }
8512 return ret_val;
8513}
8514
8515/**
8516 * wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
8517 * @wiphy: pointer to wireless wiphy structure.
8518 * @wdev: pointer to wireless_dev structure.
8519 * @data: pointer to apfind configuration data.
8520 * @data_len: the length in byte of apfind data.
8521 *
8522 * This is called when wlan driver needs to send APFIND configurations to
8523 * firmware.
8524 *
8525 * Return: An error code or 0 on success.
8526 */
8527static int wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
8528 struct wireless_dev *wdev,
8529 const void *data, int data_len)
8530{
8531 int ret;
8532
8533 vos_ssr_protect(__func__);
8534 ret = __wlan_hdd_cfg80211_apfind_cmd(wiphy, wdev, data, data_len);
8535 vos_ssr_unprotect(__func__);
8536
8537 return ret;
8538}
8539#endif /* WLAN_FEATURE_APFIND */
Hanumanth Reddy Pothula49c3f902018-02-16 16:01:13 +05308540
8541/**
8542 * __wlan_hdd_cfg80211_get_logger_supp_feature() - Get the wifi logger features
8543 * @wiphy: pointer to wireless wiphy structure.
8544 * @wdev: pointer to wireless_dev structure.
8545 * @data: Pointer to the data to be passed via vendor interface
8546 * @data_len:Length of the data to be passed
8547 *
8548 * This is called by userspace to know the supported logger features
8549 *
8550 * Return: Return the Success or Failure code.
8551 */
8552static int
8553__wlan_hdd_cfg80211_get_logger_supp_feature(struct wiphy *wiphy,
8554 struct wireless_dev *wdev,
8555 const void *data, int data_len)
8556{
8557 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
8558 int status;
8559 uint32_t features;
8560 struct sk_buff *reply_skb = NULL;
8561
8562 if (VOS_FTM_MODE == hdd_get_conparam()) {
8563 hddLog(LOGE, FL("Command not allowed in FTM mode"));
8564 return -EINVAL;
8565 }
8566
8567 status = wlan_hdd_validate_context(hdd_ctx);
8568 if (0 != status)
8569 return -EINVAL;
8570
8571 features = 0;
8572
8573 if (hdd_is_memdump_supported())
8574 features |= WIFI_LOGGER_MEMORY_DUMP_SUPPORTED;
8575
8576 if (hdd_ctx->cfg_ini->wlanLoggingEnable &&
8577 hdd_ctx->cfg_ini->enableFatalEvent &&
8578 hdd_ctx->is_fatal_event_log_sup) {
8579 features |= WIFI_LOGGER_PER_PACKET_TX_RX_STATUS_SUPPORTED;
8580 features |= WIFI_LOGGER_CONNECT_EVENT_SUPPORTED;
8581 }
8582
8583 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
8584 sizeof(uint32_t) + NLA_HDRLEN + NLMSG_HDRLEN);
8585 if (!reply_skb) {
8586 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
8587 return -ENOMEM;
8588 }
8589
8590 hddLog(LOG1, FL("Supported logger features: 0x%0x"), features);
8591 if (nla_put_u32(reply_skb, QCA_WLAN_VENDOR_ATTR_LOGGER_SUPPORTED,
8592 features)) {
8593 hddLog(LOGE, FL("nla put fail"));
8594 kfree_skb(reply_skb);
8595 return -EINVAL;
8596 }
8597
8598 return cfg80211_vendor_cmd_reply(reply_skb);
8599}
8600
8601/**
8602 * wlan_hdd_cfg80211_get_logger_supp_feature() - Get the wifi logger features
8603 * @wiphy: pointer to wireless wiphy structure.
8604 * @wdev: pointer to wireless_dev structure.
8605 * @data: Pointer to the data to be passed via vendor interface
8606 * @data_len:Length of the data to be passed
8607 *
8608 * This is called by userspace to know the supported logger features
8609 *
8610 * Return: Return the Success or Failure code.
8611 */
8612static int
8613wlan_hdd_cfg80211_get_logger_supp_feature(struct wiphy *wiphy,
8614 struct wireless_dev *wdev,
8615 const void *data, int data_len)
8616{
8617 int ret;
8618
8619 vos_ssr_protect(__func__);
8620 ret = __wlan_hdd_cfg80211_get_logger_supp_feature(wiphy, wdev,
8621 data, data_len);
8622 vos_ssr_unprotect(__func__);
8623
8624 return ret;
8625}
8626
Sunil Duttc69bccb2014-05-26 21:30:20 +05308627const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
8628{
Mukul Sharma2a271632014-10-13 14:59:01 +05308629 {
8630 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8631 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
8632 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8633 WIPHY_VENDOR_CMD_NEED_NETDEV |
8634 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308635 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05308636 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05308637
8638 {
8639 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8640 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
8641 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8642 WIPHY_VENDOR_CMD_NEED_NETDEV |
8643 WIPHY_VENDOR_CMD_NEED_RUNNING,
8644 .doit = wlan_hdd_cfg80211_nan_request
8645 },
8646
Sunil Duttc69bccb2014-05-26 21:30:20 +05308647#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8648 {
8649 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8650 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
8651 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8652 WIPHY_VENDOR_CMD_NEED_NETDEV |
8653 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308654 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05308655 },
8656
8657 {
8658 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8659 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
8660 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8661 WIPHY_VENDOR_CMD_NEED_NETDEV |
8662 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308663 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05308664 },
8665
8666 {
8667 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8668 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
8669 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8670 WIPHY_VENDOR_CMD_NEED_NETDEV |
8671 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308672 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05308673 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308674#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05308675#ifdef WLAN_FEATURE_EXTSCAN
8676 {
8677 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8678 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
8679 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8680 WIPHY_VENDOR_CMD_NEED_NETDEV |
8681 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308682 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05308683 },
8684 {
8685 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8686 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
8687 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8688 WIPHY_VENDOR_CMD_NEED_NETDEV |
8689 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308690 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05308691 },
8692 {
8693 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8694 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
8695 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8696 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308697 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05308698 },
8699 {
8700 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8701 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
8702 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8703 WIPHY_VENDOR_CMD_NEED_NETDEV |
8704 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308705 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05308706 },
8707 {
8708 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8709 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
8710 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8711 WIPHY_VENDOR_CMD_NEED_NETDEV |
8712 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308713 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05308714 },
8715 {
8716 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8717 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
8718 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8719 WIPHY_VENDOR_CMD_NEED_NETDEV |
8720 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308721 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05308722 },
8723 {
8724 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8725 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
8726 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8727 WIPHY_VENDOR_CMD_NEED_NETDEV |
8728 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308729 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05308730 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05308731#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05308732/*EXT TDLS*/
8733 {
8734 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8735 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
8736 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8737 WIPHY_VENDOR_CMD_NEED_NETDEV |
8738 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308739 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05308740 },
8741 {
8742 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8743 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
8744 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8745 WIPHY_VENDOR_CMD_NEED_NETDEV |
8746 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308747 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05308748 },
8749 {
8750 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8751 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
8752 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8753 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308754 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05308755 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05308756 {
8757 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8758 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
8759 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8760 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308761 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05308762 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05308763 {
8764 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8765 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
8766 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8767 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308768 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05308769 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05308770 {
8771 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8772 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
8773 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8774 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308775 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05308776 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05308777 {
8778 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8779 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
8780 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8781 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308782 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05308783 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05308784 {
8785 .info.vendor_id = QCA_NL80211_VENDOR_ID,
c_manjeecfd1efb2015-09-25 19:32:34 +05308786 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP,
8787 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8788 WIPHY_VENDOR_CMD_NEED_NETDEV |
8789 WIPHY_VENDOR_CMD_NEED_RUNNING,
8790 .doit = wlan_hdd_cfg80211_get_fw_mem_dump
8791 },
8792 {
8793 .info.vendor_id = QCA_NL80211_VENDOR_ID,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05308794 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
8795 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8796 WIPHY_VENDOR_CMD_NEED_NETDEV |
8797 WIPHY_VENDOR_CMD_NEED_RUNNING,
8798 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05308799 },
8800 {
8801 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8802 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
8803 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8804 WIPHY_VENDOR_CMD_NEED_NETDEV,
8805 .doit = wlan_hdd_cfg80211_wifi_logger_start
8806 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05308807 {
8808 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8809 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
8810 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8811 WIPHY_VENDOR_CMD_NEED_NETDEV|
8812 WIPHY_VENDOR_CMD_NEED_RUNNING,
8813 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05308814 },
8815 {
8816 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8817 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
8818 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8819 WIPHY_VENDOR_CMD_NEED_NETDEV |
8820 WIPHY_VENDOR_CMD_NEED_RUNNING,
8821 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05308822 },
8823 {
8824 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8825 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
8826 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8827 WIPHY_VENDOR_CMD_NEED_NETDEV |
8828 WIPHY_VENDOR_CMD_NEED_RUNNING,
8829 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05308830 },
8831#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
8832 {
8833 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8834 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
8835 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8836 WIPHY_VENDOR_CMD_NEED_NETDEV |
8837 WIPHY_VENDOR_CMD_NEED_RUNNING,
8838 .doit = wlan_hdd_cfg80211_offloaded_packets
Deepthi Gowriae6a1662015-10-12 12:59:37 +05308839 },
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05308840#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05308841 {
8842 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8843 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
8844 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8845 WIPHY_VENDOR_CMD_NEED_NETDEV |
8846 WIPHY_VENDOR_CMD_NEED_RUNNING,
8847 .doit = wlan_hdd_cfg80211_get_link_properties
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05308848 },
8849 {
8850 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8851 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION,
8852 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8853 WIPHY_VENDOR_CMD_NEED_NETDEV |
8854 WIPHY_VENDOR_CMD_NEED_RUNNING,
8855 .doit = wlan_hdd_cfg80211_wifi_configuration_set
Kapil Guptaee33bf12016-12-20 18:27:37 +05308856 },
8857#ifdef WLAN_FEATURE_APFIND
8858 {
8859 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8860 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_APFIND,
8861 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8862 WIPHY_VENDOR_CMD_NEED_NETDEV,
8863 .doit = wlan_hdd_cfg80211_apfind_cmd
8864 },
8865#endif /* WLAN_FEATURE_APFIND */
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308866 {
8867 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8868 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_SET,
8869 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8870 WIPHY_VENDOR_CMD_NEED_NETDEV |
8871 WIPHY_VENDOR_CMD_NEED_RUNNING,
8872 .doit = wlan_hdd_cfg80211_set_nud_stats
8873 },
8874 {
8875 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8876 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
8877 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8878 WIPHY_VENDOR_CMD_NEED_NETDEV |
8879 WIPHY_VENDOR_CMD_NEED_RUNNING,
8880 .doit = wlan_hdd_cfg80211_get_nud_stats
8881 },
Anurag Chouhanfcd20172017-07-19 17:25:19 +05308882 {
8883 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8884 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_STATION,
8885 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8886 WIPHY_VENDOR_CMD_NEED_NETDEV |
8887 WIPHY_VENDOR_CMD_NEED_RUNNING,
8888 .doit = hdd_cfg80211_get_station_cmd
8889 },
Hanumanth Reddy Pothula49c3f902018-02-16 16:01:13 +05308890 {
8891 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8892 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_LOGGER_FEATURE_SET,
8893 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
Hanumanth Reddy Pothula07c95582018-05-23 12:41:22 +05308894 WIPHY_VENDOR_CMD_NEED_NETDEV,
Hanumanth Reddy Pothula49c3f902018-02-16 16:01:13 +05308895 .doit = wlan_hdd_cfg80211_get_logger_supp_feature
8896 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308897};
8898
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008899/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05308900static const
8901struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008902{
8903#ifdef FEATURE_WLAN_CH_AVOID
8904 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05308905 .vendor_id = QCA_NL80211_VENDOR_ID,
8906 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008907 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308908#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
8909#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8910 {
8911 /* Index = 1*/
8912 .vendor_id = QCA_NL80211_VENDOR_ID,
8913 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
8914 },
8915 {
8916 /* Index = 2*/
8917 .vendor_id = QCA_NL80211_VENDOR_ID,
8918 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
8919 },
8920 {
8921 /* Index = 3*/
8922 .vendor_id = QCA_NL80211_VENDOR_ID,
8923 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
8924 },
8925 {
8926 /* Index = 4*/
8927 .vendor_id = QCA_NL80211_VENDOR_ID,
8928 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
8929 },
8930 {
8931 /* Index = 5*/
8932 .vendor_id = QCA_NL80211_VENDOR_ID,
8933 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
8934 },
8935 {
8936 /* Index = 6*/
8937 .vendor_id = QCA_NL80211_VENDOR_ID,
8938 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
8939 },
8940#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05308941#ifdef WLAN_FEATURE_EXTSCAN
8942 {
8943 .vendor_id = QCA_NL80211_VENDOR_ID,
8944 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
8945 },
8946 {
8947 .vendor_id = QCA_NL80211_VENDOR_ID,
8948 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
8949 },
8950 {
8951 .vendor_id = QCA_NL80211_VENDOR_ID,
8952 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
8953 },
8954 {
8955 .vendor_id = QCA_NL80211_VENDOR_ID,
8956 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
8957 },
8958 {
8959 .vendor_id = QCA_NL80211_VENDOR_ID,
8960 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
8961 },
8962 {
8963 .vendor_id = QCA_NL80211_VENDOR_ID,
8964 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
8965 },
8966 {
8967 .vendor_id = QCA_NL80211_VENDOR_ID,
8968 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
8969 },
8970 {
8971 .vendor_id = QCA_NL80211_VENDOR_ID,
8972 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
8973 },
8974 {
8975 .vendor_id = QCA_NL80211_VENDOR_ID,
8976 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
8977 },
8978 {
8979 .vendor_id = QCA_NL80211_VENDOR_ID,
8980 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
8981 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05308982#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05308983/*EXT TDLS*/
8984 {
8985 .vendor_id = QCA_NL80211_VENDOR_ID,
8986 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
8987 },
c_manjeecfd1efb2015-09-25 19:32:34 +05308988 [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = {
8989 .vendor_id = QCA_NL80211_VENDOR_ID,
8990 .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP
8991 },
8992
Srinivas Dasari030bad32015-02-18 23:23:54 +05308993
Srinivas Dasaribd1cf642017-01-23 14:54:41 +05308994 [QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX] = {
Srinivas Dasari030bad32015-02-18 23:23:54 +05308995 .vendor_id = QCA_NL80211_VENDOR_ID,
8996 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
8997 },
8998
Sushant Kaushik084f6592015-09-10 13:11:56 +05308999 {
9000 .vendor_id = QCA_NL80211_VENDOR_ID,
9001 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05309002 },
9003 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
9004 .vendor_id = QCA_NL80211_VENDOR_ID,
9005 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
9006 },
Padma, Santhosh Kumar7bbc7d92015-12-08 20:23:19 +05309007 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = {
9008 .vendor_id = QCA_NL80211_VENDOR_ID,
9009 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST
9010 },
Anurag Chouhan6ee81542017-02-09 18:09:27 +05309011 [QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET_INDEX] = {
9012 .vendor_id = QCA_NL80211_VENDOR_ID,
9013 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
9014 },
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +05309015 [QCA_NL80211_VENDOR_SUBCMD_HANG_REASON_INDEX] = {
9016 .vendor_id = QCA_NL80211_VENDOR_ID,
9017 .subcmd = QCA_NL80211_VENDOR_SUBCMD_HANG,
9018 },
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +05309019 [QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES_INDEX] = {
9020 .vendor_id = QCA_NL80211_VENDOR_ID,
9021 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
9022 },
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08009023};
9024
Jeff Johnson295189b2012-06-20 16:38:30 -07009025/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309026 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309027 * This function is called by hdd_wlan_startup()
9028 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309029 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07009030 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309031struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07009032{
9033 struct wiphy *wiphy;
9034 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309035 /*
9036 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07009037 */
9038 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
9039
9040 if (!wiphy)
9041 {
9042 /* Print error and jump into err label and free the memory */
9043 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
9044 return NULL;
9045 }
9046
Sunil Duttc69bccb2014-05-26 21:30:20 +05309047
Jeff Johnson295189b2012-06-20 16:38:30 -07009048 return wiphy;
9049}
9050
Anurag Chouhan343af7e2016-12-16 13:11:19 +05309051#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,4,0)) || \
9052 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
9053/**
9054 * hdd_config_sched_scan_plans_to_wiphy() - configure sched scan plans to wiphy
9055 * @wiphy: pointer to wiphy
9056 * @config: pointer to config
9057 *
9058 * Return: None
9059 */
9060static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
9061 hdd_config_t *config)
9062{
9063 wiphy->max_sched_scan_plans = MAX_SCHED_SCAN_PLANS;
9064 if (config->max_sched_scan_plan_interval)
9065 wiphy->max_sched_scan_plan_interval =
9066 config->max_sched_scan_plan_interval;
9067 if (config->max_sched_scan_plan_iterations)
9068 wiphy->max_sched_scan_plan_iterations =
9069 config->max_sched_scan_plan_iterations;
9070}
9071#else
9072static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
9073 hdd_config_t *config)
9074{
9075}
9076#endif
9077
Jeff Johnson295189b2012-06-20 16:38:30 -07009078/*
9079 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309080 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07009081 * private ioctl to change the band value
9082 */
9083int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
9084{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309085 int i, j;
9086 eNVChannelEnabledType channelEnabledState;
9087
Jeff Johnsone7245742012-09-05 17:12:55 -07009088 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309089
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309090 for (i = 0; i < HDD_NUM_NL80211_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07009091 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309092
9093 if (NULL == wiphy->bands[i])
9094 {
9095 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
9096 __func__, i);
9097 continue;
9098 }
9099
9100 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9101 {
9102 struct ieee80211_supported_band *band = wiphy->bands[i];
9103
9104 channelEnabledState = vos_nv_getChannelEnabledState(
9105 band->channels[j].hw_value);
9106
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309107 if (HDD_NL80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309108 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309109 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309110 continue;
9111 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309112 else if (HDD_NL80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309113 {
9114 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
9115 continue;
9116 }
9117
9118 if (NV_CHANNEL_DISABLE == channelEnabledState ||
9119 NV_CHANNEL_INVALID == channelEnabledState)
9120 {
9121 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
9122 }
9123 else if (NV_CHANNEL_DFS == channelEnabledState)
9124 {
9125 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
9126 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
9127 }
9128 else
9129 {
9130 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
9131 |IEEE80211_CHAN_RADAR);
9132 }
9133 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009134 }
9135 return 0;
9136}
Abhishek Singh2f3c4752018-04-11 14:58:53 +05309137
9138/**
9139 * hdd_add_channel_switch_support()- Adds Channel Switch flag if supported
9140 * @wiphy: Pointer to the wiphy.
9141 *
9142 * This Function adds Channel Switch support flag, if channel switch is
9143 * supported by kernel.
9144 * Return: void.
9145 */
9146#ifdef CHANNEL_SWITCH_SUPPORTED
9147static inline
9148void hdd_add_channel_switch_support(struct wiphy *wiphy)
9149{
9150 wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
9151 wiphy->max_num_csa_counters = WLAN_HDD_MAX_NUM_CSA_COUNTERS;
9152}
9153#else
9154static inline
9155void hdd_add_channel_switch_support(struct wiphy *wiphy)
9156{
9157}
9158#endif
9159
Jeff Johnson295189b2012-06-20 16:38:30 -07009160/*
9161 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309162 * This function is called by hdd_wlan_startup()
9163 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07009164 * This function is used to initialize and register wiphy structure.
9165 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309166int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 struct wiphy *wiphy,
9168 hdd_config_t *pCfg
9169 )
9170{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309171 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05309172 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9173
Jeff Johnsone7245742012-09-05 17:12:55 -07009174 ENTER();
9175
Jeff Johnson295189b2012-06-20 16:38:30 -07009176 /* Now bind the underlying wlan device with wiphy */
9177 set_wiphy_dev(wiphy, dev);
9178
9179 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07009180
Kiet Lam6c583332013-10-14 05:37:09 +05309181#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07009182 /* the flag for the other case would be initialzed in
9183 vos_init_wiphy_from_nv_bin */
Manjeet Singh9e19de62016-08-18 18:26:41 +05309184#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
9185 wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
9186#else
Amar Singhal0a402232013-10-11 20:57:16 -07009187 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05309188#endif
Manjeet Singh9e19de62016-08-18 18:26:41 +05309189#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07009190
Amar Singhalfddc28c2013-09-05 13:03:40 -07009191 /* This will disable updating of NL channels from passive to
9192 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05309193#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
9194 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
9195#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07009196 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05309197#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07009198
Nachiket Kukade5b2e7332018-04-06 14:40:22 +05309199#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) || defined(WITH_BACKPORTS)
9200 wiphy->wowlan = &wowlan_support_cfg80211_init;
9201#else
Nachiket Kukade1e1b90e2018-05-10 15:26:13 +05309202 wiphy->wowlan.flags = WIPHY_WOWLAN_ANY |
9203 WIPHY_WOWLAN_MAGIC_PKT;
Nachiket Kukade5b2e7332018-04-06 14:40:22 +05309204 wiphy->wowlan.n_patterns = WOWL_MAX_PTRNS_ALLOWED;
9205 wiphy->wowlan.pattern_min_len = 1;
9206 wiphy->wowlan.pattern_max_len = WOWL_PTRN_MAX_SIZE;
9207#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07009208
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009209#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07009210 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
9211 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
9212 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07009213 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05309214#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Rajeev Kumar Sirasanagandla0d6dd752016-08-17 15:01:39 +05309215 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05309216#else
9217 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
9218#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009219#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07009220
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009221#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07009222 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08009223#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07009224 || pCfg->isFastRoamIniFeatureEnabled
9225#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009226#ifdef FEATURE_WLAN_ESE
9227 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07009228#endif
9229 )
9230 {
9231 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
9232 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08009233#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009234#ifdef FEATURE_WLAN_TDLS
9235 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
9236 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
9237#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309238#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05309239 if (pCfg->configPNOScanSupport)
9240 {
9241 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
9242 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
9243 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
9244 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
9245 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309246#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009247
Abhishek Singh10d85972015-04-17 10:27:23 +05309248#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
9249 wiphy->features |= NL80211_FEATURE_HT_IBSS;
9250#endif
9251
Amar Singhalfddc28c2013-09-05 13:03:40 -07009252#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07009253 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
9254 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07009255 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07009256 driver need to determine what to do with both
9257 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07009258
9259 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07009260#else
9261 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07009262#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009263
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309264 wiphy->max_scan_ssids = MAX_SCAN_SSID;
9265
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05309266 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07009267
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309268 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
9269
Jeff Johnson295189b2012-06-20 16:38:30 -07009270 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05309271 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
9272 | BIT(NL80211_IFTYPE_ADHOC)
9273 | BIT(NL80211_IFTYPE_P2P_CLIENT)
9274 | BIT(NL80211_IFTYPE_P2P_GO)
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05309275 | BIT(NL80211_IFTYPE_AP)
9276 | BIT(NL80211_IFTYPE_MONITOR);
Jeff Johnson295189b2012-06-20 16:38:30 -07009277
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309278 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009279 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309280#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
9281 if( pCfg->enableMCC )
9282 {
9283 /* Currently, supports up to two channels */
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05309284 wlan_hdd_iface_combination[0].num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009285
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309286 if( !pCfg->allowMCCGODiffBI )
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05309287 wlan_hdd_iface_combination[0].beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009288
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309289 }
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05309290 wiphy->iface_combinations = wlan_hdd_iface_combination;
9291 wiphy->n_iface_combinations = ARRAY_SIZE(wlan_hdd_iface_combination);
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009292#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05309293 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08009294
Jeff Johnson295189b2012-06-20 16:38:30 -07009295 /* Before registering we need to update the ht capabilitied based
9296 * on ini values*/
9297 if( !pCfg->ShortGI20MhzEnable )
9298 {
9299 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
9300 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
Jeff Johnson295189b2012-06-20 16:38:30 -07009301 }
9302
9303 if( !pCfg->ShortGI40MhzEnable )
9304 {
9305 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
9306 }
9307
9308 if( !pCfg->nChannelBondingMode5GHz )
9309 {
9310 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
9311 }
Agrawal Ashish97dec502015-11-26 20:20:58 +05309312 /*
9313 * In case of static linked driver at the time of driver unload,
9314 * module exit doesn't happens. Module cleanup helps in cleaning
9315 * of static memory.
9316 * If driver load happens statically, at the time of driver unload,
9317 * wiphy flags don't get reset because of static memory.
9318 * It's better not to store channel in static memory.
9319 */
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309320 wiphy->bands[HDD_NL80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
9321 wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels =
Agrawal Ashish97dec502015-11-26 20:20:58 +05309322 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_2_4_GHZ));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309323 if (wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels == NULL)
Agrawal Ashish97dec502015-11-26 20:20:58 +05309324 {
9325 hddLog(VOS_TRACE_LEVEL_ERROR,
9326 FL("Not enough memory to allocate channels"));
9327 return -ENOMEM;
9328 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309329 vos_mem_copy(wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels,
Agrawal Ashish97dec502015-11-26 20:20:58 +05309330 &hdd_channels_2_4_GHZ[0],
9331 sizeof(hdd_channels_2_4_GHZ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009332
Agrawal Ashish97dec502015-11-26 20:20:58 +05309333 if (true == hdd_is_5g_supported(pHddCtx))
9334 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309335 wiphy->bands[HDD_NL80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
9336 wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels =
Agrawal Ashish97dec502015-11-26 20:20:58 +05309337 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_5_GHZ));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309338 if (wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels == NULL)
Agrawal Ashish97dec502015-11-26 20:20:58 +05309339 {
9340 hddLog(VOS_TRACE_LEVEL_ERROR,
9341 FL("Not enough memory to allocate channels"));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309342 vos_mem_free(wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels);
9343 wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels = NULL;
Agrawal Ashish97dec502015-11-26 20:20:58 +05309344 return -ENOMEM;
9345 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309346 vos_mem_copy(wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels,
Agrawal Ashish97dec502015-11-26 20:20:58 +05309347 &hdd_channels_5_GHZ[0],
9348 sizeof(hdd_channels_5_GHZ));
9349 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309350
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309351 for (i = 0; i < HDD_NUM_NL80211_BANDS; i++)
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309352 {
9353
9354 if (NULL == wiphy->bands[i])
9355 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05309356 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309357 __func__, i);
9358 continue;
9359 }
9360
9361 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9362 {
9363 struct ieee80211_supported_band *band = wiphy->bands[i];
9364
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309365 if (HDD_NL80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309366 {
9367 // Enable social channels for P2P
9368 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
9369 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
9370 else
9371 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
9372 continue;
9373 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309374 else if (HDD_NL80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05309375 {
9376 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
9377 continue;
9378 }
9379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009380 }
9381 /*Initialise the supported cipher suite details*/
9382 wiphy->cipher_suites = hdd_cipher_suites;
9383 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
9384
9385 /*signal strength in mBm (100*dBm) */
9386 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
9387
9388#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05309389 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07009390#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009391
Abhishek Singh2f3c4752018-04-11 14:58:53 +05309392 hdd_add_channel_switch_support(wiphy);
Sunil Duttc69bccb2014-05-26 21:30:20 +05309393 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
9394 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08009395 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
9396 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
9397
Anurag Chouhan343af7e2016-12-16 13:11:19 +05309398 hdd_config_sched_scan_plans_to_wiphy(wiphy, pCfg);
9399
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309400 EXIT();
9401 return 0;
9402}
9403
9404/* In this function we are registering wiphy. */
9405int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
9406{
9407 ENTER();
9408 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009409 if (0 > wiphy_register(wiphy))
9410 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309411 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07009412 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
9413 return -EIO;
9414 }
9415
9416 EXIT();
9417 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309418}
Jeff Johnson295189b2012-06-20 16:38:30 -07009419
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309420/* In this function we are updating channel list when,
9421 regulatory domain is FCC and country code is US.
9422 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
9423 As per FCC smart phone is not a indoor device.
9424 GO should not opeate on indoor channels */
9425void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
9426{
9427 int j;
9428 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9429 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
9430 //Default counrtycode from NV at the time of wiphy initialization.
9431 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
9432 &defaultCountryCode[0]))
9433 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009434 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309435 }
9436 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
9437 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309438 if (NULL == wiphy->bands[HDD_NL80211_BAND_5GHZ])
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309439 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309440 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[HDD_NL80211_BAND_5GHZ] is NULL",__func__ );
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309441 return;
9442 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309443 for (j = 0; j < wiphy->bands[HDD_NL80211_BAND_5GHZ]->n_channels; j++)
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309444 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05309445 struct ieee80211_supported_band *band = wiphy->bands[HDD_NL80211_BAND_5GHZ];
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309446 // Mark UNII -1 band channel as passive
9447 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
9448 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
9449 }
9450 }
9451}
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05309452/* This function registers for all frame which supplicant is interested in */
9453void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009454{
Jeff Johnson295189b2012-06-20 16:38:30 -07009455 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9456 /* Register for all P2P action, public action etc frames */
9457 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
Jeff Johnsone7245742012-09-05 17:12:55 -07009458 ENTER();
Abhishek Singh16e05762015-11-30 14:29:27 +05309459 /* Register frame indication call back */
9460 sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame);
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 /* Right now we are registering these frame when driver is getting
9462 initialized. Once we will move to 2.6.37 kernel, in which we have
9463 frame register ops, we will move this code as a part of that */
9464 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309465 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07009466 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
9467
9468 /* GAS Initial Response */
9469 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9470 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309471
Jeff Johnson295189b2012-06-20 16:38:30 -07009472 /* GAS Comeback Request */
9473 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9474 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
9475
9476 /* GAS Comeback Response */
9477 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9478 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
9479
9480 /* P2P Public Action */
9481 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309482 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07009483 P2P_PUBLIC_ACTION_FRAME_SIZE );
9484
9485 /* P2P Action */
9486 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9487 (v_U8_t*)P2P_ACTION_FRAME,
9488 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07009489
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05309490 /* WNM BSS Transition Request frame */
9491 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9492 (v_U8_t*)WNM_BSS_ACTION_FRAME,
9493 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07009494
9495 /* WNM-Notification */
9496 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
9497 (v_U8_t*)WNM_NOTIFICATION_FRAME,
9498 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07009499}
9500
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05309501void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009502{
Jeff Johnson295189b2012-06-20 16:38:30 -07009503 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9504 /* Register for all P2P action, public action etc frames */
9505 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
9506
Jeff Johnsone7245742012-09-05 17:12:55 -07009507 ENTER();
9508
Jeff Johnson295189b2012-06-20 16:38:30 -07009509 /* Right now we are registering these frame when driver is getting
9510 initialized. Once we will move to 2.6.37 kernel, in which we have
9511 frame register ops, we will move this code as a part of that */
9512 /* GAS Initial Request */
9513
9514 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9515 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
9516
9517 /* GAS Initial Response */
9518 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9519 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309520
Jeff Johnson295189b2012-06-20 16:38:30 -07009521 /* GAS Comeback Request */
9522 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9523 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
9524
9525 /* GAS Comeback Response */
9526 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9527 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
9528
9529 /* P2P Public Action */
9530 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309531 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 P2P_PUBLIC_ACTION_FRAME_SIZE );
9533
9534 /* P2P Action */
9535 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9536 (v_U8_t*)P2P_ACTION_FRAME,
9537 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07009538 /* WNM-Notification */
9539 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
9540 (v_U8_t*)WNM_NOTIFICATION_FRAME,
9541 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07009542}
9543
9544#ifdef FEATURE_WLAN_WAPI
9545void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05309546 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07009547{
9548 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9549 tCsrRoamSetKey setKey;
9550 v_BOOL_t isConnected = TRUE;
9551 int status = 0;
9552 v_U32_t roamId= 0xFF;
9553 tANI_U8 *pKeyPtr = NULL;
9554 int n = 0;
9555
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309556 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
9557 __func__, hdd_device_modetoString(pAdapter->device_mode),
9558 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009559
Gopichand Nakkalae7480202013-02-11 15:24:22 +05309560 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 setKey.keyId = key_index; // Store Key ID
9562 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
9563 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
9564 setKey.paeRole = 0 ; // the PAE role
9565 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9566 {
9567 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
9568 }
9569 else
9570 {
9571 isConnected = hdd_connIsConnected(pHddStaCtx);
9572 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
9573 }
9574 setKey.keyLength = key_Len;
9575 pKeyPtr = setKey.Key;
9576 memcpy( pKeyPtr, key, key_Len);
9577
Arif Hussain6d2a3322013-11-17 19:50:10 -08009578 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07009579 __func__, key_Len);
9580 for (n = 0 ; n < key_Len; n++)
9581 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
9582 __func__,n,setKey.Key[n]);
9583
9584 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9585 if ( isConnected )
9586 {
9587 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9588 pAdapter->sessionId, &setKey, &roamId );
9589 }
9590 if ( status != 0 )
9591 {
9592 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9593 "[%4d] sme_RoamSetKey returned ERROR status= %d",
9594 __LINE__, status );
9595 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9596 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309597 /* Need to clear any trace of key value in the memory.
9598 * Thus zero out the memory even though it is local
9599 * variable.
9600 */
9601 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07009602}
9603#endif /* FEATURE_WLAN_WAPI*/
9604
9605#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309606int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 beacon_data_t **ppBeacon,
9608 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009609#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309610int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009611 beacon_data_t **ppBeacon,
9612 struct cfg80211_beacon_data *params,
9613 int dtim_period)
9614#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309615{
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 int size;
9617 beacon_data_t *beacon = NULL;
9618 beacon_data_t *old = NULL;
Kapil Gupta137ef892016-12-13 19:38:00 +05309619 int head_len, tail_len, proberesp_ies_len, assocresp_ies_len;
9620 const u8 *head, *tail, *proberesp_ies, *assocresp_ies;
Jeff Johnson295189b2012-06-20 16:38:30 -07009621
Jeff Johnsone7245742012-09-05 17:12:55 -07009622 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009623 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309624 {
9625 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9626 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009627 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009629
9630 old = pAdapter->sessionCtx.ap.beacon;
9631
9632 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309633 {
9634 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9635 FL("session(%d) old and new heads points to NULL"),
9636 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009637 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309638 }
9639
9640 if (params->tail && !params->tail_len)
9641 {
9642 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9643 FL("tail_len is zero but tail is not NULL"));
9644 return -EINVAL;
9645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009646
Jeff Johnson295189b2012-06-20 16:38:30 -07009647#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
9648 /* Kernel 3.0 is not updating dtim_period for set beacon */
9649 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309650 {
9651 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9652 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009655#endif
9656
Kapil Gupta137ef892016-12-13 19:38:00 +05309657 if (params->head)
9658 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009659 head_len = params->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309660 head = params->head;
9661 } else
9662 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009663 head_len = old->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309664 head = old->head;
9665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009666
Kapil Gupta137ef892016-12-13 19:38:00 +05309667 if (params->tail || !old)
9668 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009669 tail_len = params->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309670 tail = params->tail;
9671 } else
9672 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 tail_len = old->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309674 tail = old->tail;
9675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009676
Kapil Gupta137ef892016-12-13 19:38:00 +05309677 if (params->proberesp_ies || !old)
9678 {
9679 proberesp_ies_len = params->proberesp_ies_len;
9680 proberesp_ies = params->proberesp_ies;
9681 } else
9682 {
9683 proberesp_ies_len = old->proberesp_ies_len;
9684 proberesp_ies = old->proberesp_ies;
9685 }
9686
9687 if (params->assocresp_ies || !old)
9688 {
9689 assocresp_ies_len = params->assocresp_ies_len;
9690 assocresp_ies = params->assocresp_ies;
9691 } else
9692 {
9693 assocresp_ies_len = old->assocresp_ies_len;
9694 assocresp_ies = old->assocresp_ies;
9695 }
9696
9697 size = sizeof(beacon_data_t) + head_len + tail_len +
9698 proberesp_ies_len + assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07009699
9700 beacon = kzalloc(size, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309702 {
9703 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9704 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009705 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009707
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009708#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Kapil Gupta137ef892016-12-13 19:38:00 +05309709 if (params->dtim_period)
Jeff Johnson295189b2012-06-20 16:38:30 -07009710 beacon->dtim_period = params->dtim_period;
9711 else
9712 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009713#else
Kapil Gupta137ef892016-12-13 19:38:00 +05309714 if (dtim_period)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009715 beacon->dtim_period = dtim_period;
9716 else
9717 beacon->dtim_period = old->dtim_period;
9718#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309719
Jeff Johnson295189b2012-06-20 16:38:30 -07009720 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
9721 beacon->tail = beacon->head + head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309722 beacon->proberesp_ies = beacon->tail + tail_len;
9723 beacon->assocresp_ies = beacon->proberesp_ies + proberesp_ies_len;
9724
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 beacon->head_len = head_len;
9726 beacon->tail_len = tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309727 beacon->proberesp_ies_len = proberesp_ies_len;
9728 beacon->assocresp_ies_len= assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07009729
c_manjee527ecac2017-01-25 12:25:27 +05309730 if (head && head_len)
9731 memcpy(beacon->head, head, head_len);
9732 if (tail && tail_len)
9733 memcpy(beacon->tail, tail, tail_len);
9734 if (proberesp_ies && proberesp_ies_len)
9735 memcpy(beacon->proberesp_ies, proberesp_ies, proberesp_ies_len);
9736 if (assocresp_ies && assocresp_ies_len)
9737 memcpy(beacon->assocresp_ies, assocresp_ies, assocresp_ies_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009738
9739 *ppBeacon = beacon;
9740
9741 kfree(old);
9742
9743 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009744}
Jeff Johnson295189b2012-06-20 16:38:30 -07009745
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309746v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
9747#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
9748 const v_U8_t *pIes,
9749#else
9750 v_U8_t *pIes,
9751#endif
9752 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009753{
9754 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309755 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07009756 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309757
Jeff Johnson295189b2012-06-20 16:38:30 -07009758 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309759 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009760 elem_id = ptr[0];
9761 elem_len = ptr[1];
9762 left -= 2;
9763 if(elem_len > left)
9764 {
9765 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009766 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009767 eid,elem_len,left);
9768 return NULL;
9769 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309770 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009771 {
9772 return ptr;
9773 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309774
Jeff Johnson295189b2012-06-20 16:38:30 -07009775 left -= elem_len;
9776 ptr += (elem_len + 2);
9777 }
9778 return NULL;
9779}
9780
Jeff Johnson295189b2012-06-20 16:38:30 -07009781/* Check if rate is 11g rate or not */
9782static int wlan_hdd_rate_is_11g(u8 rate)
9783{
Sanjay Devnani28322e22013-06-21 16:13:40 -07009784 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009785 u8 i;
9786 for (i = 0; i < 8; i++)
9787 {
9788 if(rate == gRateArray[i])
9789 return TRUE;
9790 }
9791 return FALSE;
9792}
9793
9794/* Check for 11g rate and set proper 11g only mode */
9795static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
9796 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
9797{
9798 u8 i, num_rates = pIe[0];
9799
9800 pIe += 1;
9801 for ( i = 0; i < num_rates; i++)
9802 {
9803 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
9804 {
9805 /* If rate set have 11g rate than change the mode to 11G */
9806 *pSapHw_mode = eSAP_DOT11_MODE_11g;
9807 if (pIe[i] & BASIC_RATE_MASK)
9808 {
9809 /* If we have 11g rate as basic rate, it means mode
9810 is 11g only mode.
9811 */
9812 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
9813 *pCheckRatesfor11g = FALSE;
9814 }
9815 }
9816 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
9817 {
9818 *require_ht = TRUE;
9819 }
9820 }
9821 return;
9822}
9823
9824static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
9825{
9826 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9827 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9828 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9829 u8 checkRatesfor11g = TRUE;
9830 u8 require_ht = FALSE;
9831 u8 *pIe=NULL;
9832
9833 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
9834
9835 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
9836 pBeacon->head_len, WLAN_EID_SUPP_RATES);
9837 if (pIe != NULL)
9838 {
9839 pIe += 1;
9840 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
9841 &pConfig->SapHw_mode);
9842 }
9843
9844 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
9845 WLAN_EID_EXT_SUPP_RATES);
9846 if (pIe != NULL)
9847 {
9848
9849 pIe += 1;
9850 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
9851 &pConfig->SapHw_mode);
9852 }
9853
9854 if( pConfig->channel > 14 )
9855 {
9856 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
9857 }
9858
9859 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
9860 WLAN_EID_HT_CAPABILITY);
9861
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309862 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 {
9864 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
9865 if(require_ht)
9866 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
9867 }
9868}
9869
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309870static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
9871 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
9872{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009873 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309874 v_U8_t *pIe = NULL;
9875 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9876
9877 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
9878 pBeacon->tail, pBeacon->tail_len);
9879
9880 if (pIe)
9881 {
9882 ielen = pIe[1] + 2;
9883 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
9884 {
9885 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
9886 }
9887 else
9888 {
9889 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
9890 return -EINVAL;
9891 }
9892 *total_ielen += ielen;
9893 }
9894 return 0;
9895}
9896
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009897static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
9898 v_U8_t *genie, v_U8_t *total_ielen)
9899{
9900 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9901 int left = pBeacon->tail_len;
9902 v_U8_t *ptr = pBeacon->tail;
9903 v_U8_t elem_id, elem_len;
9904 v_U16_t ielen = 0;
9905
9906 if ( NULL == ptr || 0 == left )
9907 return;
9908
9909 while (left >= 2)
9910 {
9911 elem_id = ptr[0];
9912 elem_len = ptr[1];
9913 left -= 2;
9914 if (elem_len > left)
9915 {
9916 hddLog( VOS_TRACE_LEVEL_ERROR,
9917 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
9918 elem_id, elem_len, left);
9919 return;
9920 }
Ashish Kumar Dhanotiya6af276b2017-08-22 16:53:48 +05309921 if ((IE_EID_VENDOR == elem_id) && (elem_len >= WPS_OUI_TYPE_SIZE))
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009922 {
9923 /* skipping the VSIE's which we don't want to include or
9924 * it will be included by existing code
9925 */
9926 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
9927#ifdef WLAN_FEATURE_WFD
9928 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
9929#endif
9930 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9931 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9932 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
9933 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9934 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
9935 {
9936 ielen = ptr[1] + 2;
9937 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
9938 {
9939 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
9940 *total_ielen += ielen;
9941 }
9942 else
9943 {
9944 hddLog( VOS_TRACE_LEVEL_ERROR,
9945 "IE Length is too big "
9946 "IEs eid=%d elem_len=%d total_ie_lent=%d",
9947 elem_id, elem_len, *total_ielen);
9948 }
9949 }
9950 }
9951
9952 left -= elem_len;
9953 ptr += (elem_len + 2);
9954 }
9955 return;
9956}
9957
Kapil Gupta137ef892016-12-13 19:38:00 +05309958int wlan_hdd_cfg80211_update_apies(hdd_adapter_t *pHostapdAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009959{
9960 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309961 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07009963 int ret = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +05309964 beacon_data_t *pBeacon = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009965
9966 genie = vos_mem_malloc(MAX_GENIE_LEN);
9967
9968 if(genie == NULL) {
9969
9970 return -ENOMEM;
9971 }
9972
Kapil Gupta137ef892016-12-13 19:38:00 +05309973 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309974 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9975 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07009976 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309977 hddLog(LOGE,
9978 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309979 ret = -EINVAL;
9980 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009981 }
9982
9983#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309984 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9985 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
9986 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309987 hddLog(LOGE,
9988 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309989 ret = -EINVAL;
9990 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009991 }
9992#endif
9993
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309994 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9995 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07009996 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309997 hddLog(LOGE,
9998 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309999 ret = -EINVAL;
10000 goto done;
10001 }
10002
10003 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
10004 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -070010005 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010007
10008 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10009 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
10010 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
10011 {
10012 hddLog(LOGE,
10013 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010014 ret = -EINVAL;
10015 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010016 }
10017
10018 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10019 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
10020 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
10021 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
10022 ==eHAL_STATUS_FAILURE)
10023 {
10024 hddLog(LOGE,
10025 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010026 ret = -EINVAL;
10027 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010028 }
10029
10030 // Added for ProResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +053010031 if ((pBeacon->proberesp_ies != NULL) && (pBeacon->proberesp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010032 {
Kapil Gupta137ef892016-12-13 19:38:00 +053010033 u16 rem_probe_resp_ie_len = pBeacon->proberesp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -070010034 u8 probe_rsp_ie_len[3] = {0};
10035 u8 counter = 0;
10036 /* Check Probe Resp Length if it is greater then 255 then Store
10037 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
10038 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
10039 Store More then 255 bytes into One Variable.
10040 */
10041 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
10042 {
10043 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
10044 {
10045 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
10046 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
10047 }
10048 else
10049 {
10050 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
10051 rem_probe_resp_ie_len = 0;
10052 }
10053 }
10054
10055 rem_probe_resp_ie_len = 0;
10056
10057 if (probe_rsp_ie_len[0] > 0)
10058 {
10059 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10060 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
Kapil Gupta137ef892016-12-13 19:38:00 +053010061 (tANI_U8*)&pBeacon->
10062 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -070010063 probe_rsp_ie_len[0], NULL,
10064 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10065 {
10066 hddLog(LOGE,
10067 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010068 ret = -EINVAL;
10069 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010070 }
10071 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
10072 }
10073
10074 if (probe_rsp_ie_len[1] > 0)
10075 {
10076 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10077 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
Kapil Gupta137ef892016-12-13 19:38:00 +053010078 (tANI_U8*)&pBeacon->
10079 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 probe_rsp_ie_len[1], NULL,
10081 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10082 {
10083 hddLog(LOGE,
10084 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010085 ret = -EINVAL;
10086 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010087 }
10088 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
10089 }
10090
10091 if (probe_rsp_ie_len[2] > 0)
10092 {
10093 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10094 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
Kapil Gupta137ef892016-12-13 19:38:00 +053010095 (tANI_U8*)&pBeacon->
10096 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -070010097 probe_rsp_ie_len[2], NULL,
10098 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10099 {
10100 hddLog(LOGE,
10101 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010102 ret = -EINVAL;
10103 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010104 }
10105 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
10106 }
10107
10108 if (probe_rsp_ie_len[1] == 0 )
10109 {
10110 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10111 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
10112 eANI_BOOLEAN_FALSE) )
10113 {
10114 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010115 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010116 }
10117 }
10118
10119 if (probe_rsp_ie_len[2] == 0 )
10120 {
10121 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10122 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
10123 eANI_BOOLEAN_FALSE) )
10124 {
10125 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010126 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010127 }
10128 }
10129
10130 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10131 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
10132 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
10133 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
10134 == eHAL_STATUS_FAILURE)
10135 {
10136 hddLog(LOGE,
10137 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010138 ret = -EINVAL;
10139 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010140 }
10141 }
10142 else
10143 {
10144 // Reset WNI_CFG_PROBE_RSP Flags
10145 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
10146
10147 hddLog(VOS_TRACE_LEVEL_INFO,
10148 "%s: No Probe Response IE received in set beacon",
10149 __func__);
10150 }
10151
10152 // Added for AssocResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +053010153 if ((pBeacon->assocresp_ies != NULL) && (pBeacon->assocresp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 {
10155 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
Kapil Gupta137ef892016-12-13 19:38:00 +053010156 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)pBeacon->assocresp_ies,
10157 pBeacon->assocresp_ies_len, NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -070010158 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10159 {
10160 hddLog(LOGE,
10161 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010162 ret = -EINVAL;
10163 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010164 }
10165
10166 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10167 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
10168 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
10169 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
10170 == eHAL_STATUS_FAILURE)
10171 {
10172 hddLog(LOGE,
10173 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -070010174 ret = -EINVAL;
10175 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -070010176 }
10177 }
10178 else
10179 {
10180 hddLog(VOS_TRACE_LEVEL_INFO,
10181 "%s: No Assoc Response IE received in set beacon",
10182 __func__);
10183
10184 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
10185 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
10186 eANI_BOOLEAN_FALSE) )
10187 {
10188 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010189 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010190 }
10191 }
10192
Jeff Johnsone7245742012-09-05 17:12:55 -070010193done:
Jeff Johnson295189b2012-06-20 16:38:30 -070010194 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +053010195 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010196}
Jeff Johnson295189b2012-06-20 16:38:30 -070010197
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010198/*
Jeff Johnson295189b2012-06-20 16:38:30 -070010199 * FUNCTION: wlan_hdd_validate_operation_channel
10200 * called by wlan_hdd_cfg80211_start_bss() and
10201 * wlan_hdd_cfg80211_set_channel()
10202 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010203 * channel list.
10204 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070010205VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -070010206{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010207
Jeff Johnson295189b2012-06-20 16:38:30 -070010208 v_U32_t num_ch = 0;
10209 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
10210 u32 indx = 0;
10211 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010212 v_U8_t fValidChannel = FALSE, count = 0;
10213 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010214
Jeff Johnson295189b2012-06-20 16:38:30 -070010215 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
10216
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010217 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070010218 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010219 /* Validate the channel */
10220 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -070010221 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010222 if ( channel == rfChannels[count].channelNum )
10223 {
10224 fValidChannel = TRUE;
10225 break;
10226 }
10227 }
10228 if (fValidChannel != TRUE)
10229 {
10230 hddLog(VOS_TRACE_LEVEL_ERROR,
10231 "%s: Invalid Channel [%d]", __func__, channel);
10232 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010233 }
10234 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010235 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010236 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053010237 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
10238 valid_ch, &num_ch))
10239 {
10240 hddLog(VOS_TRACE_LEVEL_ERROR,
10241 "%s: failed to get valid channel list", __func__);
10242 return VOS_STATUS_E_FAILURE;
10243 }
10244 for (indx = 0; indx < num_ch; indx++)
10245 {
10246 if (channel == valid_ch[indx])
10247 {
10248 break;
10249 }
10250 }
10251
Rashmi Ramanna3b59e122014-04-10 14:45:13 +053010252 if (indx >= num_ch)
10253 {
10254 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
10255 {
10256 eCsrBand band;
10257 unsigned int freq;
10258
10259 sme_GetFreqBand(hHal, &band);
10260
10261 if (eCSR_BAND_5G == band)
10262 {
10263#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
10264 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
10265 {
10266 freq = ieee80211_channel_to_frequency(channel,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053010267 HDD_NL80211_BAND_2GHZ);
Rashmi Ramanna3b59e122014-04-10 14:45:13 +053010268 }
10269 else
10270 {
10271 freq = ieee80211_channel_to_frequency(channel,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053010272 HDD_NL80211_BAND_5GHZ);
Rashmi Ramanna3b59e122014-04-10 14:45:13 +053010273 }
10274#else
10275 freq = ieee80211_channel_to_frequency(channel);
10276#endif
10277 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
10278 return VOS_STATUS_SUCCESS;
10279 }
10280 }
10281
10282 hddLog(VOS_TRACE_LEVEL_ERROR,
10283 "%s: Invalid Channel [%d]", __func__, channel);
10284 return VOS_STATUS_E_FAILURE;
10285 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010286 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +053010287
Jeff Johnson295189b2012-06-20 16:38:30 -070010288 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010289
Jeff Johnson295189b2012-06-20 16:38:30 -070010290}
10291
Viral Modi3a32cc52013-02-08 11:14:52 -080010292/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010293 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -080010294 * This function is used to set the channel number
10295 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010296static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -080010297 struct ieee80211_channel *chan,
10298 enum nl80211_channel_type channel_type
10299 )
10300{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010301 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -080010302 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -070010303 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -080010304 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010305 hdd_context_t *pHddCtx;
10306 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -080010307
10308 ENTER();
10309
10310 if( NULL == dev )
10311 {
10312 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010313 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -080010314 return -ENODEV;
10315 }
10316 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010317
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010318 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10319 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
10320 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -080010321 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010322 "%s: device_mode = %s (%d) freq = %d", __func__,
10323 hdd_device_modetoString(pAdapter->device_mode),
10324 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010325
10326 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10327 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010328 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -080010329 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010330 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -080010331 }
10332
10333 /*
10334 * Do freq to chan conversion
10335 * TODO: for 11a
10336 */
10337
10338 channel = ieee80211_frequency_to_channel(freq);
10339
10340 /* Check freq range */
10341 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
10342 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
10343 {
10344 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010345 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -080010346 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
10347 WNI_CFG_CURRENT_CHANNEL_STAMAX);
10348 return -EINVAL;
10349 }
10350
10351 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
10352
Gopichand Nakkala6ab19562013-03-07 13:59:42 +053010353 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
10354 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -080010355 {
10356 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
10357 {
10358 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010359 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -080010360 return -EINVAL;
10361 }
10362 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10363 "%s: set channel to [%d] for device mode =%d",
10364 __func__, channel,pAdapter->device_mode);
10365 }
10366 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -080010367 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -080010368 )
10369 {
10370 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10371 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
10372 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10373
10374 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
10375 {
10376 /* Link is up then return cant set channel*/
10377 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010378 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -080010379 return -EINVAL;
10380 }
10381
10382 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
10383 pHddStaCtx->conn_info.operationChannel = channel;
10384 pRoamProfile->ChannelInfo.ChannelList =
10385 &pHddStaCtx->conn_info.operationChannel;
10386 }
10387 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -080010388 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -080010389 )
10390 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010391 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
10392 {
10393 if(VOS_STATUS_SUCCESS !=
10394 wlan_hdd_validate_operation_channel(pAdapter,channel))
10395 {
10396 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010397 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010398 return -EINVAL;
10399 }
10400 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
10401 }
10402 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -080010403 {
10404 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
10405
10406 /* If auto channel selection is configured as enable/ 1 then ignore
10407 channel set by supplicant
10408 */
10409 if ( cfg_param->apAutoChannelSelection )
10410 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010411 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
10412 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -080010413 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010414 "%s: set channel to auto channel (0) for device mode =%s (%d)",
10415 __func__, hdd_device_modetoString(pAdapter->device_mode),
10416 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -080010417 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010418 else
10419 {
10420 if(VOS_STATUS_SUCCESS !=
10421 wlan_hdd_validate_operation_channel(pAdapter,channel))
10422 {
10423 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010424 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +053010425 return -EINVAL;
10426 }
10427 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
10428 }
Viral Modi3a32cc52013-02-08 11:14:52 -080010429 }
10430 }
10431 else
10432 {
10433 hddLog(VOS_TRACE_LEVEL_FATAL,
10434 "%s: Invalid device mode failed to set valid channel", __func__);
10435 return -EINVAL;
10436 }
10437 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010438 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -080010439}
10440
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010441static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
10442 struct net_device *dev,
10443 struct ieee80211_channel *chan,
10444 enum nl80211_channel_type channel_type
10445 )
10446{
10447 int ret;
10448
10449 vos_ssr_protect(__func__);
10450 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
10451 vos_ssr_unprotect(__func__);
10452
10453 return ret;
10454}
10455
Anurag Chouhan83026002016-12-13 22:46:21 +053010456#ifdef DHCP_SERVER_OFFLOAD
10457void hdd_dhcp_server_offload_done(void *fw_dhcp_srv_offload_cb_context,
10458 VOS_STATUS status)
10459{
10460 hdd_adapter_t* adapter = (hdd_adapter_t*)fw_dhcp_srv_offload_cb_context;
10461
10462 ENTER();
10463
10464 if (NULL == adapter)
10465 {
10466 hddLog(VOS_TRACE_LEVEL_ERROR,
10467 "%s: adapter is NULL",__func__);
10468 return;
10469 }
10470
10471 adapter->dhcp_status.dhcp_offload_status = status;
10472 vos_event_set(&adapter->dhcp_status.vos_event);
10473 return;
10474}
10475
10476/**
10477 * wlan_hdd_set_dhcp_server_offload() - set dhcp server offload
10478 * @hostapd_adapter: pointer to hostapd adapter.
Anurag Chouhan638f5e22017-03-06 12:28:43 +053010479 * @re_init: flag set if api called post ssr
Anurag Chouhan83026002016-12-13 22:46:21 +053010480 *
10481 * Return: None
10482 */
Anurag Chouhan638f5e22017-03-06 12:28:43 +053010483VOS_STATUS wlan_hdd_set_dhcp_server_offload(hdd_adapter_t *hostapd_adapter,
10484 bool re_init)
Anurag Chouhan83026002016-12-13 22:46:21 +053010485{
10486 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(hostapd_adapter);
10487 sir_dhcp_srv_offload_info dhcp_srv_info;
10488 tANI_U8 num_entries = 0;
10489 tANI_U8 srv_ip[IPADDR_NUM_ENTRIES];
10490 tANI_U8 num;
10491 tANI_U32 temp;
10492 VOS_STATUS ret;
10493
10494 ENTER();
10495
Anurag Chouhan638f5e22017-03-06 12:28:43 +053010496 if (!re_init) {
10497 ret = wlan_hdd_validate_context(hdd_ctx);
10498 if (0 != ret)
10499 return VOS_STATUS_E_INVAL;
10500 }
Anurag Chouhan83026002016-12-13 22:46:21 +053010501
10502 /* Prepare the request to send to SME */
10503 dhcp_srv_info = vos_mem_malloc(sizeof(*dhcp_srv_info));
10504 if (NULL == dhcp_srv_info) {
10505 hddLog(VOS_TRACE_LEVEL_ERROR,
10506 "%s: could not allocate tDhcpSrvOffloadInfo!", __func__);
10507 return VOS_STATUS_E_NOMEM;
10508 }
10509
10510 vos_mem_zero(dhcp_srv_info, sizeof(*dhcp_srv_info));
10511
10512 dhcp_srv_info->bssidx = hostapd_adapter->sessionId;
10513 dhcp_srv_info->dhcp_srv_offload_enabled = TRUE;
10514 dhcp_srv_info->dhcp_client_num = hdd_ctx->cfg_ini->dhcp_max_num_clients;
10515 dhcp_srv_info->start_lsb = hdd_ctx->cfg_ini->dhcp_start_lsb;
10516 dhcp_srv_info->dhcp_offload_callback = hdd_dhcp_server_offload_done;
10517 dhcp_srv_info->dhcp_server_offload_cb_context = hostapd_adapter;
10518
10519 hdd_string_to_u8_array(hdd_ctx->cfg_ini->dhcp_srv_ip,
10520 srv_ip,
10521 &num_entries,
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +053010522 IPADDR_NUM_ENTRIES, ".", false);
Anurag Chouhan83026002016-12-13 22:46:21 +053010523 if (num_entries != IPADDR_NUM_ENTRIES) {
10524 hddLog(VOS_TRACE_LEVEL_ERROR,
10525 "%s: incorrect IP address (%s) assigned for DHCP server!",
10526 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
10527 vos_mem_free(dhcp_srv_info);
10528 return VOS_STATUS_E_FAILURE;
10529 }
10530
10531 if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) {
10532 hddLog(VOS_TRACE_LEVEL_ERROR,
10533 "%s: invalid IP address (%s)! It could NOT be multicast IP address!",
10534 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
10535 vos_mem_free(dhcp_srv_info);
10536 return VOS_STATUS_E_FAILURE;
10537 }
10538
10539 if (srv_ip[IPADDR_NUM_ENTRIES-1] >= DHCP_START_POOL_ADDRESS) {
10540 hddLog(VOS_TRACE_LEVEL_ERROR,
10541 "%s: invalid IP address (%s)! The last field must be less than 100!",
10542 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
10543 vos_mem_free(dhcp_srv_info);
10544 return VOS_STATUS_E_FAILURE;
10545 }
10546
10547 for (num = 0; num < num_entries; num++) {
10548 temp = srv_ip[num];
10549 dhcp_srv_info->dhcp_srv_ip |= (temp << (8 * num));
10550 }
10551
10552 if (eHAL_STATUS_SUCCESS !=
10553 sme_set_dhcp_srv_offload(hdd_ctx->hHal, dhcp_srv_info)) {
10554 hddLog(VOS_TRACE_LEVEL_ERROR,
10555 "%s: sme_set_dhcp_srv_offload fail!", __func__);
10556 vos_mem_free(dhcp_srv_info);
10557 return VOS_STATUS_E_FAILURE;
10558 }
10559
10560 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10561 "%s: enable DHCP Server offload successfully!", __func__);
10562
10563 vos_mem_free(dhcp_srv_info);
10564 return 0;
10565}
10566#endif /* DHCP_SERVER_OFFLOAD */
10567
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010568/*
10569 * hdd_modify_indoor_channel_state_flags() - modify wiphy flags and cds state
10570 * @wiphy_chan: wiphy channel number
10571 * @rfChannel: channel hw value
10572 * @disable: Disable/enable the flags
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010573 * @hdd_ctx: The HDD context handler
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010574 *
10575 * Modify wiphy flags and cds state if channel is indoor.
10576 *
10577 * Return: void
10578 */
10579void hdd_modify_indoor_channel_state_flags(struct ieee80211_channel *wiphy_chan,
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010580 v_U32_t rfChannel, bool disable, hdd_context_t *hdd_ctx)
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010581{
10582 v_U32_t channelLoop;
10583 eRfChannels channelEnum = INVALID_RF_CHANNEL;
10584
10585 for (channelLoop = 0; channelLoop <= RF_CHAN_165; channelLoop++) {
10586
10587 if (rfChannels[channelLoop].channelNum == rfChannel) {
10588 channelEnum = (eRfChannels)channelLoop;
10589 break;
10590 }
10591 }
10592
10593 if (INVALID_RF_CHANNEL == channelEnum)
10594 return;
10595
10596 if (disable) {
10597 if (wiphy_chan->flags & IEEE80211_CHAN_INDOOR_ONLY) {
10598 wiphy_chan->flags |=
10599 IEEE80211_CHAN_DISABLED;
10600 regChannels[channelEnum].enabled =
10601 NV_CHANNEL_DISABLE;
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010602 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %d marked as DISABLE",
10603 channelEnum);
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010604 }
10605 } else {
10606 if (wiphy_chan->flags & IEEE80211_CHAN_INDOOR_ONLY) {
10607 wiphy_chan->flags &=
10608 ~IEEE80211_CHAN_DISABLED;
10609 /*
10610 * Indoor channels are marked as DFS
10611 * during regulatory processing
10612 */
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010613 if ((wiphy_chan->flags & (IEEE80211_CHAN_RADAR |
10614 IEEE80211_CHAN_PASSIVE_SCAN)) ||
10615 ((hdd_ctx->cfg_ini->indoor_channel_support == false)
10616 && (wiphy_chan->flags &
10617 IEEE80211_CHAN_INDOOR_ONLY))) {
10618 regChannels[channelEnum].enabled = NV_CHANNEL_DFS;
10619 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %d marked as DFS",
10620 channelEnum);
10621 } else {
10622 regChannels[channelEnum].enabled =
10623 NV_CHANNEL_ENABLE;
10624 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %d marked as ENABLE",
10625 channelEnum);
10626 }
10627 }
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010628
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010629 }
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010630}
10631
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010632void hdd_update_indoor_channel(hdd_context_t *hdd_ctx, bool disable)
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010633{
10634 int band_num;
10635 int chan_num;
10636 v_U32_t rfChannel;
10637 struct ieee80211_channel *wiphy_chan;
10638 struct wiphy *wiphy;
10639
10640 ENTER();
10641 hddLog(VOS_TRACE_LEVEL_INFO, "disable: %d", disable);
10642
10643 wiphy = hdd_ctx->wiphy;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053010644 for (band_num = 0; band_num < HDD_NUM_NL80211_BANDS; band_num++) {
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010645
10646 if (wiphy->bands[band_num] == NULL)
10647 continue;
10648
10649 for (chan_num = 0;
10650 chan_num < wiphy->bands[band_num]->n_channels;
10651 chan_num++) {
10652
10653 wiphy_chan =
10654 &(wiphy->bands[band_num]->channels[chan_num]);
10655 rfChannel = wiphy->bands[band_num]->channels[chan_num].hw_value;
10656
10657 hdd_modify_indoor_channel_state_flags(wiphy_chan, rfChannel,
Sourav Mohapatra077057d2018-02-07 19:19:18 +053010658 disable, hdd_ctx);
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010659 }
10660 }
10661 EXIT();
10662}
10663
Ganesh Kondabattini19813af2018-01-25 17:32:44 +053010664int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
10665{
10666 int status, result = 0;
10667 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10668 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10669 long ret;
10670 eConnectionState prev_conn_state;
10671 uint32_t wait_time = WLAN_WAIT_TIME_DISCONNECT;
10672
10673 ENTER();
10674
10675 status = wlan_hdd_validate_context(pHddCtx);
10676 if (0 != status)
10677 {
10678 return status;
10679 }
10680 /* Indicate sme of disconnect so that in progress connection or preauth
10681 * can be aborted
10682 */
10683 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
10684 pAdapter->sessionId);
10685 pHddCtx->isAmpAllowed = VOS_TRUE;
10686
10687 /* Need to apply spin lock before decreasing active sessions
10688 * as there can be chance for double decrement if context switch
10689 * Calls hdd_DisConnectHandler.
10690 */
10691
10692 prev_conn_state = pHddStaCtx->conn_info.connState;
10693
10694 spin_lock_bh(&pAdapter->lock_for_active_session);
10695 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
10696 {
10697 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
10698 }
10699 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
10700 spin_unlock_bh(&pAdapter->lock_for_active_session);
10701 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
10702
10703 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10704 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
10705
10706 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10707
10708 /*
10709 * stop tx queues before deleting STA/BSS context from the firmware.
10710 * tx has to be disabled because the firmware can get busy dropping
10711 * the tx frames after BSS/STA has been deleted and will not send
10712 * back a response resulting in WDI timeout
10713 */
10714 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
10715 netif_tx_disable(pAdapter->dev);
10716 netif_carrier_off(pAdapter->dev);
10717
10718 wlan_hdd_check_and_stop_mon(pAdapter, true);
10719
10720 /*issue disconnect*/
10721 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10722 pAdapter->sessionId, reason);
10723 if((eHAL_STATUS_CMD_NOT_QUEUED == status) &&
10724 prev_conn_state != eConnectionState_Connecting)
10725 {
10726 hddLog(LOG1,
10727 FL("status = %d, already disconnected"), status);
10728 result = 0;
10729 /*
10730 * Wait here instead of returning directly. This will block the
10731 * next connect command and allow processing of the disconnect
10732 * in SME else we might hit some race conditions leading to SME
10733 * and HDD out of sync. As disconnect is already in progress,
10734 * wait here for 1 sec instead of 5 sec.
10735 */
10736 wait_time = WLAN_WAIT_DISCONNECT_ALREADY_IN_PROGRESS;
10737 goto wait_for_disconnect;
10738 }
10739 /*
10740 * Wait here instead of returning directly, this will block the next
10741 * connect command and allow processing of the scan for ssid and
10742 * the previous connect command in CSR. Else we might hit some
10743 * race conditions leading to SME and HDD out of sync.
10744 */
10745 else if(eHAL_STATUS_CMD_NOT_QUEUED == status)
10746 {
10747 hddLog(LOG1,
10748 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
10749 }
10750 else if ( 0 != status )
10751 {
10752 hddLog(LOGE,
10753 FL("csrRoamDisconnect failure, returned %d"),
10754 (int)status);
10755 result = -EINVAL;
10756 goto disconnected;
10757 }
10758wait_for_disconnect:
10759 ret = wait_for_completion_timeout(&pAdapter->disconnect_comp_var,
10760 msecs_to_jiffies(wait_time));
10761 if (!ret && (eHAL_STATUS_CMD_NOT_QUEUED != status))
10762 {
10763 hddLog(LOGE,
10764 "%s: Failed to disconnect, timed out", __func__);
10765 result = -ETIMEDOUT;
10766 }
10767disconnected:
10768 hddLog(LOG1,
10769 FL("Set HDD connState to eConnectionState_NotConnected"));
10770 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
10771#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
10772 /* Sending disconnect event to userspace for kernel version < 3.11
10773 * is handled by __cfg80211_disconnect call to __cfg80211_disconnected
10774 */
10775 hddLog(LOG1, FL("Send disconnected event to userspace"));
10776
10777 wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true,
10778 WLAN_REASON_UNSPECIFIED);
10779#endif
10780
10781 EXIT();
10782 return result;
10783}
10784
10785/*
10786 * hdd_check_and_disconnect_sta_on_invalid_channel() - Disconnect STA if it is
10787 * on indoor channel
10788 * @hdd_ctx: pointer to hdd context
10789 *
10790 * STA should be disconnected before starting the SAP if it is on indoor
10791 * channel.
10792 *
10793 * Return: void
10794 */
10795void hdd_check_and_disconnect_sta_on_invalid_channel(hdd_context_t *hdd_ctx)
10796{
10797
10798 hdd_adapter_t *sta_adapter;
10799 tANI_U8 sta_chan;
10800
10801 sta_chan = hdd_get_operating_channel(hdd_ctx, WLAN_HDD_INFRA_STATION);
10802
10803 if (!sta_chan) {
10804 hddLog(LOG1, FL("STA not connected"));
10805 return;
10806 }
10807
10808 hddLog(LOG1, FL("STA connected on chan %hu"), sta_chan);
10809
10810 if (sme_IsChannelValid(hdd_ctx->hHal, sta_chan)) {
10811 hddLog(LOG1, FL("STA connected on chan %hu and it is valid"),
10812 sta_chan);
10813 return;
10814 }
10815
10816 sta_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION);
10817
10818 if (!sta_adapter) {
10819 hddLog(LOG1, FL("STA adapter doesn't exist"));
10820 return;
10821 }
10822
10823 hddLog(LOG1, FL("chan %hu not valid, issue disconnect"), sta_chan);
10824 /* Issue Disconnect request */
10825 wlan_hdd_disconnect(sta_adapter, eCSR_DISCONNECT_REASON_DEAUTH);
10826}
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053010827
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010828int wlan_hdd_restore_channels(hdd_context_t *hdd_ctx)
10829{
10830 struct hdd_cache_channels *cache_chann;
10831 struct wiphy *wiphy;
10832 int freq, status, rfChannel;
10833 int i, band_num, channel_num;
10834 struct ieee80211_channel *wiphy_channel;
10835
10836 ENTER();
10837
10838 if (!hdd_ctx) {
10839 hddLog(VOS_TRACE_LEVEL_FATAL, "HDD Context is NULL");
10840 return -EINVAL;
10841 }
10842
10843 wiphy = hdd_ctx->wiphy;
10844
10845 mutex_lock(&hdd_ctx->cache_channel_lock);
10846
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +053010847 cache_chann = hdd_ctx->original_channels;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010848
10849 if (!cache_chann || !cache_chann->num_channels) {
10850 hddLog(VOS_TRACE_LEVEL_INFO,
10851 "%s channel list is NULL or num channels are zero",
10852 __func__);
10853 mutex_unlock(&hdd_ctx->cache_channel_lock);
10854 return -EINVAL;
10855 }
10856
10857 for (i = 0; i < cache_chann->num_channels; i++) {
10858 status = hdd_wlan_get_freq(
10859 cache_chann->channel_info[i].channel_num,
10860 &freq);
10861
Rajeev Kumar Sirasanagandla17b649a2018-03-19 16:58:30 +053010862 for (band_num = 0; band_num < HDD_NUM_NL80211_BANDS;
10863 band_num++) {
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010864 for (channel_num = 0; channel_num <
10865 wiphy->bands[band_num]->n_channels;
10866 channel_num++) {
10867 wiphy_channel = &(wiphy->bands[band_num]->
10868 channels[channel_num]);
10869 if (wiphy_channel->center_freq == freq) {
10870 rfChannel = wiphy_channel->hw_value;
10871 /*
10872 *Restore the orginal states
10873 *of the channels
10874 */
10875 vos_nv_set_channel_state(
10876 rfChannel,
10877 cache_chann->
10878 channel_info[i].reg_status);
10879 wiphy_channel->flags =
10880 cache_chann->
10881 channel_info[i].wiphy_status;
10882 break;
10883 }
10884 }
10885 if (channel_num < wiphy->bands[band_num]->n_channels)
10886 break;
10887 }
10888 }
10889
10890 mutex_unlock(&hdd_ctx->cache_channel_lock);
10891
10892 status = sme_update_channel_list((tpAniSirGlobal)hdd_ctx->hHal);
10893 if (status)
10894 hddLog(VOS_TRACE_LEVEL_ERROR, "Can't Restore channel list");
10895 EXIT();
10896
10897 return 0;
10898}
10899
10900/*
10901 * wlan_hdd_disable_channels() - Cache the the channels
10902 * and current state of the channels from the channel list
10903 * received in the command and disable the channels on the
10904 * wiphy and NV table.
10905 * @hdd_ctx: Pointer to hdd context
10906 *
10907 * @return: 0 on success, Error code on failure
10908 */
10909
10910static int wlan_hdd_disable_channels(hdd_context_t *hdd_ctx)
10911{
10912 struct hdd_cache_channels *cache_chann;
10913 struct wiphy *wiphy;
10914 int freq, status, rfChannel;
10915 int i, band_num, band_ch_num;
10916 struct ieee80211_channel *wiphy_channel;
10917
10918 if (!hdd_ctx) {
10919 hddLog(VOS_TRACE_LEVEL_FATAL, "HDD Context is NULL");
10920 return -EINVAL;
10921 }
10922
10923 wiphy = hdd_ctx->wiphy;
10924
10925 mutex_lock(&hdd_ctx->cache_channel_lock);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +053010926 cache_chann = hdd_ctx->original_channels;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010927
10928 if (!cache_chann || !cache_chann->num_channels) {
10929 hddLog(VOS_TRACE_LEVEL_INFO,
10930 "%s channel list is NULL or num channels are zero",
10931 __func__);
10932 mutex_unlock(&hdd_ctx->cache_channel_lock);
10933 return -EINVAL;
10934 }
10935
10936 for (i = 0; i < cache_chann->num_channels; i++) {
10937 status = hdd_wlan_get_freq(
10938 cache_chann->channel_info[i].channel_num,
10939 &freq);
10940
Rajeev Kumar Sirasanagandla17b649a2018-03-19 16:58:30 +053010941 for (band_num = 0; band_num < HDD_NUM_NL80211_BANDS;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053010942 band_num++) {
10943 for (band_ch_num = 0; band_ch_num <
10944 wiphy->bands[band_num]->n_channels;
10945 band_ch_num++) {
10946 wiphy_channel = &(wiphy->bands[band_num]->
10947 channels[band_ch_num]);
10948 if (wiphy_channel->center_freq == freq) {
10949 rfChannel = wiphy_channel->hw_value;
10950 /*
10951 * Cache the current states of
10952 * the channels
10953 */
10954 cache_chann->
10955 channel_info[i].reg_status =
10956 vos_nv_getChannelEnabledState(
10957 rfChannel);
10958
10959 cache_chann->
10960 channel_info[i].wiphy_status =
10961 wiphy_channel->flags;
10962 hddLog(VOS_TRACE_LEVEL_INFO,
10963 "Disable channel %d reg_stat %d wiphy_stat 0x%x",
10964 cache_chann->
10965 channel_info[i].channel_num,
10966 cache_chann->
10967 channel_info[i].reg_status,
10968 wiphy_channel->flags);
10969
10970 vos_nv_set_channel_state(
10971 rfChannel,
10972 NV_CHANNEL_DISABLE);
10973 wiphy_channel->flags |=
10974 IEEE80211_CHAN_DISABLED;
10975 break;
10976 }
10977 }
10978 if (band_ch_num < wiphy->bands[band_num]->n_channels)
10979 break;
10980 }
10981 }
10982
10983 mutex_unlock(&hdd_ctx->cache_channel_lock);
10984 sme_update_channel_list((tpAniSirGlobal)hdd_ctx->hHal);
10985 return 0;
10986}
10987
Jeff Johnson295189b2012-06-20 16:38:30 -070010988#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10989static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
10990 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010991#else
10992static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
10993 struct cfg80211_beacon_data *params,
10994 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010995 enum nl80211_hidden_ssid hidden_ssid,
10996 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010997#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010998{
10999 tsap_Config_t *pConfig;
11000 beacon_data_t *pBeacon = NULL;
11001 struct ieee80211_mgmt *pMgmt_frame;
11002 v_U8_t *pIe=NULL;
11003 v_U16_t capab_info;
11004 eCsrAuthType RSNAuthType;
11005 eCsrEncryptionType RSNEncryptType;
11006 eCsrEncryptionType mcRSNEncryptType;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011007 int status = VOS_STATUS_SUCCESS, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011008 tpWLAN_SAPEventCB pSapEventCallback;
11009 hdd_hostapd_state_t *pHostapdState;
Jeff Johnson295189b2012-06-20 16:38:30 -070011010 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011011 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011012 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053011013 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -070011014 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -080011015 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Vignesh Viswanathan36575f82018-06-14 16:52:21 +053011016 hdd_adapter_t *sta_adapter;
Peng Xu2446a892014-09-05 17:21:18 +053011017 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -070011018 v_BOOL_t MFPCapable = VOS_FALSE;
11019 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +053011020 v_BOOL_t sapEnable11AC =
11021 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Kapil Gupta137ef892016-12-13 19:38:00 +053011022 u_int16_t prev_rsn_length = 0;
11023
Jeff Johnson295189b2012-06-20 16:38:30 -070011024 ENTER();
11025
Nitesh Shah9b066282017-06-06 18:05:52 +053011026 wlan_hdd_tdls_disable_offchan_and_teardown_links(pHddCtx);
Vignesh Viswanathan36575f82018-06-14 16:52:21 +053011027
11028 /*
11029 * For STA+SAP concurrency support from GUI, first STA connection gets
11030 * triggered and while it is in progress, SAP start also comes up.
11031 * Once STA association is successful, STA connect event is sent to
11032 * kernel which gets queued in kernel workqueue and supplicant won't
11033 * process M1 received from AP and send M2 until this NL80211_CONNECT
11034 * event is received. Workqueue is not scheduled as RTNL lock is already
11035 * taken by hostapd thread which has issued start_bss command to driver.
11036 * Driver cannot complete start_bss as the pending command at the head
11037 * of the SME command pending list is hw_mode_update for STA session
11038 * which cannot be processed as SME is in WAITforKey state for STA
11039 * interface. The start_bss command for SAP interface is queued behind
11040 * the hw_mode_update command and so it cannot be processed until
11041 * hw_mode_update command is processed. This is causing a deadlock so
11042 * disconnect the STA interface first if connection or key exchange is
11043 * in progress and then start SAP interface.
11044 */
11045 sta_adapter = hdd_get_sta_connection_in_progress(pHddCtx);
11046 if (sta_adapter) {
11047 hddLog(LOG1, FL("Disconnecting STA with session id: %d"),
11048 sta_adapter->sessionId);
11049 wlan_hdd_disconnect(sta_adapter, eCSR_DISCONNECT_REASON_DEAUTH);
11050 }
11051
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053011052 iniConfig = pHddCtx->cfg_ini;
11053
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011054 /* Mark the indoor channel (passive) to disable */
Sourav Mohapatra8b149332018-03-06 14:28:18 +053011055 if (iniConfig->disable_indoor_channel &&
11056 pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) {
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011057 hdd_update_indoor_channel(pHddCtx, true);
11058
11059 if (!VOS_IS_STATUS_SUCCESS(
11060 sme_update_channel_list((tpAniSirGlobal)pHddCtx->hHal))) {
11061 hdd_update_indoor_channel(pHddCtx, false);
11062 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
11063 FL("Can't start BSS: update channel list failed"));
11064 return eHAL_STATUS_FAILURE;
11065 }
Ganesh Kondabattini19813af2018-01-25 17:32:44 +053011066
11067 /* check if STA is on indoor channel */
11068 if (hdd_is_sta_sap_scc_allowed_on_dfs_chan(pHddCtx))
11069 hdd_check_and_disconnect_sta_on_invalid_channel(pHddCtx);
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011070 }
11071
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011072 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) {
11073 /* Disable the channels received in command SET_DISABLE_CHANNEL_LIST*/
11074 wlan_hdd_disable_channels(pHddCtx);
11075 hdd_check_and_disconnect_sta_on_invalid_channel(pHddCtx);
11076 }
11077
Jeff Johnson295189b2012-06-20 16:38:30 -070011078 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
11079
11080 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
11081
11082 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
11083
11084 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
11085
11086 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
11087
11088 //channel is already set in the set_channel Call back
11089 //pConfig->channel = pCommitConfig->channel;
11090
11091 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011092 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -070011093 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
11094
11095 pConfig->dtim_period = pBeacon->dtim_period;
11096
Arif Hussain6d2a3322013-11-17 19:50:10 -080011097 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -070011098 pConfig->dtim_period);
11099
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -080011100 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -070011101 {
11102 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -070011103 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +053011104 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
11105 {
11106 tANI_BOOLEAN restartNeeded;
11107 pConfig->ieee80211d = 1;
11108 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
11109 sme_setRegInfo(hHal, pConfig->countryCode);
11110 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
11111 }
11112 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -070011113 {
Jeff Johnson32d95a32012-09-10 13:15:23 -070011114 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011115 pConfig->ieee80211d = 1;
11116 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
11117 sme_setRegInfo(hHal, pConfig->countryCode);
11118 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -070011119 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070011120 else
11121 {
11122 pConfig->ieee80211d = 0;
11123 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011124 /*
11125 * If auto channel is configured i.e. channel is 0,
11126 * so skip channel validation.
11127 */
11128 if( AUTO_CHANNEL_SELECT != pConfig->channel )
11129 {
11130 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
11131 {
11132 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011133 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011134 ret = -EINVAL;
11135 goto error;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011136 }
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +053011137 pConfig->user_config_channel = pConfig->channel;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011138 }
11139 else
11140 {
11141 if(1 != pHddCtx->is_dynamic_channel_range_set)
11142 {
11143 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
11144 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
11145 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
11146 }
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +053011147 pHddCtx->is_dynamic_channel_range_set = 0;
11148 pConfig->user_config_channel = SAP_DEFAULT_24GHZ_CHANNEL;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +053011149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011150 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070011151 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011152 {
11153 pConfig->ieee80211d = 0;
11154 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053011155
11156#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
11157 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
11158 pConfig->authType = eSAP_OPEN_SYSTEM;
11159 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
11160 pConfig->authType = eSAP_SHARED_KEY;
11161 else
11162 pConfig->authType = eSAP_AUTO_SWITCH;
11163#else
11164 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
11165 pConfig->authType = eSAP_OPEN_SYSTEM;
11166 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
11167 pConfig->authType = eSAP_SHARED_KEY;
11168 else
11169 pConfig->authType = eSAP_AUTO_SWITCH;
11170#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011171
11172 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011173
11174 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -070011175 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053011176#ifdef SAP_AUTH_OFFLOAD
11177 /* In case of sap offload, hostapd.conf is configuted with open mode and
11178 * security is configured from ini file. Due to open mode in hostapd.conf
11179 * privacy bit is set to false which will result in not sending,
11180 * data packets as encrypted.
11181 * If enable_sap_auth_offload is enabled in ini and
11182 * sap_auth_offload_sec_type is type of WPA2-PSK,
11183 * driver will set privacy bit to 1.
11184 */
11185 if (pHddCtx->cfg_ini->enable_sap_auth_offload &&
11186 pHddCtx->cfg_ini->sap_auth_offload_sec_type)
11187 pConfig->privacy = VOS_TRUE;
11188#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011189
11190 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
11191
11192 /*Set wps station to configured*/
11193 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
11194
11195 if(pIe)
11196 {
11197 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
11198 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011199 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011200 ret = -EINVAL;
11201 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070011202 }
11203 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
11204 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070011205 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -070011206 /* Check 15 bit of WPS IE as it contain information for wps state
11207 * WPS state
11208 */
11209 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
11210 {
11211 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
11212 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
11213 {
11214 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
11215 }
11216 }
11217 }
11218 else
11219 {
11220 pConfig->wps_state = SAP_WPS_DISABLED;
11221 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011222 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -070011223
c_hpothufe599e92014-06-16 11:38:55 +053011224 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
11225 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
11226 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
11227 eCSR_ENCRYPT_TYPE_NONE;
11228
Jeff Johnson295189b2012-06-20 16:38:30 -070011229 pConfig->RSNWPAReqIELength = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +053011230 memset(&pConfig->RSNWPAReqIE[0], 0, sizeof(pConfig->RSNWPAReqIE));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011231 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -070011232 WLAN_EID_RSN);
11233 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011234 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011235 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053011236 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
11237 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
11238 pConfig->RSNWPAReqIELength);
11239 else
11240 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
11241 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011242 /* The actual processing may eventually be more extensive than
11243 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 * by the app.
11245 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011246 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -070011247 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
11248 &RSNEncryptType,
11249 &mcRSNEncryptType,
11250 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -080011251 &MFPCapable,
11252 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +053011253 pConfig->RSNWPAReqIE[1]+2,
11254 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011255
11256 if( VOS_STATUS_SUCCESS == status )
11257 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011258 /* Now copy over all the security attributes you have
11259 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -070011260 * */
11261 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
11262 pConfig->mcRSNEncryptType = mcRSNEncryptType;
11263 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
11264 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011265 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -080011266 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011267 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
11268 }
11269 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011270
Jeff Johnson295189b2012-06-20 16:38:30 -070011271 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
11272 pBeacon->tail, pBeacon->tail_len);
11273
11274 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
11275 {
Kapil Gupta137ef892016-12-13 19:38:00 +053011276 if (pConfig->RSNWPAReqIE[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070011277 {
11278 /*Mixed mode WPA/WPA2*/
Kapil Gupta137ef892016-12-13 19:38:00 +053011279 prev_rsn_length = pConfig->RSNWPAReqIELength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011280 pConfig->RSNWPAReqIELength += pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053011281 if (pConfig->RSNWPAReqIELength <=
11282 (sizeof(pConfig->RSNWPAReqIE) - prev_rsn_length))
11283 memcpy(&pConfig->RSNWPAReqIE[0] + prev_rsn_length, pIe,
11284 pIe[1] + 2);
11285 else
11286 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
11287 pConfig->RSNWPAReqIELength);
11288
Jeff Johnson295189b2012-06-20 16:38:30 -070011289 }
11290 else
11291 {
11292 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053011293 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
11294 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
11295 pConfig->RSNWPAReqIELength);
11296 else
11297 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
11298 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011299 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -070011300 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
11301 &RSNEncryptType,
11302 &mcRSNEncryptType,
11303 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -080011304 &MFPCapable,
11305 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +053011306 pConfig->RSNWPAReqIE[1]+2,
11307 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011308
11309 if( VOS_STATUS_SUCCESS == status )
11310 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011311 /* Now copy over all the security attributes you have
11312 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -070011313 * */
11314 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
11315 pConfig->mcRSNEncryptType = mcRSNEncryptType;
11316 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
11317 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011318 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -080011319 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011320 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
11321 }
11322 }
11323 }
11324
Kapil Gupta137ef892016-12-13 19:38:00 +053011325 if (pConfig->RSNWPAReqIELength > sizeof(pConfig->RSNWPAReqIE)) {
Jeff Johnson4416a782013-03-25 14:17:50 -070011326 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011327 ret = -EINVAL;
11328 goto error;
Jeff Johnson4416a782013-03-25 14:17:50 -070011329 }
11330
Jeff Johnson295189b2012-06-20 16:38:30 -070011331 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
11332
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011333#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070011334 if (params->ssid != NULL)
11335 {
11336 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
11337 pConfig->SSIDinfo.ssid.length = params->ssid_len;
11338 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
11339 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
11340 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011341#else
11342 if (ssid != NULL)
11343 {
11344 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
11345 pConfig->SSIDinfo.ssid.length = ssid_len;
11346 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
11347 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
11348 }
11349#endif
11350
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011351 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -070011352 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011353
Jeff Johnson295189b2012-06-20 16:38:30 -070011354 /* default value */
11355 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
11356 pConfig->num_accept_mac = 0;
11357 pConfig->num_deny_mac = 0;
11358
11359 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
11360 pBeacon->tail, pBeacon->tail_len);
11361
11362 /* pIe for black list is following form:
11363 type : 1 byte
11364 length : 1 byte
11365 OUI : 4 bytes
11366 acl type : 1 byte
11367 no of mac addr in black list: 1 byte
11368 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011369 */
11370 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070011371 {
11372 pConfig->SapMacaddr_acl = pIe[6];
11373 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -080011374 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011375 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011376 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
11377 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011378 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
11379 for (i = 0; i < pConfig->num_deny_mac; i++)
11380 {
11381 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
11382 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011383 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011384 }
11385 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
11386 pBeacon->tail, pBeacon->tail_len);
11387
11388 /* pIe for white list is following form:
11389 type : 1 byte
11390 length : 1 byte
11391 OUI : 4 bytes
11392 acl type : 1 byte
11393 no of mac addr in white list: 1 byte
11394 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011395 */
11396 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070011397 {
11398 pConfig->SapMacaddr_acl = pIe[6];
11399 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -080011400 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011401 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011402 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
11403 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011404 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
11405 for (i = 0; i < pConfig->num_accept_mac; i++)
11406 {
11407 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
11408 acl_entry++;
11409 }
11410 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011411
Jeff Johnson295189b2012-06-20 16:38:30 -070011412 wlan_hdd_set_sapHwmode(pHostapdAdapter);
11413
Jeff Johnsone7245742012-09-05 17:12:55 -070011414#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -080011415 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +053011416 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
11417 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +053011418 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
11419 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -080011420 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
11421 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +053011422 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
11423 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011424 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +053011425 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -070011426 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +053011427 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011428
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053011429 /* If ACS disable and selected channel <= 14
11430 * OR
11431 * ACS enabled and ACS operating band is choosen as 2.4
11432 * AND
11433 * VHT in 2.4G Disabled
11434 * THEN
11435 * Fallback to 11N mode
11436 */
11437 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
11438 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +053011439 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053011440 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011441 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +053011442 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
11443 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011444 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
11445 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011446 }
11447#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011448
Jeff Johnson295189b2012-06-20 16:38:30 -070011449 // ht_capab is not what the name conveys,this is used for protection bitmap
11450 pConfig->ht_capab =
11451 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
11452
Kapil Gupta137ef892016-12-13 19:38:00 +053011453 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -070011454 {
11455 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011456 ret = -EINVAL;
11457 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070011458 }
11459
11460 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011461 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
11463 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011464 pConfig->obssProtEnabled =
11465 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -070011466
Chet Lanctot8cecea22014-02-11 19:09:36 -080011467#ifdef WLAN_FEATURE_11W
11468 pConfig->mfpCapable = MFPCapable;
11469 pConfig->mfpRequired = MFPRequired;
11470 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
11471 pConfig->mfpCapable, pConfig->mfpRequired);
11472#endif
11473
Arif Hussain6d2a3322013-11-17 19:50:10 -080011474 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -080011476 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
11477 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
11478 (int)pConfig->channel);
11479 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
11480 pConfig->SapHw_mode, pConfig->privacy,
11481 pConfig->authType);
11482 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
11483 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
11484 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
11485 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011486
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011487 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -070011488 {
11489 //Bss already started. just return.
11490 //TODO Probably it should update some beacon params.
11491 hddLog( LOGE, "Bss Already started...Ignore the request");
11492 EXIT();
11493 return 0;
11494 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011495
Agarwal Ashish51325b52014-06-16 16:50:49 +053011496 if (vos_max_concurrent_connections_reached()) {
11497 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011498 ret = -EINVAL;
11499 goto error;
Agarwal Ashish51325b52014-06-16 16:50:49 +053011500 }
11501
Jeff Johnson295189b2012-06-20 16:38:30 -070011502 pConfig->persona = pHostapdAdapter->device_mode;
11503
Peng Xu2446a892014-09-05 17:21:18 +053011504 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
11505 if ( NULL != psmeConfig)
11506 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011507 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +053011508 sme_GetConfigParam(hHal, psmeConfig);
11509 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011510#ifdef WLAN_FEATURE_AP_HT40_24G
11511 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
11512 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
11513 && pHddCtx->cfg_ini->apHT40_24GEnabled)
11514 {
11515 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
11516 sme_UpdateConfig (hHal, psmeConfig);
11517 }
11518#endif
Peng Xu2446a892014-09-05 17:21:18 +053011519 vos_mem_free(psmeConfig);
11520 }
Peng Xuafc34e32014-09-25 13:23:55 +053011521 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +053011522
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011523 set_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
Jeff Johnson295189b2012-06-20 16:38:30 -070011524 pSapEventCallback = hdd_hostapd_SAPEventCB;
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +053011525
11526 vos_event_reset(&pHostapdState->vosEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -070011527 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
11528 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
11529 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011530 hddLog(LOGE,FL("SAP Start Bss fail"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011531 ret = -EINVAL;
11532 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070011533 }
11534
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011535 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011536 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
11537
11538 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011539
Jeff Johnson295189b2012-06-20 16:38:30 -070011540 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011541 {
11542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011543 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -070011544 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070011545 VOS_ASSERT(0);
11546 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011547
Jeff Johnson295189b2012-06-20 16:38:30 -070011548 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053011549 if (WLANSAP_get_sessionId(pVosContext, &pHostapdAdapter->sessionId) !=
11550 VOS_STATUS_SUCCESS)
11551 {
11552 hddLog(LOGE,FL("Fail to get Softap sessionID"));
11553 VOS_ASSERT(0);
11554 }
Kaushik, Sushantf6070802014-10-15 15:09:23 +053011555 /* Initialize WMM configuation */
11556 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +053011557 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011558
Anurag Chouhan83026002016-12-13 22:46:21 +053011559#ifdef DHCP_SERVER_OFFLOAD
11560 /* set dhcp server offload */
11561 if (iniConfig->enable_dhcp_srv_offload &&
11562 sme_IsFeatureSupportedByFW(SAP_OFFLOADS)) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011563 vos_event_reset(&pHostapdAdapter->dhcp_status.vos_event);
Anurag Chouhan638f5e22017-03-06 12:28:43 +053011564 status = wlan_hdd_set_dhcp_server_offload(pHostapdAdapter, false);
Anurag Chouhan83026002016-12-13 22:46:21 +053011565 if (!VOS_IS_STATUS_SUCCESS(status))
11566 {
11567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11568 ("HDD DHCP Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011569 vos_event_reset(&pHostapdState->vosEvent);
11570 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
11571 status = vos_wait_single_event(&pHostapdState->vosEvent,
11572 10000);
11573 if (!VOS_IS_STATUS_SUCCESS(status)) {
11574 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011575 ret = -EINVAL;
11576 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011577 }
11578 }
Anurag Chouhan83026002016-12-13 22:46:21 +053011579 }
Anurag Chouhan83026002016-12-13 22:46:21 +053011580 status = vos_wait_single_event(&pHostapdAdapter->dhcp_status.vos_event, 2000);
11581 if (!VOS_IS_STATUS_SUCCESS(status) || pHostapdAdapter->dhcp_status.dhcp_offload_status)
11582 {
11583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11584 ("ERROR: DHCP HDD vos wait for single_event failed!! %d"),
11585 pHostapdAdapter->dhcp_status.dhcp_offload_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011586 vos_event_reset(&pHostapdState->vosEvent);
11587 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
11588 status = vos_wait_single_event(&pHostapdState->vosEvent,
11589 10000);
11590 if (!VOS_IS_STATUS_SUCCESS(status)) {
11591 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011592 ret = -EINVAL;
11593 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011594 }
11595 }
Anurag Chouhan83026002016-12-13 22:46:21 +053011596 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011597#ifdef MDNS_OFFLOAD
11598 if (iniConfig->enable_mdns_offload) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011599 vos_event_reset(&pHostapdAdapter->mdns_status.vos_event);
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011600 status = wlan_hdd_set_mdns_offload(pHostapdAdapter);
11601 if (VOS_IS_STATUS_SUCCESS(status))
11602 {
11603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11604 ("HDD MDNS Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011605 vos_event_reset(&pHostapdState->vosEvent);
11606 if (VOS_STATUS_SUCCESS ==
11607 WLANSAP_StopBss(pHddCtx->pvosContext)) {
11608 status = vos_wait_single_event(&pHostapdState->vosEvent,
11609 10000);
11610 if (!VOS_IS_STATUS_SUCCESS(status)) {
11611 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011612 ret = -EINVAL;
11613 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011614 }
11615 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011616 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011617 status = vos_wait_single_event(&pHostapdAdapter->
11618 mdns_status.vos_event, 2000);
11619 if (!VOS_IS_STATUS_SUCCESS(status) ||
11620 pHostapdAdapter->mdns_status.mdns_enable_status ||
11621 pHostapdAdapter->mdns_status.mdns_fqdn_status ||
11622 pHostapdAdapter->mdns_status.mdns_resp_status)
11623 {
11624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11625 ("MDNS HDD vos wait for single_event failed!! enable %d fqdn %d resp %d"),
11626 pHostapdAdapter->mdns_status.mdns_enable_status,
11627 pHostapdAdapter->mdns_status.mdns_fqdn_status,
11628 pHostapdAdapter->mdns_status.mdns_resp_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011629 vos_event_reset(&pHostapdState->vosEvent);
11630 if (VOS_STATUS_SUCCESS ==
11631 WLANSAP_StopBss(pHddCtx->pvosContext)) {
11632 status = vos_wait_single_event(&pHostapdState->vosEvent,
11633 10000);
11634 if (!VOS_IS_STATUS_SUCCESS(status)) {
11635 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011636 ret = -EINVAL;
11637 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053011638 }
11639 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053011640 }
11641 }
11642#endif /* MDNS_OFFLOAD */
11643 } else {
11644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11645 ("DHCP Disabled ini %d, FW %d"),
11646 iniConfig->enable_dhcp_srv_offload,
11647 sme_IsFeatureSupportedByFW(SAP_OFFLOADS));
Anurag Chouhan83026002016-12-13 22:46:21 +053011648 }
11649#endif /* DHCP_SERVER_OFFLOAD */
11650
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011651#ifdef WLAN_FEATURE_P2P_DEBUG
11652 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
11653 {
11654 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
11655 {
11656 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
11657 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -080011658 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011659 }
11660 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
11661 {
11662 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
11663 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -080011664 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011665 }
11666 }
11667#endif
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +053011668 /* Check and restart SAP if it is on Unsafe channel */
11669 hdd_check_for_unsafe_ch(pHostapdAdapter, pHddCtx);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011670
Jeff Johnson295189b2012-06-20 16:38:30 -070011671 pHostapdState->bCommit = TRUE;
11672 EXIT();
11673
11674 return 0;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011675error:
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +053011676 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
11677 wlan_hdd_restore_channels(pHddCtx);
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011678 /* Revert the indoor to passive marking if START BSS fails */
Sourav Mohapatra8b149332018-03-06 14:28:18 +053011679 if (iniConfig->disable_indoor_channel &&
11680 pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) {
Sourav Mohapatra5817dc42017-12-18 17:45:16 +053011681 hdd_update_indoor_channel(pHddCtx, false);
11682 sme_update_channel_list((tpAniSirGlobal)pHddCtx->hHal);
11683 }
11684
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011685 clear_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
11686 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070011687}
11688
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011689#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011690static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011691 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070011692 struct beacon_parameters *params)
11693{
11694 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011695 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011696 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011697
11698 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011699
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011700 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11701 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
11702 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011703 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
11704 hdd_device_modetoString(pAdapter->device_mode),
11705 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011706
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 }
11713
Agarwal Ashish51325b52014-06-16 16:50:49 +053011714 if (vos_max_concurrent_connections_reached()) {
11715 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
11716 return -EINVAL;
11717 }
11718
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011719 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011720 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070011721 )
11722 {
11723 beacon_data_t *old,*new;
11724
11725 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011726
Jeff Johnson295189b2012-06-20 16:38:30 -070011727 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011728 {
11729 hddLog(VOS_TRACE_LEVEL_WARN,
11730 FL("already beacon info added to session(%d)"),
11731 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070011732 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011733 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011734
11735 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
11736
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011737 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -070011738 {
11739 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011740 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011741 return -EINVAL;
11742 }
11743
11744 pAdapter->sessionCtx.ap.beacon = new;
11745
11746 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
11747 }
11748
11749 EXIT();
11750 return status;
11751}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011752
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011753static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
11754 struct net_device *dev,
11755 struct beacon_parameters *params)
11756{
11757 int ret;
11758
11759 vos_ssr_protect(__func__);
11760 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
11761 vos_ssr_unprotect(__func__);
11762
11763 return ret;
11764}
11765
11766static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011767 struct net_device *dev,
11768 struct beacon_parameters *params)
11769{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011770 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011771 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11772 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011773 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011774
11775 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011776
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011777 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11778 TRACE_CODE_HDD_CFG80211_SET_BEACON,
11779 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
11780 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11781 __func__, hdd_device_modetoString(pAdapter->device_mode),
11782 pAdapter->device_mode);
11783
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011784 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11785 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011786 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011787 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011788 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011789 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011790
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011791 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011792 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011793 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011794 {
11795 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011796
Jeff Johnson295189b2012-06-20 16:38:30 -070011797 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011798
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011800 {
11801 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11802 FL("session(%d) old and new heads points to NULL"),
11803 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070011804 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011806
11807 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
11808
11809 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011810 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011811 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011812 return -EINVAL;
11813 }
11814
11815 pAdapter->sessionCtx.ap.beacon = new;
11816
11817 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
11818 }
11819
11820 EXIT();
11821 return status;
11822}
11823
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011824static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
11825 struct net_device *dev,
11826 struct beacon_parameters *params)
11827{
11828 int ret;
11829
11830 vos_ssr_protect(__func__);
11831 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
11832 vos_ssr_unprotect(__func__);
11833
11834 return ret;
11835}
11836
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011837#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
11838
11839#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011840static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011841 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011842#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011843static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011844 struct net_device *dev)
11845#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011846{
11847 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Vignesh Viswanathan5caacc22018-06-14 17:14:20 +053011848 hdd_adapter_t *staAdapter = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070011849 hdd_context_t *pHddCtx = NULL;
11850 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011851 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011852 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070011853
11854 ENTER();
11855
11856 if (NULL == pAdapter)
11857 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011858 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011859 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011860 return -ENODEV;
11861 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011862
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011863 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11864 TRACE_CODE_HDD_CFG80211_STOP_AP,
11865 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011866 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11867 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011868 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011869 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011870 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -070011871 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011872
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011873 pScanInfo = &pHddCtx->scan_info;
11874
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011875 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11876 __func__, hdd_device_modetoString(pAdapter->device_mode),
11877 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011878
Vignesh Viswanathan5caacc22018-06-14 17:14:20 +053011879 /*
11880 * if a sta connection is in progress in another adapter, disconnect
11881 * the sta and complete the sap operation. sta will reconnect
11882 * after sap stop is done.
11883 */
11884 staAdapter = hdd_get_sta_connection_in_progress(pHddCtx);
11885 if (staAdapter) {
11886 hddLog(LOG1, FL("disconnecting sta with session id: %d"),
11887 staAdapter->sessionId);
11888 wlan_hdd_disconnect(staAdapter, eCSR_DISCONNECT_REASON_DEAUTH);
11889 }
11890
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011891 ret = wlan_hdd_scan_abort(pAdapter);
11892
Girish Gowli4bf7a632014-06-12 13:42:11 +053011893 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -070011894 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011895 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11896 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011897
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011898 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -070011899 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11901 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -080011902
Jeff Johnsone7245742012-09-05 17:12:55 -070011903 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011904 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -070011905 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011906 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070011907 }
11908
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053011909 /* Delete all associated STAs before stopping AP/P2P GO */
11910 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +053011911 hdd_hostapd_stop(dev);
11912
Jeff Johnson295189b2012-06-20 16:38:30 -070011913 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011914 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070011915 )
11916 {
11917 beacon_data_t *old;
11918
11919 old = pAdapter->sessionCtx.ap.beacon;
11920
11921 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011922 {
11923 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11924 FL("session(%d) beacon data points to NULL"),
11925 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070011926 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011927 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011928
Jeff Johnson295189b2012-06-20 16:38:30 -070011929 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011930
11931 mutex_lock(&pHddCtx->sap_lock);
11932 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
11933 {
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +053011934 hdd_hostapd_state_t *pHostapdState =
11935 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
11936
Abhishek Singh10e17cf2018-03-12 14:34:22 +053011937 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
11938 hdd_wait_for_ecsa_complete(pHddCtx);
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +053011939 vos_event_reset(&pHostapdState->vosEvent);
11940
Jeff Johnson4416a782013-03-25 14:17:50 -070011941 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011942 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011943 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
11944
11945 if (!VOS_IS_STATUS_SUCCESS(status))
11946 {
11947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011948 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011949 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011950 }
11951 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011952 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +053011953 /* BSS stopped, clear the active sessions for this device mode */
11954 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011955 }
11956 mutex_unlock(&pHddCtx->sap_lock);
11957
11958 if(status != VOS_STATUS_SUCCESS)
11959 {
11960 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011961 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011962 return -EINVAL;
11963 }
11964
Jeff Johnson4416a782013-03-25 14:17:50 -070011965 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070011966 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
11967 ==eHAL_STATUS_FAILURE)
11968 {
11969 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011970 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070011971 }
11972
Jeff Johnson4416a782013-03-25 14:17:50 -070011973 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070011974 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
11975 eANI_BOOLEAN_FALSE) )
11976 {
11977 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011978 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070011979 }
11980
11981 // Reset WNI_CFG_PROBE_RSP Flags
11982 wlan_hdd_reset_prob_rspies(pAdapter);
11983
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053011984 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
11985
Jeff Johnson295189b2012-06-20 16:38:30 -070011986 pAdapter->sessionCtx.ap.beacon = NULL;
11987 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070011988#ifdef WLAN_FEATURE_P2P_DEBUG
11989 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
11990 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
11991 {
11992 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
11993 "GO got removed");
11994 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
11995 }
11996#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011997 }
11998 EXIT();
11999 return status;
12000}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012001
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012002#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
12003static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
12004 struct net_device *dev)
12005{
12006 int ret;
12007
12008 vos_ssr_protect(__func__);
12009 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
12010 vos_ssr_unprotect(__func__);
12011
12012 return ret;
12013}
12014#else
12015static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
12016 struct net_device *dev)
12017{
12018 int ret;
12019
12020 vos_ssr_protect(__func__);
12021 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
12022 vos_ssr_unprotect(__func__);
12023
12024 return ret;
12025}
12026#endif
12027
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012028#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
12029
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012030static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012031 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012032 struct cfg80211_ap_settings *params)
12033{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012034 hdd_adapter_t *pAdapter;
12035 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012036 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012037
12038 ENTER();
12039
Girish Gowlib143d7a2015-02-18 19:39:55 +053012040 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070012041 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012042 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +053012043 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012044 return -ENODEV;
12045 }
12046
12047 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12048 if (NULL == pAdapter)
12049 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012050 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012051 "%s: HDD adapter is Null", __func__);
12052 return -ENODEV;
12053 }
12054
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012055 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12056 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
12057 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012058 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
12059 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012060 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012061 "%s: HDD adapter magic is invalid", __func__);
12062 return -ENODEV;
12063 }
12064
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053012065 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
12066
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012067 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012068 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012069 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012070 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012071 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012072 }
12073
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012074 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
12075 __func__, hdd_device_modetoString(pAdapter->device_mode),
12076 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012077
12078 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012079 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012080 )
12081 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012082 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012083
12084 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012085
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012086 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012087 {
12088 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
12089 FL("already beacon info added to session(%d)"),
12090 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012091 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012092 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012093
Girish Gowlib143d7a2015-02-18 19:39:55 +053012094#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
12095 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
12096 &new,
12097 &params->beacon);
12098#else
12099 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
12100 &new,
12101 &params->beacon,
12102 params->dtim_period);
12103#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012104
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012105 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012106 {
12107 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053012108 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012109 return -EINVAL;
12110 }
12111 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -080012112#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -070012113 wlan_hdd_cfg80211_set_channel(wiphy, dev,
12114#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
12115 params->channel, params->channel_type);
12116#else
12117 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
12118#endif
Viral Modi3a32cc52013-02-08 11:14:52 -080012119#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012120 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053012121 params->ssid_len, params->hidden_ssid,
12122 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012123 }
12124
12125 EXIT();
12126 return status;
12127}
12128
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012129static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
12130 struct net_device *dev,
12131 struct cfg80211_ap_settings *params)
12132{
12133 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012134
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012135 vos_ssr_protect(__func__);
12136 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
12137 vos_ssr_unprotect(__func__);
12138
12139 return ret;
12140}
12141
12142static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012143 struct net_device *dev,
12144 struct cfg80211_beacon_data *params)
12145{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012146 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012147 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012148 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012149
12150 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012151
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012152 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12153 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
12154 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -080012155 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012156 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012157
12158 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12159 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012160 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070012161 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012162 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070012163 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012164
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012165 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012166 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012167 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012168 {
12169 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012170
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012171 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012172
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012173 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012174 {
12175 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12176 FL("session(%d) beacon data points to NULL"),
12177 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012178 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012179 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012180
12181 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
12182
12183 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012184 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012185 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012186 return -EINVAL;
12187 }
12188
12189 pAdapter->sessionCtx.ap.beacon = new;
12190
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053012191 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
12192 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012193 }
12194
12195 EXIT();
12196 return status;
12197}
12198
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012199static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
12200 struct net_device *dev,
12201 struct cfg80211_beacon_data *params)
12202{
12203 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012204
Mukul Sharmab0e0a982014-12-15 18:58:53 +053012205 vos_ssr_protect(__func__);
12206 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
12207 vos_ssr_unprotect(__func__);
12208
12209 return ret;
12210}
12211
12212#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070012213
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012214static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012215 struct net_device *dev,
12216 struct bss_parameters *params)
12217{
12218 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012219 hdd_context_t *pHddCtx;
12220 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012221
12222 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012223
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012224 if (NULL == pAdapter)
12225 {
12226 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12227 "%s: HDD adapter is Null", __func__);
12228 return -ENODEV;
12229 }
12230 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012231 ret = wlan_hdd_validate_context(pHddCtx);
12232 if (0 != ret)
12233 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012234 return ret;
12235 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012236 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12237 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
12238 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012239 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12240 __func__, hdd_device_modetoString(pAdapter->device_mode),
12241 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012242
12243 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012244 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012245 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012246 {
12247 /* ap_isolate == -1 means that in change bss, upper layer doesn't
12248 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012249 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -070012250 {
12251 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012252 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012253 }
12254
12255 EXIT();
12256 return 0;
12257}
12258
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012259static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
12260 struct net_device *dev,
12261 struct bss_parameters *params)
12262{
12263 int ret;
12264
12265 vos_ssr_protect(__func__);
12266 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
12267 vos_ssr_unprotect(__func__);
12268
12269 return ret;
12270}
Kiet Lam10841362013-11-01 11:36:50 +053012271/* FUNCTION: wlan_hdd_change_country_code_cd
12272* to wait for contry code completion
12273*/
12274void* wlan_hdd_change_country_code_cb(void *pAdapter)
12275{
12276 hdd_adapter_t *call_back_pAdapter = pAdapter;
12277 complete(&call_back_pAdapter->change_country_code);
12278 return NULL;
12279}
12280
Jeff Johnson295189b2012-06-20 16:38:30 -070012281/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053012282 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -070012283 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
12284 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053012285int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012286 struct net_device *ndev,
12287 enum nl80211_iftype type,
12288 u32 *flags,
12289 struct vif_params *params
12290 )
12291{
12292 struct wireless_dev *wdev;
12293 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012294 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -070012295 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012296 tCsrRoamProfile *pRoamProfile = NULL;
12297 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012298 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012299 eMib_dot11DesiredBssType connectedBssType;
12300 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012301 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012302
12303 ENTER();
12304
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012305 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012306 {
12307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12308 "%s: Adapter context is null", __func__);
12309 return VOS_STATUS_E_FAILURE;
12310 }
12311
12312 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12313 if (!pHddCtx)
12314 {
12315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12316 "%s: HDD context is null", __func__);
12317 return VOS_STATUS_E_FAILURE;
12318 }
12319
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012320 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12321 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
12322 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012323 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012324 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012326 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012327 }
12328
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012329 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12330 __func__, hdd_device_modetoString(pAdapter->device_mode),
12331 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012332
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053012333 if (pHddCtx->concurrency_mode == VOS_STA_MON) {
12334 hddLog(VOS_TRACE_LEVEL_FATAL,
12335 "%s: STA + MON is in progress, cannot change interface",
12336 __func__);
12337 }
12338
Agarwal Ashish51325b52014-06-16 16:50:49 +053012339 if (vos_max_concurrent_connections_reached()) {
12340 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12341 return -EINVAL;
12342 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012343 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070012344 wdev = ndev->ieee80211_ptr;
12345
12346#ifdef WLAN_BTAMP_FEATURE
12347 if((NL80211_IFTYPE_P2P_CLIENT == type)||
12348 (NL80211_IFTYPE_ADHOC == type)||
12349 (NL80211_IFTYPE_AP == type)||
12350 (NL80211_IFTYPE_P2P_GO == type))
12351 {
12352 pHddCtx->isAmpAllowed = VOS_FALSE;
12353 // stop AMP traffic
12354 status = WLANBAP_StopAmp();
12355 if(VOS_STATUS_SUCCESS != status )
12356 {
12357 pHddCtx->isAmpAllowed = VOS_TRUE;
12358 hddLog(VOS_TRACE_LEVEL_FATAL,
12359 "%s: Failed to stop AMP", __func__);
12360 return -EINVAL;
12361 }
12362 }
12363#endif //WLAN_BTAMP_FEATURE
12364 /* Reset the current device mode bit mask*/
12365 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
12366
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053012367 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
12368 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
12369 (type == NL80211_IFTYPE_P2P_GO)))
12370 {
12371 /* Notify Mode change in case of concurrency.
12372 * Below function invokes TDLS teardown Functionality Since TDLS is
12373 * not Supported in case of concurrency i.e Once P2P session
12374 * is detected disable offchannel and teardown TDLS links
12375 */
12376 hddLog(LOG1,
12377 FL("Device mode = %d Interface type = %d"),
12378 pAdapter->device_mode, type);
12379 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
12380 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053012381
Jeff Johnson295189b2012-06-20 16:38:30 -070012382 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070012383 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070012384 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070012385 )
12386 {
12387 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012388 if (!pWextState)
12389 {
12390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12391 "%s: pWextState is null", __func__);
12392 return VOS_STATUS_E_FAILURE;
12393 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 pRoamProfile = &pWextState->roamProfile;
12395 LastBSSType = pRoamProfile->BSSType;
12396
12397 switch (type)
12398 {
12399 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070012400 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070012401 hddLog(VOS_TRACE_LEVEL_INFO,
12402 "%s: setting interface Type to INFRASTRUCTURE", __func__);
12403 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070012404#ifdef WLAN_FEATURE_11AC
12405 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
12406 {
12407 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
12408 }
12409#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012410 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070012411 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012412 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080012413 //Check for sub-string p2p to confirm its a p2p interface
12414 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012415 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053012416#ifdef FEATURE_WLAN_TDLS
12417 mutex_lock(&pHddCtx->tdls_lock);
12418 wlan_hdd_tdls_exit(pAdapter, TRUE);
12419 mutex_unlock(&pHddCtx->tdls_lock);
12420#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080012421 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
12422 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
12423 }
12424 else
12425 {
12426 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070012427 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080012428 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012429 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053012430
Jeff Johnson295189b2012-06-20 16:38:30 -070012431 case NL80211_IFTYPE_ADHOC:
12432 hddLog(VOS_TRACE_LEVEL_INFO,
12433 "%s: setting interface Type to ADHOC", __func__);
12434 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
12435 pRoamProfile->phyMode =
12436 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070012437 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012438 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053012439 hdd_set_ibss_ops( pAdapter );
12440 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053012441
12442 status = hdd_sta_id_hash_attach(pAdapter);
12443 if (VOS_STATUS_SUCCESS != status) {
12444 hddLog(VOS_TRACE_LEVEL_ERROR,
12445 FL("Failed to initialize hash for IBSS"));
12446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012447 break;
12448
12449 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070012450 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070012451 {
12452 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
12453 "%s: setting interface Type to %s", __func__,
12454 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
12455
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080012456 //Cancel any remain on channel for GO mode
12457 if (NL80211_IFTYPE_P2P_GO == type)
12458 {
12459 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
12460 }
Mohit Khanna0f232092012-09-11 14:46:08 -070012461 if (NL80211_IFTYPE_AP == type)
12462 {
12463 /* As Loading WLAN Driver one interface being created for p2p device
12464 * address. This will take one HW STA and the max number of clients
12465 * that can connect to softAP will be reduced by one. so while changing
12466 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
12467 * interface as it is not required in SoftAP mode.
12468 */
12469
12470 // Get P2P Adapter
12471 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
12472
12473 if (pP2pAdapter)
12474 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +053012475 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +053012476 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -070012477 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
12478 }
12479 }
Swaroop Goltia2e32212014-04-09 23:37:33 +053012480 //Disable IMPS & BMPS for SAP/GO
12481 if(VOS_STATUS_E_FAILURE ==
12482 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
12483 {
12484 //Fail to Exit BMPS
12485 VOS_ASSERT(0);
12486 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053012487
12488 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
12489
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012490#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070012491
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012492 /* A Mutex Lock is introduced while changing the mode to
12493 * protect the concurrent access for the Adapters by TDLS
12494 * module.
12495 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012496 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012497#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012498 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053012499 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070012501 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
12502 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012503#ifdef FEATURE_WLAN_TDLS
12504 mutex_unlock(&pHddCtx->tdls_lock);
12505#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070012506 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
12507 (pConfig->apRandomBssidEnabled))
12508 {
12509 /* To meet Android requirements create a randomized
12510 MAC address of the form 02:1A:11:Fx:xx:xx */
12511 get_random_bytes(&ndev->dev_addr[3], 3);
12512 ndev->dev_addr[0] = 0x02;
12513 ndev->dev_addr[1] = 0x1A;
12514 ndev->dev_addr[2] = 0x11;
12515 ndev->dev_addr[3] |= 0xF0;
12516 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
12517 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080012518 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
12519 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070012520 }
12521
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 hdd_set_ap_ops( pAdapter->dev );
12523
Kiet Lam10841362013-11-01 11:36:50 +053012524 /* This is for only SAP mode where users can
12525 * control country through ini.
12526 * P2P GO follows station country code
12527 * acquired during the STA scanning. */
12528 if((NL80211_IFTYPE_AP == type) &&
12529 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
12530 {
12531 int status = 0;
12532 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
12533 "%s: setting country code from INI ", __func__);
12534 init_completion(&pAdapter->change_country_code);
12535 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
12536 (void *)(tSmeChangeCountryCallback)
12537 wlan_hdd_change_country_code_cb,
12538 pConfig->apCntryCode, pAdapter,
12539 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053012540 eSIR_FALSE,
12541 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053012542 if (eHAL_STATUS_SUCCESS == status)
12543 {
12544 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012545 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053012546 &pAdapter->change_country_code,
12547 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012548 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053012549 {
12550 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012551 FL("SME Timed out while setting country code %ld"),
12552 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080012553
12554 if (pHddCtx->isLogpInProgress)
12555 {
12556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12557 "%s: LOGP in Progress. Ignore!!!", __func__);
12558 return -EAGAIN;
12559 }
Kiet Lam10841362013-11-01 11:36:50 +053012560 }
12561 }
12562 else
12563 {
12564 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012565 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053012566 return -EINVAL;
12567 }
12568 }
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +053012569 status = hdd_init_ap_mode(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -070012570 if(status != VOS_STATUS_SUCCESS)
12571 {
12572 hddLog(VOS_TRACE_LEVEL_FATAL,
12573 "%s: Error initializing the ap mode", __func__);
12574 return -EINVAL;
12575 }
12576 hdd_set_conparam(1);
12577
Nirav Shah7e3c8132015-06-22 23:51:42 +053012578 status = hdd_sta_id_hash_attach(pAdapter);
12579 if (VOS_STATUS_SUCCESS != status)
12580 {
12581 hddLog(VOS_TRACE_LEVEL_ERROR,
12582 FL("Failed to initialize hash for AP"));
12583 return -EINVAL;
12584 }
12585
Jeff Johnson295189b2012-06-20 16:38:30 -070012586 /*interface type changed update in wiphy structure*/
12587 if(wdev)
12588 {
12589 wdev->iftype = type;
12590 pHddCtx->change_iface = type;
12591 }
12592 else
12593 {
12594 hddLog(VOS_TRACE_LEVEL_ERROR,
12595 "%s: ERROR !!!! Wireless dev is NULL", __func__);
12596 return -EINVAL;
12597 }
12598 goto done;
12599 }
12600
12601 default:
12602 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
12603 __func__);
12604 return -EOPNOTSUPP;
12605 }
12606 }
12607 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012608 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070012609 )
12610 {
12611 switch(type)
12612 {
12613 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070012614 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053012616
12617 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012618#ifdef FEATURE_WLAN_TDLS
12619
12620 /* A Mutex Lock is introduced while changing the mode to
12621 * protect the concurrent access for the Adapters by TDLS
12622 * module.
12623 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012624 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012625#endif
c_hpothu002231a2015-02-05 14:58:51 +053012626 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012627 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080012628 //Check for sub-string p2p to confirm its a p2p interface
12629 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080012630 {
12631 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
12632 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
12633 }
12634 else
12635 {
12636 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070012637 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080012638 }
Agrawal Ashishcfe83282016-09-29 13:03:45 +053012639
12640 /* set con_mode to STA only when no SAP concurrency mode */
12641 if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO)))
12642 hdd_set_conparam(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070012644 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
12645 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012646#ifdef FEATURE_WLAN_TDLS
12647 mutex_unlock(&pHddCtx->tdls_lock);
12648#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053012649 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070012650 if( VOS_STATUS_SUCCESS != status )
12651 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070012652 /* In case of JB, for P2P-GO, only change interface will be called,
12653 * This is the right place to enable back bmps_imps()
12654 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012655 if (pHddCtx->hdd_wlan_suspended)
12656 {
12657 hdd_set_pwrparams(pHddCtx);
12658 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012659 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070012660 goto done;
12661 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070012663 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070012664 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
12665 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012666 goto done;
12667 default:
12668 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
12669 __func__);
12670 return -EOPNOTSUPP;
12671
12672 }
12673
12674 }
12675 else
12676 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012677 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
12678 __func__, hdd_device_modetoString(pAdapter->device_mode),
12679 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012680 return -EOPNOTSUPP;
12681 }
12682
12683
12684 if(pRoamProfile)
12685 {
12686 if ( LastBSSType != pRoamProfile->BSSType )
12687 {
12688 /*interface type changed update in wiphy structure*/
12689 wdev->iftype = type;
12690
12691 /*the BSS mode changed, We need to issue disconnect
12692 if connected or in IBSS disconnect state*/
12693 if ( hdd_connGetConnectedBssType(
12694 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
12695 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
12696 {
12697 /*need to issue a disconnect to CSR.*/
12698 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12699 if( eHAL_STATUS_SUCCESS ==
12700 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12701 pAdapter->sessionId,
12702 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12703 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012704 ret = wait_for_completion_interruptible_timeout(
12705 &pAdapter->disconnect_comp_var,
12706 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12707 if (ret <= 0)
12708 {
12709 hddLog(VOS_TRACE_LEVEL_ERROR,
12710 FL("wait on disconnect_comp_var failed %ld"), ret);
12711 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012712 }
12713 }
12714 }
12715 }
12716
12717done:
12718 /*set bitmask based on updated value*/
12719 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070012720
12721 /* Only STA mode support TM now
12722 * all other mode, TM feature should be disabled */
12723 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
12724 (~VOS_STA & pHddCtx->concurrency_mode) )
12725 {
12726 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
12727 }
12728
Jeff Johnson295189b2012-06-20 16:38:30 -070012729#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012730 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012731 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070012732 {
12733 //we are ok to do AMP
12734 pHddCtx->isAmpAllowed = VOS_TRUE;
12735 }
12736#endif //WLAN_BTAMP_FEATURE
12737 EXIT();
12738 return 0;
12739}
12740
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053012741/*
12742 * FUNCTION: wlan_hdd_cfg80211_change_iface
12743 * wrapper function to protect the actual implementation from SSR.
12744 */
12745int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
12746 struct net_device *ndev,
12747 enum nl80211_iftype type,
12748 u32 *flags,
12749 struct vif_params *params
12750 )
12751{
12752 int ret;
12753
12754 vos_ssr_protect(__func__);
12755 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
12756 vos_ssr_unprotect(__func__);
12757
12758 return ret;
12759}
12760
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012761#ifdef FEATURE_WLAN_TDLS
12762static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012763 struct net_device *dev,
12764#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12765 const u8 *mac,
12766#else
12767 u8 *mac,
12768#endif
12769 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012770{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012771 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012772 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012773 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012774 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012775 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053012776 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012777
12778 ENTER();
12779
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012780 if (!dev) {
12781 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
12782 return -EINVAL;
12783 }
12784
12785 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12786 if (!pAdapter) {
12787 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
12788 return -EINVAL;
12789 }
12790
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053012791 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012792 {
12793 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12794 "Invalid arguments");
12795 return -EINVAL;
12796 }
Hoonki Lee27511902013-03-14 18:19:06 -070012797
12798 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
12799 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
12800 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012801 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070012802 "%s: TDLS mode is disabled OR not enabled in FW."
12803 MAC_ADDRESS_STR " Request declined.",
12804 __func__, MAC_ADDR_ARRAY(mac));
12805 return -ENOTSUPP;
12806 }
12807
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012808 if (pHddCtx->isLogpInProgress)
12809 {
12810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12811 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053012812 wlan_hdd_tdls_set_link_status(pAdapter,
12813 mac,
12814 eTDLS_LINK_IDLE,
12815 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012816 return -EBUSY;
12817 }
12818
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053012819 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053012820 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012821
12822 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012823 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012824 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
12825 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053012826 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012827 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070012828 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012829
12830 /* in add station, we accept existing valid staId if there is */
12831 if ((0 == update) &&
12832 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
12833 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012834 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012835 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012836 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012837 " link_status %d. staId %d. add station ignored.",
12838 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012839 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012840 return 0;
12841 }
12842 /* in change station, we accept only when staId is valid */
12843 if ((1 == update) &&
12844 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
12845 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
12846 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012847 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012848 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012849 "%s: " MAC_ADDRESS_STR
12850 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012851 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
12852 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
12853 mutex_unlock(&pHddCtx->tdls_lock);
12854 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012855 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012856 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070012857
12858 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053012859 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012860 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012861 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12862 "%s: " MAC_ADDRESS_STR
12863 " TDLS setup is ongoing. Request declined.",
12864 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070012865 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012866 }
12867
12868 /* first to check if we reached to maximum supported TDLS peer.
12869 TODO: for now, return -EPERM looks working fine,
12870 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012871 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
12872 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012873 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012874 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12875 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012876 " TDLS Max peer already connected. Request declined."
12877 " Num of peers (%d), Max allowed (%d).",
12878 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
12879 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070012880 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012881 }
12882 else
12883 {
12884 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012885 mutex_lock(&pHddCtx->tdls_lock);
12886 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012887 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012888 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012889 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012890 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12891 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
12892 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012893 return -EPERM;
12894 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053012895 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012896 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012897 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053012898 wlan_hdd_tdls_set_link_status(pAdapter,
12899 mac,
12900 eTDLS_LINK_CONNECTING,
12901 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012902
Jeff Johnsond75fe012013-04-06 10:53:06 -070012903 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053012904 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012905 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012907 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070012908 if(StaParams->htcap_present)
12909 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070012911 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070012913 "ht_capa->extended_capabilities: %0x",
12914 StaParams->HTCap.extendedHtCapInfo);
12915 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012917 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012919 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070012920 if(StaParams->vhtcap_present)
12921 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012922 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070012923 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
12924 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
12925 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
12926 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012927 {
12928 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012929 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012930 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012932 "[%d]: %x ", i, StaParams->supported_rates[i]);
12933 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070012934 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053012935 else if ((1 == update) && (NULL == StaParams))
12936 {
12937 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12938 "%s : update is true, but staParams is NULL. Error!", __func__);
12939 return -EPERM;
12940 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012941
12942 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
12943
12944 if (!update)
12945 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053012946 /*Before adding sta make sure that device exited from BMPS*/
12947 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
12948 {
12949 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12950 "%s: Adding tdls peer sta. Disable BMPS", __func__);
12951 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
12952 if (status != VOS_STATUS_SUCCESS) {
12953 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
12954 }
12955 }
12956
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012957 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012958 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012959 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053012960 hddLog(VOS_TRACE_LEVEL_ERROR,
12961 FL("Failed to add TDLS peer STA. Enable Bmps"));
12962 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012963 return -EPERM;
12964 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012965 }
12966 else
12967 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012968 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012969 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012970 if (ret != eHAL_STATUS_SUCCESS) {
12971 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
12972 return -EPERM;
12973 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012974 }
12975
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012976 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012977 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
12978
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053012979 mutex_lock(&pHddCtx->tdls_lock);
12980 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
12981
Masti, Narayanraddi07262462016-01-19 12:40:06 +053012982 if ((pTdlsPeer != NULL) &&
12983 (pTdlsPeer->link_status == eTDLS_LINK_TEARING))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012984 {
Masti, Narayanraddi07262462016-01-19 12:40:06 +053012985 hddLog(VOS_TRACE_LEVEL_ERROR,
12986 FL("peer link status %u"), pTdlsPeer->link_status);
12987 mutex_unlock(&pHddCtx->tdls_lock);
12988 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012989 }
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053012990 mutex_unlock(&pHddCtx->tdls_lock);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012991
Masti, Narayanraddi07262462016-01-19 12:40:06 +053012992 if (ret <= 0)
12993 {
12994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12995 "%s: timeout waiting for tdls add station indication %ld",
12996 __func__, ret);
12997 goto error;
12998 }
12999
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013000 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
13001 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013003 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013004 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013005 }
13006
13007 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070013008
13009error:
Atul Mittal115287b2014-07-08 13:26:33 +053013010 wlan_hdd_tdls_set_link_status(pAdapter,
13011 mac,
13012 eTDLS_LINK_IDLE,
13013 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070013014 return -EPERM;
13015
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013016}
13017#endif
13018
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013019VOS_STATUS wlan_hdd_send_sta_authorized_event(
13020 hdd_adapter_t *adapter,
13021 hdd_context_t *hdd_ctx,
13022 const v_MACADDR_t *mac_addr)
13023{
13024 struct sk_buff *vendor_event;
13025 uint32_t sta_flags = 0;
13026 VOS_STATUS status;
13027
13028 ENTER();
13029
13030 if (!hdd_ctx) {
13031 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is null"));
13032 return -EINVAL;
13033 }
13034
13035 vendor_event =
13036 cfg80211_vendor_event_alloc(
Ashish Kumar Dhanotiyac99fbef2018-04-11 12:23:32 +053013037 hdd_ctx->wiphy,
13038#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
13039 &adapter->wdev,
13040#endif
13041 sizeof(sta_flags) +
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013042 VOS_MAC_ADDR_SIZE + NLMSG_HDRLEN,
13043 QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES_INDEX,
13044 GFP_KERNEL);
13045 if (!vendor_event) {
13046 hddLog(VOS_TRACE_LEVEL_ERROR,
13047 FL("cfg80211_vendor_event_alloc failed"));
13048 return -EINVAL;
13049 }
13050
13051 sta_flags |= BIT(NL80211_STA_FLAG_AUTHORIZED);
13052
13053 status = nla_put_u32(vendor_event,
13054 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_STA_FLAGS,
13055 sta_flags);
13056 if (status) {
13057 hddLog(VOS_TRACE_LEVEL_ERROR, FL("STA flag put fails"));
13058 kfree_skb(vendor_event);
13059 return VOS_STATUS_E_FAILURE;
13060 }
13061 status = nla_put(vendor_event,
13062 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_STA_MAC,
13063 VOS_MAC_ADDR_SIZE, mac_addr->bytes);
13064 if (status) {
13065 hddLog(VOS_TRACE_LEVEL_ERROR, FL("STA MAC put fails"));
13066 kfree_skb(vendor_event);
13067 return VOS_STATUS_E_FAILURE;
13068 }
13069
13070 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
13071
13072 EXIT();
13073 return 0;
13074}
13075
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013076static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013077 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013078#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13079 const u8 *mac,
13080#else
Jeff Johnson295189b2012-06-20 16:38:30 -070013081 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013082#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 struct station_parameters *params)
13084{
13085 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013086 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053013087 hdd_context_t *pHddCtx;
13088 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013090 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070013091#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013092 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013093 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013094 tANI_U8 isOffChannelSupported = 0;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013095 tANI_U8 isQosWmmSta = FALSE;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070013096#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070013097
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013098 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013099
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013100 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053013101 if ((NULL == pAdapter))
13102 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053013104 "invalid adapter ");
13105 return -EINVAL;
13106 }
13107
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013108 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13109 TRACE_CODE_HDD_CHANGE_STATION,
13110 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053013111 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053013112
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013113 ret = wlan_hdd_validate_context(pHddCtx);
13114 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053013115 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013116 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053013117 }
13118
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013119 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13120
13121 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013122 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13124 "invalid HDD station context");
13125 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013126 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
13128
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013129 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
13130 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013132 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070013133 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013134 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070013135 WLANTL_STA_AUTHENTICATED);
13136
Gopichand Nakkala29149562013-05-10 21:43:41 +053013137 if (status != VOS_STATUS_SUCCESS)
13138 {
13139 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13140 "%s: Not able to change TL state to AUTHENTICATED", __func__);
13141 return -EINVAL;
13142 }
Hanumanth Reddy Pothula852449b2018-03-08 13:21:10 +053013143 status = wlan_hdd_send_sta_authorized_event(pAdapter, pHddCtx,
13144 &STAMacAddress);
13145 if (status != VOS_STATUS_SUCCESS)
13146 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 }
13148 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070013149 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
13150 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053013151#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013152 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
13153 StaParams.capability = params->capability;
13154 StaParams.uapsd_queues = params->uapsd_queues;
13155 StaParams.max_sp = params->max_sp;
13156
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013157 /* Convert (first channel , number of channels) tuple to
13158 * the total list of channels. This goes with the assumption
13159 * that if the first channel is < 14, then the next channels
13160 * are an incremental of 1 else an incremental of 4 till the number
13161 * of channels.
13162 */
13163 if (0 != params->supported_channels_len) {
13164 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
Ashish Kumar Dhanotiyaf01ec752018-04-25 15:50:15 +053013165 for ( i = 0 ; i < params->supported_channels_len
13166 && j < SIR_MAC_MAX_SUPP_CHANNELS; i+=2)
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013167 {
13168 int wifi_chan_index;
13169 StaParams.supported_channels[j] = params->supported_channels[i];
13170 wifi_chan_index =
13171 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
13172 no_of_channels = params->supported_channels[i+1];
Ashish Kumar Dhanotiyaf01ec752018-04-25 15:50:15 +053013173 for(k=1; k <= no_of_channels
13174 && j < SIR_MAC_MAX_SUPP_CHANNELS - 1; k++)
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013175 {
13176 StaParams.supported_channels[j+1] =
13177 StaParams.supported_channels[j] + wifi_chan_index;
13178 j+=1;
13179 }
13180 }
13181 StaParams.supported_channels_len = j;
13182 }
SaidiReddy Yenuga0f1a1592017-04-05 13:18:26 +053013183 if (params->supported_oper_classes_len >
13184 SIR_MAC_MAX_SUPP_OPER_CLASSES) {
13185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13186 "received oper classes:%d, resetting it to max supported %d",
13187 params->supported_oper_classes_len,
13188 SIR_MAC_MAX_SUPP_OPER_CLASSES);
13189 params->supported_oper_classes_len =
13190 SIR_MAC_MAX_SUPP_OPER_CLASSES;
13191 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013192 vos_mem_copy(StaParams.supported_oper_classes,
13193 params->supported_oper_classes,
13194 params->supported_oper_classes_len);
13195 StaParams.supported_oper_classes_len =
13196 params->supported_oper_classes_len;
13197
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053013198 if (params->ext_capab_len > sizeof(StaParams.extn_capability)) {
13199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13200 "received extn capabilities:%d, resetting it to max supported",
13201 params->ext_capab_len);
13202 params->ext_capab_len = sizeof(StaParams.extn_capability);
13203 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013204 if (0 != params->ext_capab_len)
13205 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053013206 params->ext_capab_len);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013207
13208 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070013209 {
13210 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013211 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070013212 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013213
13214 StaParams.supported_rates_len = params->supported_rates_len;
13215
13216 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
13217 * The supported_rates array , for all the structures propogating till Add Sta
13218 * to the firmware has to be modified , if the supplicant (ieee80211) is
13219 * modified to send more rates.
13220 */
13221
13222 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
13223 */
13224 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
13225 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
13226
13227 if (0 != StaParams.supported_rates_len) {
13228 int i = 0;
13229 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
13230 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013231 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013232 "Supported Rates with Length %d", StaParams.supported_rates_len);
13233 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013234 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013235 "[%d]: %0x", i, StaParams.supported_rates[i]);
13236 }
13237
13238 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070013239 {
13240 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013241 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070013242 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013243
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013244 if (0 != params->ext_capab_len ) {
13245 /*Define A Macro : TODO Sunil*/
13246 if ((1<<4) & StaParams.extn_capability[3]) {
13247 isBufSta = 1;
13248 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013249 /* TDLS Channel Switching Support */
13250 if ((1<<6) & StaParams.extn_capability[3]) {
13251 isOffChannelSupported = 1;
13252 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013253 }
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013254
13255 if (pHddCtx->cfg_ini->fEnableTDLSWmmMode &&
Nitesh Shah48df4c02016-08-12 16:27:33 +053013256 (params->ht_capa || params->vht_capa ||
13257 (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME))))
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013258 /* TDLS Peer is WME/QoS capable */
13259 isQosWmmSta = TRUE;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013260
13261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13262 "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d",
13263 __func__, isQosWmmSta, StaParams.htcap_present);
13264
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013265 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
13266 &StaParams, isBufSta,
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053013267 isOffChannelSupported,
13268 isQosWmmSta);
Naresh Jayaram3180aa42014-02-12 21:47:26 +053013269
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013270 if (VOS_STATUS_SUCCESS != status) {
13271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13272 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
13273 return -EINVAL;
13274 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013275 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
13276
13277 if (VOS_STATUS_SUCCESS != status) {
13278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13279 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
13280 return -EINVAL;
13281 }
13282 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070013283#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053013284 }
Jeff Johnsone7245742012-09-05 17:12:55 -070013285 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013286 return status;
13287}
13288
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013289#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
13290static int wlan_hdd_change_station(struct wiphy *wiphy,
13291 struct net_device *dev,
13292 const u8 *mac,
13293 struct station_parameters *params)
13294#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013295static int wlan_hdd_change_station(struct wiphy *wiphy,
13296 struct net_device *dev,
13297 u8 *mac,
13298 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013299#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013300{
13301 int ret;
13302
13303 vos_ssr_protect(__func__);
13304 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
13305 vos_ssr_unprotect(__func__);
13306
13307 return ret;
13308}
13309
Jeff Johnson295189b2012-06-20 16:38:30 -070013310/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013311 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070013312 * This function is used to initialize the key information
13313 */
13314#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013315static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 struct net_device *ndev,
13317 u8 key_index, bool pairwise,
13318 const u8 *mac_addr,
13319 struct key_params *params
13320 )
13321#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013322static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 struct net_device *ndev,
13324 u8 key_index, const u8 *mac_addr,
13325 struct key_params *params
13326 )
13327#endif
13328{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013329 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 tCsrRoamSetKey setKey;
13331 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013332 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013333 v_U32_t roamId= 0xFF;
13334 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 hdd_hostapd_state_t *pHostapdState;
13336 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013337 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013338 hdd_context_t *pHddCtx;
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013339 uint8_t i;
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013340 v_MACADDR_t *peerMacAddr;
13341 u64 rsc_counter = 0;
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013342 uint8_t staid = HDD_MAX_STA_COUNT;
13343 bool pairwise_set_key = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070013344
13345 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013346
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013347 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13348 TRACE_CODE_HDD_CFG80211_ADD_KEY,
13349 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013350 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13351 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013352 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013353 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013354 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013355 }
13356
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013357 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13358 __func__, hdd_device_modetoString(pAdapter->device_mode),
13359 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013360
13361 if (CSR_MAX_NUM_KEY <= key_index)
13362 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013363 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 key_index);
13365
13366 return -EINVAL;
13367 }
13368
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013369 if (CSR_MAX_KEY_LEN < params->key_len)
13370 {
13371 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
13372 params->key_len);
13373
13374 return -EINVAL;
13375 }
13376
Jingxiang Gec438aea2017-10-26 16:44:00 +080013377 if (CSR_MAX_RSC_LEN < params->seq_len)
13378 {
13379 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Invalid seq length %d", __func__,
13380 params->seq_len);
Ashish Kumar Dhanotiya9783b182017-12-08 14:50:46 +053013381
13382 return -EINVAL;
Jingxiang Gec438aea2017-10-26 16:44:00 +080013383 }
13384
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013385 hddLog(VOS_TRACE_LEVEL_INFO,
Jingxiang Gec438aea2017-10-26 16:44:00 +080013386 "%s: called with key index = %d & key length %d & seq length %d",
13387 __func__, key_index, params->key_len, params->seq_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013388
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013389 peerMacAddr = (v_MACADDR_t *)mac_addr;
13390
Jeff Johnson295189b2012-06-20 16:38:30 -070013391 /*extract key idx, key len and key*/
13392 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
13393 setKey.keyId = key_index;
13394 setKey.keyLength = params->key_len;
13395 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
Jingxiang Gec438aea2017-10-26 16:44:00 +080013396 vos_mem_copy(&setKey.keyRsc[0], params->seq, params->seq_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013397
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013398 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013399 {
13400 case WLAN_CIPHER_SUITE_WEP40:
13401 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
13402 break;
13403
13404 case WLAN_CIPHER_SUITE_WEP104:
13405 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
13406 break;
13407
13408 case WLAN_CIPHER_SUITE_TKIP:
13409 {
13410 u8 *pKey = &setKey.Key[0];
13411 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
13412
13413 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
13414
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013415 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070013416
13417 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013418 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 |--------------|----------|----------|
13420 <---16bytes---><--8bytes--><--8bytes-->
13421
13422 */
13423 /*Sme expects the 32 bytes key to be in the below order
13424
13425 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013426 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070013427 |--------------|----------|----------|
13428 <---16bytes---><--8bytes--><--8bytes-->
13429 */
13430 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013431 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013432
13433 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013434 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013435
13436 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013437 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013438
13439
13440 break;
13441 }
13442
13443 case WLAN_CIPHER_SUITE_CCMP:
13444 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
13445 break;
13446
13447#ifdef FEATURE_WLAN_WAPI
13448 case WLAN_CIPHER_SUITE_SMS4:
13449 {
13450 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
13451 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
13452 params->key, params->key_len);
13453 return 0;
13454 }
13455#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070013456
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013457#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013458 case WLAN_CIPHER_SUITE_KRK:
13459 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
13460 break;
13461#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070013462
13463#ifdef WLAN_FEATURE_11W
13464 case WLAN_CIPHER_SUITE_AES_CMAC:
13465 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070013466 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070013467#endif
13468
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070013470 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070013471 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013472 status = -EOPNOTSUPP;
13473 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 }
13475
13476 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
13477 __func__, setKey.encType);
13478
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013479 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070013480#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13481 (!pairwise)
13482#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013483 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013484#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013485 )
13486 {
13487 /* set group key*/
13488 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13489 "%s- %d: setting Broadcast key",
13490 __func__, __LINE__);
13491 setKey.keyDirection = eSIR_RX_ONLY;
13492 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
13493 }
13494 else
13495 {
13496 /* set pairwise key*/
13497 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13498 "%s- %d: setting pairwise key",
13499 __func__, __LINE__);
13500 setKey.keyDirection = eSIR_TX_RX;
13501 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013502 pairwise_set_key = true;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013503 }
13504 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
13505 {
13506 setKey.keyDirection = eSIR_TX_RX;
13507 /*Set the group key*/
13508 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
13509 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013510
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013511 if ( 0 != status )
13512 {
13513 hddLog(VOS_TRACE_LEVEL_ERROR,
13514 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013515 status = -EINVAL;
13516 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013517 }
13518 /*Save the keys here and call sme_RoamSetKey for setting
13519 the PTK after peer joins the IBSS network*/
13520 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
13521 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013522 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013523 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053013524 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
13525 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
13526 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013528 if( pHostapdState->bssState == BSS_START )
13529 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013530 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13531 vos_status = wlan_hdd_check_ula_done(pAdapter);
13532
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013533 if (peerMacAddr && (pairwise_set_key == true))
13534 staid = hdd_sta_id_find_from_mac_addr(pAdapter, peerMacAddr);
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013535
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013536 if ( vos_status != VOS_STATUS_SUCCESS )
13537 {
13538 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13539 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
13540 __LINE__, vos_status );
13541
13542 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
13543
13544 status = -EINVAL;
13545 goto end;
13546 }
13547
Jeff Johnson295189b2012-06-20 16:38:30 -070013548 status = WLANSAP_SetKeySta( pVosContext, &setKey);
13549
13550 if ( status != eHAL_STATUS_SUCCESS )
13551 {
13552 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13553 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
13554 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013555 status = -EINVAL;
13556 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 }
13558 }
13559
13560 /* Saving WEP keys */
13561 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
13562 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
13563 {
13564 //Save the wep key in ap context. Issue setkey after the BSS is started.
13565 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
13566 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
13567 }
13568 else
13569 {
13570 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013571 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
13573 }
13574 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013575 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
13576 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 {
13578 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13579 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13580
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013581#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13582 if (!pairwise)
13583#else
13584 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
13585#endif
13586 {
13587 /* set group key*/
13588 if (pHddStaCtx->roam_info.deferKeyComplete)
13589 {
13590 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13591 "%s- %d: Perform Set key Complete",
13592 __func__, __LINE__);
13593 hdd_PerformRoamSetKeyComplete(pAdapter);
13594 }
13595 }
13596
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013597 if (pairwise_set_key == true)
13598 staid = pHddStaCtx->conn_info.staId[0];
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013599
Jeff Johnson295189b2012-06-20 16:38:30 -070013600 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
13601
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080013602 pWextState->roamProfile.Keys.defaultIndex = key_index;
13603
13604
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070013605 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070013606 params->key, params->key_len);
13607
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013608
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
13610
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013611 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013613 __func__, setKey.peerMac[0], setKey.peerMac[1],
13614 setKey.peerMac[2], setKey.peerMac[3],
13615 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070013616 setKey.keyDirection);
13617
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013618 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053013619
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013620 if ( vos_status != VOS_STATUS_SUCCESS )
13621 {
13622 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013623 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
13624 __LINE__, vos_status );
13625
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013626 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013627
Nirav Shah4b53d4b2015-05-08 05:35:00 -070013628 status = -EINVAL;
13629 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013630
13631 }
13632
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013633#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013634 /* The supplicant may attempt to set the PTK once pre-authentication
13635 is done. Save the key in the UMAC and include it in the ADD BSS
13636 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013637 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013638 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013639 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013640 hddLog(VOS_TRACE_LEVEL_INFO_MED,
13641 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013642 status = 0;
13643 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053013644 }
13645 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
13646 {
13647 hddLog(VOS_TRACE_LEVEL_ERROR,
13648 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013649 status = -EINVAL;
13650 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013651 }
13652#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070013653
13654 /* issue set key request to SME*/
13655 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
13656 pAdapter->sessionId, &setKey, &roamId );
13657
13658 if ( 0 != status )
13659 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013660 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
13662 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013663 status = -EINVAL;
13664 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013665 }
13666
13667
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013668 /* in case of IBSS as there was no information available about WEP keys during
13669 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070013670 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013671 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
13672 !( ( IW_AUTH_KEY_MGMT_802_1X
13673 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
13675 )
13676 &&
13677 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
13678 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
13679 )
13680 )
13681 {
13682 setKey.keyDirection = eSIR_RX_ONLY;
13683 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
13684
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013685 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013687 __func__, setKey.peerMac[0], setKey.peerMac[1],
13688 setKey.peerMac[2], setKey.peerMac[3],
13689 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 setKey.keyDirection);
13691
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013692 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013693 pAdapter->sessionId, &setKey, &roamId );
13694
13695 if ( 0 != status )
13696 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013697 hddLog(VOS_TRACE_LEVEL_ERROR,
13698 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 __func__, status);
13700 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013701 status = -EINVAL;
13702 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070013703 }
13704 }
13705 }
13706
Sravan Kumar Kairam9397a402017-11-10 16:23:10 +053013707 if (pairwise_set_key == true) {
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013708 for (i = 0; i < params->seq_len; i++) {
13709 rsc_counter |= (params->seq[i] << i*8);
13710 }
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053013711 WLANTL_SetKeySeqCounter(pVosContext, rsc_counter, staid);
13712 }
13713
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013714end:
13715 /* Need to clear any trace of key value in the memory.
13716 * Thus zero out the memory even though it is local
13717 * variable.
13718 */
13719 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013720 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053013721 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013722}
13723
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013724#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13725static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
13726 struct net_device *ndev,
13727 u8 key_index, bool pairwise,
13728 const u8 *mac_addr,
13729 struct key_params *params
13730 )
13731#else
13732static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
13733 struct net_device *ndev,
13734 u8 key_index, const u8 *mac_addr,
13735 struct key_params *params
13736 )
13737#endif
13738{
13739 int ret;
13740 vos_ssr_protect(__func__);
13741#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13742 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
13743 mac_addr, params);
13744#else
13745 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
13746 params);
13747#endif
13748 vos_ssr_unprotect(__func__);
13749
13750 return ret;
13751}
13752
Jeff Johnson295189b2012-06-20 16:38:30 -070013753/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013754 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070013755 * This function is used to get the key information
13756 */
13757#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013758static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013759 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013761 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070013762 const u8 *mac_addr, void *cookie,
13763 void (*callback)(void *cookie, struct key_params*)
13764 )
13765#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013766static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013767 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013768 struct net_device *ndev,
13769 u8 key_index, const u8 *mac_addr, void *cookie,
13770 void (*callback)(void *cookie, struct key_params*)
13771 )
13772#endif
13773{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013774 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013775 hdd_wext_state_t *pWextState = NULL;
13776 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013777 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013778 hdd_context_t *pHddCtx;
13779 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013780
13781 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013782
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013783 if (NULL == pAdapter)
13784 {
13785 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13786 "%s: HDD adapter is Null", __func__);
13787 return -ENODEV;
13788 }
13789
13790 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13791 ret = wlan_hdd_validate_context(pHddCtx);
13792 if (0 != ret)
13793 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053013794 return ret;
13795 }
13796
13797 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13798 pRoamProfile = &(pWextState->roamProfile);
13799
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013800 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13801 __func__, hdd_device_modetoString(pAdapter->device_mode),
13802 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013803
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 memset(&params, 0, sizeof(params));
13805
13806 if (CSR_MAX_NUM_KEY <= key_index)
13807 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013808 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013810 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013811
13812 switch(pRoamProfile->EncryptionType.encryptionType[0])
13813 {
13814 case eCSR_ENCRYPT_TYPE_NONE:
13815 params.cipher = IW_AUTH_CIPHER_NONE;
13816 break;
13817
13818 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
13819 case eCSR_ENCRYPT_TYPE_WEP40:
13820 params.cipher = WLAN_CIPHER_SUITE_WEP40;
13821 break;
13822
13823 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
13824 case eCSR_ENCRYPT_TYPE_WEP104:
13825 params.cipher = WLAN_CIPHER_SUITE_WEP104;
13826 break;
13827
13828 case eCSR_ENCRYPT_TYPE_TKIP:
13829 params.cipher = WLAN_CIPHER_SUITE_TKIP;
13830 break;
13831
13832 case eCSR_ENCRYPT_TYPE_AES:
13833 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
13834 break;
13835
13836 default:
13837 params.cipher = IW_AUTH_CIPHER_NONE;
13838 break;
13839 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013840
c_hpothuaaf19692014-05-17 17:01:48 +053013841 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13842 TRACE_CODE_HDD_CFG80211_GET_KEY,
13843 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013844
Jeff Johnson295189b2012-06-20 16:38:30 -070013845 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
13846 params.seq_len = 0;
13847 params.seq = NULL;
13848 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
13849 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013850 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013851 return 0;
13852}
13853
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053013854#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13855static int wlan_hdd_cfg80211_get_key(
13856 struct wiphy *wiphy,
13857 struct net_device *ndev,
13858 u8 key_index, bool pairwise,
13859 const u8 *mac_addr, void *cookie,
13860 void (*callback)(void *cookie, struct key_params*)
13861 )
13862#else
13863static int wlan_hdd_cfg80211_get_key(
13864 struct wiphy *wiphy,
13865 struct net_device *ndev,
13866 u8 key_index, const u8 *mac_addr, void *cookie,
13867 void (*callback)(void *cookie, struct key_params*)
13868 )
13869#endif
13870{
13871 int ret;
13872
13873 vos_ssr_protect(__func__);
13874#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13875 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
13876 mac_addr, cookie, callback);
13877#else
13878 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
13879 callback);
13880#endif
13881 vos_ssr_unprotect(__func__);
13882
13883 return ret;
13884}
13885
Jeff Johnson295189b2012-06-20 16:38:30 -070013886/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013887 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070013888 * This function is used to delete the key information
13889 */
13890#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013891static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013892 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013893 u8 key_index,
13894 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070013895 const u8 *mac_addr
13896 )
13897#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013898static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013899 struct net_device *ndev,
13900 u8 key_index,
13901 const u8 *mac_addr
13902 )
13903#endif
13904{
13905 int status = 0;
13906
13907 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013908 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070013909 //it is observed that this is invalidating peer
13910 //key index whenever re-key is done. This is affecting data link.
13911 //It should be ok to ignore del_key.
13912#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013913 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
13914 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013915 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13916 tCsrRoamSetKey setKey;
13917 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013918
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 ENTER();
13920
13921 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
13922 __func__,pAdapter->device_mode);
13923
13924 if (CSR_MAX_NUM_KEY <= key_index)
13925 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013926 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 key_index);
13928
13929 return -EINVAL;
13930 }
13931
13932 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
13933 setKey.keyId = key_index;
13934
13935 if (mac_addr)
13936 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
13937 else
13938 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
13939
13940 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
13941
13942 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013944 )
13945 {
13946
13947 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
13949 if( pHostapdState->bssState == BSS_START)
13950 {
13951 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013952
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 if ( status != eHAL_STATUS_SUCCESS )
13954 {
13955 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13956 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
13957 __LINE__, status );
13958 }
13959 }
13960 }
13961 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013962 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 )
13964 {
13965 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13966
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013967 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
13968
13969 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013971 __func__, setKey.peerMac[0], setKey.peerMac[1],
13972 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070013973 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013974 if(pAdapter->sessionCtx.station.conn_info.connState ==
13975 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070013976 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013977 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013978 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013979
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 if ( 0 != status )
13981 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013982 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 "%s: sme_RoamSetKey failure, returned %d",
13984 __func__, status);
13985 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
13986 return -EINVAL;
13987 }
13988 }
13989 }
13990#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070013991 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013992 return status;
13993}
13994
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013995#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13996static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
13997 struct net_device *ndev,
13998 u8 key_index,
13999 bool pairwise,
14000 const u8 *mac_addr
14001 )
14002#else
14003static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
14004 struct net_device *ndev,
14005 u8 key_index,
14006 const u8 *mac_addr
14007 )
14008#endif
14009{
14010 int ret;
14011
14012 vos_ssr_protect(__func__);
14013#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14014 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
14015 mac_addr);
14016#else
14017 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
14018#endif
14019 vos_ssr_unprotect(__func__);
14020
14021 return ret;
14022}
14023
Jeff Johnson295189b2012-06-20 16:38:30 -070014024/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053014025 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 * This function is used to set the default tx key index
14027 */
14028#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053014029static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014030 struct net_device *ndev,
14031 u8 key_index,
14032 bool unicast, bool multicast)
14033#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053014034static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 struct net_device *ndev,
14036 u8 key_index)
14037#endif
14038{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014039 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014040 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053014041 hdd_wext_state_t *pWextState;
14042 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014043 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070014044
14045 ENTER();
14046
Gopichand Nakkala29149562013-05-10 21:43:41 +053014047 if ((NULL == pAdapter))
14048 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053014050 "invalid adapter");
14051 return -EINVAL;
14052 }
14053
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014054 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14055 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
14056 pAdapter->sessionId, key_index));
14057
Gopichand Nakkala29149562013-05-10 21:43:41 +053014058 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14059 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14060
14061 if ((NULL == pWextState) || (NULL == pHddStaCtx))
14062 {
14063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14064 "invalid Wext state or HDD context");
14065 return -EINVAL;
14066 }
14067
Arif Hussain6d2a3322013-11-17 19:50:10 -080014068 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014069 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014070
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 if (CSR_MAX_NUM_KEY <= key_index)
14072 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014073 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014074 key_index);
14075
14076 return -EINVAL;
14077 }
14078
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014079 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14080 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014081 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014082 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014083 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014084 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014085
Jeff Johnson295189b2012-06-20 16:38:30 -070014086 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014088 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014089 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053014090 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080014091 pHddStaCtx->conn_info.ucEncryptionType) &&
Hu Wangb1f68cb2017-08-23 20:01:49 +080014092#ifdef FEATURE_WLAN_WAPI
14093 (eCSR_ENCRYPT_TYPE_WPI !=
14094 pHddStaCtx->conn_info.ucEncryptionType) &&
14095#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014096 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080014097 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070014098 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014099 {
14100 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070014101 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014102
Jeff Johnson295189b2012-06-20 16:38:30 -070014103 tCsrRoamSetKey setKey;
14104 v_U32_t roamId= 0xFF;
14105 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014106
14107 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014108 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014109
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 Keys->defaultIndex = (u8)key_index;
14111 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
14112 setKey.keyId = key_index;
14113 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014114
14115 vos_mem_copy(&setKey.Key[0],
14116 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070014117 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014118
Gopichand Nakkala29149562013-05-10 21:43:41 +053014119 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014120
14121 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070014122 &pHddStaCtx->conn_info.bssId[0],
14123 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014124
Gopichand Nakkala29149562013-05-10 21:43:41 +053014125 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
14126 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
14127 eCSR_ENCRYPT_TYPE_WEP104)
14128 {
14129 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
14130 even though ap is configured for WEP-40 encryption. In this canse the key length
14131 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
14132 type(104) and switching encryption type to 40*/
14133 pWextState->roamProfile.EncryptionType.encryptionType[0] =
14134 eCSR_ENCRYPT_TYPE_WEP40;
14135 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
14136 eCSR_ENCRYPT_TYPE_WEP40;
14137 }
14138
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014139 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070014140 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014141
Jeff Johnson295189b2012-06-20 16:38:30 -070014142 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014143 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070014144 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014145
Jeff Johnson295189b2012-06-20 16:38:30 -070014146 if ( 0 != status )
14147 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014148 hddLog(VOS_TRACE_LEVEL_ERROR,
14149 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014150 status);
14151 return -EINVAL;
14152 }
14153 }
14154 }
14155
14156 /* In SoftAp mode setting key direction for default mode */
14157 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
14158 {
14159 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
14160 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
14161 (eCSR_ENCRYPT_TYPE_AES !=
14162 pWextState->roamProfile.EncryptionType.encryptionType[0])
14163 )
14164 {
14165 /* Saving key direction for default key index to TX default */
14166 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
14167 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
14168 }
14169 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014170 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014171 return status;
14172}
14173
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053014174#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14175static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
14176 struct net_device *ndev,
14177 u8 key_index,
14178 bool unicast, bool multicast)
14179#else
14180static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
14181 struct net_device *ndev,
14182 u8 key_index)
14183#endif
14184{
14185 int ret;
14186 vos_ssr_protect(__func__);
14187#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14188 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
14189 multicast);
14190#else
14191 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
14192#endif
14193 vos_ssr_unprotect(__func__);
14194
14195 return ret;
14196}
14197
Jeff Johnson295189b2012-06-20 16:38:30 -070014198/*
14199 * FUNCTION: wlan_hdd_cfg80211_inform_bss
14200 * This function is used to inform the BSS details to nl80211 interface.
14201 */
14202static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
14203 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
14204{
14205 struct net_device *dev = pAdapter->dev;
14206 struct wireless_dev *wdev = dev->ieee80211_ptr;
14207 struct wiphy *wiphy = wdev->wiphy;
14208 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
14209 int chan_no;
14210 int ie_length;
14211 const char *ie;
14212 unsigned int freq;
14213 struct ieee80211_channel *chan;
14214 int rssi = 0;
14215 struct cfg80211_bss *bss = NULL;
14216
Jeff Johnson295189b2012-06-20 16:38:30 -070014217 if( NULL == pBssDesc )
14218 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014219 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 return bss;
14221 }
14222
14223 chan_no = pBssDesc->channelId;
14224 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
14225 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
14226
14227 if( NULL == ie )
14228 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014229 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014230 return bss;
14231 }
14232
14233#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
14234 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
14235 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014236 freq = ieee80211_channel_to_frequency(chan_no, HDD_NL80211_BAND_2GHZ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014237 }
14238 else
14239 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014240 freq = ieee80211_channel_to_frequency(chan_no, HDD_NL80211_BAND_5GHZ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014241 }
14242#else
14243 freq = ieee80211_channel_to_frequency(chan_no);
14244#endif
14245
14246 chan = __ieee80211_get_channel(wiphy, freq);
14247
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053014248 if (!chan) {
14249 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
14250 return NULL;
14251 }
14252
Abhishek Singhaee43942014-06-16 18:55:47 +053014253 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070014254
Anand N Sunkad9f80b742015-07-30 20:05:51 +053014255 return cfg80211_inform_bss(wiphy, chan,
14256#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14257 CFG80211_BSS_FTYPE_UNKNOWN,
14258#endif
14259 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014260 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070014261 pBssDesc->capabilityInfo,
14262 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053014263 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070014264}
14265
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053014266/*
14267 * wlan_hdd_cfg80211_update_bss_list :to inform nl80211
14268 * interface that BSS might have been lost.
14269 * @pAdapter: adaptor
14270 * @bssid: bssid which might have been lost
14271 *
14272 * Return: bss which is unlinked from kernel cache
14273 */
14274struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_list(
14275 hdd_adapter_t *pAdapter, tSirMacAddr bssid)
14276{
14277 struct net_device *dev = pAdapter->dev;
14278 struct wireless_dev *wdev = dev->ieee80211_ptr;
14279 struct wiphy *wiphy = wdev->wiphy;
14280 struct cfg80211_bss *bss = NULL;
14281
Abhishek Singh5a597e62016-12-05 15:16:30 +053014282 bss = hdd_get_bss_entry(wiphy,
14283 NULL, bssid,
14284 NULL, 0);
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053014285 if (bss == NULL) {
14286 hddLog(LOGE, FL("BSS not present"));
14287 } else {
14288 hddLog(LOG1, FL("cfg80211_unlink_bss called for BSSID "
14289 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(bssid));
14290 cfg80211_unlink_bss(wiphy, bss);
14291 }
14292 return bss;
14293}
Jeff Johnson295189b2012-06-20 16:38:30 -070014294
14295
14296/*
14297 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
14298 * This function is used to inform the BSS details to nl80211 interface.
14299 */
14300struct cfg80211_bss*
14301wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
14302 tSirBssDescription *bss_desc
14303 )
14304{
14305 /*
14306 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
14307 already exists in bss data base of cfg80211 for that particular BSS ID.
14308 Using cfg80211_inform_bss_frame to update the bss entry instead of
14309 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
14310 now there is no possibility to get the mgmt(probe response) frame from PE,
14311 converting bss_desc to ieee80211_mgmt(probe response) and passing to
14312 cfg80211_inform_bss_frame.
14313 */
14314 struct net_device *dev = pAdapter->dev;
14315 struct wireless_dev *wdev = dev->ieee80211_ptr;
14316 struct wiphy *wiphy = wdev->wiphy;
14317 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080014318#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
14319 qcom_ie_age *qie_age = NULL;
14320 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
14321#else
Jeff Johnson295189b2012-06-20 16:38:30 -070014322 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080014323#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014324 const char *ie =
14325 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
14326 unsigned int freq;
14327 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053014328 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014329 struct cfg80211_bss *bss_status = NULL;
Hanumanth Reddy Pothulae04e06c2018-05-31 14:41:36 +053014330 size_t frame_len = ie_length + offsetof(struct ieee80211_mgmt,
14331 u.probe_resp.variable);
Jeff Johnson295189b2012-06-20 16:38:30 -070014332 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070014333 hdd_context_t *pHddCtx;
14334 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070014335#ifdef WLAN_OPEN_SOURCE
14336 struct timespec ts;
14337#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014338
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014339
Wilson Yangf80a0542013-10-07 13:02:37 -070014340 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14341 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070014342 if (0 != status)
14343 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070014344 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070014345 }
14346
Hanumanth Reddy Pothula33548e22018-05-31 13:28:51 +053014347 mgmt = kzalloc(frame_len, GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070014348 if (!mgmt)
14349 {
14350 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14351 "%s: memory allocation failed ", __func__);
14352 return NULL;
14353 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070014354
Jeff Johnson295189b2012-06-20 16:38:30 -070014355 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070014356
14357#ifdef WLAN_OPEN_SOURCE
14358 /* Android does not want the timestamp from the frame.
14359 Instead it wants a monotonic increasing value */
14360 get_monotonic_boottime(&ts);
14361 mgmt->u.probe_resp.timestamp =
14362 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
14363#else
14364 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070014365 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
14366 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070014367
14368#endif
14369
Jeff Johnson295189b2012-06-20 16:38:30 -070014370 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
14371 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080014372
14373#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
14374 /* GPS Requirement: need age ie per entry. Using vendor specific. */
14375 /* Assuming this is the last IE, copy at the end */
14376 ie_length -=sizeof(qcom_ie_age);
14377 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
14378 qie_age->element_id = QCOM_VENDOR_IE_ID;
14379 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
14380 qie_age->oui_1 = QCOM_OUI1;
14381 qie_age->oui_2 = QCOM_OUI2;
14382 qie_age->oui_3 = QCOM_OUI3;
14383 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
Selvaraj, Sridhar4b3a8362016-10-12 12:34:08 +053014384 /* Lowi expects the timestamp of bss in units of 1/10 ms. In driver all
14385 * bss related timestamp is in units of ms. Due to this when scan results
14386 * are sent to lowi the scan age is high.To address this, send age in units
14387 * of 1/10 ms.
14388 */
14389 qie_age->age = (vos_timer_get_system_time() -
14390 bss_desc->nReceivedTime)/10;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080014391#endif
14392
Jeff Johnson295189b2012-06-20 16:38:30 -070014393 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053014394 if (bss_desc->fProbeRsp)
14395 {
14396 mgmt->frame_control |=
14397 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
14398 }
14399 else
14400 {
14401 mgmt->frame_control |=
14402 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
14403 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014404
14405#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014406 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014407 (wiphy->bands[HDD_NL80211_BAND_2GHZ] != NULL))
Jeff Johnson295189b2012-06-20 16:38:30 -070014408 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014409 freq = ieee80211_channel_to_frequency(chan_no, HDD_NL80211_BAND_2GHZ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014410 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014411 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014412 (wiphy->bands[HDD_NL80211_BAND_5GHZ] != NULL))
Jeff Johnson295189b2012-06-20 16:38:30 -070014413
14414 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014415 freq = ieee80211_channel_to_frequency(chan_no, HDD_NL80211_BAND_5GHZ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014416 }
14417 else
14418 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053014419 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
14420 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070014421 kfree(mgmt);
14422 return NULL;
14423 }
14424#else
14425 freq = ieee80211_channel_to_frequency(chan_no);
14426#endif
14427 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080014428 /*when the band is changed on the fly using the GUI, three things are done
14429 * 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)
14430 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
14431 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
14432 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
14433 * and discards the channels correponding to previous band and calls back with zero bss results.
14434 * 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
14435 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
14436 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
14437 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
14438 * So drop the bss and continue to next bss.
14439 */
14440 if(chan == NULL)
14441 {
Deepthi Gowri306657b2016-04-28 17:10:41 +053014442 hddLog(VOS_TRACE_LEVEL_ERROR,
14443 FL("chan pointer is NULL, chan_no: %d freq: %d"),
14444 chan_no, freq);
Chilam Ngc4244af2013-04-01 15:37:32 -070014445 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080014446 return NULL;
14447 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053014448 /*To keep the rssi icon of the connected AP in the scan window
14449 *and the rssi icon of the wireless networks in sync
14450 * */
14451 if (( eConnectionState_Associated ==
14452 pAdapter->sessionCtx.station.conn_info.connState ) &&
14453 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
14454 pAdapter->sessionCtx.station.conn_info.bssId,
14455 WNI_CFG_BSSID_LEN)) &&
14456 (pHddCtx->hdd_wlan_suspended == FALSE))
14457 {
14458 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
14459 rssi = (pAdapter->rssi * 100);
14460 }
14461 else
14462 {
14463 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
14464 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014465
Nirav Shah20ac06f2013-12-12 18:14:06 +053014466 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053014467 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
14468 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053014469
Jeff Johnson295189b2012-06-20 16:38:30 -070014470 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
14471 frame_len, rssi, GFP_KERNEL);
14472 kfree(mgmt);
14473 return bss_status;
14474}
14475
14476/*
14477 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
14478 * This function is used to update the BSS data base of CFG8011
14479 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014480struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014481 tCsrRoamInfo *pRoamInfo
14482 )
14483{
14484 tCsrRoamConnectedProfile roamProfile;
14485 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14486 struct cfg80211_bss *bss = NULL;
14487
14488 ENTER();
14489
14490 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
14491 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
14492
14493 if (NULL != roamProfile.pBssDesc)
14494 {
Girish Gowlif4b68022014-08-28 23:18:57 +053014495 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
14496 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014497
14498 if (NULL == bss)
14499 {
14500 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
14501 __func__);
14502 }
14503
14504 sme_RoamFreeConnectProfile(hHal, &roamProfile);
14505 }
14506 else
14507 {
14508 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
14509 __func__);
14510 }
14511 return bss;
14512}
14513
14514/*
14515 * FUNCTION: wlan_hdd_cfg80211_update_bss
14516 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014517static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
14518 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070014519 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014520{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014521 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014522 tCsrScanResultInfo *pScanResult;
14523 eHalStatus status = 0;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014524 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070014525 tScanResultHandle pResult;
14526 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070014527 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014528 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070014529 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014530
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014531 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14532 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
14533 NO_SESSION, pAdapter->sessionId));
14534
Wilson Yangf80a0542013-10-07 13:02:37 -070014535 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014536 ret = wlan_hdd_validate_context(pHddCtx);
14537 if (0 != ret)
Jeff Johnson295189b2012-06-20 16:38:30 -070014538 {
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014539 return ret;
Wilson Yangf80a0542013-10-07 13:02:37 -070014540 }
14541
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014542 if (pAdapter->request != NULL)
14543 {
14544 if ((pAdapter->request->n_ssids == 1)
14545 && (pAdapter->request->ssids != NULL)
14546 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
14547 is_p2p_scan = true;
14548 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 /*
14550 * start getting scan results and populate cgf80211 BSS database
14551 */
14552 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
14553
14554 /* no scan results */
14555 if (NULL == pResult)
14556 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053014557 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
14558 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053014559 wlan_hdd_get_frame_logs(pAdapter,
14560 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070014561 return status;
14562 }
14563
14564 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
14565
14566 while (pScanResult)
14567 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014568 /*
14569 * cfg80211_inform_bss() is not updating ie field of bss entry, if
14570 * entry already exists in bss data base of cfg80211 for that
14571 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
14572 * bss entry instead of cfg80211_inform_bss, But this call expects
14573 * mgmt packet as input. As of now there is no possibility to get
14574 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070014575 * ieee80211_mgmt(probe response) and passing to c
14576 * fg80211_inform_bss_frame.
14577 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014578 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
14579 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
14580 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014581 pScanResult = sme_ScanResultGetNext(hHal, pResult);
14582 continue; //Skip the non p2p bss entries
14583 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014584 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
14585 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014586
Jeff Johnson295189b2012-06-20 16:38:30 -070014587
14588 if (NULL == bss_status)
14589 {
14590 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014591 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014592 }
14593 else
14594 {
Yue Maf49ba872013-08-19 12:04:25 -070014595 cfg80211_put_bss(
14596#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
14597 wiphy,
14598#endif
14599 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070014600 }
14601
14602 pScanResult = sme_ScanResultGetNext(hHal, pResult);
14603 }
14604
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014605 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053014606 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014607 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014608}
14609
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014610void
14611hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
14612{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014613 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080014614 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014615} /****** end hddPrintMacAddr() ******/
14616
14617void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070014618hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014619{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014620 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014621 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070014622 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
14623 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
14624 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014625} /****** end hddPrintPmkId() ******/
14626
14627//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
14628//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
14629
14630//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
14631//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
14632
14633#define dump_bssid(bssid) \
14634 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070014635 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
14636 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014637 }
14638
14639#define dump_pmkid(pMac, pmkid) \
14640 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070014641 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
14642 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014643 }
14644
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070014645#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014646/*
14647 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
14648 * This function is used to notify the supplicant of a new PMKSA candidate.
14649 */
14650int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014651 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014652 int index, bool preauth )
14653{
Jeff Johnsone7245742012-09-05 17:12:55 -070014654#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014655 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070014656 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014657
14658 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070014659 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014660
14661 if( NULL == pRoamInfo )
14662 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014663 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014664 return -EINVAL;
14665 }
14666
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070014667 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
14668 {
14669 dump_bssid(pRoamInfo->bssid);
14670 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014671 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070014672 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014673#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014674 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014675}
14676#endif //FEATURE_WLAN_LFR
14677
Yue Maef608272013-04-08 23:09:17 -070014678#ifdef FEATURE_WLAN_LFR_METRICS
14679/*
14680 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
14681 * 802.11r/LFR metrics reporting function to report preauth initiation
14682 *
14683 */
14684#define MAX_LFR_METRICS_EVENT_LENGTH 100
14685VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
14686 tCsrRoamInfo *pRoamInfo)
14687{
14688 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
14689 union iwreq_data wrqu;
14690
14691 ENTER();
14692
14693 if (NULL == pAdapter)
14694 {
14695 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
14696 return VOS_STATUS_E_FAILURE;
14697 }
14698
14699 /* create the event */
14700 memset(&wrqu, 0, sizeof(wrqu));
14701 memset(metrics_notification, 0, sizeof(metrics_notification));
14702
14703 wrqu.data.pointer = metrics_notification;
14704 wrqu.data.length = scnprintf(metrics_notification,
14705 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
14706 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
14707
14708 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
14709
14710 EXIT();
14711
14712 return VOS_STATUS_SUCCESS;
14713}
14714
14715/*
14716 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
14717 * 802.11r/LFR metrics reporting function to report preauth completion
14718 * or failure
14719 */
14720VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
14721 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
14722{
14723 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
14724 union iwreq_data wrqu;
14725
14726 ENTER();
14727
14728 if (NULL == pAdapter)
14729 {
14730 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
14731 return VOS_STATUS_E_FAILURE;
14732 }
14733
14734 /* create the event */
14735 memset(&wrqu, 0, sizeof(wrqu));
14736 memset(metrics_notification, 0, sizeof(metrics_notification));
14737
14738 scnprintf(metrics_notification, sizeof(metrics_notification),
14739 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
14740 MAC_ADDR_ARRAY(pRoamInfo->bssid));
14741
14742 if (1 == preauth_status)
14743 strncat(metrics_notification, " TRUE", 5);
14744 else
14745 strncat(metrics_notification, " FALSE", 6);
14746
14747 wrqu.data.pointer = metrics_notification;
14748 wrqu.data.length = strlen(metrics_notification);
14749
14750 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
14751
14752 EXIT();
14753
14754 return VOS_STATUS_SUCCESS;
14755}
14756
14757/*
14758 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
14759 * 802.11r/LFR metrics reporting function to report handover initiation
14760 *
14761 */
14762VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
14763 tCsrRoamInfo *pRoamInfo)
14764{
14765 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
14766 union iwreq_data wrqu;
14767
14768 ENTER();
14769
14770 if (NULL == pAdapter)
14771 {
14772 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
14773 return VOS_STATUS_E_FAILURE;
14774 }
14775
14776 /* create the event */
14777 memset(&wrqu, 0, sizeof(wrqu));
14778 memset(metrics_notification, 0, sizeof(metrics_notification));
14779
14780 wrqu.data.pointer = metrics_notification;
14781 wrqu.data.length = scnprintf(metrics_notification,
14782 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
14783 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
14784
14785 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
14786
14787 EXIT();
14788
14789 return VOS_STATUS_SUCCESS;
14790}
14791#endif
14792
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014793
14794/**
14795 * wlan_hdd_cfg80211_validate_scan_req - validate scan request
14796 * @scan_req: scan request to be checked
14797 *
14798 * Return: true or false
14799 */
14800#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
14801static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
14802 cfg80211_scan_request
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014803 *scan_req, hdd_context_t
14804 *hdd_ctx)
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014805{
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014806 if (!scan_req || !scan_req->wiphy ||
14807 scan_req->wiphy != hdd_ctx->wiphy) {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014808 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
14809 return false;
14810 }
14811 if (vos_is_load_unload_in_progress(VOS_MODULE_ID_HDD, NULL)) {
14812 hddLog(VOS_TRACE_LEVEL_ERROR, "Load/Unload in progress");
14813 return false;
14814 }
14815 return true;
14816}
14817#else
14818static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
14819 cfg80211_scan_request
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014820 *scan_req, hdd_context_t
14821 *hdd_ctx)
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014822{
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053014823 if (!scan_req || !scan_req->wiphy ||
14824 scan_req->wiphy != hdd_ctx->wiphy) {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053014825 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
14826 return false;
14827 }
14828 return true;
14829}
14830#endif
14831
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053014832#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))
14833/**
14834 * hdd_cfg80211_scan_done() - Scan completed callback to cfg80211
14835 * @adapter: Pointer to the adapter
14836 * @req : Scan request
14837 * @aborted : true scan aborted false scan success
14838 *
14839 * This function notifies scan done to cfg80211
14840 *
14841 * Return: none
14842 */
14843static void hdd_cfg80211_scan_done(hdd_adapter_t *adapter,
14844 struct cfg80211_scan_request *req,
14845 bool aborted)
14846{
14847 struct cfg80211_scan_info info = {
14848 .aborted = aborted
14849 };
14850
14851 if (adapter->dev->flags & IFF_UP)
14852 cfg80211_scan_done(req, &info);
14853 else
14854 hddLog(LOGW,
14855 FL("IFF_UP flag reset for %s"), adapter->dev->name);
14856}
14857#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
14858/**
14859 * hdd_cfg80211_scan_done() - Scan completed callback to cfg80211
14860 * @adapter: Pointer to the adapter
14861 * @req : Scan request
14862 * @aborted : true scan aborted false scan success
14863 *
14864 * This function notifies scan done to cfg80211
14865 *
14866 * Return: none
14867 */
14868static void hdd_cfg80211_scan_done(hdd_adapter_t *adapter,
14869 struct cfg80211_scan_request *req,
14870 bool aborted)
14871{
14872 if (adapter->dev->flags & IFF_UP)
14873 cfg80211_scan_done(req, aborted);
14874 else
14875 hddLog(LOGW,
14876 FL("IFF_UP flag reset for %s"), adapter->dev->name);
14877}
14878#else
14879/**
14880 * hdd_cfg80211_scan_done() - Scan completed callback to cfg80211
14881 * @adapter: Pointer to the adapter
14882 * @req : Scan request
14883 * @aborted : true scan aborted false scan success
14884 *
14885 * This function notifies scan done to cfg80211
14886 *
14887 * Return: none
14888 */
14889static void hdd_cfg80211_scan_done(hdd_adapter_t *adapter,
14890 struct cfg80211_scan_request *req,
14891 bool aborted)
14892{
14893 cfg80211_scan_done(req, aborted);
14894}
14895#endif
14896
Mukul Sharmab392b642017-08-17 17:45:29 +053014897#define NET_DEV_IS_IFF_UP(pAdapter) (pAdapter->dev->flags & IFF_UP)
Jeff Johnson295189b2012-06-20 16:38:30 -070014898/*
14899 * FUNCTION: hdd_cfg80211_scan_done_callback
14900 * scanning callback function, called after finishing scan
14901 *
14902 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014903static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070014904 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
14905{
14906 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014907 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070014908 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014909 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070014910 struct cfg80211_scan_request *req = NULL;
14911 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014912 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014913 long waitRet = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014914 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070014915
14916 ENTER();
14917
c_manjee1b4ab9a2016-10-26 11:36:55 +053014918 if (!pAdapter || pAdapter->magic != WLAN_HDD_ADAPTER_MAGIC ||
14919 !pAdapter->dev) {
14920 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Adapter is not valid"));
14921 return 0;
14922 }
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014923 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053014924 if (NULL == pHddCtx) {
14925 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014926 return 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014927 }
14928
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053014929#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mukul Sharmab392b642017-08-17 17:45:29 +053014930 if (!NET_DEV_IS_IFF_UP(pAdapter))
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053014931 {
14932 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down"));
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053014933 }
14934#endif
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014935 pScanInfo = &pHddCtx->scan_info;
14936
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070014938 "%s called with halHandle = %pK, pContext = %pK,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080014939 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014940 __func__, halHandle, pContext, (int) scanId, (int) status);
14941
Kiet Lamac06e2c2013-10-23 16:25:07 +053014942 pScanInfo->mScanPendingCounter = 0;
14943
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014945 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070014946 &pScanInfo->scan_req_completion_event,
14947 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014948 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014950 hddLog(VOS_TRACE_LEVEL_ERROR,
14951 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070014952 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070014953 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070014954 }
14955
Yue Maef608272013-04-08 23:09:17 -070014956 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014957 {
14958 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070014959 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 }
14961
14962 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014963 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014964 {
14965 hddLog(VOS_TRACE_LEVEL_INFO,
14966 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080014967 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070014968 (int) scanId);
14969 }
14970
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053014971#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mukul Sharmab392b642017-08-17 17:45:29 +053014972 if (NET_DEV_IS_IFF_UP(pAdapter))
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053014973#endif
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053014974 {
14975 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
14976 pAdapter);
14977 if (0 > ret)
14978 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053014979 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014980
Jeff Johnson295189b2012-06-20 16:38:30 -070014981 /* If any client wait scan result through WEXT
14982 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070014983 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 {
14985 /* The other scan request waiting for current scan finish
14986 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070014987 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070014988 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070014989 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070014990 }
14991 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070014992 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070014993 {
14994 struct net_device *dev = pAdapter->dev;
14995 union iwreq_data wrqu;
14996 int we_event;
14997 char *msg;
14998
14999 memset(&wrqu, '\0', sizeof(wrqu));
15000 we_event = SIOCGIWSCAN;
15001 msg = NULL;
15002 wireless_send_event(dev, we_event, &wrqu, msg);
15003 }
15004 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070015005 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015006
15007 /* Get the Scan Req */
15008 req = pAdapter->request;
mukul sharmae7041822015-12-03 15:09:21 +053015009 pAdapter->request = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015010
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015011 /* Scan is no longer pending */
15012 pScanInfo->mScanPending = VOS_FALSE;
15013
Hanumanth Reddy Pothulad4c817e2017-07-14 20:30:59 +053015014 if (!wlan_hdd_cfg80211_validate_scan_req(req, pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -070015015 {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053015016#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
15017 hddLog(VOS_TRACE_LEVEL_ERROR, FL("interface state %s"),
Mukul Sharmab392b642017-08-17 17:45:29 +053015018 NET_DEV_IS_IFF_UP(pAdapter) ? "up" : "down");
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053015019#endif
15020
15021 if (pAdapter->dev) {
15022 hddLog(VOS_TRACE_LEVEL_ERROR, FL("device name %s"),
15023 pAdapter->dev->name);
15024 }
mukul sharmae7041822015-12-03 15:09:21 +053015025 complete(&pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -070015026 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070015027 }
15028
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015029 /* last_scan_timestamp is used to decide if new scan
15030 * is needed or not on station interface. If last station
15031 * scan time and new station scan time is less then
15032 * last_scan_timestamp ; driver will return cached scan.
Hanumanth Reddy Pothulaf31f65c2018-01-30 19:51:27 +053015033 * Also only last_scan_timestamp is updated here last_scan_channellist
15034 * is updated on receiving scan request itself to make sure kernel
15035 * allocated scan request(scan_req) object is not dereferenced here,
15036 * because interface down, where kernel frees scan_req, may happen any
15037 * time while driver is processing scan_done_callback. So it's better
15038 * not to access scan_req in this routine.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015039 */
Hanumanth Reddy Pothulaf31f65c2018-01-30 19:51:27 +053015040 if (pScanInfo->no_cck == FALSE) { // no_cck will be set during p2p find
15041 if (status == eCSR_SCAN_SUCCESS)
15042 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
15043 else {
15044 vos_mem_zero(pHddCtx->scan_info.last_scan_channelList,
15045 sizeof(pHddCtx->scan_info.last_scan_channelList));
15046 pHddCtx->scan_info.last_scan_numChannels = 0;
15047 pScanInfo->last_scan_timestamp = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015048 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015049 }
15050
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070015051 /*
15052 * cfg80211_scan_done informing NL80211 about completion
15053 * of scanning
15054 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053015055 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
15056 {
15057 aborted = true;
15058 }
mukul sharmae7041822015-12-03 15:09:21 +053015059
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015060#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mukul Sharmab392b642017-08-17 17:45:29 +053015061 if (NET_DEV_IS_IFF_UP(pAdapter) &&
15062 wlan_hdd_cfg80211_validate_scan_req(req, pHddCtx))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015063#endif
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053015064 hdd_cfg80211_scan_done(pAdapter, req, aborted);
mukul sharmae7041822015-12-03 15:09:21 +053015065
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080015066 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070015067
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015068allow_suspend:
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053015069 if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
15070 ) && (pHddCtx->spoofMacAddr.isEnabled
15071 || pHddCtx->spoofMacAddr.isReqDeferred)) {
Siddharth Bhal76972212014-10-15 16:22:51 +053015072 /* Generate new random mac addr for next scan */
15073 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +053015074
15075 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
15076 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhal76972212014-10-15 16:22:51 +053015077 }
15078
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070015079 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015080 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070015081
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070015082 /* Acquire wakelock to handle the case where APP's tries to suspend
15083 * immediatly after the driver gets connect request(i.e after scan)
15084 * from supplicant, this result in app's is suspending and not able
15085 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015086 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070015087
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015088#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mukul Sharmab392b642017-08-17 17:45:29 +053015089 if (NET_DEV_IS_IFF_UP(pAdapter))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015090#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070015091#ifdef FEATURE_WLAN_TDLS
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053015092 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070015093#endif
15094
Jeff Johnson295189b2012-06-20 16:38:30 -070015095 EXIT();
15096 return 0;
15097}
15098
15099/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053015100 * FUNCTION: hdd_isConnectionInProgress
15101 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015102 *
15103 */
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015104v_BOOL_t hdd_isConnectionInProgress(hdd_context_t *pHddCtx, v_U8_t *session_id,
15105 scan_reject_states *reason)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015106{
15107 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
15108 hdd_station_ctx_t *pHddStaCtx = NULL;
15109 hdd_adapter_t *pAdapter = NULL;
15110 VOS_STATUS status = 0;
15111 v_U8_t staId = 0;
15112 v_U8_t *staMac = NULL;
15113
15114 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
15115
15116 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
15117 {
15118 pAdapter = pAdapterNode->pAdapter;
15119
15120 if( pAdapter )
15121 {
15122 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015123 "%s: Adapter with device mode %s (%d) exists",
15124 __func__, hdd_device_modetoString(pAdapter->device_mode),
15125 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015126 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053015127 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
15128 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
15129 (eConnectionState_Connecting ==
15130 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
15131 {
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015132 hddLog(LOG1,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070015133 "%s: %pK(%d) Connection is in progress", __func__,
Rashmi Ramannab1429032014-04-26 14:59:09 +053015134 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015135 if (session_id && reason)
15136 {
15137 *session_id = pAdapter->sessionId;
15138 *reason = eHDD_CONNECTION_IN_PROGRESS;
15139 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053015140 return VOS_TRUE;
15141 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015142 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053015143 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015144 {
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015145 hddLog(LOG1,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070015146 "%s: %pK(%d) Reassociation is in progress", __func__,
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015147 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015148 if (session_id && reason)
15149 {
15150 *session_id = pAdapter->sessionId;
15151 *reason = eHDD_REASSOC_IN_PROGRESS;
15152 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053015153 return VOS_TRUE;
15154 }
15155 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015156 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
15157 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015158 {
15159 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15160 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Vignesh Viswanathan0ac8e562018-06-14 17:24:10 +053015161 sme_is_sta_key_exchange_in_progress(pHddCtx->hHal,
15162 pAdapter->sessionId))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015163 {
15164 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015165 hddLog(LOG1,
Arif Hussain24bafea2013-11-15 15:10:03 -080015166 "%s: client " MAC_ADDRESS_STR
15167 " is in the middle of WPS/EAPOL exchange.", __func__,
15168 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015169 if (session_id && reason)
15170 {
15171 *session_id = pAdapter->sessionId;
15172 *reason = eHDD_EAPOL_IN_PROGRESS;
15173 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053015174 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015175 }
15176 }
15177 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
15178 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
15179 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015180 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
15181 ptSapContext pSapCtx = NULL;
15182 pSapCtx = VOS_GET_SAP_CB(pVosContext);
15183 if(pSapCtx == NULL){
15184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15185 FL("psapCtx is NULL"));
15186 return VOS_FALSE;
15187 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015188 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
15189 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015190 if ((pSapCtx->aStaInfo[staId].isUsed) &&
15191 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015192 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015193 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015194
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015195 hddLog(LOG1,
Arif Hussain24bafea2013-11-15 15:10:03 -080015196 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
15197 "middle of WPS/EAPOL exchange.", __func__,
15198 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015199 if (session_id && reason)
15200 {
15201 *session_id = pAdapter->sessionId;
15202 *reason = eHDD_SAP_EAPOL_IN_PROGRESS;
15203 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053015204 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015205 }
15206 }
15207 }
15208 }
15209 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
15210 pAdapterNode = pNext;
15211 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053015212 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015213}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015214
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053015215/**
15216 * csr_scan_request_assign_bssid() - Set the BSSID received from Supplicant
15217 * to the Scan request
15218 * @scanRequest: Pointer to the csr scan request
15219 * @request: Pointer to the scan request from supplicant
15220 *
15221 * Return: None
15222 */
15223#ifdef CFG80211_SCAN_BSSID
15224static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
15225 struct cfg80211_scan_request *request)
15226{
15227 vos_mem_copy(scanRequest->bssid, request->bssid, VOS_MAC_ADDR_SIZE);
15228}
15229#else
15230static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
15231 struct cfg80211_scan_request *request)
15232{
15233}
15234#endif
15235
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015236/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015237 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070015238 * this scan respond to scan trigger and update cfg80211 scan database
15239 * later, scan dump command can be used to recieve scan results
15240 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015241int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080015242#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
15243 struct net_device *dev,
15244#endif
15245 struct cfg80211_scan_request *request)
15246{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053015247 hdd_adapter_t *pAdapter = NULL;
15248 hdd_context_t *pHddCtx = NULL;
15249 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015250 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015251 tCsrScanRequest scanRequest;
15252 tANI_U8 *channelList = NULL, i;
15253 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015254 int status;
15255 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015256 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015257 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053015258 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053015259 bool is_p2p_scan = false;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015260 v_U8_t curr_session_id;
15261 scan_reject_states curr_reason;
Jeff Johnson295189b2012-06-20 16:38:30 -070015262
Siddharth Bhal0c162d02014-05-06 19:50:42 +053015263#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
15264 struct net_device *dev = NULL;
15265 if (NULL == request)
15266 {
15267 hddLog(VOS_TRACE_LEVEL_ERROR,
15268 "%s: scan req param null", __func__);
15269 return -EINVAL;
15270 }
15271 dev = request->wdev->netdev;
15272#endif
15273
15274 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
15275 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
15276 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15277
Jeff Johnson295189b2012-06-20 16:38:30 -070015278 ENTER();
15279
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015280 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
15281 __func__, hdd_device_modetoString(pAdapter->device_mode),
15282 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015283
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015284 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015285 if (0 != status)
15286 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015287 return status;
15288 }
15289
Siddharth Bhal0c162d02014-05-06 19:50:42 +053015290 if (NULL == pwextBuf)
15291 {
15292 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
15293 __func__);
15294 return -EIO;
15295 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015296 cfg_param = pHddCtx->cfg_ini;
15297 pScanInfo = &pHddCtx->scan_info;
15298
Jeff Johnson295189b2012-06-20 16:38:30 -070015299#ifdef WLAN_BTAMP_FEATURE
15300 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015301 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070015302 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080015303 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015304 "%s: No scanning when AMP is on", __func__);
15305 return -EOPNOTSUPP;
15306 }
15307#endif
15308 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015309 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070015310 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015311 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015312 "%s: Not scanning on device_mode = %s (%d)",
15313 __func__, hdd_device_modetoString(pAdapter->device_mode),
15314 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015315 return -EOPNOTSUPP;
15316 }
15317
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053015318 if (pAdapter->device_mode == WLAN_HDD_MONITOR) {
15319 hddLog(LOGE, FL("Scan is not supported for monitor adapter"));
15320 return -EOPNOTSUPP;
15321 }
15322
Jeff Johnson295189b2012-06-20 16:38:30 -070015323 if (TRUE == pScanInfo->mScanPending)
15324 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053015325 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
15326 {
15327 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
15328 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015329 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070015330 }
15331
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053015332 // Don't allow scan if PNO scan is going on.
15333 if (pHddCtx->isPnoEnable)
15334 {
15335 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15336 FL("pno scan in progress"));
15337 return -EBUSY;
15338 }
15339
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015340 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070015341 //Channel and action frame is pending
15342 //Otherwise Cancel Remain On Channel and allow Scan
15343 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015344 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070015345 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053015346 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070015347 return -EBUSY;
15348 }
15349
Jeff Johnson295189b2012-06-20 16:38:30 -070015350 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
15351 {
15352 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080015353 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015354 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015355 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015356 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
15357 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053015358 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 "%s: MAX TM Level Scan not allowed", __func__);
15360 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015361 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070015362 }
15363 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
15364
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015365 /* Check if scan is allowed at this point of time.
15366 */
Hanumanth Reddy Pothulaec960842016-09-14 19:04:26 +053015367 if (TRUE == pHddCtx->btCoexModeSet)
15368 {
15369 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15370 FL("BTCoex Mode operation in progress"));
15371 return -EBUSY;
15372 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015373 if (hdd_isConnectionInProgress(pHddCtx, &curr_session_id, &curr_reason))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015374 {
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015375
15376 if (!(pHddCtx->scan_reject_cnt % HDD_SCAN_REJECT_RATE_LIMIT))
15377 hddLog(LOGE, FL("Scan not allowed Session %d reason %d"),
15378 curr_session_id, curr_reason);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015379 if (pHddCtx->last_scan_reject_session_id != curr_session_id ||
15380 pHddCtx->last_scan_reject_reason != curr_reason ||
15381 !pHddCtx->last_scan_reject_timestamp)
15382 {
15383 pHddCtx->last_scan_reject_session_id = curr_session_id;
15384 pHddCtx->last_scan_reject_reason = curr_reason;
Abhishek Singh3e500772017-07-17 10:13:43 +053015385 pHddCtx->last_scan_reject_timestamp =
15386 jiffies_to_msecs(jiffies) + SCAN_REJECT_THRESHOLD_TIME;
Abhishek Singhe4b12562017-06-20 16:53:39 +053015387 pHddCtx->scan_reject_cnt = 0;
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053015388 }
Abhishek Singhe4b12562017-06-20 16:53:39 +053015389 else
15390 {
15391 pHddCtx->scan_reject_cnt++;
15392
Abhishek Singhe4b12562017-06-20 16:53:39 +053015393 if ((pHddCtx->scan_reject_cnt >=
15394 SCAN_REJECT_THRESHOLD) &&
Abhishek Singh3e500772017-07-17 10:13:43 +053015395 vos_system_time_after(jiffies_to_msecs(jiffies),
15396 pHddCtx->last_scan_reject_timestamp))
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015397 {
Vignesh Viswanathane0a3f922017-08-10 19:15:44 +053015398 hddLog(LOGE, FL("Session %d reason %d reject cnt %d threshold time has elapsed? %d"),
15399 curr_session_id, curr_reason, pHddCtx->scan_reject_cnt,
15400 vos_system_time_after(jiffies_to_msecs(jiffies),
15401 pHddCtx->last_scan_reject_timestamp));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015402 pHddCtx->last_scan_reject_timestamp = 0;
Abhishek Singhe4b12562017-06-20 16:53:39 +053015403 pHddCtx->scan_reject_cnt = 0;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015404 if (pHddCtx->cfg_ini->enableFatalEvent)
15405 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
15406 WLAN_LOG_INDICATOR_HOST_DRIVER,
15407 WLAN_LOG_REASON_SCAN_NOT_ALLOWED,
15408 FALSE, FALSE);
15409 else
15410 {
15411 hddLog(LOGE, FL("Triggering SSR"));
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +053015412 vos_wlanRestart(VOS_SCAN_REQ_EXPIRED);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015413 }
15414 }
15415 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080015416 return -EBUSY;
15417 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053015418 pHddCtx->last_scan_reject_timestamp = 0;
15419 pHddCtx->last_scan_reject_session_id = 0xFF;
15420 pHddCtx->last_scan_reject_reason = 0;
Abhishek Singhe4b12562017-06-20 16:53:39 +053015421 pHddCtx->scan_reject_cnt = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015422
Jeff Johnson295189b2012-06-20 16:38:30 -070015423 vos_mem_zero( &scanRequest, sizeof(scanRequest));
15424
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015425 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
15426 * Becasue of this, driver is assuming that this is not wildcard scan and so
15427 * is not aging out the scan results.
15428 */
Hanumanth Reddy Pothula998efeb2017-10-31 15:43:19 +053015429 if ((request->ssids) && (request->n_ssids == 1) &&
15430 ('\0' == request->ssids->ssid[0])) {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015431 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015432 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015433
15434 if ((request->ssids) && (0 < request->n_ssids))
15435 {
15436 tCsrSSIDInfo *SsidInfo;
15437 int j;
15438 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
15439 /* Allocate num_ssid tCsrSSIDInfo structure */
15440 SsidInfo = scanRequest.SSIDs.SSIDList =
15441 ( tCsrSSIDInfo *)vos_mem_malloc(
15442 request->n_ssids*sizeof(tCsrSSIDInfo));
15443
15444 if(NULL == scanRequest.SSIDs.SSIDList)
15445 {
15446 hddLog(VOS_TRACE_LEVEL_ERROR,
15447 "%s: memory alloc failed SSIDInfo buffer", __func__);
15448 return -ENOMEM;
15449 }
15450
15451 /* copy all the ssid's and their length */
15452 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
15453 {
15454 /* get the ssid length */
15455 SsidInfo->SSID.length = request->ssids[j].ssid_len;
15456 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
15457 SsidInfo->SSID.length);
15458 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
15459 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
15460 j, SsidInfo->SSID.ssId);
15461 }
15462 /* set the scan type to active */
15463 scanRequest.scanType = eSIR_ACTIVE_SCAN;
15464 }
15465 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070015466 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053015467 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15468 TRACE_CODE_HDD_CFG80211_SCAN,
15469 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070015470 /* set the scan type to active */
15471 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070015472 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015473 else
15474 {
15475 /*Set the scan type to default type, in this case it is ACTIVE*/
15476 scanRequest.scanType = pScanInfo->scan_mode;
15477 }
15478 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
15479 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070015480
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053015481 csr_scan_request_assign_bssid(&scanRequest, request);
15482
Jeff Johnson295189b2012-06-20 16:38:30 -070015483 /* set BSSType to default type */
15484 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
15485
15486 /*TODO: scan the requested channels only*/
15487
15488 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015489 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070015490 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015491 hddLog(VOS_TRACE_LEVEL_WARN,
15492 "No of Scan Channels exceeded limit: %d", request->n_channels);
15493 request->n_channels = MAX_CHANNEL;
15494 }
15495
15496 hddLog(VOS_TRACE_LEVEL_INFO,
15497 "No of Scan Channels: %d", request->n_channels);
15498
15499
15500 if( request->n_channels )
15501 {
15502 char chList [(request->n_channels*5)+1];
15503 int len;
15504 channelList = vos_mem_malloc( request->n_channels );
15505 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053015506 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015507 hddLog(VOS_TRACE_LEVEL_ERROR,
15508 "%s: memory alloc failed channelList", __func__);
15509 status = -ENOMEM;
15510 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053015511 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015512
15513 for( i = 0, len = 0; i < request->n_channels ; i++ )
15514 {
15515 channelList[i] = request->channels[i]->hw_value;
15516 len += snprintf(chList+len, 5, "%d ", channelList[i]);
15517 }
15518
Nirav Shah20ac06f2013-12-12 18:14:06 +053015519 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015520 "Channel-List: %s ", chList);
15521 }
c_hpothu53512302014-04-15 18:49:53 +053015522
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015523 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
15524 scanRequest.ChannelInfo.ChannelList = channelList;
15525
15526 /* set requestType to full scan */
15527 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
15528
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015529 /* if there is back to back scan happening in driver with in
15530 * nDeferScanTimeInterval interval driver should defer new scan request
15531 * and should provide last cached scan results instead of new channel list.
15532 * This rule is not applicable if scan is p2p scan.
15533 * This condition will work only in case when last request no of channels
15534 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053015535 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053015536 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015537 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015538
Sushant Kaushik86592172015-04-27 16:35:03 +053015539 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
15540 /* if wps ie is NULL , then only defer scan */
15541 if ( pWpsIe == NULL &&
15542 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053015543 {
15544 if ( pScanInfo->last_scan_timestamp !=0 &&
15545 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
15546 {
15547 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
15548 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
15549 vos_mem_compare(pScanInfo->last_scan_channelList,
15550 channelList, pScanInfo->last_scan_numChannels))
15551 {
15552 hddLog(VOS_TRACE_LEVEL_WARN,
15553 " New and old station scan time differ is less then %u",
15554 pHddCtx->cfg_ini->nDeferScanTimeInterval);
15555
15556 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015557 pAdapter);
15558
Agarwal Ashish57e84372014-12-05 18:26:53 +053015559 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053015560 "Return old cached scan as all channels and no of channels are same");
15561
Agarwal Ashish57e84372014-12-05 18:26:53 +053015562 if (0 > ret)
15563 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015564
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053015565 hdd_cfg80211_scan_done(pAdapter, request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053015566
15567 status = eHAL_STATUS_SUCCESS;
15568 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053015569 }
15570 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053015571 }
15572
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015573 /* Flush the scan results(only p2p beacons) for STA scan and P2P
15574 * search (Flush on both full scan and social scan but not on single
15575 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
15576 */
15577
15578 /* Supplicant does single channel scan after 8-way handshake
15579 * and in that case driver shoudnt flush scan results. If
15580 * driver flushes the scan results here and unfortunately if
15581 * the AP doesnt respond to our probe req then association
15582 * fails which is not desired
15583 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053015584 if ((request->n_ssids == 1)
15585 && (request->ssids != NULL)
15586 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
15587 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015588
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053015589 if( is_p2p_scan ||
15590 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015591 {
15592 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
15593 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
15594 pAdapter->sessionId );
15595 }
15596
15597 if( request->ie_len )
15598 {
15599 /* save this for future association (join requires this) */
15600 /*TODO: Array needs to be converted to dynamic allocation,
15601 * as multiple ie.s can be sent in cfg80211_scan_request structure
15602 * CR 597966
15603 */
15604 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
15605 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
15606 pScanInfo->scanAddIE.length = request->ie_len;
15607
15608 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
15609 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
15610 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070015611 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015612 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070015613 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015614 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
15615 memcpy( pwextBuf->roamProfile.addIEScan,
15616 request->ie, request->ie_len);
15617 }
15618 else
15619 {
15620 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
15621 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015622 }
15623
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015624 }
15625 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
15626 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
15627
15628 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
15629 request->ie_len);
15630 if (pP2pIe != NULL)
15631 {
15632#ifdef WLAN_FEATURE_P2P_DEBUG
15633 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
15634 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
15635 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053015636 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015637 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
15638 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
15639 "Go nego completed to Connection is started");
15640 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
15641 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053015642 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015643 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
15644 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070015645 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015646 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
15647 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
15648 "Disconnected state to Connection is started");
15649 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
15650 "for 4way Handshake");
15651 }
15652#endif
15653
15654 /* no_cck will be set during p2p find to disable 11b rates */
15655 if(TRUE == request->no_cck)
15656 {
15657 hddLog(VOS_TRACE_LEVEL_INFO,
15658 "%s: This is a P2P Search", __func__);
15659 scanRequest.p2pSearch = 1;
15660
15661 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053015662 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015663 /* set requestType to P2P Discovery */
15664 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
15665 }
15666
15667 /*
15668 Skip Dfs Channel in case of P2P Search
15669 if it is set in ini file
15670 */
15671 if(cfg_param->skipDfsChnlInP2pSearch)
15672 {
15673 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053015674 }
15675 else
15676 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053015677 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053015678 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015679
Agarwal Ashish4f616132013-12-30 23:32:50 +053015680 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015681 }
15682 }
15683
15684 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
15685
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015686#ifdef FEATURE_WLAN_TDLS
15687 /* if tdls disagree scan right now, return immediately.
15688 tdls will schedule the scan when scan is allowed. (return SUCCESS)
15689 or will reject the scan if any TDLS is in progress. (return -EBUSY)
15690 */
15691 status = wlan_hdd_tdls_scan_callback (pAdapter,
15692 wiphy,
15693#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
15694 dev,
15695#endif
15696 request);
Abhishek Singhe2b63952016-01-05 18:27:29 +053015697 if (status <= 0)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015698 {
Abhishek Singhe2b63952016-01-05 18:27:29 +053015699 if (!status)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015700 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
15701 "scan rejected %d", __func__, status);
15702 else
15703 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
15704 __func__, status);
Abhishek Singhe2b63952016-01-05 18:27:29 +053015705 hdd_wlan_block_scan_by_tdls();
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053015706 goto free_mem;
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015707 }
15708#endif
15709
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070015710 /* acquire the wakelock to avoid the apps suspend during the scan. To
15711 * address the following issues.
15712 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
15713 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
15714 * for long time, this result in apps running at full power for long time.
15715 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
15716 * be stuck in full power because of resume BMPS
15717 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015718 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070015719
Nirav Shah20ac06f2013-12-12 18:14:06 +053015720 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
15721 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015722 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
15723 scanRequest.requestType, scanRequest.scanType,
15724 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053015725 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
15726
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053015727 if (pHddCtx->spoofMacAddr.isEnabled &&
15728 pHddCtx->cfg_ini->enableMacSpoofing == 1)
Siddharth Bhal76972212014-10-15 16:22:51 +053015729 {
15730 hddLog(VOS_TRACE_LEVEL_INFO,
15731 "%s: MAC Spoofing enabled for current scan", __func__);
15732 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
15733 * to fill TxBds for probe request during current scan
15734 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053015735 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053015736 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053015737
15738 if(status != VOS_STATUS_SUCCESS)
15739 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015740 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053015741 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053015742#ifdef FEATURE_WLAN_TDLS
15743 wlan_hdd_tdls_scan_done_callback(pAdapter);
15744#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053015745 goto free_mem;
15746 }
Siddharth Bhal76972212014-10-15 16:22:51 +053015747 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053015748 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070015749 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070015750 pAdapter->sessionId, &scanRequest, &scanId,
15751 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070015752
Jeff Johnson295189b2012-06-20 16:38:30 -070015753 if (eHAL_STATUS_SUCCESS != status)
15754 {
15755 hddLog(VOS_TRACE_LEVEL_ERROR,
15756 "%s: sme_ScanRequest returned error %d", __func__, status);
15757 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070015758 if(eHAL_STATUS_RESOURCES == status)
15759 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053015760 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
15761 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070015762 status = -EBUSY;
15763 } else {
15764 status = -EIO;
15765 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053015766 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053015767
15768#ifdef FEATURE_WLAN_TDLS
15769 wlan_hdd_tdls_scan_done_callback(pAdapter);
15770#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015771 goto free_mem;
15772 }
15773
15774 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053015775 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015776 pAdapter->request = request;
15777 pScanInfo->scanId = scanId;
Hanumanth Reddy Pothulaf31f65c2018-01-30 19:51:27 +053015778 pScanInfo->no_cck = request->no_cck;
15779 pHddCtx->scan_info.last_scan_numChannels = request->n_channels;
15780 for (i = 0; i < pHddCtx->scan_info.last_scan_numChannels; i++) {
15781 pHddCtx->scan_info.last_scan_channelList[i] =
15782 request->channels[i]->hw_value;
15783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015784
15785 complete(&pScanInfo->scan_req_completion_event);
15786
15787free_mem:
15788 if( scanRequest.SSIDs.SSIDList )
15789 {
15790 vos_mem_free(scanRequest.SSIDs.SSIDList);
15791 }
15792
15793 if( channelList )
15794 vos_mem_free( channelList );
15795
15796 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015797 return status;
15798}
15799
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015800int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
15801#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
15802 struct net_device *dev,
15803#endif
15804 struct cfg80211_scan_request *request)
15805{
15806 int ret;
15807
15808 vos_ssr_protect(__func__);
15809 ret = __wlan_hdd_cfg80211_scan(wiphy,
15810#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
15811 dev,
15812#endif
15813 request);
15814 vos_ssr_unprotect(__func__);
15815
15816 return ret;
15817}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015818
15819void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
15820{
15821 v_U8_t iniDot11Mode =
15822 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
15823 eHddDot11Mode hddDot11Mode = iniDot11Mode;
15824
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053015825 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
15826 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015827 switch ( iniDot11Mode )
15828 {
15829 case eHDD_DOT11_MODE_AUTO:
15830 case eHDD_DOT11_MODE_11ac:
15831 case eHDD_DOT11_MODE_11ac_ONLY:
15832#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053015833 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
15834 sme_IsFeatureSupportedByFW(DOT11AC) )
15835 hddDot11Mode = eHDD_DOT11_MODE_11ac;
15836 else
15837 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015838#else
15839 hddDot11Mode = eHDD_DOT11_MODE_11n;
15840#endif
15841 break;
15842 case eHDD_DOT11_MODE_11n:
15843 case eHDD_DOT11_MODE_11n_ONLY:
15844 hddDot11Mode = eHDD_DOT11_MODE_11n;
15845 break;
15846 default:
15847 hddDot11Mode = iniDot11Mode;
15848 break;
15849 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053015850#ifdef WLAN_FEATURE_AP_HT40_24G
15851 if (operationChannel > SIR_11B_CHANNEL_END)
15852#endif
15853 {
15854 /* This call decides required channel bonding mode */
15855 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015856 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
Abhishek Singh02b823e2017-10-30 17:53:20 +053015857 operationChannel, eHT_MAX_CHANNEL_WIDTH);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053015858 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015859}
15860
Jeff Johnson295189b2012-06-20 16:38:30 -070015861/*
15862 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015863 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070015864 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015865int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053015866 const u8 *ssid, size_t ssid_len, const u8 *bssid,
15867 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070015868{
15869 int status = 0;
15870 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080015871 hdd_context_t *pHddCtx;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053015872 hdd_station_ctx_t *hdd_sta_ctx;
Jeff Johnson295189b2012-06-20 16:38:30 -070015873 v_U32_t roamId;
15874 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070015875 eCsrAuthType RSNAuthType;
15876
15877 ENTER();
15878
15879 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080015880 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053015881 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080015882
15883 status = wlan_hdd_validate_context(pHddCtx);
15884 if (status)
15885 {
Yue Mae36e3552014-03-05 17:06:20 -080015886 return status;
15887 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015888
Jeff Johnson295189b2012-06-20 16:38:30 -070015889 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
15890 {
15891 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
15892 return -EINVAL;
15893 }
15894
Nitesh Shah9b066282017-06-06 18:05:52 +053015895
Jeff Johnson295189b2012-06-20 16:38:30 -070015896 pRoamProfile = &pWextState->roamProfile;
15897
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015898 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070015899 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015900 hdd_station_ctx_t *pHddStaCtx;
15901 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Abhishek Singh6782c9e2017-06-06 13:37:45 +053015902 pHddStaCtx->get_mgmt_log_sent = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015903
Siddharth Bhalda0d1622015-04-24 15:47:49 +053015904 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
15905
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015906 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070015907 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
15908 {
15909 /*QoS not enabled in cfg file*/
15910 pRoamProfile->uapsd_mask = 0;
15911 }
15912 else
15913 {
15914 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015915 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070015916 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
15917 }
15918
15919 pRoamProfile->SSIDs.numOfSSIDs = 1;
15920 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
15921 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015922 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070015923 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
15924 ssid, ssid_len);
15925
Abhishek Singhb3e376c2017-01-04 15:27:13 +053015926 vos_mem_zero(pRoamProfile->BSSIDs.bssid, WNI_CFG_BSSID_LEN);
15927 vos_mem_zero(pRoamProfile->bssid_hint, WNI_CFG_BSSID_LEN);
15928
Jeff Johnson295189b2012-06-20 16:38:30 -070015929 if (bssid)
15930 {
15931 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Abhishek Singhb3e376c2017-01-04 15:27:13 +053015932 vos_mem_copy(pRoamProfile->BSSIDs.bssid, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070015933 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015934 /* Save BSSID in seperate variable as well, as RoamProfile
15935 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070015936 case of join failure we should send valid BSSID to supplicant
15937 */
Abhishek Singhb3e376c2017-01-04 15:27:13 +053015938 vos_mem_copy(pWextState->req_bssId, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070015939 WNI_CFG_BSSID_LEN);
Abhishek Singhb3e376c2017-01-04 15:27:13 +053015940
Jeff Johnson295189b2012-06-20 16:38:30 -070015941 }
Abhishek Singhb3e376c2017-01-04 15:27:13 +053015942 else if (bssid_hint)
Dhanashri Atre51981c62013-06-13 11:47:57 -070015943 {
Abhishek Singhb3e376c2017-01-04 15:27:13 +053015944 /* Store bssid_hint to use in the scan filter. */
15945 vos_mem_copy(pRoamProfile->bssid_hint, bssid_hint,
15946 WNI_CFG_BSSID_LEN);
15947 /*
15948 * Save BSSID in seperate variable as well, as RoamProfile
15949 * BSSID is getting zeroed out in the association process. And in
15950 * case of join failure we should send valid BSSID to supplicant
15951 */
15952 vos_mem_copy(pWextState->req_bssId, bssid_hint,
15953 WNI_CFG_BSSID_LEN);
15954 hddLog(LOG1, FL(" bssid_hint: "MAC_ADDRESS_STR),
15955 MAC_ADDR_ARRAY(pRoamProfile->bssid_hint));
Dhanashri Atre51981c62013-06-13 11:47:57 -070015956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015957
Abhishek Singhb3e376c2017-01-04 15:27:13 +053015958
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053015959 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
15960 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015961 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
15962 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015963 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015964 /*set gen ie*/
15965 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
15966 /*set auth*/
15967 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
15968 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015969#ifdef FEATURE_WLAN_WAPI
15970 if (pAdapter->wapi_info.nWapiMode)
15971 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070015972 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015973 switch (pAdapter->wapi_info.wapiAuthMode)
15974 {
15975 case WAPI_AUTH_MODE_PSK:
15976 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070015977 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015978 pAdapter->wapi_info.wapiAuthMode);
15979 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
15980 break;
15981 }
15982 case WAPI_AUTH_MODE_CERT:
15983 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070015984 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015985 pAdapter->wapi_info.wapiAuthMode);
15986 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
15987 break;
15988 }
15989 } // End of switch
15990 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
15991 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
15992 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070015993 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015994 pRoamProfile->AuthType.numEntries = 1;
15995 pRoamProfile->EncryptionType.numEntries = 1;
15996 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
15997 pRoamProfile->mcEncryptionType.numEntries = 1;
15998 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
15999 }
16000 }
16001#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016002#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016003 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016004 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
16005 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
16006 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016007 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
16008 sizeof (tSirGtkOffloadParams));
16009 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016010 }
16011#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016012 pRoamProfile->csrPersona = pAdapter->device_mode;
16013
Jeff Johnson32d95a32012-09-10 13:15:23 -070016014 if( operatingChannel )
16015 {
16016 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
16017 pRoamProfile->ChannelInfo.numOfChannels = 1;
16018 }
Chet Lanctot186b5732013-03-18 10:26:30 -070016019 else
16020 {
16021 pRoamProfile->ChannelInfo.ChannelList = NULL;
16022 pRoamProfile->ChannelInfo.numOfChannels = 0;
16023 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016024 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
16025 {
16026 hdd_select_cbmode(pAdapter,operatingChannel);
16027 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053016028
Agarwal Ashish40f9b872015-09-01 16:17:35 +053016029 /*
16030 * Change conn_state to connecting before sme_RoamConnect(),
16031 * because sme_RoamConnect() has a direct path to call
16032 * hdd_smeRoamCallback(), which will change the conn_state
16033 * If direct path, conn_state will be accordingly changed
16034 * to NotConnected or Associated by either
16035 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
16036 * in sme_RoamCallback()
16037 * if sme_RomConnect is to be queued,
16038 * Connecting state will remain until it is completed.
16039 * If connection state is not changed,
16040 * connection state will remain in eConnectionState_NotConnected state.
16041 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
16042 * if conn state is eConnectionState_NotConnected.
16043 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
16044 * informed of connect result indication which is an issue.
16045 */
16046
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053016047 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
16048 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053016049 {
16050 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053016051 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080016052 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
16053 eConnectionState_Connecting);
Abhishek Singh10e17cf2018-03-12 14:34:22 +053016054 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
16055 hdd_wait_for_ecsa_complete(pHddCtx);
Abhishek Singhf4669da2014-05-26 15:07:49 +053016056 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +053016057
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016058 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070016059 pAdapter->sessionId, pRoamProfile, &roamId);
16060
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053016061 if ((eHAL_STATUS_SUCCESS != status) &&
16062 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
16063 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053016064
16065 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053016066 hddLog(VOS_TRACE_LEVEL_ERROR,
16067 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
16068 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080016069 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053016070 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080016071 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053016072 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080016073
16074 pRoamProfile->ChannelInfo.ChannelList = NULL;
16075 pRoamProfile->ChannelInfo.numOfChannels = 0;
16076
Jeff Johnson295189b2012-06-20 16:38:30 -070016077 }
16078 else
16079 {
16080 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
16081 return -EINVAL;
16082 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080016083 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016084 return status;
16085}
16086
16087/*
16088 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
16089 * This function is used to set the authentication type (OPEN/SHARED).
16090 *
16091 */
16092static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
16093 enum nl80211_auth_type auth_type)
16094{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016095 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016096 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16097
16098 ENTER();
16099
16100 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016101 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070016102 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016103 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053016104 hddLog(VOS_TRACE_LEVEL_INFO,
16105 "%s: set authentication type to AUTOSWITCH", __func__);
16106 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
16107 break;
16108
16109 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016110#ifdef WLAN_FEATURE_VOWIFI_11R
16111 case NL80211_AUTHTYPE_FT:
16112#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016113 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070016114 "%s: set authentication type to OPEN", __func__);
16115 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
16116 break;
16117
16118 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016119 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070016120 "%s: set authentication type to SHARED", __func__);
16121 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
16122 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016123#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070016124 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016125 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070016126 "%s: set authentication type to CCKM WPA", __func__);
16127 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
16128 break;
16129#endif
16130
16131
16132 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016133 hddLog(VOS_TRACE_LEVEL_ERROR,
16134 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016135 auth_type);
16136 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
16137 return -EINVAL;
16138 }
16139
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016140 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070016141 pHddStaCtx->conn_info.authType;
16142 return 0;
16143}
16144
16145/*
16146 * FUNCTION: wlan_hdd_set_akm_suite
16147 * This function is used to set the key mgmt type(PSK/8021x).
16148 *
16149 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016150static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070016151 u32 key_mgmt
16152 )
16153{
16154 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
16155 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053016156 /* Should be in ieee802_11_defs.h */
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053016157#ifndef WLAN_AKM_SUITE_8021X_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053016158#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053016159#endif
16160#ifndef WLAN_AKM_SUITE_PSK_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053016161#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053016162#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016163 /*set key mgmt type*/
16164 switch(key_mgmt)
16165 {
16166 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053016167 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053016168#ifdef WLAN_FEATURE_VOWIFI_11R
16169 case WLAN_AKM_SUITE_FT_PSK:
16170#endif
16171 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070016172 __func__);
16173 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
16174 break;
16175
16176 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053016177 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053016178#ifdef WLAN_FEATURE_VOWIFI_11R
16179 case WLAN_AKM_SUITE_FT_8021X:
16180#endif
16181 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070016182 __func__);
16183 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
16184 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016185#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070016186#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
16187#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
16188 case WLAN_AKM_SUITE_CCKM:
16189 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
16190 __func__);
16191 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
16192 break;
16193#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070016194#ifndef WLAN_AKM_SUITE_OSEN
16195#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
16196 case WLAN_AKM_SUITE_OSEN:
16197 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
16198 __func__);
16199 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
16200 break;
16201#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016202
16203 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016204 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016205 __func__, key_mgmt);
16206 return -EINVAL;
16207
16208 }
16209 return 0;
16210}
16211
16212/*
16213 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016214 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070016215 * (NONE/WEP40/WEP104/TKIP/CCMP).
16216 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016217static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
16218 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070016219 bool ucast
16220 )
16221{
16222 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016223 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016224 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16225
16226 ENTER();
16227
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016228 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070016229 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053016230 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070016231 __func__, cipher);
16232 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
16233 }
16234 else
16235 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016236
Jeff Johnson295189b2012-06-20 16:38:30 -070016237 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016238 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070016239 {
16240 case IW_AUTH_CIPHER_NONE:
16241 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
16242 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016243
Jeff Johnson295189b2012-06-20 16:38:30 -070016244 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053016245 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070016246 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016247
Jeff Johnson295189b2012-06-20 16:38:30 -070016248 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053016249 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070016250 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016251
Jeff Johnson295189b2012-06-20 16:38:30 -070016252 case WLAN_CIPHER_SUITE_TKIP:
16253 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
16254 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016255
Jeff Johnson295189b2012-06-20 16:38:30 -070016256 case WLAN_CIPHER_SUITE_CCMP:
16257 encryptionType = eCSR_ENCRYPT_TYPE_AES;
16258 break;
16259#ifdef FEATURE_WLAN_WAPI
16260 case WLAN_CIPHER_SUITE_SMS4:
16261 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
16262 break;
16263#endif
16264
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016265#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070016266 case WLAN_CIPHER_SUITE_KRK:
16267 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
16268 break;
16269#endif
16270 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016271 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016272 __func__, cipher);
16273 return -EOPNOTSUPP;
16274 }
16275 }
16276
16277 if (ucast)
16278 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016279 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016280 __func__, encryptionType);
16281 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
16282 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016283 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070016284 encryptionType;
16285 }
16286 else
16287 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016288 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016289 __func__, encryptionType);
16290 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
16291 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
16292 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
16293 }
16294
16295 return 0;
16296}
16297
16298
16299/*
16300 * FUNCTION: wlan_hdd_cfg80211_set_ie
16301 * This function is used to parse WPA/RSN IE's.
16302 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016303int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016304#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16305 const u8 *ie,
16306#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016307 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016308#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016309 size_t ie_len
16310 )
16311{
16312 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016313#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16314 const u8 *genie = ie;
16315#else
Jeff Johnson295189b2012-06-20 16:38:30 -070016316 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016317#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016318 v_U16_t remLen = ie_len;
16319#ifdef FEATURE_WLAN_WAPI
16320 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
16321 u16 *tmp;
16322 v_U16_t akmsuiteCount;
16323 int *akmlist;
16324#endif
16325 ENTER();
16326
16327 /* clear previous assocAddIE */
16328 pWextState->assocAddIE.length = 0;
16329 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070016330 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016331
16332 while (remLen >= 2)
16333 {
16334 v_U16_t eLen = 0;
16335 v_U8_t elementId;
16336 elementId = *genie++;
16337 eLen = *genie++;
16338 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016339
Nachiket Kukade4aba5f02017-06-09 15:43:48 +053016340 /* Sanity check on eLen */
16341 if (eLen > remLen) {
16342 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid IE length[%d] for IE[0x%X]",
16343 __func__, eLen, elementId);
16344 VOS_ASSERT(0);
16345 return -EINVAL;
16346 }
16347
Arif Hussain6d2a3322013-11-17 19:50:10 -080016348 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070016349 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016350
16351 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070016352 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016353 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016354 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 -070016355 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016356 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016357 "%s: Invalid WPA IE", __func__);
16358 return -EINVAL;
16359 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016360 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070016361 {
16362 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016363 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070016364 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016365
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016366 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070016367 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016368 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
16369 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070016370 VOS_ASSERT(0);
16371 return -ENOMEM;
16372 }
16373 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
16374 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16375 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016376
Jeff Johnson295189b2012-06-20 16:38:30 -070016377 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
16378 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16379 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16380 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016381 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
16382 {
Nachiket Kukade3d72b7e2017-06-09 16:58:24 +053016383 if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) {
16384 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid WPA RSN IE length[%d]",
16385 __func__, eLen);
16386 VOS_ASSERT(0);
16387 return -EINVAL;
16388 }
16389
Jeff Johnson295189b2012-06-20 16:38:30 -070016390 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
16391 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
16392 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
16393 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
16394 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
16395 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016396 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053016397 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070016398 {
16399 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016400 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070016401 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016402
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016403 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070016404 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016405 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16406 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070016407 VOS_ASSERT(0);
16408 return -ENOMEM;
16409 }
16410 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
16411 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16412 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016413
Jeff Johnson295189b2012-06-20 16:38:30 -070016414 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16415 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016417#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016418 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
16419 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016420 /*Consider WFD IE, only for P2P Client */
16421 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
16422 {
16423 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016424 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070016425 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016426
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016427 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070016428 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016429 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16430 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070016431 VOS_ASSERT(0);
16432 return -ENOMEM;
16433 }
16434 // WFD IE is saved to Additional IE ; it should be accumulated to handle
16435 // WPS IE + P2P IE + WFD IE
16436 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16437 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016438
Jeff Johnson295189b2012-06-20 16:38:30 -070016439 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16440 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16441 }
16442#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016443 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016444 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016445 HS20_OUI_TYPE_SIZE)) )
16446 {
16447 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016448 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016449 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016450
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016451 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016452 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016453 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16454 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016455 VOS_ASSERT(0);
16456 return -ENOMEM;
16457 }
16458 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16459 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016460
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070016461 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16462 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16463 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070016464 /* Appending OSEN Information Element in Assiciation Request */
16465 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
16466 OSEN_OUI_TYPE_SIZE)) )
16467 {
16468 v_U16_t curAddIELen = pWextState->assocAddIE.length;
16469 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
16470 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016471
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016472 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070016473 {
16474 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16475 "Need bigger buffer space");
16476 VOS_ASSERT(0);
16477 return -ENOMEM;
16478 }
16479 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16480 pWextState->assocAddIE.length += eLen + 2;
16481
16482 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
16483 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16484 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16485 }
16486
Abhishek Singh4322e622015-06-10 15:42:54 +053016487 /* Update only for WPA IE */
16488 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
16489 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070016490
16491 /* populating as ADDIE in beacon frames */
16492 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016493 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070016494 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
16495 {
16496 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
16497 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
16498 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
16499 {
16500 hddLog(LOGE,
16501 "Coldn't pass "
16502 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
16503 }
16504 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
16505 else
16506 hddLog(LOGE,
16507 "Could not pass on "
16508 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
16509
16510 /* IBSS mode doesn't contain params->proberesp_ies still
16511 beaconIE's need to be populated in probe response frames */
16512 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
16513 {
16514 u16 rem_probe_resp_ie_len = eLen + 2;
16515 u8 probe_rsp_ie_len[3] = {0};
16516 u8 counter = 0;
16517
16518 /* Check Probe Resp Length if it is greater then 255 then
16519 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
16520 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
16521 not able Store More then 255 bytes into One Variable */
16522
16523 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
16524 {
16525 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
16526 {
16527 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
16528 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
16529 }
16530 else
16531 {
16532 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
16533 rem_probe_resp_ie_len = 0;
16534 }
16535 }
16536
16537 rem_probe_resp_ie_len = 0;
16538
16539 if (probe_rsp_ie_len[0] > 0)
16540 {
16541 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
16542 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
16543 (tANI_U8*)(genie - 2),
16544 probe_rsp_ie_len[0], NULL,
16545 eANI_BOOLEAN_FALSE)
16546 == eHAL_STATUS_FAILURE)
16547 {
16548 hddLog(LOGE,
16549 "Could not pass"
16550 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
16551 }
16552 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
16553 }
16554
16555 if (probe_rsp_ie_len[1] > 0)
16556 {
16557 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
16558 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
16559 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
16560 probe_rsp_ie_len[1], NULL,
16561 eANI_BOOLEAN_FALSE)
16562 == eHAL_STATUS_FAILURE)
16563 {
16564 hddLog(LOGE,
16565 "Could not pass"
16566 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
16567 }
16568 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
16569 }
16570
16571 if (probe_rsp_ie_len[2] > 0)
16572 {
16573 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
16574 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
16575 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
16576 probe_rsp_ie_len[2], NULL,
16577 eANI_BOOLEAN_FALSE)
16578 == eHAL_STATUS_FAILURE)
16579 {
16580 hddLog(LOGE,
16581 "Could not pass"
16582 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
16583 }
16584 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
16585 }
16586
16587 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
16588 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
16589 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
16590 {
16591 hddLog(LOGE,
16592 "Could not pass"
16593 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
16594 }
16595 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070016596 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070016597 break;
16598 case DOT11F_EID_RSN:
Nachiket Kukade307d4892018-01-23 23:36:25 +053016599 if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) {
16600 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid WPA RSN IE length[%d], exceeds %d bytes",
16601 __func__, eLen, MAX_WPA_RSN_IE_LEN - 2);
16602 VOS_ASSERT(0);
16603 return -EINVAL;
16604 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016605 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
16606 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
16607 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
16608 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
16609 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
16610 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053016611
Abhishek Singhb16f3562016-01-20 11:08:32 +053016612 /* Appending extended capabilities with Interworking or
16613 * bsstransition bit set in Assoc Req.
Abhishek Singh15d95602015-03-24 15:52:57 +053016614 *
16615 * In assoc req this EXT Cap will only be taken into account if
Abhishek Singhb16f3562016-01-20 11:08:32 +053016616 * interworkingService or bsstransition bit is set to 1.
16617 * Driver is only interested in interworkingService and
16618 * bsstransition capability from supplicant.
16619 * If in future any other EXT Cap info is
Abhishek Singh15d95602015-03-24 15:52:57 +053016620 * required from supplicat, it needs to be handled while
16621 * sending Assoc Req in LIM.
16622 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016623 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016624 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016625 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016626 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016627 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016628
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016629 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016630 {
Jeff Johnson902c9832012-12-10 14:28:09 -080016631 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
16632 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016633 VOS_ASSERT(0);
16634 return -ENOMEM;
16635 }
16636 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
16637 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016638
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016639 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
16640 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
16641 break;
16642 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016643#ifdef FEATURE_WLAN_WAPI
16644 case WLAN_EID_WAPI:
16645 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070016646 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070016647 pAdapter->wapi_info.nWapiMode);
16648 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016649 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070016650 akmsuiteCount = WPA_GET_LE16(tmp);
16651 tmp = tmp + 1;
16652 akmlist = (int *)(tmp);
16653 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
16654 {
16655 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
16656 }
16657 else
16658 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016659 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070016660 VOS_ASSERT(0);
16661 return -EINVAL;
16662 }
16663
16664 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
16665 {
16666 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016667 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016668 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016669 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016670 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016671 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016672 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016673 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016674 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
16675 }
16676 break;
16677#endif
16678 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016679 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016680 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070016681 /* when Unknown IE is received we should break and continue
16682 * to the next IE in the buffer instead we were returning
16683 * so changing this to break */
16684 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016685 }
16686 genie += eLen;
16687 remLen -= eLen;
16688 }
16689 EXIT();
16690 return 0;
16691}
16692
16693/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053016694 * FUNCTION: hdd_isWPAIEPresent
16695 * Parse the received IE to find the WPA IE
16696 *
16697 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016698static bool hdd_isWPAIEPresent(
16699#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
16700 const u8 *ie,
16701#else
16702 u8 *ie,
16703#endif
16704 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053016705{
16706 v_U8_t eLen = 0;
16707 v_U16_t remLen = ie_len;
16708 v_U8_t elementId = 0;
16709
16710 while (remLen >= 2)
16711 {
16712 elementId = *ie++;
16713 eLen = *ie++;
16714 remLen -= 2;
16715 if (eLen > remLen)
16716 {
16717 hddLog(VOS_TRACE_LEVEL_ERROR,
16718 "%s: IE length is wrong %d", __func__, eLen);
16719 return FALSE;
16720 }
16721 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
16722 {
16723 /* OUI - 0x00 0X50 0XF2
16724 WPA Information Element - 0x01
16725 WPA version - 0x01*/
16726 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
16727 return TRUE;
16728 }
16729 ie += eLen;
16730 remLen -= eLen;
16731 }
16732 return FALSE;
16733}
16734
16735/*
Jeff Johnson295189b2012-06-20 16:38:30 -070016736 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016737 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070016738 * parameters during connect operation.
16739 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016740int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070016741 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016742 )
Jeff Johnson295189b2012-06-20 16:38:30 -070016743{
16744 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016745 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016746 ENTER();
16747
16748 /*set wpa version*/
16749 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
16750
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016751 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070016752 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053016753 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070016754 {
16755 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
16756 }
16757 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
16758 {
16759 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
16760 }
16761 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016762
16763 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016764 pWextState->wpaVersion);
16765
16766 /*set authentication type*/
16767 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
16768
16769 if (0 > status)
16770 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016771 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016772 "%s: failed to set authentication type ", __func__);
16773 return status;
16774 }
16775
16776 /*set key mgmt type*/
16777 if (req->crypto.n_akm_suites)
16778 {
16779 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
16780 if (0 > status)
16781 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016782 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070016783 __func__);
16784 return status;
16785 }
16786 }
16787
16788 /*set pairwise cipher type*/
16789 if (req->crypto.n_ciphers_pairwise)
16790 {
16791 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
16792 req->crypto.ciphers_pairwise[0], true);
16793 if (0 > status)
16794 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016795 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016796 "%s: failed to set unicast cipher type", __func__);
16797 return status;
16798 }
16799 }
16800 else
16801 {
16802 /*Reset previous cipher suite to none*/
16803 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
16804 if (0 > status)
16805 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016806 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016807 "%s: failed to set unicast cipher type", __func__);
16808 return status;
16809 }
16810 }
16811
16812 /*set group cipher type*/
16813 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
16814 false);
16815
16816 if (0 > status)
16817 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016818 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070016819 __func__);
16820 return status;
16821 }
16822
Chet Lanctot186b5732013-03-18 10:26:30 -070016823#ifdef WLAN_FEATURE_11W
16824 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
16825#endif
16826
Jeff Johnson295189b2012-06-20 16:38:30 -070016827 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
16828 if (req->ie_len)
16829 {
16830 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
16831 if ( 0 > status)
16832 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016833 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070016834 __func__);
16835 return status;
16836 }
16837 }
16838
16839 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016840 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070016841 {
16842 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
16843 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
16844 )
16845 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016846 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070016847 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
16848 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016849 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070016850 __func__);
16851 return -EOPNOTSUPP;
16852 }
16853 else
16854 {
16855 u8 key_len = req->key_len;
16856 u8 key_idx = req->key_idx;
16857
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016858 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070016859 && (CSR_MAX_NUM_KEY > key_idx)
16860 )
16861 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016862 hddLog(VOS_TRACE_LEVEL_INFO,
16863 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016864 __func__, key_idx, key_len);
16865 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016866 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070016867 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016868 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070016869 (u8)key_len;
16870 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
16871 }
16872 }
16873 }
16874 }
16875
16876 return status;
16877}
16878
16879/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016880 * FUNCTION: wlan_hdd_try_disconnect
16881 * This function is used to disconnect from previous
16882 * connection
16883 */
Agrawal Ashishc407f192017-01-23 17:18:35 +053016884int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016885{
16886 long ret = 0;
Abhishek Singhf1b048a2016-01-13 13:57:27 +053016887 int status, result = 0;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016888 hdd_station_ctx_t *pHddStaCtx;
16889 eMib_dot11DesiredBssType connectedBssType;
Abhishek Singh19a7dd92015-12-30 16:31:51 +053016890 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016891
Abhishek Singh19a7dd92015-12-30 16:31:51 +053016892 ret = wlan_hdd_validate_context(pHddCtx);
16893 if (0 != ret)
16894 {
16895 return ret;
16896 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016897 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16898
16899 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
16900
16901 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
16902 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
Abhishek Singh630ff592016-01-07 18:15:53 +053016903 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) ||
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016904 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
16905 {
Abhishek Singh9f4df782017-03-15 17:29:10 +053016906 /* Indicate disconnect to SME so that in-progress connection or preauth
16907 * can be aborted
16908 */
16909 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
16910 pAdapter->sessionId);
Abhishek Singh19a7dd92015-12-30 16:31:51 +053016911 spin_lock_bh(&pAdapter->lock_for_active_session);
16912 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
16913 {
16914 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
16915 }
16916 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singhf7962582015-10-23 10:54:06 +053016917 hdd_connSetConnectionState(pHddStaCtx,
16918 eConnectionState_Disconnecting);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016919 /* Issue disconnect to CSR */
16920 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053016921 status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016922 pAdapter->sessionId,
Abhishek Singhf1b048a2016-01-13 13:57:27 +053016923 eCSR_DISCONNECT_REASON_UNSPECIFIED);
16924 if(eHAL_STATUS_CMD_NOT_QUEUED == status) {
16925 hddLog(LOG1,
16926 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
16927 } else if ( 0 != status ) {
16928 hddLog(LOGE,
16929 FL("csrRoamDisconnect failure, returned %d"),
16930 (int)status );
16931 result = -EINVAL;
16932 goto disconnected;
16933 }
16934 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016935 &pAdapter->disconnect_comp_var,
16936 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053016937 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status)) {
16938 hddLog(LOGE,
16939 "%s: Failed to disconnect, timed out", __func__);
16940 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016941 }
16942 }
16943 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
16944 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053016945 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016946 &pAdapter->disconnect_comp_var,
16947 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053016948 if (!ret)
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016949 {
16950 hddLog(LOGE, FL("Failed to receive disconnect event"));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053016951 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016952 }
16953 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053016954disconnected:
16955 hddLog(LOG1,
16956 FL("Set HDD connState to eConnectionState_NotConnected"));
16957 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
16958 return result;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016959}
16960
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053016961/**
16962 * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present
16963 * @adapter: Pointer to the HDD adapter
16964 * @req: Pointer to the structure cfg_connect_params receieved from user space
16965 *
16966 * This function will start reassociation if bssid hint, channel hint and
16967 * previous bssid parameters are present in the connect request
16968 *
16969 * Return: success if reassociation is happening
16970 * Error code if reassociation is not permitted or not happening
16971 */
16972#ifdef CFG80211_CONNECT_PREV_BSSID
16973static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
16974 struct cfg80211_connect_params *req)
16975{
16976 int status = -EPERM;
16977 if (req->bssid_hint && req->channel_hint && req->prev_bssid) {
16978 hddLog(VOS_TRACE_LEVEL_INFO,
16979 FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR),
16980 req->channel_hint->hw_value,
16981 MAC_ADDR_ARRAY(req->bssid_hint));
16982 status = hdd_reassoc(adapter, req->bssid_hint,
16983 req->channel_hint->hw_value,
16984 CONNECT_CMD_USERSPACE);
16985 }
16986 return status;
16987}
16988#else
16989static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
16990 struct cfg80211_connect_params *req)
16991{
16992 return -EPERM;
16993}
16994#endif
16995
Abhishek Singhe3beee22017-07-31 15:35:40 +053016996/**
16997 * wlan_hdd_check_ht20_ht40_ind() - check if Supplicant has indicated to
16998 * connect in HT20 mode
16999 * @hdd_ctx: hdd context
17000 * @adapter: Pointer to the HDD adapter
17001 * @req: Pointer to the structure cfg_connect_params receieved from user space
17002 *
17003 * This function will check if supplicant has indicated to to connect in HT20
17004 * mode. this is currently applicable only for 2.4Ghz mode only.
17005 * if feature is enabled and supplicant indicate HT20 set
17006 * force_24ghz_in_ht20 to true to force 2.4Ghz in HT20 else set it to false.
17007 *
17008 * Return: void
17009 */
17010#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
17011static void wlan_hdd_check_ht20_ht40_ind(hdd_context_t *hdd_ctx,
17012 hdd_adapter_t *adapter,
17013 struct cfg80211_connect_params *req)
17014{
17015 hdd_wext_state_t *wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
17016 tCsrRoamProfile *roam_profile;
17017
17018 roam_profile = &wext_state->roamProfile;
17019 roam_profile->force_24ghz_in_ht20 = false;
17020 if (hdd_ctx->cfg_ini->override_ht20_40_24g &&
17021 !(req->ht_capa.cap_info &
17022 IEEE80211_HT_CAP_SUP_WIDTH_20_40))
17023 roam_profile->force_24ghz_in_ht20 = true;
17024
17025 hddLog(LOG1, FL("req->ht_capa.cap_info %x override_ht20_40_24g %d"),
17026 req->ht_capa.cap_info, hdd_ctx->cfg_ini->override_ht20_40_24g);
17027}
17028#else
17029static inline void wlan_hdd_check_ht20_ht40_ind(hdd_context_t *hdd_ctx,
17030 hdd_adapter_t *adapter,
17031 struct cfg80211_connect_params *req)
17032{
17033 hdd_wext_state_t *wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
17034 tCsrRoamProfile *roam_profile;
17035
17036 roam_profile = &wext_state->roamProfile;
17037 roam_profile->force_24ghz_in_ht20 = false;
17038}
17039#endif
17040
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017041/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053017042 * FUNCTION: __wlan_hdd_cfg80211_connect
17043 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070017044 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017045static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017046 struct net_device *ndev,
17047 struct cfg80211_connect_params *req
17048 )
17049{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017050 int status;
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017051 u16 channel;
Edhar, Mahesh Kumar496c7f72016-03-18 12:47:44 +053017052#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
17053 defined(CFG80211_BSSID_HINT_BACKPORT)
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017054 const u8 *bssid_hint = req->bssid_hint;
17055#else
17056 const u8 *bssid_hint = NULL;
17057#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017058 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070017059 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053017060 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017061
17062 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017063
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017064 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17065 TRACE_CODE_HDD_CFG80211_CONNECT,
17066 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017067 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053017068 "%s: device_mode = %s (%d)", __func__,
17069 hdd_device_modetoString(pAdapter->device_mode),
17070 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070017071
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017072 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080017073 if (!pHddCtx)
17074 {
17075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17076 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053017077 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080017078 }
17079
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017080 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017081 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070017082 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017083 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017084 }
17085
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053017086 if (wlan_hdd_check_and_stop_mon(pAdapter, true))
17087 return -EINVAL;
17088
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053017089 status = wlan_hdd_reassoc_bssid_hint(pAdapter, req);
17090 if (0 == status)
17091 return status;
17092
Agarwal Ashish51325b52014-06-16 16:50:49 +053017093
Jeff Johnson295189b2012-06-20 16:38:30 -070017094#ifdef WLAN_BTAMP_FEATURE
17095 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017096 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070017097 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017098 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070017099 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080017100 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070017101 }
17102#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017103
17104 //If Device Mode is Station Concurrent Sessions Exit BMps
17105 //P2P Mode will be taken care in Open/close adapter
17106 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053017107 (vos_concurrent_open_sessions_running())) {
17108 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
17109 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017110 }
17111
17112 /*Try disconnecting if already in connected state*/
17113 status = wlan_hdd_try_disconnect(pAdapter);
17114 if ( 0 > status)
17115 {
17116 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
17117 " connection"));
17118 return -EALREADY;
17119 }
Agrawal Ashish559530c2015-12-01 18:04:20 +053017120 /* Check for max concurrent connections after doing disconnect if any*/
17121 if (vos_max_concurrent_connections_reached()) {
17122 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
17123 return -ECONNREFUSED;
17124 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017125
Jeff Johnson295189b2012-06-20 16:38:30 -070017126 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017127 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070017128
17129 if ( 0 > status)
17130 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017131 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070017132 __func__);
17133 return status;
17134 }
Sravan Kumar Kairam589c5722016-01-27 20:28:53 +053017135
17136 if (pHddCtx->spoofMacAddr.isEnabled)
17137 {
17138 hddLog(VOS_TRACE_LEVEL_INFO,
17139 "%s: MAC Spoofing enabled ", __func__);
17140 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
17141 * to fill TxBds for probe request during SSID scan which may happen
17142 * as part of connect command
17143 */
17144 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
17145 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
17146 if (status != VOS_STATUS_SUCCESS)
17147 return -ECONNREFUSED;
17148 }
17149
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017150 if (req->channel)
17151 channel = req->channel->hw_value;
Mohit Khanna765234a2012-09-11 15:08:35 -070017152 else
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017153 channel = 0;
Kapil Gupta312028a2016-10-25 14:15:20 +053017154
17155 /* Abort if any scan is going on */
17156 status = wlan_hdd_scan_abort(pAdapter);
17157 if (0 != status)
17158 hddLog(VOS_TRACE_LEVEL_ERROR, FL("scan abort failed"));
17159
Abhishek Singhe3beee22017-07-31 15:35:40 +053017160 wlan_hdd_check_ht20_ht40_ind(pHddCtx, pAdapter, req);
17161
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053017162 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
17163 req->ssid_len, req->bssid,
17164 bssid_hint, channel);
Jeff Johnson295189b2012-06-20 16:38:30 -070017165
Sushant Kaushikd7083982015-03-18 14:33:24 +053017166 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070017167 {
17168 //ReEnable BMPS if disabled
17169 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
17170 (NULL != pHddCtx))
17171 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053017172 if (pHddCtx->hdd_wlan_suspended)
17173 {
17174 hdd_set_pwrparams(pHddCtx);
17175 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017176 //ReEnable Bmps and Imps back
17177 hdd_enable_bmps_imps(pHddCtx);
17178 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053017179 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017180 return status;
17181 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017182 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017183 EXIT();
17184 return status;
17185}
17186
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017187static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
17188 struct net_device *ndev,
17189 struct cfg80211_connect_params *req)
17190{
17191 int ret;
17192 vos_ssr_protect(__func__);
17193 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
17194 vos_ssr_unprotect(__func__);
17195
17196 return ret;
17197}
Jeff Johnson295189b2012-06-20 16:38:30 -070017198
17199/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017200 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070017201 * This function is used to issue a disconnect request to SME
17202 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017203static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017204 struct net_device *dev,
17205 u16 reason
17206 )
17207{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017208 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017209 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017210 tCsrRoamProfile *pRoamProfile;
17211 hdd_station_ctx_t *pHddStaCtx;
17212 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017213#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017214 tANI_U8 staIdx;
17215#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017216
Jeff Johnson295189b2012-06-20 16:38:30 -070017217 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017218
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017219 if (!pAdapter) {
17220 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
17221 return -EINVAL;
17222 }
17223
17224 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17225 if (!pHddStaCtx) {
17226 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
17227 return -EINVAL;
17228 }
17229
17230 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17231 status = wlan_hdd_validate_context(pHddCtx);
17232 if (0 != status)
17233 {
17234 return status;
17235 }
17236
17237 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
17238
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017239 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17240 TRACE_CODE_HDD_CFG80211_DISCONNECT,
17241 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053017242 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
17243 __func__, hdd_device_modetoString(pAdapter->device_mode),
17244 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070017245
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017246 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
17247 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070017248
Jeff Johnson295189b2012-06-20 16:38:30 -070017249 if (NULL != pRoamProfile)
17250 {
17251 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053017252 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
17253 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070017254 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017255 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070017256 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017257 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070017258 switch(reason)
17259 {
17260 case WLAN_REASON_MIC_FAILURE:
17261 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
17262 break;
17263
17264 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
17265 case WLAN_REASON_DISASSOC_AP_BUSY:
17266 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
17267 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
17268 break;
17269
17270 case WLAN_REASON_PREV_AUTH_NOT_VALID:
17271 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053017272 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070017273 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
17274 break;
17275
Jeff Johnson295189b2012-06-20 16:38:30 -070017276 default:
17277 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
17278 break;
17279 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017280 pScanInfo = &pHddCtx->scan_info;
17281 if (pScanInfo->mScanPending)
17282 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053017283 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017284 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053017285 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053017286 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053017287 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053017288 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017289#ifdef FEATURE_WLAN_TDLS
17290 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080017291 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017292 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080017293 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
17294 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017295 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017296 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080017297 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017299 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080017300 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017301 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017302 status = sme_DeleteTdlsPeerSta(
17303 WLAN_HDD_GET_HAL_CTX(pAdapter),
17304 pAdapter->sessionId,
17305 mac);
17306 if (status != eHAL_STATUS_SUCCESS) {
17307 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
17308 return -EPERM;
17309 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080017310 }
17311 }
17312#endif
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053017313
17314 hddLog(LOG1, FL("Disconnecting with reasoncode:%u connState %d"),
17315 reasonCode,
17316 pHddStaCtx->conn_info.connState);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053017317 status = wlan_hdd_disconnect(pAdapter, reasonCode);
17318 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070017319 {
17320 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017321 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070017322 __func__, (int)status );
17323 return -EINVAL;
17324 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017325 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053017326 else
17327 {
17328 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
17329 "called while in %d state", __func__,
17330 pHddStaCtx->conn_info.connState);
17331 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017332 }
17333 else
17334 {
17335 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
17336 }
17337
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017338 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070017339 return status;
17340}
17341
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053017342static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
17343 struct net_device *dev,
17344 u16 reason
17345 )
17346{
17347 int ret;
17348 vos_ssr_protect(__func__);
17349 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
17350 vos_ssr_unprotect(__func__);
17351
17352 return ret;
17353}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053017354
Jeff Johnson295189b2012-06-20 16:38:30 -070017355/*
17356 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017357 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070017358 * settings in IBSS mode.
17359 */
17360static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017361 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070017362 struct cfg80211_ibss_params *params
17363 )
17364{
17365 int status = 0;
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +053017366 tANI_U32 ret;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017367 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070017368 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
17369 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017370
Jeff Johnson295189b2012-06-20 16:38:30 -070017371 ENTER();
17372
17373 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070017374 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070017375
17376 if (params->ie_len && ( NULL != params->ie) )
17377 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017378 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
17379 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070017380 {
17381 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
17382 encryptionType = eCSR_ENCRYPT_TYPE_AES;
17383 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017384 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070017385 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070017386 tDot11fIEWPA dot11WPAIE;
17387 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017388 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070017389
Wilson Yang00256342013-10-10 23:13:38 -070017390 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017391 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
17392 params->ie_len, DOT11F_EID_WPA);
17393 if ( NULL != ie )
17394 {
17395 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
Hanumanth Reddy Pothulad6d2d2c2018-06-27 12:28:12 +053017396
17397 if (ie[1] < DOT11F_IE_WPA_MIN_LEN ||
17398 ie[1] > DOT11F_IE_WPA_MAX_LEN) {
17399 hddLog(LOGE, FL("invalid ie len:%d"), ie[1]);
17400 return -EINVAL;
17401 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017402 // Unpack the WPA IE
17403 //Skip past the EID byte and length byte - and four byte WiFi OUI
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +053017404 ret = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017405 &ie[2+4],
17406 ie[1] - 4,
17407 &dot11WPAIE);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +053017408 if (DOT11F_FAILED(ret))
17409 {
17410 hddLog(LOGE,
17411 FL("unpack failed status:(0x%08x)"),
17412 ret);
17413 return -EINVAL;
17414 }
17415
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017416 /*Extract the multicast cipher, the encType for unicast
17417 cipher for wpa-none is none*/
17418 encryptionType =
17419 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
17420 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017421 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070017422
Jeff Johnson295189b2012-06-20 16:38:30 -070017423 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
17424
17425 if (0 > status)
17426 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017427 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070017428 __func__);
17429 return status;
17430 }
17431 }
17432
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017433 pWextState->roamProfile.AuthType.authType[0] =
17434 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070017435 eCSR_AUTH_TYPE_OPEN_SYSTEM;
Jeff Johnson295189b2012-06-20 16:38:30 -070017436 if (params->privacy)
17437 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017438 /* Security enabled IBSS, At this time there is no information available
17439 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070017440 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017441 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070017442 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017443 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070017444 *enable privacy bit in beacons */
17445
17446 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
17447 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070017448 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
17449 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070017450 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
17451 pWextState->roamProfile.EncryptionType.numEntries = 1;
17452 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070017453 return status;
17454}
17455
17456/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017457 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017458 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070017459 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017460static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017461 struct net_device *dev,
17462 struct cfg80211_ibss_params *params
17463 )
17464{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017465 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070017466 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
17467 tCsrRoamProfile *pRoamProfile;
17468 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017469 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17470 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017471 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070017472
17473 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017474
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017475 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17476 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
17477 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017478 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053017479 "%s: device_mode = %s (%d)", __func__,
17480 hdd_device_modetoString(pAdapter->device_mode),
17481 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070017482
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017483 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017484 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070017485 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017486 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017487 }
17488
17489 if (NULL == pWextState)
17490 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017491 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070017492 __func__);
17493 return -EIO;
17494 }
17495
Agarwal Ashish51325b52014-06-16 16:50:49 +053017496 if (vos_max_concurrent_connections_reached()) {
17497 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
17498 return -ECONNREFUSED;
17499 }
17500
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053017501 /*Try disconnecting if already in connected state*/
17502 status = wlan_hdd_try_disconnect(pAdapter);
17503 if ( 0 > status)
17504 {
17505 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
17506 " IBSS connection"));
17507 return -EALREADY;
17508 }
17509
Jeff Johnson295189b2012-06-20 16:38:30 -070017510 pRoamProfile = &pWextState->roamProfile;
17511
17512 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
17513 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017514 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017515 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070017516 return -EINVAL;
17517 }
17518
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070017519 /* BSSID is provided by upper layers hence no need to AUTO generate */
17520 if (NULL != params->bssid) {
17521 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
17522 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
17523 hddLog (VOS_TRACE_LEVEL_ERROR,
17524 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
17525 return -EIO;
17526 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017527 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070017528 }
krunal sonie9002db2013-11-25 14:24:17 -080017529 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
17530 {
17531 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
17532 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
17533 {
17534 hddLog (VOS_TRACE_LEVEL_ERROR,
17535 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
17536 return -EIO;
17537 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017538
17539 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080017540 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017541 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080017542 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070017543
Jeff Johnson295189b2012-06-20 16:38:30 -070017544 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070017545 if (NULL !=
17546#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
17547 params->chandef.chan)
17548#else
17549 params->channel)
17550#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017551 {
17552 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017553 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
17554 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
17555 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17556 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070017557
17558 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017559 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070017560 ieee80211_frequency_to_channel(
17561#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
17562 params->chandef.chan->center_freq);
17563#else
17564 params->channel->center_freq);
17565#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017566
17567 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
17568 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070017569 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017570 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
17571 __func__);
17572 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070017573 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017574
17575 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070017576 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017577 if (channelNum == validChan[indx])
17578 {
17579 break;
17580 }
17581 }
17582 if (indx >= numChans)
17583 {
17584 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070017585 __func__, channelNum);
17586 return -EINVAL;
17587 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017588 /* Set the Operational Channel */
17589 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
17590 channelNum);
17591 pRoamProfile->ChannelInfo.numOfChannels = 1;
17592 pHddStaCtx->conn_info.operationChannel = channelNum;
17593 pRoamProfile->ChannelInfo.ChannelList =
17594 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070017595 }
17596
17597 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017598 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070017599 if (status < 0)
17600 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017601 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070017602 __func__);
17603 return status;
17604 }
17605
17606 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017607 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Abhishek Singh4d924682015-11-17 15:23:06 +053017608 params->ssid_len, (const u8 *)&bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070017609 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070017610
17611 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070017612 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070017613
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017614 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017615 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017616}
17617
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017618static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
17619 struct net_device *dev,
17620 struct cfg80211_ibss_params *params
17621 )
17622{
17623 int ret = 0;
17624
17625 vos_ssr_protect(__func__);
17626 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
17627 vos_ssr_unprotect(__func__);
17628
17629 return ret;
17630}
17631
Jeff Johnson295189b2012-06-20 16:38:30 -070017632/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017633 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017634 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070017635 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017636static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017637 struct net_device *dev
17638 )
17639{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017640 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017641 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
17642 tCsrRoamProfile *pRoamProfile;
17643 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017644 int status;
Abhishek Singh69de3302016-11-11 16:44:32 +053017645 eHalStatus hal_status;
Abhishek Singh7cd040e2016-01-07 10:51:04 +053017646#ifdef WLAN_FEATURE_RMC
17647 tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN] = {0};
17648#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017649
17650 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017651
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017652 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17653 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
17654 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017655 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017656 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017657 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017658 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017659 }
17660
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053017661 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
17662 hdd_device_modetoString(pAdapter->device_mode),
17663 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070017664 if (NULL == pWextState)
17665 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017666 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070017667 __func__);
17668 return -EIO;
17669 }
17670
17671 pRoamProfile = &pWextState->roamProfile;
17672
17673 /* Issue disconnect only if interface type is set to IBSS */
17674 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
17675 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017676 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070017677 __func__);
17678 return -EINVAL;
17679 }
17680
Abhishek Singh7cd040e2016-01-07 10:51:04 +053017681#ifdef WLAN_FEATURE_RMC
17682 /* Clearing add IE of beacon */
17683 if (ccmCfgSetStr(pHddCtx->hHal,
17684 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0],
17685 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN,
17686 NULL, eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
17687 {
17688 hddLog (VOS_TRACE_LEVEL_ERROR,
17689 "%s: unable to clear PROBE_RSP_BCN_ADDNIE_DATA", __func__);
17690 return -EINVAL;
17691 }
17692 if (ccmCfgSetInt(pHddCtx->hHal,
17693 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0, NULL,
17694 eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
17695 {
17696 hddLog (VOS_TRACE_LEVEL_ERROR,
17697 "%s: unable to clear WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
17698 __func__);
17699 return -EINVAL;
17700 }
17701
17702 // Reset WNI_CFG_PROBE_RSP Flags
17703 wlan_hdd_reset_prob_rspies(pAdapter);
17704
17705 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
17706 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 0,NULL,
17707 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
17708 {
17709 hddLog (VOS_TRACE_LEVEL_ERROR,
17710 "%s: unable to clear WNI_CFG_PROBE_RSP_ADDNIE_FLAG",
17711 __func__);
17712 return -EINVAL;
17713 }
17714#endif
17715
Jeff Johnson295189b2012-06-20 16:38:30 -070017716 /* Issue Disconnect request */
17717 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singh69de3302016-11-11 16:44:32 +053017718 hal_status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
17719 pAdapter->sessionId,
17720 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
17721 if (!HAL_STATUS_SUCCESS(hal_status)) {
17722 hddLog(LOGE,
17723 FL("sme_RoamDisconnect failed hal_status(%d)"),
17724 hal_status);
17725 return -EAGAIN;
17726 }
17727 status = wait_for_completion_timeout(
17728 &pAdapter->disconnect_comp_var,
17729 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
17730 if (!status) {
17731 hddLog(LOGE,
17732 FL("wait on disconnect_comp_var failed"));
17733 return -ETIMEDOUT;
17734 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017735
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017736 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070017737 return 0;
17738}
17739
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017740static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
17741 struct net_device *dev
17742 )
17743{
17744 int ret = 0;
17745
17746 vos_ssr_protect(__func__);
17747 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
17748 vos_ssr_unprotect(__func__);
17749
17750 return ret;
17751}
17752
Jeff Johnson295189b2012-06-20 16:38:30 -070017753/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053017754 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070017755 * This function is used to set the phy parameters
17756 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
17757 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053017758static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070017759 u32 changed)
17760{
17761 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
17762 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017763 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017764
17765 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017766
17767 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017768 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
17769 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017770
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017771 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017772 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017773 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017774 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017775 }
17776
Jeff Johnson295189b2012-06-20 16:38:30 -070017777 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
17778 {
17779 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
17780 WNI_CFG_RTS_THRESHOLD_STAMAX :
17781 wiphy->rts_threshold;
17782
17783 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017784 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070017785 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017786 hddLog(VOS_TRACE_LEVEL_ERROR,
17787 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070017788 __func__, rts_threshold);
17789 return -EINVAL;
17790 }
17791
17792 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
17793 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017794 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070017795 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017796 hddLog(VOS_TRACE_LEVEL_ERROR,
17797 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070017798 __func__, rts_threshold);
17799 return -EIO;
17800 }
17801
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017802 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070017803 rts_threshold);
17804 }
17805
17806 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
17807 {
17808 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
17809 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
17810 wiphy->frag_threshold;
17811
17812 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017813 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070017814 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017815 hddLog(VOS_TRACE_LEVEL_ERROR,
17816 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070017817 frag_threshold);
17818 return -EINVAL;
17819 }
17820
17821 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
17822 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017823 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070017824 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017825 hddLog(VOS_TRACE_LEVEL_ERROR,
17826 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070017827 __func__, frag_threshold);
17828 return -EIO;
17829 }
17830
17831 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
17832 frag_threshold);
17833 }
17834
17835 if ((changed & WIPHY_PARAM_RETRY_SHORT)
17836 || (changed & WIPHY_PARAM_RETRY_LONG))
17837 {
17838 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
17839 wiphy->retry_short :
17840 wiphy->retry_long;
17841
17842 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
17843 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
17844 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017845 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070017846 __func__, retry_value);
17847 return -EINVAL;
17848 }
17849
17850 if (changed & WIPHY_PARAM_RETRY_SHORT)
17851 {
17852 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
17853 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017854 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070017855 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017856 hddLog(VOS_TRACE_LEVEL_ERROR,
17857 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070017858 __func__, retry_value);
17859 return -EIO;
17860 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017861 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070017862 __func__, retry_value);
17863 }
17864 else if (changed & WIPHY_PARAM_RETRY_SHORT)
17865 {
17866 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
17867 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017868 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070017869 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017870 hddLog(VOS_TRACE_LEVEL_ERROR,
17871 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070017872 __func__, retry_value);
17873 return -EIO;
17874 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017875 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070017876 __func__, retry_value);
17877 }
17878 }
17879
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017880 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070017881 return 0;
17882}
17883
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053017884static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
17885 u32 changed)
17886{
17887 int ret;
17888
17889 vos_ssr_protect(__func__);
17890 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
17891 vos_ssr_unprotect(__func__);
17892
17893 return ret;
17894}
17895
Jeff Johnson295189b2012-06-20 16:38:30 -070017896/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053017897 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070017898 * This function is used to set the txpower
17899 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053017900static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070017901#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
17902 struct wireless_dev *wdev,
17903#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017904#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017905 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070017906#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017907 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070017908#endif
17909 int dbm)
17910{
17911 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017912 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017913 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
17914 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017915 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017916
17917 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017918
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017919 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17920 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
17921 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017922 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017923 if (0 != status)
17924 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017925 return status;
17926 }
17927
17928 hHal = pHddCtx->hHal;
17929
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017930 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
17931 dbm, ccmCfgSetCallback,
17932 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070017933 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017934 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070017935 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
17936 return -EIO;
17937 }
17938
17939 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
17940 dbm);
17941
17942 switch(type)
17943 {
17944 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
17945 /* Fall through */
17946 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
17947 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
17948 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017949 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
17950 __func__);
17951 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070017952 }
17953 break;
17954 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017955 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070017956 __func__);
17957 return -EOPNOTSUPP;
17958 break;
17959 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017960 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
17961 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070017962 return -EIO;
17963 }
17964
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017965 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070017966 return 0;
17967}
17968
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053017969static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
17970#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
17971 struct wireless_dev *wdev,
17972#endif
17973#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
17974 enum tx_power_setting type,
17975#else
17976 enum nl80211_tx_power_setting type,
17977#endif
17978 int dbm)
17979{
17980 int ret;
17981 vos_ssr_protect(__func__);
17982 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
17983#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
17984 wdev,
17985#endif
17986#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
17987 type,
17988#else
17989 type,
17990#endif
17991 dbm);
17992 vos_ssr_unprotect(__func__);
17993
17994 return ret;
17995}
17996
Jeff Johnson295189b2012-06-20 16:38:30 -070017997/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017998 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070017999 * This function is used to read the txpower
18000 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018001static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070018002#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18003 struct wireless_dev *wdev,
18004#endif
18005 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070018006{
18007
18008 hdd_adapter_t *pAdapter;
18009 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018010 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070018011
Jeff Johnsone7245742012-09-05 17:12:55 -070018012 ENTER();
18013
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018014 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018015 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018016 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018017 *dbm = 0;
18018 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018019 }
18020
Jeff Johnson295189b2012-06-20 16:38:30 -070018021 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
18022 if (NULL == pAdapter)
18023 {
18024 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
18025 return -ENOENT;
18026 }
18027
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018028 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18029 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
18030 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070018031 wlan_hdd_get_classAstats(pAdapter);
18032 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
18033
Jeff Johnsone7245742012-09-05 17:12:55 -070018034 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070018035 return 0;
18036}
18037
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018038static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
18039#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18040 struct wireless_dev *wdev,
18041#endif
18042 int *dbm)
18043{
18044 int ret;
18045
18046 vos_ssr_protect(__func__);
18047 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
18048#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
18049 wdev,
18050#endif
18051 dbm);
18052 vos_ssr_unprotect(__func__);
18053
18054 return ret;
18055}
18056
Dustin Brown8c1d4092017-07-28 18:08:01 +053018057/*
18058 * wlan_hdd_fill_summary_stats() - populate station_info summary stats
18059 * @stats: summary stats to use as a source
18060 * @info: kernel station_info struct to use as a destination
18061 *
18062 * Return: None
18063 */
18064static void wlan_hdd_fill_summary_stats(tCsrSummaryStatsInfo *stats,
18065 struct station_info *info)
18066{
18067 int i;
18068
18069 info->rx_packets = stats->rx_frm_cnt;
18070 info->tx_packets = 0;
18071 info->tx_retries = 0;
18072 info->tx_failed = 0;
18073
18074 for (i = 0; i < 4; ++i) {
18075 info->tx_packets += stats->tx_frm_cnt[i];
18076 info->tx_retries += stats->multiple_retry_cnt[i];
18077 info->tx_failed += stats->fail_cnt[i];
18078 }
18079
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018080#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
18081 !defined(WITH_BACKPORTS)
Dustin Brown8c1d4092017-07-28 18:08:01 +053018082 info->filled |= STATION_INFO_TX_PACKETS |
18083 STATION_INFO_TX_RETRIES |
18084 STATION_INFO_TX_FAILED |
18085 STATION_INFO_RX_PACKETS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018086#else
18087 info->filled |= BIT(NL80211_STA_INFO_TX_PACKETS) |
18088 BIT(NL80211_STA_INFO_TX_RETRIES) |
18089 BIT(NL80211_STA_INFO_TX_FAILED) |
18090 BIT(NL80211_STA_INFO_RX_PACKETS);
18091#endif
Dustin Brown8c1d4092017-07-28 18:08:01 +053018092}
18093
18094/**
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018095 * wlan_hdd_sap_get_sta_rssi() - get RSSI of the SAP client
18096 * @adapter: sap adapter pointer
18097 * @staid: station id of the client
18098 * @rssi: rssi value to fill
18099 *
18100 * Return: None
18101 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053018102void
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018103wlan_hdd_sap_get_sta_rssi(hdd_adapter_t *adapter, uint8_t staid, s8 *rssi)
18104{
18105 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
18106
18107 WLANTL_GetSAPStaRSSi(pVosContext, staid, rssi);
18108}
18109
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018110#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
18111 !defined(WITH_BACKPORTS)
18112static inline void wlan_hdd_fill_station_info_signal(struct station_info
18113 *sinfo)
18114{
18115 sinfo->filled |= STATION_INFO_SIGNAL;
18116}
18117#else
18118static inline void wlan_hdd_fill_station_info_signal(struct station_info
18119 *sinfo)
18120{
18121 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
18122}
18123#endif
18124
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018125/**
Dustin Brown8c1d4092017-07-28 18:08:01 +053018126 * wlan_hdd_get_sap_stats() - get aggregate SAP stats
18127 * @adapter: sap adapter to get stats for
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018128 * @mac: mac address of the station
Dustin Brown8c1d4092017-07-28 18:08:01 +053018129 * @info: kernel station_info struct to populate
18130 *
18131 * Fetch the vdev-level aggregate stats for the given SAP adapter. This is to
18132 * support "station dump" and "station get" for SAP vdevs, even though they
18133 * aren't technically stations.
18134 *
18135 * Return: errno
18136 */
18137static int
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018138wlan_hdd_get_sap_stats(hdd_adapter_t *adapter,
18139#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18140 const u8* mac,
18141#else
18142 u8* mac,
18143#endif
18144 struct station_info *info)
Dustin Brown8c1d4092017-07-28 18:08:01 +053018145{
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018146 v_MACADDR_t *peerMacAddr;
18147 uint8_t staid;
Dustin Brown8c1d4092017-07-28 18:08:01 +053018148 VOS_STATUS status;
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018149 bool bc_mac_addr;
Dustin Brown8c1d4092017-07-28 18:08:01 +053018150
18151 status = wlan_hdd_get_station_stats(adapter);
18152 if (!VOS_IS_STATUS_SUCCESS(status)) {
18153 hddLog(VOS_TRACE_LEVEL_ERROR,
18154 "Failed to get SAP stats; status:%d", status);
18155 return 0;
18156 }
18157
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018158 peerMacAddr = (v_MACADDR_t *)mac;
18159 bc_mac_addr = vos_is_macaddr_broadcast(peerMacAddr);
18160 staid = hdd_sta_id_find_from_mac_addr(adapter, peerMacAddr);
18161 hddLog(VOS_TRACE_LEVEL_INFO, "Get SAP stats for sta id:%d", staid);
18162
18163 if (staid < WLAN_MAX_STA_COUNT && !bc_mac_addr) {
18164 wlan_hdd_sap_get_sta_rssi(adapter, staid, &info->signal);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018165 wlan_hdd_fill_station_info_signal(info);
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018166 }
18167
Dustin Brown8c1d4092017-07-28 18:08:01 +053018168 wlan_hdd_fill_summary_stats(&adapter->hdd_stats.summary_stat, info);
18169
18170 return 0;
18171}
18172
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018173static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053018174#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18175 const u8* mac,
18176#else
18177 u8* mac,
18178#endif
18179 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070018180{
18181 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
18182 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18183 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053018184 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070018185
18186 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
18187 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070018188
18189 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
18190 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
18191 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
18192 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
18193 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
18194 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
18195 tANI_U16 maxRate = 0;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053018196 int8_t snr = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018197 tANI_U16 myRate;
18198 tANI_U16 currentRate = 0;
18199 tANI_U8 maxSpeedMCS = 0;
18200 tANI_U8 maxMCSIdx = 0;
18201 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053018202 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070018203 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018204 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070018205
Leo Chang6f8870f2013-03-26 18:11:36 -070018206#ifdef WLAN_FEATURE_11AC
18207 tANI_U32 vht_mcs_map;
18208 eDataRate11ACMaxMcs vhtMaxMcs;
18209#endif /* WLAN_FEATURE_11AC */
18210
Jeff Johnsone7245742012-09-05 17:12:55 -070018211 ENTER();
18212
Dustin Brown8c1d4092017-07-28 18:08:01 +053018213 status = wlan_hdd_validate_context(pHddCtx);
18214 if (0 != status)
18215 {
18216 return status;
18217 }
18218
18219 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053018220 return wlan_hdd_get_sap_stats(pAdapter, mac, sinfo);
Dustin Brown8c1d4092017-07-28 18:08:01 +053018221
Jeff Johnson295189b2012-06-20 16:38:30 -070018222 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
18223 (0 == ssidlen))
18224 {
18225 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
18226 " Invalid ssidlen, %d", __func__, ssidlen);
18227 /*To keep GUI happy*/
18228 return 0;
18229 }
18230
Mukul Sharma811205f2014-07-09 21:07:30 +053018231 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
18232 {
18233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18234 "%s: Roaming in progress, so unable to proceed this request", __func__);
Sachin Ahuja81ab1812016-08-19 21:35:58 +053018235 /* return a cached value */
18236 sinfo->signal = pAdapter->rssi;
Mukul Sharma811205f2014-07-09 21:07:30 +053018237 return 0;
18238 }
18239
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053018240 wlan_hdd_get_station_stats(pAdapter);
18241 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070018242
Kiet Lam3b17fc82013-09-27 05:24:08 +053018243 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053018244 wlan_hdd_get_snr(pAdapter, &snr);
18245 pHddStaCtx->conn_info.signal = sinfo->signal;
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +053018246 pHddStaCtx->cache_conn_info.signal = sinfo->signal;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053018247 pHddStaCtx->conn_info.noise = pHddStaCtx->conn_info.signal - snr;
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +053018248 pHddStaCtx->cache_conn_info.noise = pHddStaCtx->conn_info.noise;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018249 wlan_hdd_fill_station_info_signal(sinfo);
Kiet Lam3b17fc82013-09-27 05:24:08 +053018250
c_hpothu09f19542014-05-30 21:53:31 +053018251 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053018252 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
18253 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053018254 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053018255 {
18256 rate_flags = pAdapter->maxRateFlags;
18257 }
c_hpothu44ff4e02014-05-08 00:13:57 +053018258
Jeff Johnson295189b2012-06-20 16:38:30 -070018259 //convert to the UI units of 100kbps
18260 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
18261
18262#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070018263 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 -070018264 sinfo->signal,
18265 pCfg->reportMaxLinkSpeed,
18266 myRate,
18267 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070018268 (int) pCfg->linkSpeedRssiMid,
18269 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070018270 (int) rate_flags,
18271 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070018272#endif //LINKSPEED_DEBUG_ENABLED
18273
Hanumanth Reddy Pothula596b8b32018-05-01 20:17:38 +053018274#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || defined(WITH_BACKPORTS)
18275 /* assume basic BW. anything else will override this later */
18276 sinfo->txrate.bw = RATE_INFO_BW_20;
18277#endif
18278
Jeff Johnson295189b2012-06-20 16:38:30 -070018279 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
18280 {
18281 // we do not want to necessarily report the current speed
18282 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
18283 {
18284 // report the max possible speed
18285 rssidx = 0;
18286 }
18287 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
18288 {
18289 // report the max possible speed with RSSI scaling
18290 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
18291 {
18292 // report the max possible speed
18293 rssidx = 0;
18294 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070018295 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070018296 {
18297 // report middle speed
18298 rssidx = 1;
18299 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070018300 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
18301 {
18302 // report middle speed
18303 rssidx = 2;
18304 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018305 else
18306 {
18307 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070018308 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070018309 }
18310 }
18311 else
18312 {
18313 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
18314 hddLog(VOS_TRACE_LEVEL_ERROR,
18315 "%s: Invalid value for reportMaxLinkSpeed: %u",
18316 __func__, pCfg->reportMaxLinkSpeed);
18317 rssidx = 0;
18318 }
18319
18320 maxRate = 0;
18321
18322 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053018323 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
18324 OperationalRates, &ORLeng))
18325 {
18326 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
18327 /*To keep GUI happy*/
18328 return 0;
18329 }
18330
Jeff Johnson295189b2012-06-20 16:38:30 -070018331 for (i = 0; i < ORLeng; i++)
18332 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018333 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070018334 {
18335 /* Validate Rate Set */
18336 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
18337 {
18338 currentRate = supported_data_rate[j].supported_rate[rssidx];
18339 break;
18340 }
18341 }
18342 /* Update MAX rate */
18343 maxRate = (currentRate > maxRate)?currentRate:maxRate;
18344 }
18345
18346 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053018347 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
18348 ExtendedRates, &ERLeng))
18349 {
18350 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
18351 /*To keep GUI happy*/
18352 return 0;
18353 }
18354
Jeff Johnson295189b2012-06-20 16:38:30 -070018355 for (i = 0; i < ERLeng; i++)
18356 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018357 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070018358 {
18359 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
18360 {
18361 currentRate = supported_data_rate[j].supported_rate[rssidx];
18362 break;
18363 }
18364 }
18365 /* Update MAX rate */
18366 maxRate = (currentRate > maxRate)?currentRate:maxRate;
18367 }
c_hpothu79aab322014-07-14 21:11:01 +053018368
Kiet Lamb69f8dc2013-11-15 15:34:27 +053018369 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053018370 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053018371 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053018372 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070018373 {
c_hpothu79aab322014-07-14 21:11:01 +053018374 if (rate_flags & eHAL_TX_RATE_VHT80)
18375 mode = 2;
18376 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
18377 mode = 1;
18378 else
18379 mode = 0;
18380
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053018381 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
18382 MCSRates, &MCSLeng))
18383 {
18384 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
18385 /*To keep GUI happy*/
18386 return 0;
18387 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018388 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070018389#ifdef WLAN_FEATURE_11AC
18390 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018391 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070018392 {
Leo Chang6f8870f2013-03-26 18:11:36 -070018393 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018394 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070018395 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070018396 {
Leo Chang6f8870f2013-03-26 18:11:36 -070018397 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070018398 }
Leo Chang6f8870f2013-03-26 18:11:36 -070018399 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070018400 {
Leo Chang6f8870f2013-03-26 18:11:36 -070018401 maxMCSIdx = 7;
18402 }
18403 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
18404 {
18405 maxMCSIdx = 8;
18406 }
18407 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
18408 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018409 //VHT20 is supporting 0~8
18410 if (rate_flags & eHAL_TX_RATE_VHT20)
18411 maxMCSIdx = 8;
18412 else
18413 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070018414 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018415
c_hpothu79aab322014-07-14 21:11:01 +053018416 if (0 != rssidx)/*check for scaled */
18417 {
18418 //get middle rate MCS index if rssi=1/2
18419 for (i=0; i <= maxMCSIdx; i++)
18420 {
18421 if (sinfo->signal <= rssiMcsTbl[mode][i])
18422 {
18423 maxMCSIdx = i;
18424 break;
18425 }
18426 }
18427 }
18428
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018429 if (rate_flags & eHAL_TX_RATE_VHT80)
18430 {
18431 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
18432 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
18433 }
18434 else if (rate_flags & eHAL_TX_RATE_VHT40)
18435 {
18436 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
18437 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
18438 }
18439 else if (rate_flags & eHAL_TX_RATE_VHT20)
18440 {
18441 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
18442 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
18443 }
18444
Leo Chang6f8870f2013-03-26 18:11:36 -070018445 maxSpeedMCS = 1;
18446 if (currentRate > maxRate)
18447 {
18448 maxRate = currentRate;
18449 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018450
Leo Chang6f8870f2013-03-26 18:11:36 -070018451 }
18452 else
18453#endif /* WLAN_FEATURE_11AC */
18454 {
18455 if (rate_flags & eHAL_TX_RATE_HT40)
18456 {
18457 rateFlag |= 1;
18458 }
18459 if (rate_flags & eHAL_TX_RATE_SGI)
18460 {
18461 rateFlag |= 2;
18462 }
18463
Girish Gowli01abcee2014-07-31 20:18:55 +053018464 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053018465 if (rssidx == 1 || rssidx == 2)
18466 {
18467 //get middle rate MCS index if rssi=1/2
18468 for (i=0; i <= 7; i++)
18469 {
18470 if (sinfo->signal <= rssiMcsTbl[mode][i])
18471 {
18472 temp = i+1;
18473 break;
18474 }
18475 }
18476 }
c_hpothu79aab322014-07-14 21:11:01 +053018477
18478 for (i = 0; i < MCSLeng; i++)
18479 {
Leo Chang6f8870f2013-03-26 18:11:36 -070018480 for (j = 0; j < temp; j++)
18481 {
18482 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
18483 {
18484 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053018485 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070018486 break;
18487 }
18488 }
18489 if ((j < temp) && (currentRate > maxRate))
18490 {
18491 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070018492 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018493 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053018494 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070018495 }
18496 }
18497
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018498 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
18499 {
18500 maxRate = myRate;
18501 maxSpeedMCS = 1;
18502 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
18503 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018504 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053018505 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070018506 {
18507 maxRate = myRate;
18508 if (rate_flags & eHAL_TX_RATE_LEGACY)
18509 {
18510 maxSpeedMCS = 0;
18511 }
18512 else
18513 {
18514 maxSpeedMCS = 1;
18515 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
18516 }
18517 }
18518
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018519 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070018520 {
18521 sinfo->txrate.legacy = maxRate;
18522#ifdef LINKSPEED_DEBUG_ENABLED
18523 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
18524#endif //LINKSPEED_DEBUG_ENABLED
18525 }
18526 else
18527 {
18528 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070018529#ifdef WLAN_FEATURE_11AC
18530 sinfo->txrate.nss = 1;
18531 if (rate_flags & eHAL_TX_RATE_VHT80)
18532 {
18533 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018534#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18535 defined(WITH_BACKPORTS)
18536 sinfo->txrate.bw = RATE_INFO_BW_80;
18537#else
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018538 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018539#endif
Leo Chang6f8870f2013-03-26 18:11:36 -070018540 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018541 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070018542 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018543 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018544#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18545 defined(WITH_BACKPORTS)
18546 sinfo->txrate.bw = RATE_INFO_BW_40;
18547#else
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018548 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018549#endif
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018550 }
18551 else if (rate_flags & eHAL_TX_RATE_VHT20)
18552 {
18553 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
18554 }
18555#endif /* WLAN_FEATURE_11AC */
18556 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
18557 {
18558 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
18559 if (rate_flags & eHAL_TX_RATE_HT40)
18560 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018561#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18562 defined(WITH_BACKPORTS)
18563 sinfo->txrate.bw = RATE_INFO_BW_40;
18564#else
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018565 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018566#endif
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018567 }
Leo Chang6f8870f2013-03-26 18:11:36 -070018568 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018569 if (rate_flags & eHAL_TX_RATE_SGI)
18570 {
18571 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
18572 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053018573
Jeff Johnson295189b2012-06-20 16:38:30 -070018574#ifdef LINKSPEED_DEBUG_ENABLED
18575 pr_info("Reporting MCS rate %d flags %x\n",
18576 sinfo->txrate.mcs,
18577 sinfo->txrate.flags );
18578#endif //LINKSPEED_DEBUG_ENABLED
18579 }
18580 }
18581 else
18582 {
18583 // report current rate instead of max rate
18584
18585 if (rate_flags & eHAL_TX_RATE_LEGACY)
18586 {
18587 //provide to the UI in units of 100kbps
18588 sinfo->txrate.legacy = myRate;
18589#ifdef LINKSPEED_DEBUG_ENABLED
18590 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
18591#endif //LINKSPEED_DEBUG_ENABLED
18592 }
18593 else
18594 {
18595 //must be MCS
18596 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070018597#ifdef WLAN_FEATURE_11AC
18598 sinfo->txrate.nss = 1;
18599 if (rate_flags & eHAL_TX_RATE_VHT80)
18600 {
18601 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
18602 }
18603 else
18604#endif /* WLAN_FEATURE_11AC */
18605 {
18606 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
18607 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018608 if (rate_flags & eHAL_TX_RATE_SGI)
18609 {
18610 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
18611 }
18612 if (rate_flags & eHAL_TX_RATE_HT40)
18613 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018614#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18615 defined(WITH_BACKPORTS)
18616 sinfo->txrate.bw = RATE_INFO_BW_40;
18617#else
Jeff Johnson295189b2012-06-20 16:38:30 -070018618 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018619#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018620 }
Leo Chang6f8870f2013-03-26 18:11:36 -070018621#ifdef WLAN_FEATURE_11AC
18622 else if (rate_flags & eHAL_TX_RATE_VHT80)
18623 {
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018624#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || \
18625 defined(WITH_BACKPORTS)
18626 sinfo->txrate.bw = RATE_INFO_BW_80;
18627#else
Leo Chang6f8870f2013-03-26 18:11:36 -070018628 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018629#endif
Leo Chang6f8870f2013-03-26 18:11:36 -070018630 }
18631#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070018632#ifdef LINKSPEED_DEBUG_ENABLED
18633 pr_info("Reporting actual MCS rate %d flags %x\n",
18634 sinfo->txrate.mcs,
18635 sinfo->txrate.flags );
18636#endif //LINKSPEED_DEBUG_ENABLED
18637 }
18638 }
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018639
18640#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
18641 !defined(WITH_BACKPORTS)
Jeff Johnson295189b2012-06-20 16:38:30 -070018642 sinfo->filled |= STATION_INFO_TX_BITRATE;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018643#else
18644 sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE);
18645#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018646
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018647 sinfo->tx_packets =
18648 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
18649 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
18650 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
18651 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
18652
18653 sinfo->tx_retries =
18654 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
18655 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
18656 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
18657 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
18658
18659 sinfo->tx_failed =
18660 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
18661 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
18662 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
18663 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
18664
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018665#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
18666 !defined(WITH_BACKPORTS)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018667 sinfo->filled |=
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018668 STATION_INFO_RX_PACKETS |
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018669 STATION_INFO_TX_PACKETS |
18670 STATION_INFO_TX_RETRIES |
18671 STATION_INFO_TX_FAILED;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018672#else
18673 sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS) |
18674 BIT(NL80211_STA_INFO_TX_PACKETS) |
18675 BIT(NL80211_STA_INFO_TX_RETRIES) |
18676 BIT(NL80211_STA_INFO_TX_FAILED);
18677#endif
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018678
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053018679 sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt;
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053018680
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +053018681 vos_mem_copy(&pHddStaCtx->conn_info.txrate,
18682 &sinfo->txrate, sizeof(sinfo->txrate));
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +053018683 vos_mem_copy(&pHddStaCtx->cache_conn_info.txrate,
18684 &sinfo->txrate, sizeof(sinfo->txrate));
18685
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053018686 if (rate_flags & eHAL_TX_RATE_LEGACY)
18687 hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"),
18688 sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets,
18689 sinfo->rx_packets);
18690 else
18691 hddLog(LOG1,
18692 FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"),
18693 sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags,
18694 sinfo->tx_packets, sinfo->rx_packets);
18695
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018696 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18697 TRACE_CODE_HDD_CFG80211_GET_STA,
18698 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070018699 EXIT();
18700 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018701}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053018702#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
18703static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
18704 const u8* mac, struct station_info *sinfo)
18705#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018706static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
18707 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053018708#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018709{
18710 int ret;
18711
18712 vos_ssr_protect(__func__);
18713 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
18714 vos_ssr_unprotect(__func__);
18715
18716 return ret;
18717}
18718
18719static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070018720 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070018721{
18722 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018723 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070018724 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018725 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070018726
Jeff Johnsone7245742012-09-05 17:12:55 -070018727 ENTER();
18728
Jeff Johnson295189b2012-06-20 16:38:30 -070018729 if (NULL == pAdapter)
18730 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080018731 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070018732 return -ENODEV;
18733 }
18734
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018735 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18736 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
18737 pAdapter->sessionId, timeout));
18738
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018739 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018740 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018741 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018742 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018743 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018744 }
18745
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018746 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
18747 (TRUE == pHddCtx->hdd_wlan_suspended) &&
18748 (pHddCtx->cfg_ini->fhostArpOffload) &&
18749 (eConnectionState_Associated ==
18750 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
18751 {
Amar Singhald53568e2013-09-26 11:03:45 -070018752
18753 hddLog(VOS_TRACE_LEVEL_INFO,
18754 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053018755 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018756 if (!VOS_IS_STATUS_SUCCESS(vos_status))
18757 {
18758 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080018759 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053018760 __func__, vos_status);
18761 }
18762 }
18763
Jeff Johnson295189b2012-06-20 16:38:30 -070018764 /**The get power cmd from the supplicant gets updated by the nl only
18765 *on successful execution of the function call
18766 *we are oppositely mapped w.r.t mode in the driver
18767 **/
18768 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
18769
18770 if (VOS_STATUS_E_FAILURE == vos_status)
18771 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018772 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18773 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070018774 return -EINVAL;
18775 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018776 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070018777 return 0;
18778}
18779
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018780static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
18781 struct net_device *dev, bool mode, int timeout)
18782{
18783 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070018784
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018785 vos_ssr_protect(__func__);
18786 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
18787 vos_ssr_unprotect(__func__);
18788
18789 return ret;
18790}
Sushant Kaushik084f6592015-09-10 13:11:56 +053018791
Jeff Johnson295189b2012-06-20 16:38:30 -070018792#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018793static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
18794 struct net_device *netdev,
18795 u8 key_index)
18796{
18797 ENTER();
18798 return 0;
18799}
18800
Jeff Johnson295189b2012-06-20 16:38:30 -070018801static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018802 struct net_device *netdev,
18803 u8 key_index)
18804{
18805 int ret;
18806 vos_ssr_protect(__func__);
18807 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
18808 vos_ssr_unprotect(__func__);
18809 return ret;
18810}
18811#endif //LINUX_VERSION_CODE
18812
18813#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
18814static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
18815 struct net_device *dev,
18816 struct ieee80211_txq_params *params)
18817{
18818 ENTER();
18819 return 0;
18820}
18821#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
18822static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
18823 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070018824{
Jeff Johnsone7245742012-09-05 17:12:55 -070018825 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070018826 return 0;
18827}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018828#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070018829
18830#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
18831static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018832 struct net_device *dev,
18833 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070018834{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018835 int ret;
18836
18837 vos_ssr_protect(__func__);
18838 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
18839 vos_ssr_unprotect(__func__);
18840 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070018841}
18842#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
18843static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
18844 struct ieee80211_txq_params *params)
18845{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018846 int ret;
18847
18848 vos_ssr_protect(__func__);
18849 ret = __wlan_hdd_set_txq_params(wiphy, params);
18850 vos_ssr_unprotect(__func__);
18851 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070018852}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018853#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018854
Naresh Jayaram69e3f282014-10-14 12:29:12 +053018855static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018856 struct net_device *dev,
18857 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070018858{
18859 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018860 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018861 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018862 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018863 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053018864 v_CONTEXT_t pVosContext = NULL;
18865 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018866
Jeff Johnsone7245742012-09-05 17:12:55 -070018867 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018868
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018869 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070018870 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018871 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070018872 return -EINVAL;
18873 }
18874
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018875 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18876 TRACE_CODE_HDD_CFG80211_DEL_STA,
18877 pAdapter->sessionId, pAdapter->device_mode));
18878
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018879 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
18880 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018881 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018882 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018883 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018884 }
18885
Jeff Johnson295189b2012-06-20 16:38:30 -070018886 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070018887 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070018888 )
18889 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053018890 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
18891 pSapCtx = VOS_GET_SAP_CB(pVosContext);
18892 if(pSapCtx == NULL){
18893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18894 FL("psapCtx is NULL"));
18895 return -ENOENT;
18896 }
Agrawal Ashish306b75f2017-01-11 19:16:25 +053018897 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
18898 {
18899 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
18900 "Change reason code to eSIR_MAC_DISASSOC_LEAVING_BSS_REASON in sap auth offload");
18901 pDelStaParams->reason_code = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
18902 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018903 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070018904 {
18905 v_U16_t i;
18906 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
18907 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053018908 if ((pSapCtx->aStaInfo[i].isUsed) &&
18909 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070018910 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018911 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053018912 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018913 ETHER_ADDR_LEN);
18914
Jeff Johnson295189b2012-06-20 16:38:30 -070018915 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080018916 "%s: Delete STA with MAC::"
18917 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018918 __func__,
18919 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
18920 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070018921 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053018922 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070018923 }
18924 }
18925 }
18926 else
18927 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018928
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018929 vos_status = hdd_softap_GetStaId(pAdapter,
18930 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018931 if (!VOS_IS_STATUS_SUCCESS(vos_status))
18932 {
18933 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080018934 "%s: Skip this DEL STA as this is not used::"
18935 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018936 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018937 return -ENOENT;
18938 }
18939
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053018940 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018941 {
18942 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080018943 "%s: Skip this DEL STA as deauth is in progress::"
18944 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018945 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018946 return -ENOENT;
18947 }
18948
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053018949 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018950
Jeff Johnson295189b2012-06-20 16:38:30 -070018951 hddLog(VOS_TRACE_LEVEL_INFO,
18952 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080018953 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070018954 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018955 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018956
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018957 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018958 if (!VOS_IS_STATUS_SUCCESS(vos_status))
18959 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053018960 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018961 hddLog(VOS_TRACE_LEVEL_INFO,
18962 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080018963 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018964 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018965 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080018966 return -ENOENT;
18967 }
18968
Jeff Johnson295189b2012-06-20 16:38:30 -070018969 }
18970 }
18971
18972 EXIT();
18973
18974 return 0;
18975}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053018976
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018977#ifdef USE_CFG80211_DEL_STA_V2
Kapil Gupta137ef892016-12-13 19:38:00 +053018978int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Naresh Jayaram69e3f282014-10-14 12:29:12 +053018979 struct net_device *dev,
18980 struct station_del_parameters *param)
18981#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053018982#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
Kapil Gupta137ef892016-12-13 19:38:00 +053018983int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053018984 struct net_device *dev, const u8 *mac)
18985#else
Kapil Gupta137ef892016-12-13 19:38:00 +053018986int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018987 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053018988#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053018989#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018990{
18991 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018992 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070018993
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018994 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018995
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053018996#ifdef USE_CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053018997 if (NULL == param) {
18998 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018999 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019000 return -EINVAL;
19001 }
19002
19003 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
19004 param->subtype, &delStaParams);
19005
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019006#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053019007 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019008 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053019009#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053019010 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
19011
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019012 vos_ssr_unprotect(__func__);
19013
19014 return ret;
19015}
19016
19017static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019018 struct net_device *dev,
19019#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
19020 const u8 *mac,
19021#else
19022 u8 *mac,
19023#endif
19024 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080019025{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019026 hdd_adapter_t *pAdapter;
19027 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080019028 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080019029#ifdef FEATURE_WLAN_TDLS
19030 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019031
Hoonki Lee11f7dda2013-02-14 16:55:44 -080019032 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019033
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019034 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19035 if (NULL == pAdapter)
19036 {
19037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19038 "%s: Adapter is NULL",__func__);
19039 return -EINVAL;
19040 }
19041 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19042 status = wlan_hdd_validate_context(pHddCtx);
19043 if (0 != status)
19044 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019045 return status;
19046 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019047
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019048 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19049 TRACE_CODE_HDD_CFG80211_ADD_STA,
19050 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019051 mask = params->sta_flags_mask;
19052
19053 set = params->sta_flags_set;
19054
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053019055 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019056 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
19057 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019058
19059 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
19060 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080019061 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019062 }
19063 }
19064#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019065 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080019066 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070019067}
19068
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019069#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
19070static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
19071 struct net_device *dev, const u8 *mac,
19072 struct station_parameters *params)
19073#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019074static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
19075 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053019076#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019077{
19078 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019079
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019080 vos_ssr_protect(__func__);
19081 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
19082 vos_ssr_unprotect(__func__);
19083
19084 return ret;
19085}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019086#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070019087
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019088static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070019089 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019090{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019091 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19092 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019093 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019094 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019095 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019096 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070019097
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019098 ENTER();
19099
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019100 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019101 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019102 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019103 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019104 return -EINVAL;
19105 }
19106
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019107 if (!pmksa) {
19108 hddLog(LOGE, FL("pmksa is NULL"));
19109 return -EINVAL;
19110 }
19111
19112 if (!pmksa->bssid || !pmksa->pmkid) {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070019113 hddLog(LOGE, FL("pmksa->bssid(%pK) or pmksa->pmkid(%pK) is NULL"),
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019114 pmksa->bssid, pmksa->pmkid);
19115 return -EINVAL;
19116 }
19117
19118 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
19119 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
19120
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019121 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19122 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019123 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019124 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019125 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019126 }
19127
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019128 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019129 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19130
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019131 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
19132 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019133
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019134 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019135 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019136 &pmk_id, 1, FALSE);
19137
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019138 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19139 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
19140 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019141
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019142 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019143 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019144}
19145
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019146static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
19147 struct cfg80211_pmksa *pmksa)
19148{
19149 int ret;
19150
19151 vos_ssr_protect(__func__);
19152 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
19153 vos_ssr_unprotect(__func__);
19154
19155 return ret;
19156}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019157
Wilson Yang6507c4e2013-10-01 20:11:19 -070019158
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019159static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070019160 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019161{
Wilson Yang6507c4e2013-10-01 20:11:19 -070019162 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19163 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019164 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080019165 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019166
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019167 ENTER();
19168
Wilson Yang6507c4e2013-10-01 20:11:19 -070019169 /* Validate pAdapter */
19170 if (NULL == pAdapter)
19171 {
19172 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
19173 return -EINVAL;
19174 }
19175
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019176 if (!pmksa) {
19177 hddLog(LOGE, FL("pmksa is NULL"));
19178 return -EINVAL;
19179 }
19180
19181 if (!pmksa->bssid) {
19182 hddLog(LOGE, FL("pmksa->bssid is NULL"));
19183 return -EINVAL;
19184 }
19185
Kiet Lam98c46a12014-10-31 15:34:57 -070019186 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
19187 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
19188
Wilson Yang6507c4e2013-10-01 20:11:19 -070019189 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19190 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070019191 if (0 != status)
19192 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070019193 return status;
19194 }
19195
19196 /*Retrieve halHandle*/
19197 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19198
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019199 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19200 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
19201 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019202 /* Delete the PMKID CSR cache */
19203 if (eHAL_STATUS_SUCCESS !=
19204 sme_RoamDelPMKIDfromCache(halHandle,
19205 pAdapter->sessionId, pmksa->bssid, FALSE)) {
19206 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
19207 MAC_ADDR_ARRAY(pmksa->bssid));
19208 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019209 }
19210
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019211 EXIT();
19212 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019213}
19214
Wilson Yang6507c4e2013-10-01 20:11:19 -070019215
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019216static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
19217 struct cfg80211_pmksa *pmksa)
19218{
19219 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019220
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019221 vos_ssr_protect(__func__);
19222 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
19223 vos_ssr_unprotect(__func__);
19224
19225 return ret;
19226
19227}
19228
19229static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019230{
Wilson Yang6507c4e2013-10-01 20:11:19 -070019231 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19232 tHalHandle halHandle;
19233 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080019234 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019235
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019236 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070019237
19238 /* Validate pAdapter */
19239 if (NULL == pAdapter)
19240 {
19241 hddLog(VOS_TRACE_LEVEL_ERROR,
19242 "%s: Invalid Adapter" ,__func__);
19243 return -EINVAL;
19244 }
19245
19246 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19247 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070019248 if (0 != status)
19249 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070019250 return status;
19251 }
19252
19253 /*Retrieve halHandle*/
19254 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19255
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053019256 /* Flush the PMKID cache in CSR */
19257 if (eHAL_STATUS_SUCCESS !=
19258 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
19259 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
19260 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070019261 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019262 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080019263 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019264}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053019265
19266static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
19267{
19268 int ret;
19269
19270 vos_ssr_protect(__func__);
19271 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
19272 vos_ssr_unprotect(__func__);
19273
19274 return ret;
19275}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019276#endif
19277
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019278#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019279static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
19280 struct net_device *dev,
19281 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019282{
19283 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19284 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019285 hdd_context_t *pHddCtx;
19286 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019287
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019288 ENTER();
19289
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019290 if (NULL == pAdapter)
19291 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080019292 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019293 return -ENODEV;
19294 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019295 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19296 ret = wlan_hdd_validate_context(pHddCtx);
19297 if (0 != ret)
19298 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019299 return ret;
19300 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019301 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019302 if (NULL == pHddStaCtx)
19303 {
19304 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
19305 return -EINVAL;
19306 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019307
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019308 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19309 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
19310 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019311 // Added for debug on reception of Re-assoc Req.
19312 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
19313 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080019314 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019315 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080019316 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019317 }
19318
19319#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080019320 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019321 ftie->ie_len);
19322#endif
19323
19324 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053019325 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
19326 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019327 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019328
19329 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019330 return 0;
19331}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019332
19333static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
19334 struct net_device *dev,
19335 struct cfg80211_update_ft_ies_params *ftie)
19336{
19337 int ret;
19338
19339 vos_ssr_protect(__func__);
19340 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
19341 vos_ssr_unprotect(__func__);
19342
19343 return ret;
19344}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019345#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019346
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019347#ifdef FEATURE_WLAN_SCAN_PNO
19348
19349void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
19350 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
19351{
19352 int ret;
19353 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
19354 hdd_context_t *pHddCtx;
19355
Nirav Shah80830bf2013-12-31 16:35:12 +053019356 ENTER();
19357
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019358 if (NULL == pAdapter)
19359 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053019360 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019361 "%s: HDD adapter is Null", __func__);
19362 return ;
19363 }
19364
19365 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19366 if (NULL == pHddCtx)
19367 {
19368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19369 "%s: HDD context is Null!!!", __func__);
19370 return ;
19371 }
19372
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019373 spin_lock(&pHddCtx->schedScan_lock);
19374 if (TRUE == pHddCtx->isWiphySuspended)
19375 {
19376 pHddCtx->isSchedScanUpdatePending = TRUE;
19377 spin_unlock(&pHddCtx->schedScan_lock);
19378 hddLog(VOS_TRACE_LEVEL_INFO,
19379 "%s: Update cfg80211 scan database after it resume", __func__);
19380 return ;
19381 }
19382 spin_unlock(&pHddCtx->schedScan_lock);
19383
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019384 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
19385
19386 if (0 > ret)
19387 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053019388 else
19389 {
19390 /* Acquire wakelock to handle the case where APP's tries to suspend
19391 * immediatly after the driver gets connect request(i.e after pno)
19392 * from supplicant, this result in app's is suspending and not able
19393 * to process the connect request to AP */
19394 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
19395 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019396 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19398 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019399}
19400
19401/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019402 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053019403 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019404 */
19405static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
19406{
19407 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
19408 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019409 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019410 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19411 int status = 0;
Agrawal Ashishcff31692016-12-16 17:17:50 +053019412
19413 if (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
19414 {
19415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19416 "%s: PNO is allowed only in STA interface", __func__);
19417 return eHAL_STATUS_FAILURE;
19418 }
19419
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019420 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
19421
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053019422 /* The current firmware design does not allow PNO during any
Agrawal Ashishcff31692016-12-16 17:17:50 +053019423 * active sessions. PNO is allowed only in case when sap session
19424 * is present and sapo auth offload feature enabled in firmare.
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053019425 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019426 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
19427 {
19428 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019429 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019430
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019431 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
19432 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
19433 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
19434 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
Agrawal Ashishcff31692016-12-16 17:17:50 +053019435 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode &&
19436 !pHddCtx->cfg_ini->enable_sap_auth_offload)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053019437 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019438 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019439 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019440 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019441 }
19442 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
19443 pAdapterNode = pNext;
19444 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019445 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019446}
19447
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019448void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
19449{
19450 hdd_adapter_t *pAdapter = callbackContext;
19451 hdd_context_t *pHddCtx;
19452
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019453 ENTER();
19454
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019455 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
19456 {
19457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19458 FL("Invalid adapter or adapter has invalid magic"));
19459 return;
19460 }
19461
19462 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19463 if (0 != wlan_hdd_validate_context(pHddCtx))
19464 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019465 return;
19466 }
19467
c_hpothub53c45d2014-08-18 16:53:14 +053019468 if (VOS_STATUS_SUCCESS != status)
19469 {
19470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019471 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053019472 pHddCtx->isPnoEnable = FALSE;
19473 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019474
19475 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
19476 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019477 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019478}
19479
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019480#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) || \
19481 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
19482/**
19483 * hdd_config_sched_scan_plan() - configures the sched scan plans
19484 * from the framework.
19485 * @pno_req: pointer to PNO scan request
19486 * @request: pointer to scan request from framework
19487 *
19488 * Return: None
19489 */
19490static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
19491 struct cfg80211_sched_scan_request *request,
19492 hdd_context_t *hdd_ctx)
19493{
19494 v_U32_t i = 0;
19495
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019496 pno_req->scanTimers.ucScanTimersCount = request->n_scan_plans;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019497 for (i = 0; i < request->n_scan_plans; i++)
19498 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019499 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
19500 request->scan_plans[i].iterations;
19501 pno_req->scanTimers.aTimerValues[i].uTimerValue =
19502 request->scan_plans[i].interval;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019503 }
19504}
19505#else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019506static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019507 struct cfg80211_sched_scan_request *request,
19508 hdd_context_t *hdd_ctx)
19509{
19510 v_U32_t i, temp_int;
19511 /* Driver gets only one time interval which is hardcoded in
19512 * supplicant for 10000ms. Taking power consumption into account 6
19513 * timers will be used, Timervalue is increased exponentially
19514 * i.e 10,20,40, 80,160,320 secs. And number of scan cycle for each
19515 * timer is configurable through INI param gPNOScanTimerRepeatValue.
19516 * If it is set to 0 only one timer will be used and PNO scan cycle
19517 * will be repeated after each interval specified by supplicant
19518 * till PNO is disabled.
19519 */
19520 if (0 == hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue)
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019521 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019522 HDD_PNO_SCAN_TIMERS_SET_ONE;
19523 else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019524 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019525 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
19526
19527 temp_int = (request->interval)/1000;
19528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19529 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
19530 temp_int, hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue);
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019531 for ( i = 0; i < pno_req->scanTimers.ucScanTimersCount; i++)
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019532 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019533 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019534 hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue;
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019535 pno_req->scanTimers.aTimerValues[i].uTimerValue = temp_int;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019536 temp_int *= 2;
19537 }
19538 //Repeat last timer until pno disabled.
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019539 pno_req->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019540}
19541#endif
19542
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019543/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053019544 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
19545 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019546 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053019547static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019548 struct net_device *dev, struct cfg80211_sched_scan_request *request)
19549{
19550 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019551 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019552 hdd_context_t *pHddCtx;
19553 tHalHandle hHal;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053019554 v_U32_t i, indx, num_ch, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053019555 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
19556 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019557 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
19558 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019559 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053019560 hdd_config_t *pConfig = NULL;
19561 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019562
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019563 ENTER();
19564
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019565 if (NULL == pAdapter)
19566 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019568 "%s: HDD adapter is Null", __func__);
19569 return -ENODEV;
19570 }
19571
19572 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019573 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019574
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019575 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019576 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019577 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019578 }
19579
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053019580 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019581 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
19582 if (NULL == hHal)
19583 {
19584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19585 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019586 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019587 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019588 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19589 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
19590 pAdapter->sessionId, pAdapter->device_mode));
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053019591 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053019592 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053019593 {
19594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19595 "%s: aborting the existing scan is unsuccessfull", __func__);
19596 return -EBUSY;
19597 }
19598
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019599 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019600 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053019601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053019602 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053019603 return -EBUSY;
19604 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019605
c_hpothu37f21312014-04-09 21:49:54 +053019606 if (TRUE == pHddCtx->isPnoEnable)
19607 {
19608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
19609 FL("already PNO is enabled"));
19610 return -EBUSY;
19611 }
c_hpothu225aa7c2014-10-22 17:45:13 +053019612
19613 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
19614 {
19615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19616 "%s: abort ROC failed ", __func__);
19617 return -EBUSY;
19618 }
19619
c_hpothu37f21312014-04-09 21:49:54 +053019620 pHddCtx->isPnoEnable = TRUE;
19621
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019622 pnoRequest.enable = 1; /*Enable PNO */
19623 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019624
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019625 if (( !pnoRequest.ucNetworksCount ) ||
19626 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019627 {
19628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053019629 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019630 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053019631 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019632 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019633 goto error;
19634 }
19635
19636 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
19637 {
19638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053019639 "%s: Incorrect number of channels %d",
19640 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019641 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019642 goto error;
19643 }
19644
19645 /* Framework provides one set of channels(all)
19646 * common for all saved profile */
19647 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
19648 channels_allowed, &num_channels_allowed))
19649 {
19650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19651 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019652 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019653 goto error;
19654 }
19655 /* Checking each channel against allowed channel list */
19656 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053019657 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019658 {
Nirav Shah80830bf2013-12-31 16:35:12 +053019659 char chList [(request->n_channels*5)+1];
19660 int len;
19661 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019662 {
Nirav Shah80830bf2013-12-31 16:35:12 +053019663 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019664 {
Nirav Shah80830bf2013-12-31 16:35:12 +053019665 if (request->channels[i]->hw_value == channels_allowed[indx])
19666 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053019667 if ((!pConfig->enableDFSPnoChnlScan) &&
19668 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
19669 {
19670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19671 "%s : Dropping DFS channel : %d",
19672 __func__,channels_allowed[indx]);
19673 num_ignore_dfs_ch++;
19674 break;
19675 }
19676
Nirav Shah80830bf2013-12-31 16:35:12 +053019677 valid_ch[num_ch++] = request->channels[i]->hw_value;
19678 len += snprintf(chList+len, 5, "%d ",
19679 request->channels[i]->hw_value);
19680 break ;
19681 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019682 }
19683 }
Nirav Shah80830bf2013-12-31 16:35:12 +053019684 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019685
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053019686 /*If all channels are DFS and dropped, then ignore the PNO request*/
19687 if (num_ignore_dfs_ch == request->n_channels)
19688 {
19689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19690 "%s : All requested channels are DFS channels", __func__);
19691 ret = -EINVAL;
19692 goto error;
19693 }
19694 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019695
19696 pnoRequest.aNetworks =
19697 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
19698 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019699 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019700 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
19701 FL("failed to allocate memory aNetworks %u"),
19702 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
19703 goto error;
19704 }
19705 vos_mem_zero(pnoRequest.aNetworks,
19706 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
19707
19708 /* Filling per profile params */
19709 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
19710 {
19711 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019712 request->match_sets[i].ssid.ssid_len;
19713
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019714 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
19715 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019716 {
19717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053019718 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019719 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019720 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019721 goto error;
19722 }
19723
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019724 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019725 request->match_sets[i].ssid.ssid,
19726 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053019727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19728 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019729 i, pnoRequest.aNetworks[i].ssId.ssId);
19730 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
19731 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
19732 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019733
19734 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019735 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
19736 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019737
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019738 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019739 }
19740
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053019741 for (i = 0; i < request->n_ssids; i++)
19742 {
19743 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019744 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053019745 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019746 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053019747 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019748 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053019749 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019750 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053019751 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019752 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053019753 break;
19754 }
19755 j++;
19756 }
19757 }
19758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19759 "Number of hidden networks being Configured = %d",
19760 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053019761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080019762 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019763
19764 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
19765 if (pnoRequest.p24GProbeTemplate == NULL)
19766 {
19767 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
19768 FL("failed to allocate memory p24GProbeTemplate %u"),
19769 SIR_PNO_MAX_PB_REQ_SIZE);
19770 goto error;
19771 }
19772
19773 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
19774 if (pnoRequest.p5GProbeTemplate == NULL)
19775 {
19776 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
19777 FL("failed to allocate memory p5GProbeTemplate %u"),
19778 SIR_PNO_MAX_PB_REQ_SIZE);
19779 goto error;
19780 }
19781
19782 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
19783 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
19784
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053019785 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
19786 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053019787 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019788 pnoRequest.us24GProbeTemplateLen = request->ie_len;
19789 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
19790 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053019791
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019792 pnoRequest.us5GProbeTemplateLen = request->ie_len;
19793 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
19794 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053019795 }
19796
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053019797 hdd_config_sched_scan_plan(&pnoRequest, request, pHddCtx);
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053019798
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019799 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019800
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019801 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019802 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
19803 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019804 pAdapter->pno_req_status = 0;
19805
Nirav Shah80830bf2013-12-31 16:35:12 +053019806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19807 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019808 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
19809 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053019810
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019811 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019812 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019813 hdd_cfg80211_sched_scan_done_callback, pAdapter);
19814 if (eHAL_STATUS_SUCCESS != status)
19815 {
19816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053019817 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019818 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019819 goto error;
19820 }
19821
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019822 ret = wait_for_completion_timeout(
19823 &pAdapter->pno_comp_var,
19824 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
19825 if (0 >= ret)
19826 {
19827 // Did not receive the response for PNO enable in time.
19828 // Assuming the PNO enable was success.
19829 // Returning error from here, because we timeout, results
19830 // in side effect of Wifi (Wifi Setting) not to work.
19831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19832 FL("Timed out waiting for PNO to be Enabled"));
19833 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019834 }
19835
19836 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053019837 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019838
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019839error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19841 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053019842 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019843 if (pnoRequest.aNetworks)
19844 vos_mem_free(pnoRequest.aNetworks);
19845 if (pnoRequest.p24GProbeTemplate)
19846 vos_mem_free(pnoRequest.p24GProbeTemplate);
19847 if (pnoRequest.p5GProbeTemplate)
19848 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019849
19850 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019851 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019852}
19853
19854/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053019855 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
19856 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019857 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053019858static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
19859 struct net_device *dev, struct cfg80211_sched_scan_request *request)
19860{
19861 int ret;
19862
19863 vos_ssr_protect(__func__);
19864 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
19865 vos_ssr_unprotect(__func__);
19866
19867 return ret;
19868}
19869
19870/*
19871 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
19872 * Function to disable PNO
19873 */
19874static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019875 struct net_device *dev)
19876{
19877 eHalStatus status = eHAL_STATUS_FAILURE;
19878 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19879 hdd_context_t *pHddCtx;
19880 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019881 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019882 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019883
19884 ENTER();
19885
19886 if (NULL == pAdapter)
19887 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019889 "%s: HDD adapter is Null", __func__);
19890 return -ENODEV;
19891 }
19892
19893 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019894
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019895 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019896 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019897 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019898 "%s: HDD context is Null", __func__);
19899 return -ENODEV;
19900 }
19901
19902 /* The return 0 is intentional when isLogpInProgress and
19903 * isLoadUnloadInProgress. We did observe a crash due to a return of
19904 * failure in sched_scan_stop , especially for a case where the unload
19905 * of the happens at the same time. The function __cfg80211_stop_sched_scan
19906 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
19907 * success. If it returns a failure , then its next invocation due to the
19908 * clean up of the second interface will have the dev pointer corresponding
19909 * to the first one leading to a crash.
19910 */
19911 if (pHddCtx->isLogpInProgress)
19912 {
19913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19914 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053019915 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019916 return ret;
19917 }
19918
Mihir Shete18156292014-03-11 15:38:30 +053019919 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019920 {
19921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19922 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
19923 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019924 }
19925
19926 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
19927 if (NULL == hHal)
19928 {
19929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19930 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019931 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019932 }
19933
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019934 pnoRequest.enable = 0; /* Disable PNO */
19935 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019936
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019937 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19938 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
19939 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053019940
19941 INIT_COMPLETION(pAdapter->pno_comp_var);
19942 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
19943 pnoRequest.callbackContext = pAdapter;
19944 pAdapter->pno_req_status = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053019945 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019946 pAdapter->sessionId,
19947 NULL, pAdapter);
19948 if (eHAL_STATUS_SUCCESS != status)
19949 {
19950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19951 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019952 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019953 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019954 }
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053019955 ret = wait_for_completion_timeout(
19956 &pAdapter->pno_comp_var,
19957 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
19958 if (0 >= ret)
19959 {
19960 // Did not receive the response for PNO disable in time.
19961 // Assuming the PNO disable was success.
19962 // Returning error from here, because we timeout, results
19963 // in side effect of Wifi (Wifi Setting) not to work.
Anurag Chouhan96b41cb2016-09-28 18:54:47 +053019964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053019965 FL("Timed out waiting for PNO to be disabled"));
19966 ret = 0;
19967 }
19968
19969 ret = pAdapter->pno_req_status;
19970 pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019971
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019972error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019973 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053019974 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019975
19976 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053019977 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019978}
19979
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053019980/*
19981 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
19982 * NL interface to disable PNO
19983 */
19984static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
19985 struct net_device *dev)
19986{
19987 int ret;
19988
19989 vos_ssr_protect(__func__);
19990 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
19991 vos_ssr_unprotect(__func__);
19992
19993 return ret;
19994}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019995#endif /*FEATURE_WLAN_SCAN_PNO*/
19996
19997
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019998#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053019999#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020000static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20001 struct net_device *dev,
20002 u8 *peer, u8 action_code,
20003 u8 dialog_token,
20004 u16 status_code, u32 peer_capability,
20005 const u8 *buf, size_t len)
20006#else /* TDLS_MGMT_VERSION2 */
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053020007#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || \
20008 defined(WITH_BACKPORTS)
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020009static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20010 struct net_device *dev,
20011 const u8 *peer, u8 action_code,
20012 u8 dialog_token, u16 status_code,
20013 u32 peer_capability, bool initiator,
20014 const u8 *buf, size_t len)
20015#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
20016static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20017 struct net_device *dev,
20018 const u8 *peer, u8 action_code,
20019 u8 dialog_token, u16 status_code,
20020 u32 peer_capability, const u8 *buf,
20021 size_t len)
20022#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
20023static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20024 struct net_device *dev,
20025 u8 *peer, u8 action_code,
20026 u8 dialog_token,
20027 u16 status_code, u32 peer_capability,
20028 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053020029#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020030static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20031 struct net_device *dev,
20032 u8 *peer, u8 action_code,
20033 u8 dialog_token,
20034 u16 status_code, const u8 *buf,
20035 size_t len)
20036#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053020037#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020038{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020039 hdd_adapter_t *pAdapter;
20040 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020041 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070020042 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080020043 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070020044 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020045 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053020046 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020047#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053020048 u32 peer_capability = 0;
20049#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053020050 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020051 hdd_station_ctx_t *pHddStaCtx = NULL;
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020052 tdlsCtx_t *pHddTdlsCtx;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053020053
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020054 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
20055 if (NULL == pAdapter)
20056 {
20057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20058 "%s: Adapter is NULL",__func__);
20059 return -EINVAL;
20060 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053020061 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20062 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
20063 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020064
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020065 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020066 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020067 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053020068 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020069 "Invalid arguments");
20070 return -EINVAL;
20071 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020072
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080020073 if (pHddCtx->isLogpInProgress)
20074 {
20075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20076 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053020077 wlan_hdd_tdls_set_link_status(pAdapter,
20078 peer,
20079 eTDLS_LINK_IDLE,
20080 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080020081 return -EBUSY;
20082 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020083
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020084 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
20085 {
20086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20087 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
20088 return -EAGAIN;
20089 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020090
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020091 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
20092 if (!pHddTdlsCtx) {
20093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20094 "%s: pHddTdlsCtx not valid.", __func__);
Hanumanth Reddy Pothula36dfa522018-03-12 16:42:08 +053020095 return -EINVAL;
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020096 }
20097
Hoonki Lee27511902013-03-14 18:19:06 -070020098 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020099 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053020100 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070020101 "%s: TDLS mode is disabled OR not enabled in FW."
20102 MAC_ADDRESS_STR " action %d declined.",
20103 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020104 return -ENOTSUPP;
20105 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080020106
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020107 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
20108
20109 if( NULL == pHddStaCtx )
20110 {
20111 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20112 "%s: HDD station context NULL ",__func__);
20113 return -EINVAL;
20114 }
20115
20116 /* STA should be connected and authenticated
20117 * before sending any TDLS frames
20118 */
20119 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
20120 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
20121 {
20122 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20123 "STA is not connected or unauthenticated. "
20124 "connState %u, uIsAuthenticated %u",
20125 pHddStaCtx->conn_info.connState,
20126 pHddStaCtx->conn_info.uIsAuthenticated);
20127 return -EAGAIN;
20128 }
20129
Hoonki Lee27511902013-03-14 18:19:06 -070020130 /* other than teardown frame, other mgmt frames are not sent if disabled */
20131 if (SIR_MAC_TDLS_TEARDOWN != action_code)
20132 {
20133 /* if tdls_mode is disabled to respond to peer's request */
20134 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
20135 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053020136 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070020137 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070020138 " TDLS mode is disabled. action %d declined.",
20139 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070020140
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020141 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070020142 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053020143
20144 if (vos_max_concurrent_connections_reached())
20145 {
20146 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
20147 return -EINVAL;
20148 }
Hoonki Lee27511902013-03-14 18:19:06 -070020149 }
20150
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020151 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
20152 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053020153 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020154 {
20155 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020156 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070020157 " TDLS setup is ongoing. action %d declined.",
20158 __func__, MAC_ADDR_ARRAY(peer), action_code);
20159 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020160 }
20161 }
20162
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020163 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
20164 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080020165 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053020166 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
20167 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080020168 {
20169 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
20170 we return error code at 'add_station()'. Hence we have this
20171 check again in addtion to add_station().
20172 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020173 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080020174 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020175 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20176 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053020177 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
20178 __func__, MAC_ADDR_ARRAY(peer), action_code,
20179 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053020180 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080020181 }
20182 else
20183 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020184 /* maximum reached. tweak to send error code to peer and return
20185 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080020186 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020187 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20188 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053020189 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
20190 __func__, MAC_ADDR_ARRAY(peer), status_code,
20191 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070020192 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020193 /* fall through to send setup resp with failure status
20194 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080020195 }
20196 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020197 else
20198 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020199 mutex_lock(&pHddCtx->tdls_lock);
20200 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070020201 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020202 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020203 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020204 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070020205 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
20206 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020207 return -EPERM;
20208 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020209 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020210 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080020211 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020212
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053020213 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053020214 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020215 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
20216 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020217
Hoonki Leea34dd892013-02-05 22:56:02 -080020218 /*Except teardown responder will not be used so just make 0*/
20219 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080020220 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080020221 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070020222
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020223 mutex_lock(&pHddCtx->tdls_lock);
20224 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070020225
20226 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
20227 responder = pTdlsPeer->is_responder;
20228 else
Hoonki Leea34dd892013-02-05 22:56:02 -080020229 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070020230 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053020231 "%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 -070020232 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
20233 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020234 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070020235 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080020236 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020237 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020238 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020239
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053020240 /* Discard TDLS setup if peer is removed by user app */
20241 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
20242 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
20243 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
20244 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
20245
20246 mutex_lock(&pHddCtx->tdls_lock);
20247 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
20248 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
20249 mutex_unlock(&pHddCtx->tdls_lock);
20250 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
20251 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
20252 MAC_ADDR_ARRAY(peer), action_code);
20253 return -EINVAL;
20254 }
20255 mutex_unlock(&pHddCtx->tdls_lock);
20256 }
20257
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053020258 /* For explicit trigger of DIS_REQ come out of BMPS for
20259 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070020260 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Deepthi Gowrif78f1f72016-03-21 13:13:28 +053020261 (SIR_MAC_TDLS_SETUP_CNF== action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053020262 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
20263 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070020264 {
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020265 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053020266 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020267 "%s: Sending frame action_code %u.Disable BMPS", __func__,
20268 action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020269 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
20270 if (status != VOS_STATUS_SUCCESS) {
20271 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053020272 } else {
20273 pHddTdlsCtx->is_tdls_disabled_bmps = true;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020274 }
Hoonki Lee14621352013-04-16 17:51:19 -070020275 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020276 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020277 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020278 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
20279 }
20280 }
Hoonki Lee14621352013-04-16 17:51:19 -070020281 }
20282
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020283 /* make sure doesn't call send_mgmt() while it is pending */
20284 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
20285 {
20286 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080020287 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020288 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020289 ret = -EBUSY;
20290 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020291 }
20292
20293 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020294 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
20295
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020296 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
20297 pAdapter->sessionId, peer, action_code, dialog_token,
20298 status_code, peer_capability, (tANI_U8 *)buf, len,
20299 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020300
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020301 if (VOS_STATUS_SUCCESS != status)
20302 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20304 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020305 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020306 ret = -EINVAL;
20307 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020308 }
20309
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20311 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
20312 WAIT_TIME_TDLS_MGMT);
20313
Hoonki Leed37cbb32013-04-20 00:31:14 -070020314 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
20315 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
20316
20317 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020318 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070020319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070020320 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070020321 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020322 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080020323
20324 if (pHddCtx->isLogpInProgress)
20325 {
20326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20327 "%s: LOGP in Progress. Ignore!!!", __func__);
20328 return -EAGAIN;
20329 }
Abhishek Singh837adf22015-10-01 17:37:37 +053020330 if (rc <= 0)
20331 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
20332 WLAN_LOG_INDICATOR_HOST_DRIVER,
20333 WLAN_LOG_REASON_HDD_TIME_OUT,
20334 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080020335
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020336 ret = -EINVAL;
20337 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020338 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053020339 else
20340 {
20341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20342 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
20343 __func__, rc, pAdapter->mgmtTxCompletionStatus);
20344 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020345
Gopichand Nakkala05922802013-03-14 12:23:19 -070020346 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070020347 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020348 ret = max_sta_failed;
20349 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070020350 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020351
Hoonki Leea34dd892013-02-05 22:56:02 -080020352 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
20353 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020354 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020355 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
20356 }
Hoonki Leea34dd892013-02-05 22:56:02 -080020357 }
20358 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
20359 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020360 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020361 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
20362 }
Hoonki Leea34dd892013-02-05 22:56:02 -080020363 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020364
20365 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053020366
20367tx_failed:
20368 /* add_station will be called before sending TDLS_SETUP_REQ and
20369 * TDLS_SETUP_RSP and as part of add_station driver will enable
20370 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
20371 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
20372 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
20373 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
20374 */
20375
20376 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
20377 (SIR_MAC_TDLS_SETUP_RSP == action_code))
20378 wlan_hdd_tdls_check_bmps(pAdapter);
20379 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020380}
20381
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020382#if TDLS_MGMT_VERSION2
20383static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
20384 u8 *peer, u8 action_code, u8 dialog_token,
20385 u16 status_code, u32 peer_capability,
20386 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020387#else /* TDLS_MGMT_VERSION2 */
20388#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
20389static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20390 struct net_device *dev,
20391 const u8 *peer, u8 action_code,
20392 u8 dialog_token, u16 status_code,
20393 u32 peer_capability, bool initiator,
20394 const u8 *buf, size_t len)
20395#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
20396static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20397 struct net_device *dev,
20398 const u8 *peer, u8 action_code,
20399 u8 dialog_token, u16 status_code,
20400 u32 peer_capability, const u8 *buf,
20401 size_t len)
20402#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
20403static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
20404 struct net_device *dev,
20405 u8 *peer, u8 action_code,
20406 u8 dialog_token,
20407 u16 status_code, u32 peer_capability,
20408 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020409#else
20410static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
20411 u8 *peer, u8 action_code, u8 dialog_token,
20412 u16 status_code, const u8 *buf, size_t len)
20413#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020414#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020415{
20416 int ret;
20417
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020418 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020419#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020420 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20421 dialog_token, status_code,
20422 peer_capability, buf, len);
20423#else /* TDLS_MGMT_VERSION2 */
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053020424#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || \
20425 defined(WITH_BACKPORTS)
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020426 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20427 dialog_token, status_code,
20428 peer_capability, initiator,
20429 buf, len);
20430#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
20431 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20432 dialog_token, status_code,
20433 peer_capability, buf, len);
20434#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
20435 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20436 dialog_token, status_code,
20437 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020438#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020439 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
20440 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020441#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020442#endif
20443 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020444
Anand N Sunkad9f80b742015-07-30 20:05:51 +053020445 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020446}
Atul Mittal115287b2014-07-08 13:26:33 +053020447
20448int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020449#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
20450 const u8 *peer,
20451#else
Atul Mittal115287b2014-07-08 13:26:33 +053020452 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020453#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020454 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053020455 cfg80211_exttdls_callback callback)
20456{
20457
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020458 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053020459 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053020460 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053020461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20462 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
20463 __func__, MAC_ADDR_ARRAY(peer));
20464
20465 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
20466 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
20467
20468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020469 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
20470 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
20471 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053020472 return -ENOTSUPP;
20473 }
20474
20475 /* To cater the requirement of establishing the TDLS link
20476 * irrespective of the data traffic , get an entry of TDLS peer.
20477 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053020478 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020479 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
20480 if (pTdlsPeer == NULL) {
20481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20482 "%s: peer " MAC_ADDRESS_STR " not existing",
20483 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053020484 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020485 return -EINVAL;
20486 }
20487
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053020488 /* check FW TDLS Off Channel capability */
20489 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053020490 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053020491 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020492 {
20493 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
20494 pTdlsPeer->peerParams.global_operating_class =
20495 tdls_peer_params->global_operating_class;
20496 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
20497 pTdlsPeer->peerParams.min_bandwidth_kbps =
20498 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053020499 /* check configured channel is valid, non dfs and
20500 * not current operating channel */
20501 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
20502 tdls_peer_params->channel)) &&
20503 (pHddStaCtx) &&
20504 (tdls_peer_params->channel !=
20505 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020506 {
20507 pTdlsPeer->isOffChannelConfigured = TRUE;
20508 }
20509 else
20510 {
20511 pTdlsPeer->isOffChannelConfigured = FALSE;
20512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20513 "%s: Configured Tdls Off Channel is not valid", __func__);
20514
20515 }
20516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053020517 "%s: tdls_off_channel %d isOffChannelConfigured %d "
20518 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020519 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053020520 pTdlsPeer->isOffChannelConfigured,
20521 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020522 }
20523 else
20524 {
20525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053020526 "%s: TDLS off channel FW capability %d, "
20527 "host capab %d or Invalid TDLS Peer Params", __func__,
20528 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
20529 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020530 }
20531
Atul Mittal115287b2014-07-08 13:26:33 +053020532 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
20533
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020534 mutex_unlock(&pHddCtx->tdls_lock);
20535
Atul Mittal115287b2014-07-08 13:26:33 +053020536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20537 " %s TDLS Add Force Peer Failed",
20538 __func__);
20539 return -EINVAL;
20540 }
20541 /*EXT TDLS*/
20542
20543 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020544 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20546 " %s TDLS set callback Failed",
20547 __func__);
20548 return -EINVAL;
20549 }
20550
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020551 mutex_unlock(&pHddCtx->tdls_lock);
20552
Atul Mittal115287b2014-07-08 13:26:33 +053020553 return(0);
20554
20555}
20556
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020557int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
20558#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
20559 const u8 *peer
20560#else
20561 u8 *peer
20562#endif
20563)
Atul Mittal115287b2014-07-08 13:26:33 +053020564{
20565
20566 hddTdlsPeer_t *pTdlsPeer;
20567 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053020568
Atul Mittal115287b2014-07-08 13:26:33 +053020569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20570 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
20571 __func__, MAC_ADDR_ARRAY(peer));
20572
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053020573 if (0 != wlan_hdd_validate_context(pHddCtx)) {
20574 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
20575 return -EINVAL;
20576 }
20577
Atul Mittal115287b2014-07-08 13:26:33 +053020578 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
20579 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
20580
20581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020582 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
20583 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
20584 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053020585 return -ENOTSUPP;
20586 }
20587
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020588 mutex_lock(&pHddCtx->tdls_lock);
20589 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053020590
20591 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020592 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020593 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053020594 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053020595 __func__, MAC_ADDR_ARRAY(peer));
20596 return -EINVAL;
20597 }
20598 else {
20599 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
20600 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053020601 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL,
20602 pTdlsPeer->peerMac);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020603 /* if channel switch is configured, reset
20604 the channel for this peer */
20605 if (TRUE == pTdlsPeer->isOffChannelConfigured)
20606 {
20607 pTdlsPeer->peerParams.channel = 0;
20608 pTdlsPeer->isOffChannelConfigured = FALSE;
20609 }
Atul Mittal115287b2014-07-08 13:26:33 +053020610 }
20611
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020612 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020613 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020614 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053020615 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020616 }
Atul Mittal115287b2014-07-08 13:26:33 +053020617
20618 /*EXT TDLS*/
20619
20620 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020621 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053020622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20623 " %s TDLS set callback Failed",
20624 __func__);
20625 return -EINVAL;
20626 }
Atul Mittal115287b2014-07-08 13:26:33 +053020627
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020628 mutex_unlock(&pHddCtx->tdls_lock);
20629
20630 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053020631}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053020632static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053020633#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
20634 const u8 *peer,
20635#else
20636 u8 *peer,
20637#endif
20638 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020639{
20640 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
20641 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053020642 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070020643 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053020644
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020645 ENTER();
20646
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053020647 if (!pAdapter) {
20648 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
20649 return -EINVAL;
20650 }
20651
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053020652 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20653 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
20654 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053020655 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020656 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080020657 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070020658 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020659 return -EINVAL;
20660 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080020661
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053020662 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053020663 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080020664 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053020665 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080020666 }
20667
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020668
20669 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080020670 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020671 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080020672 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020673 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
20674 "Cannot process TDLS commands",
20675 pHddCtx->cfg_ini->fEnableTDLSSupport,
20676 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020677 return -ENOTSUPP;
20678 }
20679
20680 switch (oper) {
20681 case NL80211_TDLS_ENABLE_LINK:
20682 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020683 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053020684 long ret;
Hanumantha Reddy Pothulada389492016-02-11 17:29:27 +053020685 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams = { {0}, 0,
20686 0, 0, 0, 0, 0, 0, {0}, 0, {0} };
Agarwal Ashish16020c42014-12-29 22:01:11 +053020687 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020688 tANI_U16 numCurrTdlsPeers = 0;
20689 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053020690 tANI_U8 suppChannelLen = 0;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020691 tSirMacAddr peerMac;
20692 int channel;
20693 tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020694
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053020695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20696 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
20697 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020698
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020699 mutex_lock(&pHddCtx->tdls_lock);
20700 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053020701 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053020702 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020703 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053020704 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
20705 " (oper %d) not exsting. ignored",
20706 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
20707 return -EINVAL;
20708 }
20709
20710 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20711 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
20712 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
20713 "NL80211_TDLS_ENABLE_LINK");
20714
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070020715 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
20716 {
20717 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
20718 MAC_ADDRESS_STR " failed",
20719 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020720 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070020721 return -EINVAL;
20722 }
20723
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053020724 /* before starting tdls connection, set tdls
20725 * off channel established status to default value */
20726 pTdlsPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020727
20728 mutex_unlock(&pHddCtx->tdls_lock);
20729
Deepthi Gowri2d85bbf2016-07-25 15:43:31 +053020730 wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020731 /* TDLS Off Channel, Disable tdls channel switch,
20732 when there are more than one tdls link */
20733 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053020734 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020735 {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020736 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020737 /* get connected peer and send disable tdls off chan */
20738 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053020739 if ((connPeer) &&
20740 (connPeer->isOffChannelSupported == TRUE) &&
20741 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020742 {
20743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20744 "%s: More then one peer connected, Disable "
20745 "TDLS channel switch", __func__);
20746
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053020747 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020748 vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr));
20749 channel = connPeer->peerParams.channel;
20750
20751 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020752
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020753 ret = sme_SendTdlsChanSwitchReq(
20754 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020755 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020756 peerMac,
20757 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020758 TDLS_OFF_CHANNEL_BW_OFFSET,
20759 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020760 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053020761 hddLog(VOS_TRACE_LEVEL_ERROR,
20762 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020763 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020764 }
20765 else
20766 {
20767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20768 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053020769 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020770 "isOffChannelConfigured %d",
20771 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053020772 (connPeer ? (connPeer->isOffChannelSupported)
20773 : -1),
20774 (connPeer ? (connPeer->isOffChannelConfigured)
20775 : -1));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020776 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020777 }
20778 }
20779
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020780 mutex_lock(&pHddCtx->tdls_lock);
20781 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
20782 if ( NULL == pTdlsPeer ) {
20783 mutex_unlock(&pHddCtx->tdls_lock);
20784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20785 "%s: " MAC_ADDRESS_STR
20786 " (oper %d) peer got freed in other context. ignored",
20787 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
20788 return -EINVAL;
20789 }
20790 peer_status = pTdlsPeer->link_status;
20791 mutex_unlock(&pHddCtx->tdls_lock);
20792
20793 if (eTDLS_LINK_CONNECTED != peer_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070020794 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053020795 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053020796
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053020797 if (0 != wlan_hdd_tdls_get_link_establish_params(
20798 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020799 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053020800 return -EINVAL;
20801 }
20802 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053020803
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020804 ret = sme_SendTdlsLinkEstablishParams(
20805 WLAN_HDD_GET_HAL_CTX(pAdapter),
20806 pAdapter->sessionId, peer,
20807 &tdlsLinkEstablishParams);
20808 if (ret != VOS_STATUS_SUCCESS) {
20809 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
20810 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053020811 /* Send TDLS peer UAPSD capabilities to the firmware and
20812 * register with the TL on after the response for this operation
20813 * is received .
20814 */
20815 ret = wait_for_completion_interruptible_timeout(
20816 &pAdapter->tdls_link_establish_req_comp,
20817 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Masti, Narayanraddie1892a52015-12-15 15:01:01 +053020818
20819 mutex_lock(&pHddCtx->tdls_lock);
20820 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
20821 if ( NULL == pTdlsPeer ) {
20822 mutex_unlock(&pHddCtx->tdls_lock);
20823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20824 "%s %d: " MAC_ADDRESS_STR
20825 " (oper %d) peer got freed in other context. ignored",
20826 __func__, __LINE__, MAC_ADDR_ARRAY(peer),
20827 (int)oper);
20828 return -EINVAL;
20829 }
20830 peer_status = pTdlsPeer->link_status;
20831 mutex_unlock(&pHddCtx->tdls_lock);
20832
20833 if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING))
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053020834 {
20835 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053020836 FL("Link Establish Request Failed Status %ld"),
20837 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053020838 return -EINVAL;
20839 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053020840 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053020841
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020842 mutex_lock(&pHddCtx->tdls_lock);
20843 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
20844 if ( NULL == pTdlsPeer ) {
20845 mutex_unlock(&pHddCtx->tdls_lock);
20846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20847 "%s: " MAC_ADDRESS_STR
20848 " (oper %d) peer got freed in other context. ignored",
20849 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
20850 return -EINVAL;
20851 }
20852
Atul Mittal115287b2014-07-08 13:26:33 +053020853 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
20854 eTDLS_LINK_CONNECTED,
20855 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053020856 staDesc.ucSTAId = pTdlsPeer->staId;
20857 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053020858
20859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20860 "%s: tdlsLinkEstablishParams of peer "
20861 MAC_ADDRESS_STR "uapsdQueues: %d"
20862 "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d"
20863 "isResponder: %d peerstaId: %d",
20864 __func__,
20865 MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac),
20866 tdlsLinkEstablishParams.uapsdQueues,
20867 tdlsLinkEstablishParams.qos,
20868 tdlsLinkEstablishParams.maxSp,
20869 tdlsLinkEstablishParams.isBufSta,
20870 tdlsLinkEstablishParams.isOffChannelSupported,
20871 tdlsLinkEstablishParams.isResponder,
20872 pTdlsPeer->staId);
20873
20874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20875 "%s: StaDesc ucSTAId: %d ucQosEnabled: %d",
20876 __func__,
20877 staDesc.ucSTAId,
20878 staDesc.ucQosEnabled);
20879
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020880 ret = WLANTL_UpdateTdlsSTAClient(
20881 pHddCtx->pvosContext,
20882 &staDesc);
20883 if (ret != VOS_STATUS_SUCCESS) {
20884 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
20885 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053020886
Gopichand Nakkala471708b2013-06-04 20:03:01 +053020887 /* Mark TDLS client Authenticated .*/
20888 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
20889 pTdlsPeer->staId,
20890 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070020891 if (VOS_STATUS_SUCCESS == status)
20892 {
Hoonki Lee14621352013-04-16 17:51:19 -070020893 if (pTdlsPeer->is_responder == 0)
20894 {
20895 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053020896 tdlsConnInfo_t *tdlsInfo;
20897
20898 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
20899
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053020900 if (!vos_timer_is_initialized(
20901 &pTdlsPeer->initiatorWaitTimeoutTimer))
20902 {
20903 /* Initialize initiator wait callback */
20904 vos_timer_init(
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053020905 &pTdlsPeer->initiatorWaitTimeoutTimer,
20906 VOS_TIMER_TYPE_SW,
20907 wlan_hdd_tdls_initiator_wait_cb,
20908 tdlsInfo);
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053020909 }
Hoonki Lee14621352013-04-16 17:51:19 -070020910 wlan_hdd_tdls_timer_restart(pAdapter,
20911 &pTdlsPeer->initiatorWaitTimeoutTimer,
20912 WAIT_TIME_TDLS_INITIATOR);
20913 /* suspend initiator TX until it receives direct packet from the
20914 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020915 ret = WLANTL_SuspendDataTx(
20916 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
20917 &staId, NULL);
20918 if (ret != VOS_STATUS_SUCCESS) {
20919 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
20920 }
Hoonki Lee14621352013-04-16 17:51:19 -070020921 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020922
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053020923 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053020924 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053020925 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053020926 suppChannelLen =
20927 tdlsLinkEstablishParams.supportedChannelsLen;
20928
20929 if ((suppChannelLen > 0) &&
20930 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
20931 {
20932 tANI_U8 suppPeerChannel = 0;
20933 int i = 0;
20934 for (i = 0U; i < suppChannelLen; i++)
20935 {
20936 suppPeerChannel =
20937 tdlsLinkEstablishParams.supportedChannels[i];
20938
20939 pTdlsPeer->isOffChannelSupported = FALSE;
20940 if (suppPeerChannel ==
20941 pTdlsPeer->peerParams.channel)
20942 {
20943 pTdlsPeer->isOffChannelSupported = TRUE;
20944 break;
20945 }
20946 }
20947 }
20948 else
20949 {
20950 pTdlsPeer->isOffChannelSupported = FALSE;
20951 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053020952 }
20953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20954 "%s: TDLS channel switch request for channel "
20955 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053020956 "%d isOffChannelSupported %d", __func__,
20957 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053020958 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053020959 suppChannelLen,
20960 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053020961
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020962 /* TDLS Off Channel, Enable tdls channel switch,
20963 when their is only one tdls link and it supports */
20964 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
20965 if ((numCurrTdlsPeers == 1) &&
20966 (TRUE == pTdlsPeer->isOffChannelSupported) &&
20967 (TRUE == pTdlsPeer->isOffChannelConfigured))
20968 {
20969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20970 "%s: Send TDLS channel switch request for channel %d",
20971 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053020972
20973 pTdlsPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020974 vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr));
20975 channel = pTdlsPeer->peerParams.channel;
20976
20977 mutex_unlock(&pHddCtx->tdls_lock);
20978
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020979 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
20980 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020981 peerMac,
20982 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020983 TDLS_OFF_CHANNEL_BW_OFFSET,
20984 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053020985 if (ret != VOS_STATUS_SUCCESS) {
20986 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
20987 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053020988 }
20989 else
20990 {
20991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20992 "%s: TDLS channel switch request not sent"
20993 " numCurrTdlsPeers %d "
20994 "isOffChannelSupported %d "
20995 "isOffChannelConfigured %d",
20996 __func__, numCurrTdlsPeers,
20997 pTdlsPeer->isOffChannelSupported,
20998 pTdlsPeer->isOffChannelConfigured);
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053020999 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021000 }
21001
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070021002 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021003 else
21004 mutex_unlock(&pHddCtx->tdls_lock);
21005
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021006 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021007
21008 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053021009 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
21010 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021011 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053021012 int ac;
21013 uint8 ucAc[4] = { WLANTL_AC_VO,
21014 WLANTL_AC_VI,
21015 WLANTL_AC_BK,
21016 WLANTL_AC_BE };
21017 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
21018 for(ac=0; ac < 4; ac++)
21019 {
21020 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
21021 pTdlsPeer->staId, ucAc[ac],
21022 tlTid[ac], tlTid[ac], 0, 0,
21023 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021024 if (status != VOS_STATUS_SUCCESS) {
21025 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
21026 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053021027 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053021028 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021029 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053021030
Bhargav Shah66896792015-10-01 18:17:37 +053021031 /* stop TCP delack timer if TDLS is enable */
21032 set_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
21033 hdd_manage_delack_timer(pHddCtx);
Abhishek Singh67fa6bc2016-01-05 15:57:19 +053021034 hdd_wlan_tdls_enable_link_event(peer,
21035 pTdlsPeer->isOffChannelSupported,
21036 pTdlsPeer->isOffChannelConfigured,
21037 pTdlsPeer->isOffChannelEstablished);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021038 }
21039 break;
21040 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080021041 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021042 tANI_U16 numCurrTdlsPeers = 0;
21043 hddTdlsPeer_t *connPeer = NULL;
21044
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21046 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
21047 __func__, MAC_ADDR_ARRAY(peer));
21048
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021049 mutex_lock(&pHddCtx->tdls_lock);
21050 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021051
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021052
Sunil Dutt41de4e22013-11-14 18:09:02 +053021053 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021054 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021055 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
21056 " (oper %d) not exsting. ignored",
21057 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
21058 return -EINVAL;
21059 }
21060
21061 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21062 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
21063 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
21064 "NL80211_TDLS_DISABLE_LINK");
21065
Hoonki Lee5305c3a2013-04-29 23:28:59 -070021066 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080021067 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021068 long status;
21069
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053021070 /* set tdls off channel status to false for this peer */
21071 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053021072 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
21073 eTDLS_LINK_TEARING,
21074 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
21075 eTDLS_LINK_UNSPECIFIED:
21076 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021077 mutex_unlock(&pHddCtx->tdls_lock);
21078
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021079 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
21080
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021081 status = sme_DeleteTdlsPeerSta(
21082 WLAN_HDD_GET_HAL_CTX(pAdapter),
21083 pAdapter->sessionId, peer );
21084 if (status != VOS_STATUS_SUCCESS) {
21085 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
21086 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021087
21088 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
21089 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021090
21091 mutex_lock(&pHddCtx->tdls_lock);
21092 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
21093 if ( NULL == pTdlsPeer ) {
21094 mutex_unlock(&pHddCtx->tdls_lock);
21095 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
21096 " peer was freed in other context",
21097 __func__, MAC_ADDR_ARRAY(peer));
21098 return -EINVAL;
21099 }
21100
Atul Mittal271a7652014-09-12 13:18:22 +053021101 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053021102 eTDLS_LINK_IDLE,
21103 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021104 mutex_unlock(&pHddCtx->tdls_lock);
21105
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021106 if (status <= 0)
21107 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070021108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21109 "%s: Del station failed status %ld",
21110 __func__, status);
21111 return -EPERM;
21112 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021113
21114 /* TDLS Off Channel, Enable tdls channel switch,
21115 when their is only one tdls link and it supports */
21116 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
21117 if (numCurrTdlsPeers == 1)
21118 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021119 tSirMacAddr peerMac;
21120 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053021121
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021122 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021123 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053021124
21125 if (connPeer == NULL) {
21126 mutex_unlock(&pHddCtx->tdls_lock);
21127 hddLog(VOS_TRACE_LEVEL_ERROR,
21128 "%s connPeer is NULL", __func__);
21129 return -EINVAL;
21130 }
21131
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021132 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
21133 channel = connPeer->peerParams.channel;
21134
21135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21136 "%s: TDLS channel switch "
21137 "isOffChannelSupported %d "
21138 "isOffChannelConfigured %d "
21139 "isOffChannelEstablished %d",
21140 __func__,
21141 (connPeer ? connPeer->isOffChannelSupported : -1),
21142 (connPeer ? connPeer->isOffChannelConfigured : -1),
21143 (connPeer ? connPeer->isOffChannelEstablished : -1));
21144
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021145 if ((connPeer) &&
21146 (connPeer->isOffChannelSupported == TRUE) &&
21147 (connPeer->isOffChannelConfigured == TRUE))
21148 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053021149 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021150 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021151 status = sme_SendTdlsChanSwitchReq(
21152 WLAN_HDD_GET_HAL_CTX(pAdapter),
21153 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021154 peerMac,
21155 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053021156 TDLS_OFF_CHANNEL_BW_OFFSET,
21157 TDLS_CHANNEL_SWITCH_ENABLE);
21158 if (status != VOS_STATUS_SUCCESS) {
21159 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
21160 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021161 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021162 else
21163 mutex_unlock(&pHddCtx->tdls_lock);
21164 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021165 else
21166 {
21167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21168 "%s: TDLS channel switch request not sent "
21169 "numCurrTdlsPeers %d ",
21170 __func__, numCurrTdlsPeers);
21171 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080021172 }
21173 else
21174 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053021175 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21177 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080021178 }
Bhargav Shah66896792015-10-01 18:17:37 +053021179 if (numCurrTdlsPeers == 0) {
21180 /* start TCP delack timer if TDLS is disable */
21181 clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
21182 hdd_manage_delack_timer(pHddCtx);
21183 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080021184 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070021185 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021186 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053021187 {
Atul Mittal115287b2014-07-08 13:26:33 +053021188 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021189
Atul Mittal115287b2014-07-08 13:26:33 +053021190 if (0 != status)
21191 {
21192 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021193 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053021194 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053021195 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053021196 break;
21197 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021198 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053021199 {
Atul Mittal115287b2014-07-08 13:26:33 +053021200 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
21201 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053021202 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053021203 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053021204
Atul Mittal115287b2014-07-08 13:26:33 +053021205 if (0 != status)
21206 {
21207 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021208 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053021209 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053021210 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053021211 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053021212 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021213 case NL80211_TDLS_DISCOVERY_REQ:
21214 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053021215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053021216 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053021217 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021218 return -ENOTSUPP;
21219 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053021220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21221 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021222 return -ENOTSUPP;
21223 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021224
21225 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021226 return 0;
21227}
Chilam NG571c65a2013-01-19 12:27:36 +053021228
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021229static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053021230#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
21231 const u8 *peer,
21232#else
21233 u8 *peer,
21234#endif
21235 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021236{
21237 int ret;
21238
21239 vos_ssr_protect(__func__);
21240 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
21241 vos_ssr_unprotect(__func__);
21242
21243 return ret;
21244}
21245
Chilam NG571c65a2013-01-19 12:27:36 +053021246int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
21247 struct net_device *dev, u8 *peer)
21248{
Arif Hussaina7c8e412013-11-20 11:06:42 -080021249 hddLog(VOS_TRACE_LEVEL_INFO,
21250 "tdls send discover req: "MAC_ADDRESS_STR,
21251 MAC_ADDR_ARRAY(peer));
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053021252#if TDLS_MGMT_VERSION2
21253 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21254 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
21255#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053021256#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
21257 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21258 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
21259#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
21260 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21261 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
21262#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
21263 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21264 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
21265#else
Chilam NG571c65a2013-01-19 12:27:36 +053021266 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
21267 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053021268#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053021269#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053021270}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080021271#endif
21272
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021273#ifdef WLAN_FEATURE_GTK_OFFLOAD
21274/*
21275 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
21276 * Callback rountine called upon receiving response for
21277 * get offload info
21278 */
21279void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
21280 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
21281{
21282
21283 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021284 tANI_U8 tempReplayCounter[8];
21285 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021286
21287 ENTER();
21288
21289 if (NULL == pAdapter)
21290 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053021291 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021292 "%s: HDD adapter is Null", __func__);
21293 return ;
21294 }
21295
21296 if (NULL == pGtkOffloadGetInfoRsp)
21297 {
21298 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21299 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
21300 return ;
21301 }
21302
21303 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
21304 {
21305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21306 "%s: wlan Failed to get replay counter value",
21307 __func__);
21308 return ;
21309 }
21310
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021311 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
21312 /* Update replay counter */
21313 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
21314 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
21315
21316 {
21317 /* changing from little to big endian since supplicant
21318 * works on big endian format
21319 */
21320 int i;
21321 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
21322
21323 for (i = 0; i < 8; i++)
21324 {
21325 tempReplayCounter[7-i] = (tANI_U8)p[i];
21326 }
21327 }
21328
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021329 /* Update replay counter to NL */
21330 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021331 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021332}
21333
21334/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021335 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021336 * This function is used to offload GTK rekeying job to the firmware.
21337 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021338int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021339 struct cfg80211_gtk_rekey_data *data)
21340{
21341 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
21342 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
21343 hdd_station_ctx_t *pHddStaCtx;
21344 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021345 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021346 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021347 eHalStatus status = eHAL_STATUS_FAILURE;
21348
21349 ENTER();
21350
21351 if (NULL == pAdapter)
21352 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053021353 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021354 "%s: HDD adapter is Null", __func__);
21355 return -ENODEV;
21356 }
21357
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053021358 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
21359 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
21360 pAdapter->sessionId, pAdapter->device_mode));
21361
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021362 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021363 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021364 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053021365 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021366 }
21367
21368 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
21369 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
21370 if (NULL == hHal)
21371 {
21372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21373 "%s: HAL context is Null!!!", __func__);
21374 return -EAGAIN;
21375 }
21376
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021377 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
21378 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
21379 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
21380 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021381 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021382 {
21383 /* changing from big to little endian since driver
21384 * works on little endian format
21385 */
21386 tANI_U8 *p =
21387 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
21388 int i;
21389
21390 for (i = 0; i < 8; i++)
21391 {
21392 p[7-i] = data->replay_ctr[i];
21393 }
21394 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021395
21396 if (TRUE == pHddCtx->hdd_wlan_suspended)
21397 {
21398 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021399 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
21400 sizeof (tSirGtkOffloadParams));
21401 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021402 pAdapter->sessionId);
21403
21404 if (eHAL_STATUS_SUCCESS != status)
21405 {
21406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21407 "%s: sme_SetGTKOffload failed, returned %d",
21408 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053021409
21410 /* Need to clear any trace of key value in the memory.
21411 * Thus zero out the memory even though it is local
21412 * variable.
21413 */
21414 vos_mem_zero(&hddGtkOffloadReqParams,
21415 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021416 return status;
21417 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21419 "%s: sme_SetGTKOffload successfull", __func__);
21420 }
21421 else
21422 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21424 "%s: wlan not suspended GTKOffload request is stored",
21425 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021426 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021427
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053021428 /* Need to clear any trace of key value in the memory.
21429 * Thus zero out the memory even though it is local
21430 * variable.
21431 */
21432 vos_mem_zero(&hddGtkOffloadReqParams,
21433 sizeof(hddGtkOffloadReqParams));
21434
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021435 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053021436 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021437}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053021438
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021439int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
21440 struct cfg80211_gtk_rekey_data *data)
21441{
21442 int ret;
21443
21444 vos_ssr_protect(__func__);
21445 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
21446 vos_ssr_unprotect(__func__);
21447
21448 return ret;
21449}
21450#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021451/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053021452 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021453 * This function is used to set access control policy
21454 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053021455static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
21456 struct net_device *dev,
21457 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021458{
21459 int i;
21460 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
21461 hdd_hostapd_state_t *pHostapdState;
21462 tsap_Config_t *pConfig;
21463 v_CONTEXT_t pVosContext = NULL;
21464 hdd_context_t *pHddCtx;
21465 int status;
21466
21467 ENTER();
21468
21469 if (NULL == pAdapter)
21470 {
21471 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
21472 "%s: HDD adapter is Null", __func__);
21473 return -ENODEV;
21474 }
21475
21476 if (NULL == params)
21477 {
21478 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
21479 "%s: params is Null", __func__);
21480 return -EINVAL;
21481 }
21482
21483 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
21484 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021485 if (0 != status)
21486 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021487 return status;
21488 }
21489
21490 pVosContext = pHddCtx->pvosContext;
21491 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
21492
21493 if (NULL == pHostapdState)
21494 {
21495 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
21496 "%s: pHostapdState is Null", __func__);
21497 return -EINVAL;
21498 }
21499
21500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
21501 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053021502 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
21503 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
21504 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021505
21506 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
21507 {
21508 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
21509
21510 /* default value */
21511 pConfig->num_accept_mac = 0;
21512 pConfig->num_deny_mac = 0;
21513
21514 /**
21515 * access control policy
21516 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
21517 * listed in hostapd.deny file.
21518 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
21519 * listed in hostapd.accept file.
21520 */
21521 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
21522 {
21523 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
21524 }
21525 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
21526 {
21527 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
21528 }
21529 else
21530 {
21531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21532 "%s:Acl Policy : %d is not supported",
21533 __func__, params->acl_policy);
21534 return -ENOTSUPP;
21535 }
21536
21537 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
21538 {
21539 pConfig->num_accept_mac = params->n_acl_entries;
21540 for (i = 0; i < params->n_acl_entries; i++)
21541 {
21542 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21543 "** Add ACL MAC entry %i in WhiletList :"
21544 MAC_ADDRESS_STR, i,
21545 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
21546
21547 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
21548 sizeof(qcmacaddr));
21549 }
21550 }
21551 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
21552 {
21553 pConfig->num_deny_mac = params->n_acl_entries;
21554 for (i = 0; i < params->n_acl_entries; i++)
21555 {
21556 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21557 "** Add ACL MAC entry %i in BlackList :"
21558 MAC_ADDRESS_STR, i,
21559 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
21560
21561 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
21562 sizeof(qcmacaddr));
21563 }
21564 }
21565
21566 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
21567 {
21568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21569 "%s: SAP Set Mac Acl fail", __func__);
21570 return -EINVAL;
21571 }
21572 }
21573 else
21574 {
21575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053021576 "%s: Invalid device_mode = %s (%d)",
21577 __func__, hdd_device_modetoString(pAdapter->device_mode),
21578 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021579 return -EINVAL;
21580 }
21581
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021582 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053021583 return 0;
21584}
21585
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053021586static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
21587 struct net_device *dev,
21588 const struct cfg80211_acl_data *params)
21589{
21590 int ret;
21591 vos_ssr_protect(__func__);
21592 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
21593 vos_ssr_unprotect(__func__);
21594
21595 return ret;
21596}
21597
Leo Chang9056f462013-08-01 19:21:11 -070021598#ifdef WLAN_NL80211_TESTMODE
21599#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070021600void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070021601(
21602 void *pAdapter,
21603 void *indCont
21604)
21605{
Leo Changd9df8aa2013-09-26 13:32:26 -070021606 tSirLPHBInd *lphbInd;
21607 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053021608 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070021609
21610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070021611 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070021612
c_hpothu73f35e62014-04-18 13:40:08 +053021613 if (pAdapter == NULL)
21614 {
21615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21616 "%s: pAdapter is NULL\n",__func__);
21617 return;
21618 }
21619
Leo Chang9056f462013-08-01 19:21:11 -070021620 if (NULL == indCont)
21621 {
21622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070021623 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070021624 return;
21625 }
21626
c_hpothu73f35e62014-04-18 13:40:08 +053021627 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070021628 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070021629 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053021630 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070021631 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070021632 GFP_ATOMIC);
21633 if (!skb)
21634 {
21635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21636 "LPHB timeout, NL buffer alloc fail");
21637 return;
21638 }
21639
Leo Changac3ba772013-10-07 09:47:04 -070021640 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070021641 {
21642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21643 "WLAN_HDD_TM_ATTR_CMD put fail");
21644 goto nla_put_failure;
21645 }
Leo Changac3ba772013-10-07 09:47:04 -070021646 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070021647 {
21648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21649 "WLAN_HDD_TM_ATTR_TYPE put fail");
21650 goto nla_put_failure;
21651 }
Leo Changac3ba772013-10-07 09:47:04 -070021652 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070021653 sizeof(tSirLPHBInd), lphbInd))
21654 {
21655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21656 "WLAN_HDD_TM_ATTR_DATA put fail");
21657 goto nla_put_failure;
21658 }
Leo Chang9056f462013-08-01 19:21:11 -070021659 cfg80211_testmode_event(skb, GFP_ATOMIC);
21660 return;
21661
21662nla_put_failure:
21663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21664 "NLA Put fail");
21665 kfree_skb(skb);
21666
21667 return;
21668}
21669#endif /* FEATURE_WLAN_LPHB */
21670
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021671static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070021672{
21673 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
21674 int err = 0;
21675#ifdef FEATURE_WLAN_LPHB
21676 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070021677 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021678
21679 ENTER();
21680
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053021681 err = wlan_hdd_validate_context(pHddCtx);
21682 if (0 != err)
21683 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053021684 return err;
21685 }
Leo Chang9056f462013-08-01 19:21:11 -070021686#endif /* FEATURE_WLAN_LPHB */
21687
21688 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
21689 if (err)
21690 {
21691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21692 "%s Testmode INV ATTR", __func__);
21693 return err;
21694 }
21695
21696 if (!tb[WLAN_HDD_TM_ATTR_CMD])
21697 {
21698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21699 "%s Testmode INV CMD", __func__);
21700 return -EINVAL;
21701 }
21702
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053021703 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
21704 TRACE_CODE_HDD_CFG80211_TESTMODE,
21705 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070021706 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
21707 {
21708#ifdef FEATURE_WLAN_LPHB
21709 /* Low Power Heartbeat configuration request */
21710 case WLAN_HDD_TM_CMD_WLAN_HB:
21711 {
21712 int buf_len;
21713 void *buf;
21714 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080021715 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070021716
21717 if (!tb[WLAN_HDD_TM_ATTR_DATA])
21718 {
21719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21720 "%s Testmode INV DATA", __func__);
21721 return -EINVAL;
21722 }
21723
21724 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
21725 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080021726
Manjeet Singh3c577442017-02-10 19:03:38 +053021727 if (buf_len > sizeof(*hb_params)) {
21728 hddLog(LOGE, FL("buf_len=%d exceeded hb_params size limit"),
21729 buf_len);
21730 return -ERANGE;
21731 }
21732
Amar Singhal05852702014-02-04 14:40:00 -080021733 hb_params_temp =(tSirLPHBReq *)buf;
21734 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
21735 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
21736 return -EINVAL;
21737
Leo Chang9056f462013-08-01 19:21:11 -070021738 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
21739 if (NULL == hb_params)
21740 {
21741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21742 "%s Request Buffer Alloc Fail", __func__);
21743 return -EINVAL;
21744 }
21745
Ashish Kumar Dhanotiya3a8c0a72017-07-13 18:58:59 +053021746 vos_mem_zero(hb_params, sizeof(tSirLPHBReq));
Leo Chang9056f462013-08-01 19:21:11 -070021747 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070021748 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
21749 hb_params,
21750 wlan_hdd_cfg80211_lphb_ind_handler);
21751 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070021752 {
Leo Changd9df8aa2013-09-26 13:32:26 -070021753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21754 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070021755 vos_mem_free(hb_params);
21756 }
Leo Chang9056f462013-08-01 19:21:11 -070021757 return 0;
21758 }
21759#endif /* FEATURE_WLAN_LPHB */
21760 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053021761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
21762 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070021763 return -EOPNOTSUPP;
21764 }
21765
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021766 EXIT();
21767 return err;
Leo Chang9056f462013-08-01 19:21:11 -070021768}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021769
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053021770static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
21771#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
21772 struct wireless_dev *wdev,
21773#endif
21774 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021775{
21776 int ret;
21777
21778 vos_ssr_protect(__func__);
21779 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
21780 vos_ssr_unprotect(__func__);
21781
21782 return ret;
21783}
Leo Chang9056f462013-08-01 19:21:11 -070021784#endif /* CONFIG_NL80211_TESTMODE */
21785
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053021786extern void hdd_set_wlan_suspend_mode(bool suspend);
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021787static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053021788 struct net_device *dev,
21789 int idx, struct survey_info *survey)
21790{
21791 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
21792 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053021793 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053021794 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053021795 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053021796 v_S7_t snr,rssi;
21797 int status, i, j, filled = 0;
21798
21799 ENTER();
21800
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053021801 if (NULL == pAdapter)
21802 {
21803 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
21804 "%s: HDD adapter is Null", __func__);
21805 return -ENODEV;
21806 }
21807
21808 if (NULL == wiphy)
21809 {
21810 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
21811 "%s: wiphy is Null", __func__);
21812 return -ENODEV;
21813 }
21814
21815 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
21816 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053021817 if (0 != status)
21818 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053021819 return status;
21820 }
21821
Mihir Sheted9072e02013-08-21 17:02:29 +053021822 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
21823
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053021824 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053021825 0 != pAdapter->survey_idx ||
21826 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053021827 {
21828 /* The survey dump ops when implemented completely is expected to
21829 * return a survey of all channels and the ops is called by the
21830 * kernel with incremental values of the argument 'idx' till it
21831 * returns -ENONET. But we can only support the survey for the
21832 * operating channel for now. survey_idx is used to track
21833 * that the ops is called only once and then return -ENONET for
21834 * the next iteration
21835 */
21836 pAdapter->survey_idx = 0;
21837 return -ENONET;
21838 }
21839
Mukul Sharma9d5233b2015-06-11 20:28:20 +053021840 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
21841 {
21842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21843 "%s: Roaming in progress, hence return ", __func__);
21844 return -ENONET;
21845 }
21846
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053021847 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
21848
21849 wlan_hdd_get_snr(pAdapter, &snr);
21850 wlan_hdd_get_rssi(pAdapter, &rssi);
21851
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053021852 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
21853 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
21854 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053021855 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
21856 hdd_wlan_get_freq(channel, &freq);
21857
21858
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053021859 for (i = 0; i < HDD_NUM_NL80211_BANDS; i++)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053021860 {
21861 if (NULL == wiphy->bands[i])
21862 {
21863 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
21864 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
21865 continue;
21866 }
21867
21868 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
21869 {
21870 struct ieee80211_supported_band *band = wiphy->bands[i];
21871
21872 if (band->channels[j].center_freq == (v_U16_t)freq)
21873 {
21874 survey->channel = &band->channels[j];
21875 /* The Rx BDs contain SNR values in dB for the received frames
21876 * while the supplicant expects noise. So we calculate and
21877 * return the value of noise (dBm)
21878 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
21879 */
21880 survey->noise = rssi - snr;
21881 survey->filled = SURVEY_INFO_NOISE_DBM;
21882 filled = 1;
21883 }
21884 }
21885 }
21886
21887 if (filled)
21888 pAdapter->survey_idx = 1;
21889 else
21890 {
21891 pAdapter->survey_idx = 0;
21892 return -ENONET;
21893 }
21894
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021895 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053021896 return 0;
21897}
21898
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053021899static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
21900 struct net_device *dev,
21901 int idx, struct survey_info *survey)
21902{
21903 int ret;
21904
21905 vos_ssr_protect(__func__);
21906 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
21907 vos_ssr_unprotect(__func__);
21908
21909 return ret;
21910}
21911
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053021912/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053021913 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053021914 * this is called when cfg80211 driver resume
21915 * driver updates latest sched_scan scan result(if any) to cfg80211 database
21916 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053021917int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053021918{
21919 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
21920 hdd_adapter_t *pAdapter;
21921 hdd_adapter_list_node_t *pAdapterNode, *pNext;
21922 VOS_STATUS status = VOS_STATUS_SUCCESS;
21923
21924 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021925
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053021926 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053021927 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053021928 return 0;
21929 }
21930
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053021931 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
21932 NO_SESSION, pHddCtx->isWiphySuspended));
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053021933
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053021934 if (pHddCtx->is_ap_mode_wow_supported)
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053021935 {
21936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21937 "%s: Resume SoftAP", __func__);
21938 hdd_set_wlan_suspend_mode(false);
21939 }
21940
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053021941 spin_lock(&pHddCtx->schedScan_lock);
21942 pHddCtx->isWiphySuspended = FALSE;
21943 if (TRUE != pHddCtx->isSchedScanUpdatePending)
21944 {
21945 spin_unlock(&pHddCtx->schedScan_lock);
21946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21947 "%s: Return resume is not due to PNO indication", __func__);
21948 return 0;
21949 }
21950 // Reset flag to avoid updatating cfg80211 data old results again
21951 pHddCtx->isSchedScanUpdatePending = FALSE;
21952 spin_unlock(&pHddCtx->schedScan_lock);
21953
21954 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
21955
21956 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
21957 {
21958 pAdapter = pAdapterNode->pAdapter;
21959 if ( (NULL != pAdapter) &&
21960 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
21961 {
21962 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053021963 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053021964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
21965 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053021966 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053021967 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053021968 {
21969 /* Acquire wakelock to handle the case where APP's tries to
21970 * suspend immediately after updating the scan results. Whis
21971 * results in app's is in suspended state and not able to
21972 * process the connect request to AP
21973 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053021974 hdd_prevent_suspend_timeout(2000,
21975 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053021976 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053021977 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053021978
21979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21980 "%s : cfg80211 scan result database updated", __func__);
21981
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021982 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053021983 return 0;
21984
21985 }
21986 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
21987 pAdapterNode = pNext;
21988 }
21989
21990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
21991 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053021992 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053021993 return 0;
21994}
21995
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053021996int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
21997{
21998 int ret;
21999
22000 vos_ssr_protect(__func__);
22001 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
22002 vos_ssr_unprotect(__func__);
22003
22004 return ret;
22005}
22006
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022007/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022008 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022009 * this is called when cfg80211 driver suspends
22010 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022011int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022012 struct cfg80211_wowlan *wow)
22013{
22014 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022015 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022016
22017 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053022018
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022019 ret = wlan_hdd_validate_context(pHddCtx);
22020 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022021 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022022 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022023 }
22024
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053022025 if (pHddCtx->is_ap_mode_wow_supported) {
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053022026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
22027 "%s: Suspend SoftAP", __func__);
22028 hdd_set_wlan_suspend_mode(true);
22029 }
22030
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053022031
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053022032 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
22033 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
22034 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022035 pHddCtx->isWiphySuspended = TRUE;
22036
22037 EXIT();
22038
22039 return 0;
22040}
22041
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053022042int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
22043 struct cfg80211_wowlan *wow)
22044{
22045 int ret;
22046
22047 vos_ssr_protect(__func__);
22048 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
22049 vos_ssr_unprotect(__func__);
22050
22051 return ret;
22052}
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022053
22054#ifdef FEATURE_OEM_DATA_SUPPORT
22055static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022056 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022057{
22058 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
22059
22060 ENTER();
22061
22062 if (wlan_hdd_validate_context(pHddCtx)) {
22063 return;
22064 }
22065 if (!pMsg)
22066 {
22067 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
22068 return;
22069 }
22070
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022071 send_oem_data_rsp_msg(evLen, pMsg);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022072
22073 EXIT();
22074 return;
22075
22076}
22077
22078void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022079 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022080{
22081 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
22082
22083 ENTER();
22084
22085 if (wlan_hdd_validate_context(pHddCtx)) {
22086 return;
22087 }
22088
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022089 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d) evLen %d"), evType, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022090
22091 switch(evType) {
22092 case SIR_HAL_START_OEM_DATA_RSP_IND_NEW:
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053022093 wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053022094 break;
22095 default:
22096 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
22097 break;
22098 }
22099 EXIT();
22100}
22101#endif
22102
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053022103#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
22104 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053022105/**
22106 * __wlan_hdd_cfg80211_abort_scan() - cfg80211 abort scan api
22107 * @wiphy: Pointer to wiphy
22108 * @wdev: Pointer to wireless device structure
22109 *
22110 * This function is used to abort an ongoing scan
22111 *
22112 * Return: None
22113 */
22114static void __wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
22115 struct wireless_dev *wdev)
22116{
22117 struct net_device *dev = wdev->netdev;
22118 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
22119 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
22120 int ret;
22121
22122 ENTER();
22123
22124 if (NULL == adapter) {
22125 hddLog(VOS_TRACE_LEVEL_FATAL, FL("HDD adapter is NULL"));
22126 return;
22127 }
22128
22129 ret = wlan_hdd_validate_context(hdd_ctx);
22130 if (0 != ret)
22131 return;
22132
22133 wlan_hdd_scan_abort(adapter);
22134
22135 return;
22136}
22137
22138/**
22139 * wlan_hdd_cfg80211_abort_scan - cfg80211 abort scan api
22140 * @wiphy: Pointer to wiphy
22141 * @wdev: Pointer to wireless device structure
22142 *
22143 * Return: None
22144 */
22145void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
22146 struct wireless_dev *wdev)
22147{
22148 vos_ssr_protect(__func__);
22149 __wlan_hdd_cfg80211_abort_scan(wiphy, wdev);
22150 vos_ssr_unprotect(__func__);
22151
22152 return;
22153}
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053022154#endif
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053022155
Abhishek Singh936c6932017-11-07 17:28:23 +053022156#ifdef CHANNEL_SWITCH_SUPPORTED
22157/**
22158 * __wlan_hdd_cfg80211_channel_switch()- function to switch
22159 * channel in SAP/GO
22160 * @wiphy: wiphy pointer
22161 * @dev: dev pointer.
22162 * @csa_params: Change channel params
22163 *
22164 * This function is called to switch channel in SAP/GO
22165 *
22166 * Return: 0 if success else return non zero
22167 */
22168static int __wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy,
22169 struct net_device *dev, struct cfg80211_csa_settings *csa_params)
22170{
22171 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
22172 hdd_context_t *hdd_ctx;
22173 uint8_t channel;
22174 int ret;
Abhishek Singh10e17cf2018-03-12 14:34:22 +053022175 ptSapContext sap_ctx;
Abhishek Singh936c6932017-11-07 17:28:23 +053022176 v_CONTEXT_t vos_ctx;
22177
22178 hddLog(LOGE, FL("Set Freq %d"), csa_params->chandef.chan->center_freq);
22179
22180 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
22181 ret = wlan_hdd_validate_context(hdd_ctx);
22182 if (ret)
22183 return ret;
22184
22185 vos_ctx = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
22186 if (!vos_ctx) {
22187 hddLog(LOGE, FL("Vos ctx is null"));
22188 return -EINVAL;
22189 }
22190
Abhishek Singh10e17cf2018-03-12 14:34:22 +053022191 if (WLAN_HDD_SOFTAP != adapter->device_mode)
Abhishek Singh936c6932017-11-07 17:28:23 +053022192 return -ENOTSUPP;
22193
Abhishek Singh10e17cf2018-03-12 14:34:22 +053022194 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
22195 if (!sap_ctx) {
22196 hddLog(LOGE, FL("sap_ctx is NULL"));
22197 return -EINVAL;
22198 }
22199
22200 ret = wlansap_chk_n_set_chan_change_in_progress(sap_ctx);
22201 if (ret)
22202 return ret;
22203
22204 INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp);
22205
Abhishek Singh936c6932017-11-07 17:28:23 +053022206 channel = vos_freq_to_chan(csa_params->chandef.chan->center_freq);
Abhishek Singhceb6fe22017-11-27 13:53:18 +053022207 ret = wlansap_set_channel_change(vos_ctx, channel, false);
Abhishek Singh936c6932017-11-07 17:28:23 +053022208
Abhishek Singh10e17cf2018-03-12 14:34:22 +053022209 if (ret) {
22210 wlansap_reset_chan_change_in_progress(sap_ctx);
22211 complete(&sap_ctx->ecsa_info.chan_switch_comp);
22212 }
22213
Abhishek Singh936c6932017-11-07 17:28:23 +053022214 return ret;
22215}
22216
22217/**
22218 * wlan_hdd_cfg80211_channel_switch()- function to switch
22219 * channel in SAP/GO
22220 * @wiphy: wiphy pointer
22221 * @dev: dev pointer.
22222 * @csa_params: Change channel params
22223 *
22224 * This function is called to switch channel in SAP/GO
22225 *
22226 * Return: 0 if success else return non zero
22227 */
22228static int wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy,
22229 struct net_device *dev, struct cfg80211_csa_settings *csa_params)
22230{
22231 int ret;
22232
22233 vos_ssr_protect(__func__);
22234 ret = __wlan_hdd_cfg80211_channel_switch(wiphy, dev, csa_params);
22235 vos_ssr_unprotect(__func__);
22236
22237 return ret;
22238}
22239#endif
22240
Jeff Johnson295189b2012-06-20 16:38:30 -070022241/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053022242static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070022243{
22244 .add_virtual_intf = wlan_hdd_add_virtual_intf,
22245 .del_virtual_intf = wlan_hdd_del_virtual_intf,
22246 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
22247 .change_station = wlan_hdd_change_station,
22248#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
22249 .add_beacon = wlan_hdd_cfg80211_add_beacon,
22250 .del_beacon = wlan_hdd_cfg80211_del_beacon,
22251 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070022252#else
22253 .start_ap = wlan_hdd_cfg80211_start_ap,
22254 .change_beacon = wlan_hdd_cfg80211_change_beacon,
22255 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070022256#endif
22257 .change_bss = wlan_hdd_cfg80211_change_bss,
22258 .add_key = wlan_hdd_cfg80211_add_key,
22259 .get_key = wlan_hdd_cfg80211_get_key,
22260 .del_key = wlan_hdd_cfg80211_del_key,
22261 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080022262#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070022263 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080022264#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070022265 .scan = wlan_hdd_cfg80211_scan,
22266 .connect = wlan_hdd_cfg80211_connect,
22267 .disconnect = wlan_hdd_cfg80211_disconnect,
22268 .join_ibss = wlan_hdd_cfg80211_join_ibss,
22269 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
22270 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
22271 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
22272 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070022273 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
22274 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053022275 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070022276#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
22277 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
22278 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
22279 .set_txq_params = wlan_hdd_set_txq_params,
22280#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070022281 .get_station = wlan_hdd_cfg80211_get_station,
22282 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
22283 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070022284 .add_station = wlan_hdd_cfg80211_add_station,
22285#ifdef FEATURE_WLAN_LFR
22286 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
22287 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
22288 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
22289#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070022290#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
22291 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
22292#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080022293#ifdef FEATURE_WLAN_TDLS
22294 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
22295 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
22296#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053022297#ifdef WLAN_FEATURE_GTK_OFFLOAD
22298 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
22299#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053022300#ifdef FEATURE_WLAN_SCAN_PNO
22301 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
22302 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
22303#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053022304 .resume = wlan_hdd_cfg80211_resume_wlan,
22305 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053022306 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070022307#ifdef WLAN_NL80211_TESTMODE
22308 .testmode_cmd = wlan_hdd_cfg80211_testmode,
22309#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053022310 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053022311#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
22312 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053022313 .abort_scan = wlan_hdd_cfg80211_abort_scan,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053022314#endif
Abhishek Singh936c6932017-11-07 17:28:23 +053022315#ifdef CHANNEL_SWITCH_SUPPORTED
22316 .channel_switch = wlan_hdd_cfg80211_channel_switch,
22317#endif
22318
Jeff Johnson295189b2012-06-20 16:38:30 -070022319};
22320