blob: 366776e2bd0011c388f05e97020c11d4f27fdcfa [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +053026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Kiet Lama7f454d2014-07-24 12:04:06 -070030
31
Jeff Johnson295189b2012-06-20 16:38:30 -070032/**========================================================================
33
34 \file wlan_hdd_cfg80211.c
35
36 \brief WLAN Host Device Driver implementation
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070041
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070042 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070049 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070053 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070054 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070057 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070058 ==========================================================================*/
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
66#include <wlan_hdd_includes.h>
67#include <net/arp.h>
68#include <net/cfg80211.h>
69#include <linux/wireless.h>
70#include <wlan_hdd_wowl.h>
71#include <aniGlobal.h>
72#include "ccmApi.h"
73#include "sirParams.h"
74#include "dot11f.h"
75#include "wlan_hdd_assoc.h"
76#include "wlan_hdd_wext.h"
77#include "sme_Api.h"
78#include "wlan_hdd_p2p.h"
79#include "wlan_hdd_cfg80211.h"
80#include "wlan_hdd_hostapd.h"
81#include "sapInternal.h"
82#include "wlan_hdd_softap_tx_rx.h"
83#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053084#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053085#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089#ifdef WLAN_BTAMP_FEATURE
90#include "bap_hdd_misc.h"
91#endif
92#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080093#ifdef FEATURE_WLAN_TDLS
94#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"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080097#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053098#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070099#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700100
101#define g_mode_rates_size (12)
102#define a_mode_rates_size (8)
103#define FREQ_BASE_80211G (2407)
104#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700105#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530106#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700107#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800108 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700109
110#define HDD2GHZCHAN(freq, chan, flag) { \
111 .band = IEEE80211_BAND_2GHZ, \
112 .center_freq = (freq), \
113 .hw_value = (chan),\
114 .flags = (flag), \
115 .max_antenna_gain = 0 ,\
116 .max_power = 30, \
117}
118
119#define HDD5GHZCHAN(freq, chan, flag) { \
120 .band = IEEE80211_BAND_5GHZ, \
121 .center_freq = (freq), \
122 .hw_value = (chan),\
123 .flags = (flag), \
124 .max_antenna_gain = 0 ,\
125 .max_power = 30, \
126}
127
128#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
129{\
130 .bitrate = rate, \
131 .hw_value = rate_id, \
132 .flags = flag, \
133}
134
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530135#ifdef WLAN_FEATURE_VOWIFI_11R
136#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
137#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
138#endif
139
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530141#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530142
Sunil Duttc69bccb2014-05-26 21:30:20 +0530143#ifdef WLAN_FEATURE_LINK_LAYER_STATS
144/*
145 * Used to allocate the size of 4096 for the link layer stats.
146 * The size of 4096 is considered assuming that all data per
147 * respective event fit with in the limit.Please take a call
148 * on the limit based on the data requirements on link layer
149 * statistics.
150 */
151#define LL_STATS_EVENT_BUF_SIZE 4096
152#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530153#ifdef WLAN_FEATURE_EXTSCAN
154/*
155 * Used to allocate the size of 4096 for the EXTScan NL data.
156 * The size of 4096 is considered assuming that all data per
157 * respective event fit with in the limit.Please take a call
158 * on the limit based on the data requirements.
159 */
160
161#define EXTSCAN_EVENT_BUF_SIZE 4096
162#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
163#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530164
Atul Mittal115287b2014-07-08 13:26:33 +0530165/*EXT TDLS*/
166/*
167 * Used to allocate the size of 4096 for the TDLS.
168 * The size of 4096 is considered assuming that all data per
169 * respective event fit with in the limit.Please take a call
170 * on the limit based on the data requirements on link layer
171 * statistics.
172 */
173#define EXTTDLS_EVENT_BUF_SIZE 4096
174
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530175static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700176{
177 WLAN_CIPHER_SUITE_WEP40,
178 WLAN_CIPHER_SUITE_WEP104,
179 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800180#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700181#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
182 WLAN_CIPHER_SUITE_KRK,
183 WLAN_CIPHER_SUITE_CCMP,
184#else
185 WLAN_CIPHER_SUITE_CCMP,
186#endif
187#ifdef FEATURE_WLAN_WAPI
188 WLAN_CIPHER_SUITE_SMS4,
189#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700190#ifdef WLAN_FEATURE_11W
191 WLAN_CIPHER_SUITE_AES_CMAC,
192#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700193};
194
195static inline int is_broadcast_ether_addr(const u8 *addr)
196{
197 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
198 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
199}
200
201static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530202{
Jeff Johnson295189b2012-06-20 16:38:30 -0700203 HDD2GHZCHAN(2412, 1, 0) ,
204 HDD2GHZCHAN(2417, 2, 0) ,
205 HDD2GHZCHAN(2422, 3, 0) ,
206 HDD2GHZCHAN(2427, 4, 0) ,
207 HDD2GHZCHAN(2432, 5, 0) ,
208 HDD2GHZCHAN(2437, 6, 0) ,
209 HDD2GHZCHAN(2442, 7, 0) ,
210 HDD2GHZCHAN(2447, 8, 0) ,
211 HDD2GHZCHAN(2452, 9, 0) ,
212 HDD2GHZCHAN(2457, 10, 0) ,
213 HDD2GHZCHAN(2462, 11, 0) ,
214 HDD2GHZCHAN(2467, 12, 0) ,
215 HDD2GHZCHAN(2472, 13, 0) ,
216 HDD2GHZCHAN(2484, 14, 0) ,
217};
218
Jeff Johnson295189b2012-06-20 16:38:30 -0700219static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
220{
221 HDD2GHZCHAN(2412, 1, 0) ,
222 HDD2GHZCHAN(2437, 6, 0) ,
223 HDD2GHZCHAN(2462, 11, 0) ,
224};
Jeff Johnson295189b2012-06-20 16:38:30 -0700225
226static struct ieee80211_channel hdd_channels_5_GHZ[] =
227{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700228 HDD5GHZCHAN(4920, 240, 0) ,
229 HDD5GHZCHAN(4940, 244, 0) ,
230 HDD5GHZCHAN(4960, 248, 0) ,
231 HDD5GHZCHAN(4980, 252, 0) ,
232 HDD5GHZCHAN(5040, 208, 0) ,
233 HDD5GHZCHAN(5060, 212, 0) ,
234 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 HDD5GHZCHAN(5180, 36, 0) ,
236 HDD5GHZCHAN(5200, 40, 0) ,
237 HDD5GHZCHAN(5220, 44, 0) ,
238 HDD5GHZCHAN(5240, 48, 0) ,
239 HDD5GHZCHAN(5260, 52, 0) ,
240 HDD5GHZCHAN(5280, 56, 0) ,
241 HDD5GHZCHAN(5300, 60, 0) ,
242 HDD5GHZCHAN(5320, 64, 0) ,
243 HDD5GHZCHAN(5500,100, 0) ,
244 HDD5GHZCHAN(5520,104, 0) ,
245 HDD5GHZCHAN(5540,108, 0) ,
246 HDD5GHZCHAN(5560,112, 0) ,
247 HDD5GHZCHAN(5580,116, 0) ,
248 HDD5GHZCHAN(5600,120, 0) ,
249 HDD5GHZCHAN(5620,124, 0) ,
250 HDD5GHZCHAN(5640,128, 0) ,
251 HDD5GHZCHAN(5660,132, 0) ,
252 HDD5GHZCHAN(5680,136, 0) ,
253 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800254#ifdef FEATURE_WLAN_CH144
255 HDD5GHZCHAN(5720,144, 0) ,
256#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 HDD5GHZCHAN(5745,149, 0) ,
258 HDD5GHZCHAN(5765,153, 0) ,
259 HDD5GHZCHAN(5785,157, 0) ,
260 HDD5GHZCHAN(5805,161, 0) ,
261 HDD5GHZCHAN(5825,165, 0) ,
262};
263
264static struct ieee80211_rate g_mode_rates[] =
265{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530266 HDD_G_MODE_RATETAB(10, 0x1, 0),
267 HDD_G_MODE_RATETAB(20, 0x2, 0),
268 HDD_G_MODE_RATETAB(55, 0x4, 0),
269 HDD_G_MODE_RATETAB(110, 0x8, 0),
270 HDD_G_MODE_RATETAB(60, 0x10, 0),
271 HDD_G_MODE_RATETAB(90, 0x20, 0),
272 HDD_G_MODE_RATETAB(120, 0x40, 0),
273 HDD_G_MODE_RATETAB(180, 0x80, 0),
274 HDD_G_MODE_RATETAB(240, 0x100, 0),
275 HDD_G_MODE_RATETAB(360, 0x200, 0),
276 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700277 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530278};
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280static struct ieee80211_rate a_mode_rates[] =
281{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530282 HDD_G_MODE_RATETAB(60, 0x10, 0),
283 HDD_G_MODE_RATETAB(90, 0x20, 0),
284 HDD_G_MODE_RATETAB(120, 0x40, 0),
285 HDD_G_MODE_RATETAB(180, 0x80, 0),
286 HDD_G_MODE_RATETAB(240, 0x100, 0),
287 HDD_G_MODE_RATETAB(360, 0x200, 0),
288 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 HDD_G_MODE_RATETAB(540, 0x800, 0),
290};
291
292static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
293{
294 .channels = hdd_channels_2_4_GHZ,
295 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
296 .band = IEEE80211_BAND_2GHZ,
297 .bitrates = g_mode_rates,
298 .n_bitrates = g_mode_rates_size,
299 .ht_cap.ht_supported = 1,
300 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
301 | IEEE80211_HT_CAP_GRN_FLD
302 | IEEE80211_HT_CAP_DSSSCCK40
303 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
304 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
305 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
306 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
307 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
308 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
309};
310
Jeff Johnson295189b2012-06-20 16:38:30 -0700311static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
312{
313 .channels = hdd_social_channels_2_4_GHZ,
314 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
315 .band = IEEE80211_BAND_2GHZ,
316 .bitrates = g_mode_rates,
317 .n_bitrates = g_mode_rates_size,
318 .ht_cap.ht_supported = 1,
319 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
320 | IEEE80211_HT_CAP_GRN_FLD
321 | IEEE80211_HT_CAP_DSSSCCK40
322 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
323 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
324 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
325 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
326 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
327 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
328};
Jeff Johnson295189b2012-06-20 16:38:30 -0700329
330static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
331{
332 .channels = hdd_channels_5_GHZ,
333 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
334 .band = IEEE80211_BAND_5GHZ,
335 .bitrates = a_mode_rates,
336 .n_bitrates = a_mode_rates_size,
337 .ht_cap.ht_supported = 1,
338 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
339 | IEEE80211_HT_CAP_GRN_FLD
340 | IEEE80211_HT_CAP_DSSSCCK40
341 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
342 | IEEE80211_HT_CAP_SGI_40
343 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
344 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
345 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
346 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
347 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
348 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
349};
350
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530351/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 TX/RX direction for each kind of interface */
353static const struct ieee80211_txrx_stypes
354wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
355 [NL80211_IFTYPE_STATION] = {
356 .tx = 0xffff,
357 .rx = BIT(SIR_MAC_MGMT_ACTION) |
358 BIT(SIR_MAC_MGMT_PROBE_REQ),
359 },
360 [NL80211_IFTYPE_AP] = {
361 .tx = 0xffff,
362 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
363 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
364 BIT(SIR_MAC_MGMT_PROBE_REQ) |
365 BIT(SIR_MAC_MGMT_DISASSOC) |
366 BIT(SIR_MAC_MGMT_AUTH) |
367 BIT(SIR_MAC_MGMT_DEAUTH) |
368 BIT(SIR_MAC_MGMT_ACTION),
369 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700370 [NL80211_IFTYPE_ADHOC] = {
371 .tx = 0xffff,
372 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
373 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
374 BIT(SIR_MAC_MGMT_PROBE_REQ) |
375 BIT(SIR_MAC_MGMT_DISASSOC) |
376 BIT(SIR_MAC_MGMT_AUTH) |
377 BIT(SIR_MAC_MGMT_DEAUTH) |
378 BIT(SIR_MAC_MGMT_ACTION),
379 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 [NL80211_IFTYPE_P2P_CLIENT] = {
381 .tx = 0xffff,
382 .rx = BIT(SIR_MAC_MGMT_ACTION) |
383 BIT(SIR_MAC_MGMT_PROBE_REQ),
384 },
385 [NL80211_IFTYPE_P2P_GO] = {
386 /* This is also same as for SoftAP */
387 .tx = 0xffff,
388 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
389 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
390 BIT(SIR_MAC_MGMT_PROBE_REQ) |
391 BIT(SIR_MAC_MGMT_DISASSOC) |
392 BIT(SIR_MAC_MGMT_AUTH) |
393 BIT(SIR_MAC_MGMT_DEAUTH) |
394 BIT(SIR_MAC_MGMT_ACTION),
395 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700396};
397
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800398#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800399static const struct ieee80211_iface_limit
400wlan_hdd_iface_limit[] = {
401 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800402 /* max = 3 ; Our driver create two interfaces during driver init
403 * wlan0 and p2p0 interfaces. p2p0 is considered as station
404 * interface until a group is formed. In JB architecture, once the
405 * group is formed, interface type of p2p0 is changed to P2P GO or
406 * Client.
407 * When supplicant remove the group, it first issue a set interface
408 * cmd to change the mode back to Station. In JB this works fine as
409 * we advertize two station type interface during driver init.
410 * Some vendors create separate interface for P2P GO/Client,
411 * after group formation(Third one). But while group remove
412 * supplicant first tries to change the mode(3rd interface) to STATION
413 * But as we advertized only two sta type interfaces nl80211 was
414 * returning error for the third one which was leading to failure in
415 * delete interface. Ideally while removing the group, supplicant
416 * should not try to change the 3rd interface mode to Station type.
417 * Till we get a fix in wpa_supplicant, we advertize max STA
418 * interface type to 3
419 */
420 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800421 .types = BIT(NL80211_IFTYPE_STATION),
422 },
423 {
424 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700425 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800426 },
427 {
428 .max = 1,
429 .types = BIT(NL80211_IFTYPE_P2P_GO) |
430 BIT(NL80211_IFTYPE_P2P_CLIENT),
431 },
432};
433
434/* By default, only single channel concurrency is allowed */
435static struct ieee80211_iface_combination
436wlan_hdd_iface_combination = {
437 .limits = wlan_hdd_iface_limit,
438 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800439 /*
440 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
441 * and p2p0 interfaces during driver init
442 * Some vendors create separate interface for P2P operations.
443 * wlan0: STA interface
444 * p2p0: P2P Device interface, action frames goes
445 * through this interface.
446 * p2p-xx: P2P interface, After GO negotiation this interface is
447 * created for p2p operations(GO/CLIENT interface).
448 */
449 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800450 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
451 .beacon_int_infra_match = false,
452};
453#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800454
Jeff Johnson295189b2012-06-20 16:38:30 -0700455static struct cfg80211_ops wlan_hdd_cfg80211_ops;
456
457/* Data rate 100KBPS based on IE Index */
458struct index_data_rate_type
459{
460 v_U8_t beacon_rate_index;
461 v_U16_t supported_rate[4];
462};
463
464/* 11B, 11G Rate table include Basic rate and Extended rate
465 The IDX field is the rate index
466 The HI field is the rate when RSSI is strong or being ignored
467 (in this case we report actual rate)
468 The MID field is the rate when RSSI is moderate
469 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
470 The LO field is the rate when RSSI is low
471 (in this case we don't report rates, actual current rate used)
472 */
473static const struct
474{
475 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700476 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700477} supported_data_rate[] =
478{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700479/* IDX HI HM LM LO (RSSI-based index */
480 {2, { 10, 10, 10, 0}},
481 {4, { 20, 20, 10, 0}},
482 {11, { 55, 20, 10, 0}},
483 {12, { 60, 55, 20, 0}},
484 {18, { 90, 55, 20, 0}},
485 {22, {110, 55, 20, 0}},
486 {24, {120, 90, 60, 0}},
487 {36, {180, 120, 60, 0}},
488 {44, {220, 180, 60, 0}},
489 {48, {240, 180, 90, 0}},
490 {66, {330, 180, 90, 0}},
491 {72, {360, 240, 90, 0}},
492 {96, {480, 240, 120, 0}},
493 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700494};
495
496/* MCS Based rate table */
497static struct index_data_rate_type supported_mcs_rate[] =
498{
499/* MCS L20 L40 S20 S40 */
500 {0, {65, 135, 72, 150}},
501 {1, {130, 270, 144, 300}},
502 {2, {195, 405, 217, 450}},
503 {3, {260, 540, 289, 600}},
504 {4, {390, 810, 433, 900}},
505 {5, {520, 1080, 578, 1200}},
506 {6, {585, 1215, 650, 1350}},
507 {7, {650, 1350, 722, 1500}}
508};
509
Leo Chang6f8870f2013-03-26 18:11:36 -0700510#ifdef WLAN_FEATURE_11AC
511
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530512#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700513
514struct index_vht_data_rate_type
515{
516 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530517 v_U16_t supported_VHT80_rate[2];
518 v_U16_t supported_VHT40_rate[2];
519 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700520};
521
522typedef enum
523{
524 DATA_RATE_11AC_MAX_MCS_7,
525 DATA_RATE_11AC_MAX_MCS_8,
526 DATA_RATE_11AC_MAX_MCS_9,
527 DATA_RATE_11AC_MAX_MCS_NA
528} eDataRate11ACMaxMcs;
529
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530530/* SSID broadcast type */
531typedef enum eSSIDBcastType
532{
533 eBCAST_UNKNOWN = 0,
534 eBCAST_NORMAL = 1,
535 eBCAST_HIDDEN = 2,
536} tSSIDBcastType;
537
Leo Chang6f8870f2013-03-26 18:11:36 -0700538/* MCS Based VHT rate table */
539static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
540{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530541/* MCS L80 S80 L40 S40 L20 S40*/
542 {0, {293, 325}, {135, 150}, {65, 72}},
543 {1, {585, 650}, {270, 300}, {130, 144}},
544 {2, {878, 975}, {405, 450}, {195, 217}},
545 {3, {1170, 1300}, {540, 600}, {260, 289}},
546 {4, {1755, 1950}, {810, 900}, {390, 433}},
547 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
548 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
549 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
550 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
551 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700552};
553#endif /* WLAN_FEATURE_11AC */
554
c_hpothu79aab322014-07-14 21:11:01 +0530555/*array index points to MCS and array value points respective rssi*/
556static int rssiMcsTbl[][10] =
557{
558/*MCS 0 1 2 3 4 5 6 7 8 9*/
559 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
560 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
561 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
562};
563
Jeff Johnson295189b2012-06-20 16:38:30 -0700564extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530565#ifdef FEATURE_WLAN_SCAN_PNO
566static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
567#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700568
Leo Chang9056f462013-08-01 19:21:11 -0700569#ifdef WLAN_NL80211_TESTMODE
570enum wlan_hdd_tm_attr
571{
572 WLAN_HDD_TM_ATTR_INVALID = 0,
573 WLAN_HDD_TM_ATTR_CMD = 1,
574 WLAN_HDD_TM_ATTR_DATA = 2,
575 WLAN_HDD_TM_ATTR_TYPE = 3,
576 /* keep last */
577 WLAN_HDD_TM_ATTR_AFTER_LAST,
578 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
579};
580
581enum wlan_hdd_tm_cmd
582{
583 WLAN_HDD_TM_CMD_WLAN_HB = 1,
584};
585
586#define WLAN_HDD_TM_DATA_MAX_LEN 5000
587
588static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
589{
590 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
591 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
592 .len = WLAN_HDD_TM_DATA_MAX_LEN },
593};
594#endif /* WLAN_NL80211_TESTMODE */
595
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800596#ifdef FEATURE_WLAN_CH_AVOID
597/*
598 * FUNCTION: wlan_hdd_send_avoid_freq_event
599 * This is called when wlan driver needs to send vendor specific
600 * avoid frequency range event to userspace
601 */
602int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
603 tHddAvoidFreqList *pAvoidFreqList)
604{
605 struct sk_buff *vendor_event;
606
607 ENTER();
608
609 if (!pHddCtx)
610 {
611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
612 "%s: HDD context is null", __func__);
613 return -1;
614 }
615
616 if (!pAvoidFreqList)
617 {
618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
619 "%s: pAvoidFreqList is null", __func__);
620 return -1;
621 }
622
623 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
624 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530625 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800626 GFP_KERNEL);
627 if (!vendor_event)
628 {
629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
630 "%s: cfg80211_vendor_event_alloc failed", __func__);
631 return -1;
632 }
633
634 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
635 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
636
637 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
638
639 EXIT();
640 return 0;
641}
642#endif /* FEATURE_WLAN_CH_AVOID */
643
Srinivas Dasari030bad32015-02-18 23:23:54 +0530644/*
645 * FUNCTION: __wlan_hdd_cfg80211_nan_request
646 * This is called when wlan driver needs to send vendor specific
647 * nan request event.
648 */
649static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
650 struct wireless_dev *wdev,
651 const void *data, int data_len)
652{
653 tNanRequestReq nan_req;
654 VOS_STATUS status;
655 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530656 struct net_device *dev = wdev->netdev;
657 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
658 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530659 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
660
661 if (0 == data_len)
662 {
663 hddLog(VOS_TRACE_LEVEL_ERROR,
664 FL("NAN - Invalid Request, length = 0"));
665 return ret_val;
666 }
667
668 if (NULL == data)
669 {
670 hddLog(VOS_TRACE_LEVEL_ERROR,
671 FL("NAN - Invalid Request, data is NULL"));
672 return ret_val;
673 }
674
675 status = wlan_hdd_validate_context(pHddCtx);
676 if (0 != status)
677 {
678 hddLog(VOS_TRACE_LEVEL_ERROR,
679 FL("HDD context is not valid"));
680 return -EINVAL;
681 }
682
683 hddLog(LOG1, FL("Received NAN command"));
684 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
685 (tANI_U8 *)data, data_len);
686
687 /* check the NAN Capability */
688 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
689 {
690 hddLog(VOS_TRACE_LEVEL_ERROR,
691 FL("NAN is not supported by Firmware"));
692 return -EINVAL;
693 }
694
695 nan_req.request_data_len = data_len;
696 nan_req.request_data = data;
697
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530698 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530699 if (VOS_STATUS_SUCCESS == status)
700 {
701 ret_val = 0;
702 }
703 return ret_val;
704}
705
706/*
707 * FUNCTION: wlan_hdd_cfg80211_nan_request
708 * Wrapper to protect the nan vendor command from ssr
709 */
710static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
711 struct wireless_dev *wdev,
712 const void *data, int data_len)
713{
714 int ret;
715
716 vos_ssr_protect(__func__);
717 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
718 vos_ssr_unprotect(__func__);
719
720 return ret;
721}
722
723/*
724 * FUNCTION: wlan_hdd_cfg80211_nan_callback
725 * This is a callback function and it gets called
726 * when we need to report nan response event to
727 * upper layers.
728 */
729static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
730{
731 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
732 struct sk_buff *vendor_event;
733 int status;
734 tSirNanEvent *data;
735
736 ENTER();
737 if (NULL == msg)
738 {
739 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
740 FL(" msg received here is null"));
741 return;
742 }
743 data = msg;
744
745 status = wlan_hdd_validate_context(pHddCtx);
746
747 if (0 != status)
748 {
749 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
750 FL("HDD context is not valid"));
751 return;
752 }
753
754 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
755 data->event_data_len +
756 NLMSG_HDRLEN,
757 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
758 GFP_KERNEL);
759
760 if (!vendor_event)
761 {
762 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
763 FL("cfg80211_vendor_event_alloc failed"));
764 return;
765 }
766 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
767 data->event_data_len, data->event_data))
768 {
769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
770 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
771 kfree_skb(vendor_event);
772 return;
773 }
774 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
775 EXIT();
776}
777
778/*
779 * FUNCTION: wlan_hdd_cfg80211_nan_init
780 * This function is called to register the callback to sme layer
781 */
782inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
783{
784 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
785}
786
787
Sunil Duttc69bccb2014-05-26 21:30:20 +0530788#ifdef WLAN_FEATURE_LINK_LAYER_STATS
789
790static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
791 struct sk_buff *vendor_event)
792{
793 if (nla_put_u8(vendor_event,
794 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
795 stats->rate.preamble) ||
796 nla_put_u8(vendor_event,
797 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
798 stats->rate.nss) ||
799 nla_put_u8(vendor_event,
800 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
801 stats->rate.bw) ||
802 nla_put_u8(vendor_event,
803 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
804 stats->rate.rateMcsIdx) ||
805 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
806 stats->rate.bitrate ) ||
807 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
808 stats->txMpdu ) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
810 stats->rxMpdu ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
812 stats->mpduLost ) ||
813 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
814 stats->retries) ||
815 nla_put_u32(vendor_event,
816 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
817 stats->retriesShort ) ||
818 nla_put_u32(vendor_event,
819 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
820 stats->retriesLong))
821 {
822 hddLog(VOS_TRACE_LEVEL_ERROR,
823 FL("QCA_WLAN_VENDOR_ATTR put fail"));
824 return FALSE;
825 }
826 return TRUE;
827}
828
829static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
830 struct sk_buff *vendor_event)
831{
832 u32 i = 0;
833 struct nlattr *rateInfo;
834 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
835 stats->type) ||
836 nla_put(vendor_event,
837 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
838 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
839 nla_put_u32(vendor_event,
840 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
841 stats->capabilities) ||
842 nla_put_u32(vendor_event,
843 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
844 stats->numRate))
845 {
846 hddLog(VOS_TRACE_LEVEL_ERROR,
847 FL("QCA_WLAN_VENDOR_ATTR put fail"));
848 goto error;
849 }
850
851 rateInfo = nla_nest_start(vendor_event,
852 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530853 if(!rateInfo)
854 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530855 for (i = 0; i < stats->numRate; i++)
856 {
857 struct nlattr *rates;
858 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
859 stats->rateStats +
860 (i * sizeof(tSirWifiRateStat)));
861 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530862 if(!rates)
863 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530864
865 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
866 {
867 hddLog(VOS_TRACE_LEVEL_ERROR,
868 FL("QCA_WLAN_VENDOR_ATTR put fail"));
869 return FALSE;
870 }
871 nla_nest_end(vendor_event, rates);
872 }
873 nla_nest_end(vendor_event, rateInfo);
874
875 return TRUE;
876error:
877 return FALSE;
878}
879
880static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
881 struct sk_buff *vendor_event)
882{
883 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
884 stats->ac ) ||
885 nla_put_u32(vendor_event,
886 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
887 stats->txMpdu ) ||
888 nla_put_u32(vendor_event,
889 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
890 stats->rxMpdu ) ||
891 nla_put_u32(vendor_event,
892 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
893 stats->txMcast ) ||
894 nla_put_u32(vendor_event,
895 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
896 stats->rxMcast ) ||
897 nla_put_u32(vendor_event,
898 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
899 stats->rxAmpdu ) ||
900 nla_put_u32(vendor_event,
901 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
902 stats->txAmpdu ) ||
903 nla_put_u32(vendor_event,
904 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
905 stats->mpduLost )||
906 nla_put_u32(vendor_event,
907 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
908 stats->retries ) ||
909 nla_put_u32(vendor_event,
910 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
911 stats->retriesShort ) ||
912 nla_put_u32(vendor_event,
913 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
914 stats->retriesLong ) ||
915 nla_put_u32(vendor_event,
916 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
917 stats->contentionTimeMin ) ||
918 nla_put_u32(vendor_event,
919 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
920 stats->contentionTimeMax ) ||
921 nla_put_u32(vendor_event,
922 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
923 stats->contentionTimeAvg ) ||
924 nla_put_u32(vendor_event,
925 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
926 stats->contentionNumSamples ))
927 {
928 hddLog(VOS_TRACE_LEVEL_ERROR,
929 FL("QCA_WLAN_VENDOR_ATTR put fail") );
930 return FALSE;
931 }
932 return TRUE;
933}
934
935static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
936 struct sk_buff *vendor_event)
937{
Dino Myclec8f3f332014-07-21 16:48:27 +0530938 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530939 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
940 nla_put(vendor_event,
941 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
942 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
943 nla_put_u32(vendor_event,
944 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
945 stats->state ) ||
946 nla_put_u32(vendor_event,
947 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
948 stats->roaming ) ||
949 nla_put_u32(vendor_event,
950 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
951 stats->capabilities ) ||
952 nla_put(vendor_event,
953 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
954 strlen(stats->ssid), stats->ssid) ||
955 nla_put(vendor_event,
956 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
957 WNI_CFG_BSSID_LEN, stats->bssid) ||
958 nla_put(vendor_event,
959 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
960 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
961 nla_put(vendor_event,
962 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
963 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
964 )
965 {
966 hddLog(VOS_TRACE_LEVEL_ERROR,
967 FL("QCA_WLAN_VENDOR_ATTR put fail") );
968 return FALSE;
969 }
970 return TRUE;
971}
972
Dino Mycle3b9536d2014-07-09 22:05:24 +0530973static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
974 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530975 struct sk_buff *vendor_event)
976{
977 int i = 0;
978 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530979 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
980 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530981 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530982
Sunil Duttc69bccb2014-05-26 21:30:20 +0530983 if (FALSE == put_wifi_interface_info(
984 &pWifiIfaceStat->info,
985 vendor_event))
986 {
987 hddLog(VOS_TRACE_LEVEL_ERROR,
988 FL("QCA_WLAN_VENDOR_ATTR put fail") );
989 return FALSE;
990
991 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530992 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
993 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
994 if (NULL == pWifiIfaceStatTL)
995 {
996 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
997 return FALSE;
998 }
999
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05301000 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
1001 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1002 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1003 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1004
1005 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1007 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1008 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301009
1010 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1011 {
1012 if (VOS_STATUS_SUCCESS ==
1013 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1014 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1015 {
1016 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1017 * obtained from TL structure
1018 */
1019
1020 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1021 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301022 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1023
Srinivas Dasari98947432014-11-07 19:41:24 +05301024 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1025 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1026 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1027 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1028 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1030 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1031 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301032
Srinivas Dasari98947432014-11-07 19:41:24 +05301033 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1034 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1035 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1036 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1037 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1039 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1040 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301041
Srinivas Dasari98947432014-11-07 19:41:24 +05301042 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1043 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1044 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1045 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1046 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1048 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1049 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301050 }
1051 else
1052 {
1053 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1054 }
1055
Dino Mycle3b9536d2014-07-09 22:05:24 +05301056 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1057 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1058 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1059 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1060 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1062 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1063 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1064 }
1065 else
1066 {
1067 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1068 }
1069
1070
Sunil Duttc69bccb2014-05-26 21:30:20 +05301071
1072 if (nla_put_u32(vendor_event,
1073 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1074 pWifiIfaceStat->beaconRx) ||
1075 nla_put_u32(vendor_event,
1076 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1077 pWifiIfaceStat->mgmtRx) ||
1078 nla_put_u32(vendor_event,
1079 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1080 pWifiIfaceStat->mgmtActionRx) ||
1081 nla_put_u32(vendor_event,
1082 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1083 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301084 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301085 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1086 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301087 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301088 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1089 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301090 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301091 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1092 pWifiIfaceStat->rssiAck))
1093 {
1094 hddLog(VOS_TRACE_LEVEL_ERROR,
1095 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301096 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301097 return FALSE;
1098 }
1099
1100 wmmInfo = nla_nest_start(vendor_event,
1101 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301102 if(!wmmInfo)
1103 {
1104 vos_mem_free(pWifiIfaceStatTL);
1105 return FALSE;
1106 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301107 for (i = 0; i < WIFI_AC_MAX; i++)
1108 {
1109 struct nlattr *wmmStats;
1110 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301111 if(!wmmStats)
1112 {
1113 vos_mem_free(pWifiIfaceStatTL);
1114 return FALSE;
1115 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301116 if (FALSE == put_wifi_wmm_ac_stat(
1117 &pWifiIfaceStat->AccessclassStats[i],
1118 vendor_event))
1119 {
1120 hddLog(VOS_TRACE_LEVEL_ERROR,
1121 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301122 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301123 return FALSE;
1124 }
1125
1126 nla_nest_end(vendor_event, wmmStats);
1127 }
1128 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301129 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301130 return TRUE;
1131}
1132
1133static tSirWifiInterfaceMode
1134 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1135{
1136 switch (deviceMode)
1137 {
1138 case WLAN_HDD_INFRA_STATION:
1139 return WIFI_INTERFACE_STA;
1140 case WLAN_HDD_SOFTAP:
1141 return WIFI_INTERFACE_SOFTAP;
1142 case WLAN_HDD_P2P_CLIENT:
1143 return WIFI_INTERFACE_P2P_CLIENT;
1144 case WLAN_HDD_P2P_GO:
1145 return WIFI_INTERFACE_P2P_GO;
1146 case WLAN_HDD_IBSS:
1147 return WIFI_INTERFACE_IBSS;
1148 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301149 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301150 }
1151}
1152
1153static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1154 tpSirWifiInterfaceInfo pInfo)
1155{
1156 v_U8_t *staMac = NULL;
1157 hdd_station_ctx_t *pHddStaCtx;
1158 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1159 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1160
1161 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1162
1163 vos_mem_copy(pInfo->macAddr,
1164 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1165
1166 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1167 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1168 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1169 {
1170 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1171 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1172 {
1173 pInfo->state = WIFI_DISCONNECTED;
1174 }
1175 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1176 {
1177 hddLog(VOS_TRACE_LEVEL_ERROR,
1178 "%s: Session ID %d, Connection is in progress", __func__,
1179 pAdapter->sessionId);
1180 pInfo->state = WIFI_ASSOCIATING;
1181 }
1182 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1183 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1184 {
1185 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1186 hddLog(VOS_TRACE_LEVEL_ERROR,
1187 "%s: client " MAC_ADDRESS_STR
1188 " is in the middle of WPS/EAPOL exchange.", __func__,
1189 MAC_ADDR_ARRAY(staMac));
1190 pInfo->state = WIFI_AUTHENTICATING;
1191 }
1192 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1193 {
1194 pInfo->state = WIFI_ASSOCIATED;
1195 vos_mem_copy(pInfo->bssid,
1196 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1197 vos_mem_copy(pInfo->ssid,
1198 pHddStaCtx->conn_info.SSID.SSID.ssId,
1199 pHddStaCtx->conn_info.SSID.SSID.length);
1200 //NULL Terminate the string.
1201 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1202 }
1203 }
1204 vos_mem_copy(pInfo->countryStr,
1205 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1206
1207 vos_mem_copy(pInfo->apCountryStr,
1208 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1209
1210 return TRUE;
1211}
1212
1213/*
1214 * hdd_link_layer_process_peer_stats () - This function is called after
1215 * receiving Link Layer Peer statistics from FW.This function converts
1216 * the firmware data to the NL data and sends the same to the kernel/upper
1217 * layers.
1218 */
1219static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1220 v_VOID_t *pData)
1221{
1222 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1223 tpSirWifiRateStat pWifiRateStat;
1224 tpSirWifiPeerStat pWifiPeerStat;
1225 tpSirWifiPeerInfo pWifiPeerInfo;
1226 struct nlattr *peerInfo;
1227 struct sk_buff *vendor_event;
1228 int status, i;
1229
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301230 ENTER();
1231
Sunil Duttc69bccb2014-05-26 21:30:20 +05301232 status = wlan_hdd_validate_context(pHddCtx);
1233 if (0 != status)
1234 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301235 return;
1236 }
1237
1238 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1239
1240 hddLog(VOS_TRACE_LEVEL_INFO,
1241 "LL_STATS_PEER_ALL : numPeers %u",
1242 pWifiPeerStat->numPeers);
1243 {
1244 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1245 {
1246 pWifiPeerInfo = (tpSirWifiPeerInfo)
1247 ((uint8 *)pWifiPeerStat->peerInfo +
1248 ( i * sizeof(tSirWifiPeerInfo)));
1249
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301250 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1251 pWifiPeerInfo->type = WIFI_PEER_AP;
1252 }
1253 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1254 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1255 }
1256
Sunil Duttc69bccb2014-05-26 21:30:20 +05301257 hddLog(VOS_TRACE_LEVEL_INFO,
1258 " %d) LL_STATS Channel Stats "
1259 " Peer Type %u "
1260 " peerMacAddress %pM "
1261 " capabilities 0x%x "
1262 " numRate %u ",
1263 i,
1264 pWifiPeerInfo->type,
1265 pWifiPeerInfo->peerMacAddress,
1266 pWifiPeerInfo->capabilities,
1267 pWifiPeerInfo->numRate);
1268 {
1269 int j;
1270 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1271 {
1272 pWifiRateStat = (tpSirWifiRateStat)
1273 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1274 ( j * sizeof(tSirWifiRateStat)));
1275
1276 hddLog(VOS_TRACE_LEVEL_INFO,
1277 " peer Rate Stats "
1278 " preamble %u "
1279 " nss %u "
1280 " bw %u "
1281 " rateMcsIdx %u "
1282 " reserved %u "
1283 " bitrate %u "
1284 " txMpdu %u "
1285 " rxMpdu %u "
1286 " mpduLost %u "
1287 " retries %u "
1288 " retriesShort %u "
1289 " retriesLong %u",
1290 pWifiRateStat->rate.preamble,
1291 pWifiRateStat->rate.nss,
1292 pWifiRateStat->rate.bw,
1293 pWifiRateStat->rate.rateMcsIdx,
1294 pWifiRateStat->rate.reserved,
1295 pWifiRateStat->rate.bitrate,
1296 pWifiRateStat->txMpdu,
1297 pWifiRateStat->rxMpdu,
1298 pWifiRateStat->mpduLost,
1299 pWifiRateStat->retries,
1300 pWifiRateStat->retriesShort,
1301 pWifiRateStat->retriesLong);
1302 }
1303 }
1304 }
1305 }
1306
1307 /*
1308 * Allocate a size of 4096 for the peer stats comprising
1309 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1310 * sizeof (tSirWifiRateStat).Each field is put with an
1311 * NL attribute.The size of 4096 is considered assuming
1312 * that number of rates shall not exceed beyond 50 with
1313 * the sizeof (tSirWifiRateStat) being 32.
1314 */
1315 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1316 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1317 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1318 GFP_KERNEL);
1319 if (!vendor_event)
1320 {
1321 hddLog(VOS_TRACE_LEVEL_ERROR,
1322 "%s: cfg80211_vendor_event_alloc failed",
1323 __func__);
1324 return;
1325 }
1326 if (nla_put_u32(vendor_event,
1327 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1328 pWifiPeerStat->numPeers))
1329 {
1330 hddLog(VOS_TRACE_LEVEL_ERROR,
1331 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1332 kfree_skb(vendor_event);
1333 return;
1334 }
1335
1336 peerInfo = nla_nest_start(vendor_event,
1337 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301338 if(!peerInfo)
1339 {
1340 hddLog(VOS_TRACE_LEVEL_ERROR,
1341 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1342 __func__);
1343 kfree_skb(vendor_event);
1344 return;
1345 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301346
1347 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1348 pWifiPeerStat->peerInfo);
1349
1350 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1351 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301352 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301353 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301354
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301355 if(!peers)
1356 {
1357 hddLog(VOS_TRACE_LEVEL_ERROR,
1358 "%s: peer stats put fail",
1359 __func__);
1360 kfree_skb(vendor_event);
1361 return;
1362 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301363 if (FALSE == put_wifi_peer_info(
1364 pWifiPeerInfo, vendor_event))
1365 {
1366 hddLog(VOS_TRACE_LEVEL_ERROR,
1367 "%s: put_wifi_peer_info put fail", __func__);
1368 kfree_skb(vendor_event);
1369 return;
1370 }
1371
1372 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1373 pWifiPeerStat->peerInfo +
1374 (i * sizeof(tSirWifiPeerInfo)) +
1375 (numRate * sizeof (tSirWifiRateStat)));
1376 nla_nest_end(vendor_event, peers);
1377 }
1378 nla_nest_end(vendor_event, peerInfo);
1379 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301380
1381 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301382}
1383
1384/*
1385 * hdd_link_layer_process_iface_stats () - This function is called after
1386 * receiving Link Layer Interface statistics from FW.This function converts
1387 * the firmware data to the NL data and sends the same to the kernel/upper
1388 * layers.
1389 */
1390static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1391 v_VOID_t *pData)
1392{
1393 tpSirWifiIfaceStat pWifiIfaceStat;
1394 struct sk_buff *vendor_event;
1395 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1396 int status;
1397
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301398 ENTER();
1399
Sunil Duttc69bccb2014-05-26 21:30:20 +05301400 status = wlan_hdd_validate_context(pHddCtx);
1401 if (0 != status)
1402 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301403 return;
1404 }
1405 /*
1406 * Allocate a size of 4096 for the interface stats comprising
1407 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1408 * assuming that all these fit with in the limit.Please take
1409 * a call on the limit based on the data requirements on
1410 * interface statistics.
1411 */
1412 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1413 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1414 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1415 GFP_KERNEL);
1416 if (!vendor_event)
1417 {
1418 hddLog(VOS_TRACE_LEVEL_ERROR,
1419 FL("cfg80211_vendor_event_alloc failed") );
1420 return;
1421 }
1422
1423 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1424
Dino Mycle3b9536d2014-07-09 22:05:24 +05301425
1426 if (FALSE == hdd_get_interface_info( pAdapter,
1427 &pWifiIfaceStat->info))
1428 {
1429 hddLog(VOS_TRACE_LEVEL_ERROR,
1430 FL("hdd_get_interface_info get fail") );
1431 kfree_skb(vendor_event);
1432 return;
1433 }
1434
1435 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1436 vendor_event))
1437 {
1438 hddLog(VOS_TRACE_LEVEL_ERROR,
1439 FL("put_wifi_iface_stats fail") );
1440 kfree_skb(vendor_event);
1441 return;
1442 }
1443
Sunil Duttc69bccb2014-05-26 21:30:20 +05301444 hddLog(VOS_TRACE_LEVEL_INFO,
1445 "WMI_LINK_STATS_IFACE Data");
1446
1447 hddLog(VOS_TRACE_LEVEL_INFO,
1448 "LL_STATS_IFACE: "
1449 " Mode %u "
1450 " MAC %pM "
1451 " State %u "
1452 " Roaming %u "
1453 " capabilities 0x%x "
1454 " SSID %s "
1455 " BSSID %pM",
1456 pWifiIfaceStat->info.mode,
1457 pWifiIfaceStat->info.macAddr,
1458 pWifiIfaceStat->info.state,
1459 pWifiIfaceStat->info.roaming,
1460 pWifiIfaceStat->info.capabilities,
1461 pWifiIfaceStat->info.ssid,
1462 pWifiIfaceStat->info.bssid);
1463
1464 hddLog(VOS_TRACE_LEVEL_INFO,
1465 " AP country str: %c%c%c",
1466 pWifiIfaceStat->info.apCountryStr[0],
1467 pWifiIfaceStat->info.apCountryStr[1],
1468 pWifiIfaceStat->info.apCountryStr[2]);
1469
1470
1471 hddLog(VOS_TRACE_LEVEL_INFO,
1472 " Country Str Association: %c%c%c",
1473 pWifiIfaceStat->info.countryStr[0],
1474 pWifiIfaceStat->info.countryStr[1],
1475 pWifiIfaceStat->info.countryStr[2]);
1476
1477 hddLog(VOS_TRACE_LEVEL_INFO,
1478 " beaconRx %u "
1479 " mgmtRx %u "
1480 " mgmtActionRx %u "
1481 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301482 " rssiMgmt %d "
1483 " rssiData %d "
1484 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301485 pWifiIfaceStat->beaconRx,
1486 pWifiIfaceStat->mgmtRx,
1487 pWifiIfaceStat->mgmtActionRx,
1488 pWifiIfaceStat->mgmtActionTx,
1489 pWifiIfaceStat->rssiMgmt,
1490 pWifiIfaceStat->rssiData,
1491 pWifiIfaceStat->rssiAck );
1492
1493
1494 {
1495 int i;
1496 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1497 {
1498 hddLog(VOS_TRACE_LEVEL_INFO,
1499
1500 " %d) LL_STATS IFACE: "
1501 " ac: %u txMpdu: %u "
1502 " rxMpdu: %u txMcast: %u "
1503 " rxMcast: %u rxAmpdu: %u "
1504 " txAmpdu: %u mpduLost: %u "
1505 " retries: %u retriesShort: %u "
1506 " retriesLong: %u contentionTimeMin: %u "
1507 " contentionTimeMax: %u contentionTimeAvg: %u "
1508 " contentionNumSamples: %u",
1509 i,
1510 pWifiIfaceStat->AccessclassStats[i].ac,
1511 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1512 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1513 pWifiIfaceStat->AccessclassStats[i].txMcast,
1514 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1515 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1516 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1517 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1518 pWifiIfaceStat->AccessclassStats[i].retries,
1519 pWifiIfaceStat->
1520 AccessclassStats[i].retriesShort,
1521 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1522 pWifiIfaceStat->
1523 AccessclassStats[i].contentionTimeMin,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].contentionTimeMax,
1526 pWifiIfaceStat->
1527 AccessclassStats[i].contentionTimeAvg,
1528 pWifiIfaceStat->
1529 AccessclassStats[i].contentionNumSamples);
1530
1531 }
1532 }
1533
Sunil Duttc69bccb2014-05-26 21:30:20 +05301534 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301535
1536 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301537}
1538
1539/*
1540 * hdd_link_layer_process_radio_stats () - This function is called after
1541 * receiving Link Layer Radio statistics from FW.This function converts
1542 * the firmware data to the NL data and sends the same to the kernel/upper
1543 * layers.
1544 */
1545static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1546 v_VOID_t *pData)
1547{
1548 int status, i;
1549 tpSirWifiRadioStat pWifiRadioStat;
1550 tpSirWifiChannelStats pWifiChannelStats;
1551 struct sk_buff *vendor_event;
1552 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1553 struct nlattr *chList;
1554
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301555 ENTER();
1556
Sunil Duttc69bccb2014-05-26 21:30:20 +05301557 status = wlan_hdd_validate_context(pHddCtx);
1558 if (0 != status)
1559 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301560 return;
1561 }
1562 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1563
1564 hddLog(VOS_TRACE_LEVEL_INFO,
1565 "LL_STATS_RADIO"
1566 " radio is %d onTime is %u "
1567 " txTime is %u rxTime is %u "
1568 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301569 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301570 " onTimePnoScan is %u onTimeHs20 is %u "
1571 " numChannels is %u",
1572 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1573 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1574 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301575 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301576 pWifiRadioStat->onTimeRoamScan,
1577 pWifiRadioStat->onTimePnoScan,
1578 pWifiRadioStat->onTimeHs20,
1579 pWifiRadioStat->numChannels);
1580 /*
1581 * Allocate a size of 4096 for the Radio stats comprising
1582 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1583 * (tSirWifiChannelStats).Each channel data is put with an
1584 * NL attribute.The size of 4096 is considered assuming that
1585 * number of channels shall not exceed beyond 60 with the
1586 * sizeof (tSirWifiChannelStats) being 24 bytes.
1587 */
1588
1589 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1590 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1591 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1592 GFP_KERNEL);
1593
1594 if (!vendor_event)
1595 {
1596 hddLog(VOS_TRACE_LEVEL_ERROR,
1597 FL("cfg80211_vendor_event_alloc failed") );
1598 return;
1599 }
1600
1601 if (nla_put_u32(vendor_event,
1602 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1603 pWifiRadioStat->radio) ||
1604 nla_put_u32(vendor_event,
1605 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1606 pWifiRadioStat->onTime) ||
1607 nla_put_u32(vendor_event,
1608 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1609 pWifiRadioStat->txTime) ||
1610 nla_put_u32(vendor_event,
1611 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1612 pWifiRadioStat->rxTime) ||
1613 nla_put_u32(vendor_event,
1614 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1615 pWifiRadioStat->onTimeScan) ||
1616 nla_put_u32(vendor_event,
1617 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1618 pWifiRadioStat->onTimeNbd) ||
1619 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301620 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1621 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301622 nla_put_u32(vendor_event,
1623 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1624 pWifiRadioStat->onTimeRoamScan) ||
1625 nla_put_u32(vendor_event,
1626 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1627 pWifiRadioStat->onTimePnoScan) ||
1628 nla_put_u32(vendor_event,
1629 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1630 pWifiRadioStat->onTimeHs20) ||
1631 nla_put_u32(vendor_event,
1632 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1633 pWifiRadioStat->numChannels))
1634 {
1635 hddLog(VOS_TRACE_LEVEL_ERROR,
1636 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1637 kfree_skb(vendor_event);
1638 return ;
1639 }
1640
1641 chList = nla_nest_start(vendor_event,
1642 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301643 if(!chList)
1644 {
1645 hddLog(VOS_TRACE_LEVEL_ERROR,
1646 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1647 __func__);
1648 kfree_skb(vendor_event);
1649 return;
1650 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301651 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1652 {
1653 struct nlattr *chInfo;
1654
1655 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1656 pWifiRadioStat->channels +
1657 (i * sizeof(tSirWifiChannelStats)));
1658
1659 hddLog(VOS_TRACE_LEVEL_INFO,
1660 " %d) Channel Info"
1661 " width is %u "
1662 " CenterFreq %u "
1663 " CenterFreq0 %u "
1664 " CenterFreq1 %u "
1665 " onTime %u "
1666 " ccaBusyTime %u",
1667 i,
1668 pWifiChannelStats->channel.width,
1669 pWifiChannelStats->channel.centerFreq,
1670 pWifiChannelStats->channel.centerFreq0,
1671 pWifiChannelStats->channel.centerFreq1,
1672 pWifiChannelStats->onTime,
1673 pWifiChannelStats->ccaBusyTime);
1674
1675
1676 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301677 if(!chInfo)
1678 {
1679 hddLog(VOS_TRACE_LEVEL_ERROR,
1680 "%s: failed to put chInfo",
1681 __func__);
1682 kfree_skb(vendor_event);
1683 return;
1684 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301685
1686 if (nla_put_u32(vendor_event,
1687 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1688 pWifiChannelStats->channel.width) ||
1689 nla_put_u32(vendor_event,
1690 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1691 pWifiChannelStats->channel.centerFreq) ||
1692 nla_put_u32(vendor_event,
1693 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1694 pWifiChannelStats->channel.centerFreq0) ||
1695 nla_put_u32(vendor_event,
1696 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1697 pWifiChannelStats->channel.centerFreq1) ||
1698 nla_put_u32(vendor_event,
1699 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1700 pWifiChannelStats->onTime) ||
1701 nla_put_u32(vendor_event,
1702 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1703 pWifiChannelStats->ccaBusyTime))
1704 {
1705 hddLog(VOS_TRACE_LEVEL_ERROR,
1706 FL("cfg80211_vendor_event_alloc failed") );
1707 kfree_skb(vendor_event);
1708 return ;
1709 }
1710 nla_nest_end(vendor_event, chInfo);
1711 }
1712 nla_nest_end(vendor_event, chList);
1713
1714 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301715
1716 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301717 return;
1718}
1719
1720/*
1721 * hdd_link_layer_stats_ind_callback () - This function is called after
1722 * receiving Link Layer indications from FW.This callback converts the firmware
1723 * data to the NL data and send the same to the kernel/upper layers.
1724 */
1725static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1726 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301727 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301728{
Dino Mycled3d50022014-07-07 12:58:25 +05301729 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1730 hdd_adapter_t *pAdapter = NULL;
1731 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301732 int status;
1733
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301734 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301735
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301736 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301737 if (0 != status)
1738 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301739 return;
1740 }
1741
Dino Mycled3d50022014-07-07 12:58:25 +05301742 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1743 if (NULL == pAdapter)
1744 {
1745 hddLog(VOS_TRACE_LEVEL_ERROR,
1746 FL(" MAC address %pM does not exist with host"),
1747 macAddr);
1748 return;
1749 }
1750
Sunil Duttc69bccb2014-05-26 21:30:20 +05301751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301752 "%s: Interface: %s LLStats indType: %d", __func__,
1753 pAdapter->dev->name, indType);
1754
Sunil Duttc69bccb2014-05-26 21:30:20 +05301755 switch (indType)
1756 {
1757 case SIR_HAL_LL_STATS_RESULTS_RSP:
1758 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301759 hddLog(VOS_TRACE_LEVEL_INFO,
1760 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1761 hddLog(VOS_TRACE_LEVEL_INFO,
1762 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1763 linkLayerStatsResults->paramId);
1764 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301765 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1766 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301767 hddLog(VOS_TRACE_LEVEL_INFO,
1768 "LL_STATS RESULTS RESPONSE respId = %u",
1769 linkLayerStatsResults->respId);
1770 hddLog(VOS_TRACE_LEVEL_INFO,
1771 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1772 linkLayerStatsResults->moreResultToFollow);
1773 hddLog(VOS_TRACE_LEVEL_INFO,
1774 "LL_STATS RESULTS RESPONSE result = %p",
1775 linkLayerStatsResults->result);
1776 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1777 {
1778 hdd_link_layer_process_radio_stats(pAdapter,
1779 (v_VOID_t *)linkLayerStatsResults->result);
1780 }
1781 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1782 {
1783 hdd_link_layer_process_iface_stats(pAdapter,
1784 (v_VOID_t *)linkLayerStatsResults->result);
1785 }
1786 else if ( linkLayerStatsResults->paramId &
1787 WMI_LINK_STATS_ALL_PEER )
1788 {
1789 hdd_link_layer_process_peer_stats(pAdapter,
1790 (v_VOID_t *)linkLayerStatsResults->result);
1791 } /* WMI_LINK_STATS_ALL_PEER */
1792 else
1793 {
1794 hddLog(VOS_TRACE_LEVEL_ERROR,
1795 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1796 }
1797
1798 break;
1799 }
1800 default:
1801 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1802 break;
1803 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301804
1805 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301806 return;
1807}
1808
1809const struct
1810nla_policy
1811qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1812{
1813 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1814 { .type = NLA_U32 },
1815 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1816 { .type = NLA_U32 },
1817};
1818
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301819static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1820 struct wireless_dev *wdev,
1821 const void *data,
1822 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301823{
1824 int status;
1825 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301826 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301827 struct net_device *dev = wdev->netdev;
1828 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1829 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Srinivas Dasari98947432014-11-07 19:41:24 +05301830 hdd_station_ctx_t *pHddStaCtx;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301831
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301832 ENTER();
1833
Sunil Duttc69bccb2014-05-26 21:30:20 +05301834 status = wlan_hdd_validate_context(pHddCtx);
1835 if (0 != status)
1836 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301837 return -EINVAL;
1838 }
1839
1840 if (NULL == pAdapter)
1841 {
1842 hddLog(VOS_TRACE_LEVEL_ERROR,
1843 FL("HDD adapter is Null"));
1844 return -ENODEV;
1845 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301846 /* check the LLStats Capability */
1847 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1848 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1849 {
1850 hddLog(VOS_TRACE_LEVEL_ERROR,
1851 FL("Link Layer Statistics not supported by Firmware"));
1852 return -EINVAL;
1853 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301854
1855 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1856 (struct nlattr *)data,
1857 data_len, qca_wlan_vendor_ll_set_policy))
1858 {
1859 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1860 return -EINVAL;
1861 }
1862 if (!tb_vendor
1863 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1864 {
1865 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1866 return -EINVAL;
1867 }
1868 if (!tb_vendor[
1869 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1870 {
1871 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1872 return -EINVAL;
1873 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301874 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301875 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301876
Dino Mycledf0a5d92014-07-04 09:41:55 +05301877 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301878 nla_get_u32(
1879 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1880
Dino Mycledf0a5d92014-07-04 09:41:55 +05301881 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301882 nla_get_u32(
1883 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1884
Dino Mycled3d50022014-07-07 12:58:25 +05301885 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1886 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301887
1888
1889 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301890 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301891 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301892 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301893 hddLog(VOS_TRACE_LEVEL_INFO,
1894 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301895 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301896 hddLog(VOS_TRACE_LEVEL_INFO,
1897 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301898 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301899
1900 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1901 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301902 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301903 {
1904 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1905 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301906 return -EINVAL;
1907
1908 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301909
1910 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1911 if (VOS_STATUS_SUCCESS !=
1912 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1913 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE))
1914 {
1915 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1916 "WLANTL_ClearInterfaceStats Failed", __func__);
1917 return -EINVAL;
1918 }
1919
1920 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1921 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1922 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1923 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1924
Sunil Duttc69bccb2014-05-26 21:30:20 +05301925 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301926 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301927 {
1928 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1929 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301930 return -EINVAL;
1931 }
1932
1933 pAdapter->isLinkLayerStatsSet = 1;
1934
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301935 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301936 return 0;
1937}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301938static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1939 struct wireless_dev *wdev,
1940 const void *data,
1941 int data_len)
1942{
1943 int ret = 0;
1944
1945 vos_ssr_protect(__func__);
1946 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1947 vos_ssr_unprotect(__func__);
1948
1949 return ret;
1950}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301951
1952const struct
1953nla_policy
1954qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1955{
1956 /* Unsigned 32bit value provided by the caller issuing the GET stats
1957 * command. When reporting
1958 * the stats results, the driver uses the same value to indicate
1959 * which GET request the results
1960 * correspond to.
1961 */
1962 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1963
1964 /* Unsigned 32bit value . bit mask to identify what statistics are
1965 requested for retrieval */
1966 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1967};
1968
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301969static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1970 struct wireless_dev *wdev,
1971 const void *data,
1972 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301973{
1974 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1975 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301976 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301977 struct net_device *dev = wdev->netdev;
1978 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1979 int status;
1980
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301981 ENTER();
1982
Sunil Duttc69bccb2014-05-26 21:30:20 +05301983 status = wlan_hdd_validate_context(pHddCtx);
1984 if (0 != status)
1985 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301986 return -EINVAL ;
1987 }
1988
1989 if (NULL == pAdapter)
1990 {
1991 hddLog(VOS_TRACE_LEVEL_FATAL,
1992 "%s: HDD adapter is Null", __func__);
1993 return -ENODEV;
1994 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301995 /* check the LLStats Capability */
1996 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1997 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1998 {
1999 hddLog(VOS_TRACE_LEVEL_ERROR,
2000 FL("Link Layer Statistics not supported by Firmware"));
2001 return -EINVAL;
2002 }
2003
Sunil Duttc69bccb2014-05-26 21:30:20 +05302004
2005 if (!pAdapter->isLinkLayerStatsSet)
2006 {
2007 hddLog(VOS_TRACE_LEVEL_FATAL,
2008 "%s: isLinkLayerStatsSet : %d",
2009 __func__, pAdapter->isLinkLayerStatsSet);
2010 return -EINVAL;
2011 }
2012
2013 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2014 (struct nlattr *)data,
2015 data_len, qca_wlan_vendor_ll_get_policy))
2016 {
2017 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2018 return -EINVAL;
2019 }
2020
2021 if (!tb_vendor
2022 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2023 {
2024 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2025 return -EINVAL;
2026 }
2027
2028 if (!tb_vendor
2029 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2030 {
2031 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2032 return -EINVAL;
2033 }
2034
Sunil Duttc69bccb2014-05-26 21:30:20 +05302035
Dino Mycledf0a5d92014-07-04 09:41:55 +05302036 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302037 nla_get_u32( tb_vendor[
2038 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302039 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302040 nla_get_u32( tb_vendor[
2041 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2042
Dino Mycled3d50022014-07-07 12:58:25 +05302043 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2044 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302045
2046 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302047 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302048 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302049 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302050 hddLog(VOS_TRACE_LEVEL_INFO,
2051 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302052 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302053
2054 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302055 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302056 {
2057 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2058 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302059 return -EINVAL;
2060 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302061
2062 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302063 return 0;
2064}
2065
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302066static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2067 struct wireless_dev *wdev,
2068 const void *data,
2069 int data_len)
2070{
2071 int ret = 0;
2072
2073 vos_ssr_protect(__func__);
2074 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2075 vos_ssr_unprotect(__func__);
2076
2077 return ret;
2078}
2079
Sunil Duttc69bccb2014-05-26 21:30:20 +05302080const struct
2081nla_policy
2082qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2083{
2084 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2085 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2086 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2087 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2088};
2089
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302090static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2091 struct wireless_dev *wdev,
2092 const void *data,
2093 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302094{
2095 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2096 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302097 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302098 struct net_device *dev = wdev->netdev;
2099 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2100 u32 statsClearReqMask;
2101 u8 stopReq;
2102 int status;
2103
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302104 ENTER();
2105
Sunil Duttc69bccb2014-05-26 21:30:20 +05302106 status = wlan_hdd_validate_context(pHddCtx);
2107 if (0 != status)
2108 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302109 return -EINVAL;
2110 }
2111
2112 if (NULL == pAdapter)
2113 {
2114 hddLog(VOS_TRACE_LEVEL_FATAL,
2115 "%s: HDD adapter is Null", __func__);
2116 return -ENODEV;
2117 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302118 /* check the LLStats Capability */
2119 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2120 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2121 {
2122 hddLog(VOS_TRACE_LEVEL_ERROR,
2123 FL("Enable LLStats Capability"));
2124 return -EINVAL;
2125 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302126
2127 if (!pAdapter->isLinkLayerStatsSet)
2128 {
2129 hddLog(VOS_TRACE_LEVEL_FATAL,
2130 "%s: isLinkLayerStatsSet : %d",
2131 __func__, pAdapter->isLinkLayerStatsSet);
2132 return -EINVAL;
2133 }
2134
2135 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2136 (struct nlattr *)data,
2137 data_len, qca_wlan_vendor_ll_clr_policy))
2138 {
2139 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2140 return -EINVAL;
2141 }
2142
2143 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2144
2145 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2146 {
2147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2148 return -EINVAL;
2149
2150 }
2151
Sunil Duttc69bccb2014-05-26 21:30:20 +05302152
Dino Mycledf0a5d92014-07-04 09:41:55 +05302153 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302154 nla_get_u32(
2155 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2156
Dino Mycledf0a5d92014-07-04 09:41:55 +05302157 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302158 nla_get_u8(
2159 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2160
2161 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302162 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302163
Dino Mycled3d50022014-07-07 12:58:25 +05302164 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2165 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302166
2167 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302168 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302169 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302170 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302171 hddLog(VOS_TRACE_LEVEL_INFO,
2172 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302173 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302174 hddLog(VOS_TRACE_LEVEL_INFO,
2175 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302176 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302177
2178 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302179 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302180 {
2181 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302182 hdd_station_ctx_t *pHddStaCtx;
2183
2184 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2185 if (VOS_STATUS_SUCCESS !=
2186 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2187 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2188 {
2189 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2190 "WLANTL_ClearInterfaceStats Failed", __func__);
2191 return -EINVAL;
2192 }
2193 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2194 (statsClearReqMask & WIFI_STATS_IFACE)) {
2195 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2196 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2197 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2198 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2199 }
2200
Sunil Duttc69bccb2014-05-26 21:30:20 +05302201 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2202 2 * sizeof(u32) +
2203 NLMSG_HDRLEN);
2204
2205 if (temp_skbuff != NULL)
2206 {
2207
2208 if (nla_put_u32(temp_skbuff,
2209 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2210 statsClearReqMask) ||
2211 nla_put_u32(temp_skbuff,
2212 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2213 stopReq))
2214 {
2215 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2216 kfree_skb(temp_skbuff);
2217 return -EINVAL;
2218 }
2219 /* If the ask is to stop the stats collection as part of clear
2220 * (stopReq = 1) , ensure that no further requests of get
2221 * go to the firmware by having isLinkLayerStatsSet set to 0.
2222 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302223 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302224 * case the firmware is just asked to clear the statistics.
2225 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302226 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302227 pAdapter->isLinkLayerStatsSet = 0;
2228 return cfg80211_vendor_cmd_reply(temp_skbuff);
2229 }
2230 return -ENOMEM;
2231 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302232
2233 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302234 return -EINVAL;
2235}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302236static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2237 struct wireless_dev *wdev,
2238 const void *data,
2239 int data_len)
2240{
2241 int ret = 0;
2242
2243 vos_ssr_protect(__func__);
2244 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2245 vos_ssr_unprotect(__func__);
2246
2247 return ret;
2248
2249
2250}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302251#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2252
Dino Mycle6fb96c12014-06-10 11:52:40 +05302253#ifdef WLAN_FEATURE_EXTSCAN
2254static const struct nla_policy
2255wlan_hdd_extscan_config_policy
2256 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2257{
2258 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2259 { .type = NLA_U32 },
2260 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2261 { .type = NLA_U32 },
2262 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2263 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2264 { .type = NLA_U32 },
2265 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2266 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2267
2268 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2269 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2270 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2271 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2272 { .type = NLA_U8 },
2273 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2274 { .type = NLA_U32 },
2275 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2276 { .type = NLA_U32 },
2277 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2278 { .type = NLA_U32 },
2279 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2280 { .type = NLA_U8 },
2281 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2282 { .type = NLA_U8 },
2283 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2284 { .type = NLA_U8 },
2285
2286 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2287 { .type = NLA_U32 },
2288 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2289 { .type = NLA_UNSPEC },
2290 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2291 { .type = NLA_S32 },
2292 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2293 { .type = NLA_S32 },
2294 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2295 { .type = NLA_U32 },
2296 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2297 { .type = NLA_U32 },
2298 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2299 { .type = NLA_U32 },
2300 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2301 = { .type = NLA_U32 },
2302 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2303 { .type = NLA_U32 },
2304 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2305 NLA_U32 },
2306};
2307
2308static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2309{
2310 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2311 struct sk_buff *skb = NULL;
2312 tpSirEXTScanCapabilitiesEvent pData =
2313 (tpSirEXTScanCapabilitiesEvent) pMsg;
2314
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302315 ENTER();
2316
2317 if (wlan_hdd_validate_context(pHddCtx))
2318 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302319 return;
2320 }
2321
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302322 if (!pMsg)
2323 {
2324 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2325 return;
2326 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302327 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2328 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2329 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2330 GFP_KERNEL);
2331
2332 if (!skb) {
2333 hddLog(VOS_TRACE_LEVEL_ERROR,
2334 FL("cfg80211_vendor_event_alloc failed"));
2335 return;
2336 }
2337
2338 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2339 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2340 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2341 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2342 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2343 pData->maxRssiSampleSize);
2344 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2345 pData->maxScanReportingThreshold);
2346 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2347 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2348 pData->maxSignificantWifiChangeAPs);
2349 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2350 pData->maxBsidHistoryEntries);
2351
2352 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2353 pData->requestId) ||
2354 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2355 nla_put_u32(skb,
2356 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2357 pData->scanCacheSize) ||
2358 nla_put_u32(skb,
2359 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2360 pData->scanBuckets) ||
2361 nla_put_u32(skb,
2362 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2363 pData->maxApPerScan) ||
2364 nla_put_u32(skb,
2365 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2366 pData->maxRssiSampleSize) ||
2367 nla_put_u32(skb,
2368 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2369 pData->maxScanReportingThreshold) ||
2370 nla_put_u32(skb,
2371 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2372 pData->maxHotlistAPs) ||
2373 nla_put_u32(skb,
2374 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2375 pData->maxSignificantWifiChangeAPs) ||
2376 nla_put_u32(skb,
2377 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2378 pData->maxBsidHistoryEntries)) {
2379 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2380 goto nla_put_failure;
2381 }
2382
2383 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302384 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302385 return;
2386
2387nla_put_failure:
2388 kfree_skb(skb);
2389 return;
2390}
2391
2392
2393static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2394{
2395 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2396 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2397 struct sk_buff *skb = NULL;
2398 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2399
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302400 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302401
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302402 if (wlan_hdd_validate_context(pHddCtx)){
2403 return;
2404 }
2405 if (!pMsg)
2406 {
2407 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302408 return;
2409 }
2410
2411 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2412 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2413 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2414 GFP_KERNEL);
2415
2416 if (!skb) {
2417 hddLog(VOS_TRACE_LEVEL_ERROR,
2418 FL("cfg80211_vendor_event_alloc failed"));
2419 return;
2420 }
2421 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2422 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2423 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2424
2425 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2426 pData->requestId) ||
2427 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2428 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2429 goto nla_put_failure;
2430 }
2431
2432 /*
2433 * Store the Request ID for comparing with the requestID obtained
2434 * in other requests.HDD shall return a failure is the extscan_stop
2435 * request is issued with a different requestId as that of the
2436 * extscan_start request. Also, This requestId shall be used while
2437 * indicating the full scan results to the upper layers.
2438 * The requestId is stored with the assumption that the firmware
2439 * shall return the ext scan start request's requestId in ext scan
2440 * start response.
2441 */
2442 if (pData->status == 0)
2443 pMac->sme.extScanStartReqId = pData->requestId;
2444
2445
2446 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302447 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302448 return;
2449
2450nla_put_failure:
2451 kfree_skb(skb);
2452 return;
2453}
2454
2455
2456static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2457{
2458 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2459 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2460 struct sk_buff *skb = NULL;
2461
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302462 ENTER();
2463
2464 if (wlan_hdd_validate_context(pHddCtx)){
2465 return;
2466 }
2467 if (!pMsg)
2468 {
2469 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302470 return;
2471 }
2472
2473 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2474 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2475 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2476 GFP_KERNEL);
2477
2478 if (!skb) {
2479 hddLog(VOS_TRACE_LEVEL_ERROR,
2480 FL("cfg80211_vendor_event_alloc failed"));
2481 return;
2482 }
2483 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2484 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2485
2486 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2487 pData->requestId) ||
2488 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2489 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2490 goto nla_put_failure;
2491 }
2492
2493 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302494 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302495 return;
2496
2497nla_put_failure:
2498 kfree_skb(skb);
2499 return;
2500}
2501
2502
2503static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2504 void *pMsg)
2505{
2506 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2507 struct sk_buff *skb = NULL;
2508 tpSirEXTScanSetBssidHotListRspParams pData =
2509 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2510
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302511 ENTER();
2512
2513 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302514 return;
2515 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302516 if (!pMsg)
2517 {
2518 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2519 return;
2520 }
2521
Dino Mycle6fb96c12014-06-10 11:52:40 +05302522 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2523 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2524 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2525 GFP_KERNEL);
2526
2527 if (!skb) {
2528 hddLog(VOS_TRACE_LEVEL_ERROR,
2529 FL("cfg80211_vendor_event_alloc failed"));
2530 return;
2531 }
2532 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2533 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2534 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2535
2536 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2537 pData->requestId) ||
2538 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2539 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2540 goto nla_put_failure;
2541 }
2542
2543 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302544 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302545 return;
2546
2547nla_put_failure:
2548 kfree_skb(skb);
2549 return;
2550}
2551
2552static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2553 void *pMsg)
2554{
2555 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2556 struct sk_buff *skb = NULL;
2557 tpSirEXTScanResetBssidHotlistRspParams pData =
2558 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2559
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302560 ENTER();
2561
2562 if (wlan_hdd_validate_context(pHddCtx)) {
2563 return;
2564 }
2565 if (!pMsg)
2566 {
2567 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302568 return;
2569 }
2570
2571 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2572 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2573 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2574 GFP_KERNEL);
2575
2576 if (!skb) {
2577 hddLog(VOS_TRACE_LEVEL_ERROR,
2578 FL("cfg80211_vendor_event_alloc failed"));
2579 return;
2580 }
2581 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2582 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2583
2584 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2585 pData->requestId) ||
2586 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2587 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2588 goto nla_put_failure;
2589 }
2590
2591 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302592 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302593 return;
2594
2595nla_put_failure:
2596 kfree_skb(skb);
2597 return;
2598}
2599
2600
2601static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2602 void *pMsg)
2603{
2604 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2605 struct sk_buff *skb = NULL;
2606 tpSirEXTScanSetSignificantChangeRspParams pData =
2607 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2608
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302609 ENTER();
2610
2611 if (wlan_hdd_validate_context(pHddCtx)) {
2612 return;
2613 }
2614 if (!pMsg)
2615 {
2616 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302617 return;
2618 }
2619
2620 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2621 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2622 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2623 GFP_KERNEL);
2624
2625 if (!skb) {
2626 hddLog(VOS_TRACE_LEVEL_ERROR,
2627 FL("cfg80211_vendor_event_alloc failed"));
2628 return;
2629 }
2630 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2631 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2632 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2633
2634 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2635 pData->requestId) ||
2636 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2637 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2638 goto nla_put_failure;
2639 }
2640
2641 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302642 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302643 return;
2644
2645nla_put_failure:
2646 kfree_skb(skb);
2647 return;
2648}
2649
2650
2651static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2652 void *pMsg)
2653{
2654 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2655 struct sk_buff *skb = NULL;
2656 tpSirEXTScanResetSignificantChangeRspParams pData =
2657 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2658
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302659 ENTER();
2660
2661 if (wlan_hdd_validate_context(pHddCtx)) {
2662 return;
2663 }
2664 if (!pMsg)
2665 {
2666 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302667 return;
2668 }
2669
2670 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2671 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2672 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2673 GFP_KERNEL);
2674
2675 if (!skb) {
2676 hddLog(VOS_TRACE_LEVEL_ERROR,
2677 FL("cfg80211_vendor_event_alloc failed"));
2678 return;
2679 }
2680 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2681 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2682 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2683
2684 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2685 pData->requestId) ||
2686 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2687 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2688 goto nla_put_failure;
2689 }
2690
2691 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302692 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302693 return;
2694
2695nla_put_failure:
2696 kfree_skb(skb);
2697 return;
2698}
2699
2700static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2701 void *pMsg)
2702{
2703 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2704 struct sk_buff *skb = NULL;
2705 tANI_U32 i = 0, j, resultsPerEvent;
2706 tANI_S32 totalResults;
2707 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2708 tpSirWifiScanResult pSirWifiScanResult;
2709
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302710 ENTER();
2711
2712 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302713 return;
2714 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302715 if (!pMsg)
2716 {
2717 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2718 return;
2719 }
2720
Dino Mycle6fb96c12014-06-10 11:52:40 +05302721 totalResults = pData->numOfAps;
2722 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2723 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2724 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2725
2726 do{
2727 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2728 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2729 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2730
2731 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2732 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2733 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2734 GFP_KERNEL);
2735
2736 if (!skb) {
2737 hddLog(VOS_TRACE_LEVEL_ERROR,
2738 FL("cfg80211_vendor_event_alloc failed"));
2739 return;
2740 }
2741
2742 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2743
2744 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2745 pData->requestId) ||
2746 nla_put_u32(skb,
2747 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2748 resultsPerEvent)) {
2749 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2750 goto fail;
2751 }
2752 if (nla_put_u8(skb,
2753 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2754 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2755 {
2756 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2757 goto fail;
2758 }
2759
2760 if (resultsPerEvent) {
2761 struct nlattr *aps;
2762
2763 aps = nla_nest_start(skb,
2764 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2765 if (!aps)
2766 {
2767 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2768 goto fail;
2769 }
2770
2771 for (j = 0; j < resultsPerEvent; j++, i++) {
2772 struct nlattr *ap;
2773 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2774 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2775
2776 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2777 "Ssid (%s)"
2778 "Bssid: %pM "
2779 "Channel (%u)"
2780 "Rssi (%d)"
2781 "RTT (%u)"
2782 "RTT_SD (%u)",
2783 i,
2784 pSirWifiScanResult->ts,
2785 pSirWifiScanResult->ssid,
2786 pSirWifiScanResult->bssid,
2787 pSirWifiScanResult->channel,
2788 pSirWifiScanResult->rssi,
2789 pSirWifiScanResult->rtt,
2790 pSirWifiScanResult->rtt_sd);
2791
2792 ap = nla_nest_start(skb, j + 1);
2793 if (!ap)
2794 {
2795 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2796 goto fail;
2797 }
2798
2799 if (nla_put_u64(skb,
2800 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2801 pSirWifiScanResult->ts) )
2802 {
2803 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2804 goto fail;
2805 }
2806 if (nla_put(skb,
2807 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2808 sizeof(pSirWifiScanResult->ssid),
2809 pSirWifiScanResult->ssid) )
2810 {
2811 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2812 goto fail;
2813 }
2814 if (nla_put(skb,
2815 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2816 sizeof(pSirWifiScanResult->bssid),
2817 pSirWifiScanResult->bssid) )
2818 {
2819 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2820 goto fail;
2821 }
2822 if (nla_put_u32(skb,
2823 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2824 pSirWifiScanResult->channel) )
2825 {
2826 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2827 goto fail;
2828 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302829 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302830 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2831 pSirWifiScanResult->rssi) )
2832 {
2833 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2834 goto fail;
2835 }
2836 if (nla_put_u32(skb,
2837 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2838 pSirWifiScanResult->rtt) )
2839 {
2840 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2841 goto fail;
2842 }
2843 if (nla_put_u32(skb,
2844 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2845 pSirWifiScanResult->rtt_sd))
2846 {
2847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2848 goto fail;
2849 }
2850
2851 nla_nest_end(skb, ap);
2852 }
2853 nla_nest_end(skb, aps);
2854
2855 }
2856 cfg80211_vendor_event(skb, GFP_KERNEL);
2857 } while (totalResults > 0);
2858
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302859 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302860 return;
2861fail:
2862 kfree_skb(skb);
2863 return;
2864}
2865
2866static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2867 void *pMsg)
2868{
2869 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2870 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2871 struct sk_buff *skb = NULL;
2872 tANI_U32 i;
2873
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302874 ENTER();
2875
2876 if (wlan_hdd_validate_context(pHddCtx)) {
2877 return;
2878 }
2879 if (!pMsg)
2880 {
2881 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302882 return;
2883 }
2884
2885 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2886 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2887 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2888 GFP_KERNEL);
2889
2890 if (!skb) {
2891 hddLog(VOS_TRACE_LEVEL_ERROR,
2892 FL("cfg80211_vendor_event_alloc failed"));
2893 return;
2894 }
2895 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2896 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2897 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2898 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2899
2900 for (i = 0; i < pData->numOfAps; i++) {
2901 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2902 "Ssid (%s) "
2903 "Bssid (" MAC_ADDRESS_STR ") "
2904 "Channel (%u) "
2905 "Rssi (%d) "
2906 "RTT (%u) "
2907 "RTT_SD (%u) ",
2908 i,
2909 pData->ap[i].ts,
2910 pData->ap[i].ssid,
2911 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2912 pData->ap[i].channel,
2913 pData->ap[i].rssi,
2914 pData->ap[i].rtt,
2915 pData->ap[i].rtt_sd);
2916 }
2917
2918 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2919 pData->requestId) ||
2920 nla_put_u32(skb,
2921 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2922 pData->numOfAps)) {
2923 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2924 goto fail;
2925 }
2926 if (pData->numOfAps) {
2927 struct nlattr *aps;
2928
2929 aps = nla_nest_start(skb,
2930 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2931 if (!aps)
2932 goto fail;
2933
2934 for (i = 0; i < pData->numOfAps; i++) {
2935 struct nlattr *ap;
2936
2937 ap = nla_nest_start(skb, i + 1);
2938 if (!ap)
2939 goto fail;
2940
2941 if (nla_put_u64(skb,
2942 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2943 pData->ap[i].ts) ||
2944 nla_put(skb,
2945 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2946 sizeof(pData->ap[i].ssid),
2947 pData->ap[i].ssid) ||
2948 nla_put(skb,
2949 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2950 sizeof(pData->ap[i].bssid),
2951 pData->ap[i].bssid) ||
2952 nla_put_u32(skb,
2953 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2954 pData->ap[i].channel) ||
2955 nla_put_s32(skb,
2956 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2957 pData->ap[i].rssi) ||
2958 nla_put_u32(skb,
2959 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2960 pData->ap[i].rtt) ||
2961 nla_put_u32(skb,
2962 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2963 pData->ap[i].rtt_sd))
2964 goto fail;
2965
2966 nla_nest_end(skb, ap);
2967 }
2968 nla_nest_end(skb, aps);
2969
2970 if (nla_put_u8(skb,
2971 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2972 pData->moreData))
2973 goto fail;
2974 }
2975
2976 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302977 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302978 return;
2979
2980fail:
2981 kfree_skb(skb);
2982 return;
2983
2984}
2985static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
2986 void *pMsg)
2987{
2988 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2989 struct sk_buff *skb = NULL;
2990 tANI_U32 i, j;
2991 tpSirWifiSignificantChangeEvent pData =
2992 (tpSirWifiSignificantChangeEvent) pMsg;
2993
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302994 ENTER();
2995
2996 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302997 return;
2998 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302999 if (!pMsg)
3000 {
3001 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3002 return;
3003 }
3004
Dino Mycle6fb96c12014-06-10 11:52:40 +05303005 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3006 EXTSCAN_EVENT_BUF_SIZE,
3007 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3008 GFP_KERNEL);
3009
3010 if (!skb) {
3011 hddLog(VOS_TRACE_LEVEL_ERROR,
3012 FL("cfg80211_vendor_event_alloc failed"));
3013 return;
3014 }
3015 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3016 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3017 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3018 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3019 pData->numSigRssiBss);
3020 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3021
3022 for (i = 0; i < pData->numSigRssiBss; i++) {
3023 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3024 " num RSSI %u ",
3025 i, pData->sigRssiResult[i].bssid,
3026 pData->sigRssiResult[i].channel,
3027 pData->sigRssiResult[i].numRssi);
3028
3029 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3030
3031 hddLog(VOS_TRACE_LEVEL_INFO,
3032 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303033 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303034
3035 }
3036 }
3037
3038
3039 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3040 pData->requestId) ||
3041 nla_put_u32(skb,
3042 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3043 pData->numSigRssiBss)) {
3044 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3045 goto fail;
3046 }
3047
3048 if (pData->numSigRssiBss) {
3049 struct nlattr *aps;
3050 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3051 if (!aps)
3052 goto fail;
3053 for (i = 0; i < pData->numSigRssiBss; i++) {
3054 struct nlattr *ap;
3055
3056 ap = nla_nest_start(skb, i);
3057 if (!ap)
3058 goto fail;
3059 if (nla_put(skb,
3060 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3061 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3062 nla_put_u32(skb,
3063 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3064 pData->sigRssiResult[i].channel) ||
3065 nla_put_u32(skb,
3066 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3067 pData->sigRssiResult[i].numRssi) ||
3068 nla_put(skb,
3069 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3070 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3071 pData->sigRssiResult[i].rssi))
3072 goto fail;
3073 nla_nest_end(skb, ap);
3074 }
3075 nla_nest_end(skb, aps);
3076 if (nla_put_u8(skb,
3077 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3078 pData->moreData))
3079 goto fail;
3080 }
3081 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303082 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303083 return;
3084fail:
3085 kfree_skb(skb);
3086 return;
3087}
3088
3089static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3090 void *pMsg)
3091{
3092 struct sk_buff *skb;
3093 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3094 tpSirWifiFullScanResultEvent pData =
3095 (tpSirWifiFullScanResultEvent) (pMsg);
3096
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303097 ENTER();
3098
3099 if (wlan_hdd_validate_context(pHddCtx)) {
3100 return;
3101 }
3102 if (!pMsg)
3103 {
3104 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303105 return;
3106 }
3107
3108 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3109 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3110 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3111 GFP_KERNEL);
3112
3113 if (!skb) {
3114 hddLog(VOS_TRACE_LEVEL_ERROR,
3115 FL("cfg80211_vendor_event_alloc failed"));
3116 return;
3117 }
3118
3119 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3120 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3121 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3122 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3123 "Ssid (%s)"
3124 "Bssid (" MAC_ADDRESS_STR ")"
3125 "Channel (%u)"
3126 "Rssi (%d)"
3127 "RTT (%u)"
3128 "RTT_SD (%u)"),
3129 pData->ap.ts,
3130 pData->ap.ssid,
3131 MAC_ADDR_ARRAY(pData->ap.bssid),
3132 pData->ap.channel,
3133 pData->ap.rssi,
3134 pData->ap.rtt,
3135 pData->ap.rtt_sd);
3136 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3137 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3138 pData->requestId) ||
3139 nla_put_u64(skb,
3140 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3141 pData->ap.ts) ||
3142 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3143 sizeof(pData->ap.ssid),
3144 pData->ap.ssid) ||
3145 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3146 WNI_CFG_BSSID_LEN,
3147 pData->ap.bssid) ||
3148 nla_put_u32(skb,
3149 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3150 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303151 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303152 pData->ap.rssi) ||
3153 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3154 pData->ap.rtt) ||
3155 nla_put_u32(skb,
3156 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3157 pData->ap.rtt_sd) ||
3158 nla_put_u16(skb,
3159 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3160 pData->ap.beaconPeriod) ||
3161 nla_put_u16(skb,
3162 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3163 pData->ap.capability) ||
3164 nla_put_u32(skb,
3165 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3166 pData->ieLength))
3167 {
3168 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3169 goto nla_put_failure;
3170 }
3171 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3172 pData->ieLength,
3173 pData->ie))
3174 {
3175 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3176 goto nla_put_failure;
3177 }
3178
3179 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303180 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303181 return;
3182
3183nla_put_failure:
3184 kfree_skb(skb);
3185 return;
3186}
3187
3188static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3189 void *pMsg)
3190{
3191 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3192 struct sk_buff *skb = NULL;
3193 tpSirEXTScanResultsAvailableIndParams pData =
3194 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3195
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303196 ENTER();
3197
3198 if (wlan_hdd_validate_context(pHddCtx)){
3199 return;
3200 }
3201 if (!pMsg)
3202 {
3203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303204 return;
3205 }
3206
3207 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3208 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3209 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3210 GFP_KERNEL);
3211
3212 if (!skb) {
3213 hddLog(VOS_TRACE_LEVEL_ERROR,
3214 FL("cfg80211_vendor_event_alloc failed"));
3215 return;
3216 }
3217
3218 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3219 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3220 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3221 pData->numResultsAvailable);
3222 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3223 pData->requestId) ||
3224 nla_put_u32(skb,
3225 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3226 pData->numResultsAvailable)) {
3227 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3228 goto nla_put_failure;
3229 }
3230
3231 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303232 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303233 return;
3234
3235nla_put_failure:
3236 kfree_skb(skb);
3237 return;
3238}
3239
3240static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3241{
3242 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3243 struct sk_buff *skb = NULL;
3244 tpSirEXTScanProgressIndParams pData =
3245 (tpSirEXTScanProgressIndParams) pMsg;
3246
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303247 ENTER();
3248
3249 if (wlan_hdd_validate_context(pHddCtx)){
3250 return;
3251 }
3252 if (!pMsg)
3253 {
3254 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303255 return;
3256 }
3257
3258 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3259 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3260 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3261 GFP_KERNEL);
3262
3263 if (!skb) {
3264 hddLog(VOS_TRACE_LEVEL_ERROR,
3265 FL("cfg80211_vendor_event_alloc failed"));
3266 return;
3267 }
3268 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3269 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3270 pData->extScanEventType);
3271 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3272 pData->status);
3273
3274 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3275 pData->extScanEventType) ||
3276 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303277 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3278 pData->requestId) ||
3279 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303280 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3281 pData->status)) {
3282 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3283 goto nla_put_failure;
3284 }
3285
3286 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303287 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303288 return;
3289
3290nla_put_failure:
3291 kfree_skb(skb);
3292 return;
3293}
3294
3295void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3296 void *pMsg)
3297{
3298 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3299
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303300 ENTER();
3301
Dino Mycle6fb96c12014-06-10 11:52:40 +05303302 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303303 return;
3304 }
3305
3306 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3307
3308
3309 switch(evType) {
3310 case SIR_HAL_EXTSCAN_START_RSP:
3311 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3312 break;
3313
3314 case SIR_HAL_EXTSCAN_STOP_RSP:
3315 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3316 break;
3317 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3318 /* There is no need to send this response to upper layer
3319 Just log the message */
3320 hddLog(VOS_TRACE_LEVEL_INFO,
3321 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3322 break;
3323 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3324 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3325 break;
3326
3327 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3328 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3329 break;
3330
3331 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3332 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3333 break;
3334
3335 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3336 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3337 break;
3338 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3339 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3340 break;
3341 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3342 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3343 break;
3344 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3345 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3346 break;
3347 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3348 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3349 break;
3350 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3351 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3352 break;
3353 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3354 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3355 break;
3356 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3357 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3358 break;
3359 default:
3360 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3361 break;
3362 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303363 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303364}
3365
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303366static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3367 struct wireless_dev *wdev,
3368 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303369{
Dino Myclee8843b32014-07-04 14:21:45 +05303370 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303371 struct net_device *dev = wdev->netdev;
3372 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3373 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3374 struct nlattr
3375 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3376 eHalStatus status;
3377
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303378 ENTER();
3379
Dino Mycle6fb96c12014-06-10 11:52:40 +05303380 status = wlan_hdd_validate_context(pHddCtx);
3381 if (0 != status)
3382 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303383 return -EINVAL;
3384 }
Dino Myclee8843b32014-07-04 14:21:45 +05303385 /* check the EXTScan Capability */
3386 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3387 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3388 {
3389 hddLog(VOS_TRACE_LEVEL_ERROR,
3390 FL("EXTScan not enabled/supported by Firmware"));
3391 return -EINVAL;
3392 }
3393
Dino Mycle6fb96c12014-06-10 11:52:40 +05303394 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3395 data, dataLen,
3396 wlan_hdd_extscan_config_policy)) {
3397 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3398 return -EINVAL;
3399 }
3400
3401 /* Parse and fetch request Id */
3402 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3403 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3404 return -EINVAL;
3405 }
3406
Dino Mycle6fb96c12014-06-10 11:52:40 +05303407
Dino Myclee8843b32014-07-04 14:21:45 +05303408 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303409 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303410 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303411
Dino Myclee8843b32014-07-04 14:21:45 +05303412 reqMsg.sessionId = pAdapter->sessionId;
3413 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303414
Dino Myclee8843b32014-07-04 14:21:45 +05303415 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303416 if (!HAL_STATUS_SUCCESS(status)) {
3417 hddLog(VOS_TRACE_LEVEL_ERROR,
3418 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303419 return -EINVAL;
3420 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303421 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303422 return 0;
3423}
3424
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303425static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3426 struct wireless_dev *wdev,
3427 const void *data, int dataLen)
3428{
3429 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303430
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303431 vos_ssr_protect(__func__);
3432 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3433 vos_ssr_unprotect(__func__);
3434
3435 return ret;
3436}
3437
3438static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3439 struct wireless_dev *wdev,
3440 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303441{
Dino Myclee8843b32014-07-04 14:21:45 +05303442 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303443 struct net_device *dev = wdev->netdev;
3444 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3445 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3446 struct nlattr
3447 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3448 eHalStatus status;
3449
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303450 ENTER();
3451
Dino Mycle6fb96c12014-06-10 11:52:40 +05303452 status = wlan_hdd_validate_context(pHddCtx);
3453 if (0 != status)
3454 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303455 return -EINVAL;
3456 }
Dino Myclee8843b32014-07-04 14:21:45 +05303457 /* check the EXTScan Capability */
3458 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3459 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3460 {
3461 hddLog(VOS_TRACE_LEVEL_ERROR,
3462 FL("EXTScan not enabled/supported by Firmware"));
3463 return -EINVAL;
3464 }
3465
Dino Mycle6fb96c12014-06-10 11:52:40 +05303466 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3467 data, dataLen,
3468 wlan_hdd_extscan_config_policy)) {
3469 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3470 return -EINVAL;
3471 }
3472 /* Parse and fetch request Id */
3473 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3474 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3475 return -EINVAL;
3476 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303477
Dino Myclee8843b32014-07-04 14:21:45 +05303478 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303479 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3480
Dino Myclee8843b32014-07-04 14:21:45 +05303481 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303482
Dino Myclee8843b32014-07-04 14:21:45 +05303483 reqMsg.sessionId = pAdapter->sessionId;
3484 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303485
3486 /* Parse and fetch flush parameter */
3487 if (!tb
3488 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3489 {
3490 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3491 goto failed;
3492 }
Dino Myclee8843b32014-07-04 14:21:45 +05303493 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303494 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3495
Dino Myclee8843b32014-07-04 14:21:45 +05303496 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303497
Dino Myclee8843b32014-07-04 14:21:45 +05303498 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303499 if (!HAL_STATUS_SUCCESS(status)) {
3500 hddLog(VOS_TRACE_LEVEL_ERROR,
3501 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303502 return -EINVAL;
3503 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303504 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303505 return 0;
3506
3507failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303508 return -EINVAL;
3509}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303510static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3511 struct wireless_dev *wdev,
3512 const void *data, int dataLen)
3513{
3514 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303515
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303516 vos_ssr_protect(__func__);
3517 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3518 vos_ssr_unprotect(__func__);
3519
3520 return ret;
3521}
3522
3523static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303524 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303525 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303526{
3527 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3528 struct net_device *dev = wdev->netdev;
3529 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3530 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3531 struct nlattr
3532 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3533 struct nlattr
3534 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3535 struct nlattr *apTh;
3536 eHalStatus status;
3537 tANI_U8 i = 0;
3538 int rem;
3539
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303540 ENTER();
3541
Dino Mycle6fb96c12014-06-10 11:52:40 +05303542 status = wlan_hdd_validate_context(pHddCtx);
3543 if (0 != status)
3544 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303545 return -EINVAL;
3546 }
Dino Myclee8843b32014-07-04 14:21:45 +05303547 /* check the EXTScan Capability */
3548 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3549 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3550 {
3551 hddLog(VOS_TRACE_LEVEL_ERROR,
3552 FL("EXTScan not enabled/supported by Firmware"));
3553 return -EINVAL;
3554 }
3555
Dino Mycle6fb96c12014-06-10 11:52:40 +05303556 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3557 data, dataLen,
3558 wlan_hdd_extscan_config_policy)) {
3559 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3560 return -EINVAL;
3561 }
3562
3563 /* Parse and fetch request Id */
3564 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3565 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3566 return -EINVAL;
3567 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303568 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3569 vos_mem_malloc(sizeof(*pReqMsg));
3570 if (!pReqMsg) {
3571 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3572 return -ENOMEM;
3573 }
3574
Dino Myclee8843b32014-07-04 14:21:45 +05303575
Dino Mycle6fb96c12014-06-10 11:52:40 +05303576 pReqMsg->requestId = nla_get_u32(
3577 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3578 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3579
3580 /* Parse and fetch number of APs */
3581 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3582 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3583 goto fail;
3584 }
3585
3586 pReqMsg->sessionId = pAdapter->sessionId;
3587 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3588
3589 pReqMsg->numAp = nla_get_u32(
3590 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3591 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3592
3593 nla_for_each_nested(apTh,
3594 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3595 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3596 nla_data(apTh), nla_len(apTh),
3597 NULL)) {
3598 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3599 goto fail;
3600 }
3601
3602 /* Parse and fetch MAC address */
3603 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3604 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3605 goto fail;
3606 }
3607 memcpy(pReqMsg->ap[i].bssid, nla_data(
3608 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3609 sizeof(tSirMacAddr));
3610 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3611
3612 /* Parse and fetch low RSSI */
3613 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3614 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3615 goto fail;
3616 }
3617 pReqMsg->ap[i].low = nla_get_s32(
3618 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3619 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3620
3621 /* Parse and fetch high RSSI */
3622 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3623 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3624 goto fail;
3625 }
3626 pReqMsg->ap[i].high = nla_get_s32(
3627 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3628 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3629 pReqMsg->ap[i].high);
3630
3631 /* Parse and fetch channel */
3632 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3633 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3634 goto fail;
3635 }
3636 pReqMsg->ap[i].channel = nla_get_u32(
3637 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3638 hddLog(VOS_TRACE_LEVEL_INFO,
3639 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3640 i++;
3641 }
3642 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3643 if (!HAL_STATUS_SUCCESS(status)) {
3644 hddLog(VOS_TRACE_LEVEL_ERROR,
3645 FL("sme_SetBssHotlist failed(err=%d)"), status);
3646 vos_mem_free(pReqMsg);
3647 return -EINVAL;
3648 }
3649
Dino Myclee8843b32014-07-04 14:21:45 +05303650 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303651 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303652 return 0;
3653
3654fail:
3655 vos_mem_free(pReqMsg);
3656 return -EINVAL;
3657}
3658
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303659static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3660 struct wireless_dev *wdev,
3661 const void *data, int dataLen)
3662{
3663 int ret = 0;
3664
3665 vos_ssr_protect(__func__);
3666 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3667 dataLen);
3668 vos_ssr_unprotect(__func__);
3669
3670 return ret;
3671}
3672
3673static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303674 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303675 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303676{
3677 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3678 struct net_device *dev = wdev->netdev;
3679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3680 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3681 struct nlattr
3682 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3683 struct nlattr
3684 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3685 struct nlattr *apTh;
3686 eHalStatus status;
3687 int i = 0;
3688 int rem;
3689
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303690 ENTER();
3691
Dino Mycle6fb96c12014-06-10 11:52:40 +05303692 status = wlan_hdd_validate_context(pHddCtx);
3693 if (0 != status)
3694 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303695 return -EINVAL;
3696 }
Dino Myclee8843b32014-07-04 14:21:45 +05303697 /* check the EXTScan Capability */
3698 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3699 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3700 {
3701 hddLog(VOS_TRACE_LEVEL_ERROR,
3702 FL("EXTScan not enabled/supported by Firmware"));
3703 return -EINVAL;
3704 }
3705
Dino Mycle6fb96c12014-06-10 11:52:40 +05303706 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3707 data, dataLen,
3708 wlan_hdd_extscan_config_policy)) {
3709 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3710 return -EINVAL;
3711 }
3712
3713 /* Parse and fetch request Id */
3714 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3715 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3716 return -EINVAL;
3717 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303718 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303719 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303720 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303721 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3722 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303723 }
3724
Dino Myclee8843b32014-07-04 14:21:45 +05303725
3726
Dino Mycle6fb96c12014-06-10 11:52:40 +05303727 pReqMsg->requestId = nla_get_u32(
3728 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3729 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3730
3731 /* Parse and fetch RSSI sample size */
3732 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3733 {
3734 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3735 goto fail;
3736 }
3737 pReqMsg->rssiSampleSize = nla_get_u32(
3738 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3739 hddLog(VOS_TRACE_LEVEL_INFO,
3740 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3741
3742 /* Parse and fetch lost AP sample size */
3743 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3744 {
3745 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3746 goto fail;
3747 }
3748 pReqMsg->lostApSampleSize = nla_get_u32(
3749 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3750 hddLog(VOS_TRACE_LEVEL_INFO,
3751 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3752 /* Parse and fetch minimum Breaching */
3753 if (!tb
3754 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3755 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3756 goto fail;
3757 }
3758 pReqMsg->minBreaching = nla_get_u32(
3759 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3760 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3761
3762 /* Parse and fetch number of APs */
3763 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3765 goto fail;
3766 }
3767 pReqMsg->numAp = nla_get_u32(
3768 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3769 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3770
3771 pReqMsg->sessionId = pAdapter->sessionId;
3772 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3773
3774 nla_for_each_nested(apTh,
3775 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3776 if(nla_parse(tb2,
3777 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3778 nla_data(apTh), nla_len(apTh),
3779 NULL)) {
3780 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3781 goto fail;
3782 }
3783
3784 /* Parse and fetch MAC address */
3785 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3786 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3787 goto fail;
3788 }
3789 memcpy(pReqMsg->ap[i].bssid, nla_data(
3790 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3791 sizeof(tSirMacAddr));
3792
3793 /* Parse and fetch low RSSI */
3794 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3795 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3796 goto fail;
3797 }
3798 pReqMsg->ap[i].low = nla_get_s32(
3799 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3800 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3801
3802 /* Parse and fetch high RSSI */
3803 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3805 goto fail;
3806 }
3807 pReqMsg->ap[i].high = nla_get_s32(
3808 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3809 hddLog(VOS_TRACE_LEVEL_INFO,
3810 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3811
3812 /* Parse and fetch channel */
3813 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3814 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3815 goto fail;
3816 }
3817 pReqMsg->ap[i].channel = nla_get_u32(
3818 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3819 hddLog(VOS_TRACE_LEVEL_INFO,
3820 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3821 i++;
3822 }
3823
3824 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3825 if (!HAL_STATUS_SUCCESS(status)) {
3826 hddLog(VOS_TRACE_LEVEL_ERROR,
3827 FL("sme_SetSignificantChange failed(err=%d)"), status);
3828 vos_mem_free(pReqMsg);
3829 return -EINVAL;
3830 }
Dino Myclee8843b32014-07-04 14:21:45 +05303831 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303832 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303833 return 0;
3834
3835fail:
3836 vos_mem_free(pReqMsg);
3837 return -EINVAL;
3838}
3839
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303840static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3841 struct wireless_dev *wdev,
3842 const void *data, int dataLen)
3843{
3844 int ret = 0;
3845
3846 vos_ssr_protect(__func__);
3847 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3848 dataLen);
3849 vos_ssr_unprotect(__func__);
3850
3851 return ret;
3852}
3853
3854static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303855 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303856 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303857{
3858 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3859 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3860 tANI_U8 numChannels = 0;
3861 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3862 tANI_U32 requestId;
3863 tWifiBand wifiBand;
3864 eHalStatus status;
3865 struct sk_buff *replySkb;
3866 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303867 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303868
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303869 ENTER();
3870
Dino Mycle6fb96c12014-06-10 11:52:40 +05303871 status = wlan_hdd_validate_context(pHddCtx);
3872 if (0 != status)
3873 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303874 return -EINVAL;
3875 }
Dino Myclee8843b32014-07-04 14:21:45 +05303876 /* check the EXTScan Capability */
3877 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3878 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3879 {
3880 hddLog(VOS_TRACE_LEVEL_ERROR,
3881 FL("EXTScan not enabled/supported by Firmware"));
3882 return -EINVAL;
3883 }
3884
Dino Mycle6fb96c12014-06-10 11:52:40 +05303885 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3886 data, dataLen,
3887 wlan_hdd_extscan_config_policy)) {
3888 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3889 return -EINVAL;
3890 }
3891
3892 /* Parse and fetch request Id */
3893 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3894 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3895 return -EINVAL;
3896 }
3897 requestId = nla_get_u32(
3898 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3899 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3900
3901 /* Parse and fetch wifi band */
3902 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3903 {
3904 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3905 return -EINVAL;
3906 }
3907 wifiBand = nla_get_u32(
3908 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3909 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3910
3911 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3912 wifiBand, ChannelList,
3913 &numChannels);
3914 if (eHAL_STATUS_SUCCESS != status) {
3915 hddLog(VOS_TRACE_LEVEL_ERROR,
3916 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3917 return -EINVAL;
3918 }
3919 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3920 for (i = 0; i < numChannels; i++)
3921 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3922
3923 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3924 sizeof(u32) * numChannels +
3925 NLMSG_HDRLEN);
3926
3927 if (!replySkb) {
3928 hddLog(VOS_TRACE_LEVEL_ERROR,
3929 FL("valid channels: buffer alloc fail"));
3930 return -EINVAL;
3931 }
3932 if (nla_put_u32(replySkb,
3933 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3934 numChannels) ||
3935 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3936 sizeof(u32) * numChannels, ChannelList)) {
3937
3938 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3939 kfree_skb(replySkb);
3940 return -EINVAL;
3941 }
3942
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303943 ret = cfg80211_vendor_cmd_reply(replySkb);
3944
3945 EXIT();
3946 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303947}
3948
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303949static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3950 struct wireless_dev *wdev,
3951 const void *data, int dataLen)
3952{
3953 int ret = 0;
3954
3955 vos_ssr_protect(__func__);
3956 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
3957 dataLen);
3958 vos_ssr_unprotect(__func__);
3959
3960 return ret;
3961}
3962
3963static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303964 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303965 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303966{
Dino Myclee8843b32014-07-04 14:21:45 +05303967 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303968 struct net_device *dev = wdev->netdev;
3969 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3970 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3971 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3972 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3973 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3974 struct nlattr *buckets;
3975 struct nlattr *channels;
3976 int rem1;
3977 int rem2;
3978 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303979 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303980
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303981 ENTER();
3982
Dino Mycle6fb96c12014-06-10 11:52:40 +05303983 status = wlan_hdd_validate_context(pHddCtx);
3984 if (0 != status)
3985 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303986 return -EINVAL;
3987 }
Dino Myclee8843b32014-07-04 14:21:45 +05303988 /* check the EXTScan Capability */
3989 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3990 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3991 {
3992 hddLog(VOS_TRACE_LEVEL_ERROR,
3993 FL("EXTScan not enabled/supported by Firmware"));
3994 return -EINVAL;
3995 }
3996
Dino Mycle6fb96c12014-06-10 11:52:40 +05303997 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3998 data, dataLen,
3999 wlan_hdd_extscan_config_policy)) {
4000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4001 return -EINVAL;
4002 }
4003
4004 /* Parse and fetch request Id */
4005 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4006 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4007 return -EINVAL;
4008 }
4009
Dino Myclee8843b32014-07-04 14:21:45 +05304010 pReqMsg = (tpSirEXTScanStartReqParams)
4011 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304012 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304013 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4014 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304015 }
4016
4017 pReqMsg->requestId = nla_get_u32(
4018 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4019 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4020
4021 pReqMsg->sessionId = pAdapter->sessionId;
4022 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4023
4024 /* Parse and fetch base period */
4025 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4026 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4027 goto fail;
4028 }
4029 pReqMsg->basePeriod = nla_get_u32(
4030 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4031 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4032 pReqMsg->basePeriod);
4033
4034 /* Parse and fetch max AP per scan */
4035 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4036 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4037 goto fail;
4038 }
4039 pReqMsg->maxAPperScan = nla_get_u32(
4040 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4041 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4042 pReqMsg->maxAPperScan);
4043
4044 /* Parse and fetch report threshold */
4045 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4046 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4047 goto fail;
4048 }
4049 pReqMsg->reportThreshold = nla_get_u8(
4050 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4051 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4052 pReqMsg->reportThreshold);
4053
4054 /* Parse and fetch number of buckets */
4055 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4056 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4057 goto fail;
4058 }
4059 pReqMsg->numBuckets = nla_get_u8(
4060 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4061 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4062 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4063 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4064 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4065 }
4066 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4067 pReqMsg->numBuckets);
4068 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4069 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4070 goto fail;
4071 }
4072
4073 nla_for_each_nested(buckets,
4074 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4075 if(nla_parse(bucket,
4076 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4077 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4078 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4079 goto fail;
4080 }
4081
4082 /* Parse and fetch bucket spec */
4083 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4085 goto fail;
4086 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304087
4088 pReqMsg->buckets[index].bucket = nla_get_u8(
4089 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4090
4091 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4092 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304093
4094 /* Parse and fetch wifi band */
4095 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4096 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4097 goto fail;
4098 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304099 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304100 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4101 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304102 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304103
4104 /* Parse and fetch period */
4105 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4106 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4107 goto fail;
4108 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304109 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304110 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4111 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304112 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304113
4114 /* Parse and fetch report events */
4115 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4116 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4117 goto fail;
4118 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304119 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304120 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4121 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304122 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304123
4124 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304125 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4126 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304127 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4128 goto fail;
4129 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304130 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304131 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4132 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304133 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304134
4135 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4136 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4137 goto fail;
4138 }
4139
4140 j = 0;
4141 nla_for_each_nested(channels,
4142 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4143 if(nla_parse(channel,
4144 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4145 nla_data(channels), nla_len(channels),
4146 NULL)) { //wlan_hdd_extscan_config_policy here
4147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4148 goto fail;
4149 }
4150
4151 /* Parse and fetch channel */
4152 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4153 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4154 goto fail;
4155 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304156 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304157 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4158 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304159 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304160
4161 /* Parse and fetch dwell time */
4162 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4163 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4164 goto fail;
4165 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304166 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304167 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4168 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304169 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304170
4171 /* Parse and fetch channel spec passive */
4172 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4173 hddLog(VOS_TRACE_LEVEL_ERROR,
4174 FL("attr channel spec passive failed"));
4175 goto fail;
4176 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304177 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304178 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4179 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304180 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304181 j++;
4182 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304183 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304184 }
4185 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4186 if (!HAL_STATUS_SUCCESS(status)) {
4187 hddLog(VOS_TRACE_LEVEL_ERROR,
4188 FL("sme_EXTScanStart failed(err=%d)"), status);
4189 vos_mem_free(pReqMsg);
4190 return -EINVAL;
4191 }
4192
Dino Myclee8843b32014-07-04 14:21:45 +05304193 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304194 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304195 return 0;
4196
4197fail:
4198 vos_mem_free(pReqMsg);
4199 return -EINVAL;
4200}
4201
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304202static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4203 struct wireless_dev *wdev,
4204 const void *data, int dataLen)
4205{
4206 int ret = 0;
4207
4208 vos_ssr_protect(__func__);
4209 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4210 vos_ssr_unprotect(__func__);
4211
4212 return ret;
4213}
4214
4215static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304216 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304217 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304218{
Dino Myclee8843b32014-07-04 14:21:45 +05304219 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304220 struct net_device *dev = wdev->netdev;
4221 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4222 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4223 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4224 eHalStatus status;
4225
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304226 ENTER();
4227
Dino Mycle6fb96c12014-06-10 11:52:40 +05304228 status = wlan_hdd_validate_context(pHddCtx);
4229 if (0 != status)
4230 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304231 return -EINVAL;
4232 }
Dino Myclee8843b32014-07-04 14:21:45 +05304233 /* check the EXTScan Capability */
4234 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4235 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4236 {
4237 hddLog(VOS_TRACE_LEVEL_ERROR,
4238 FL("EXTScan not enabled/supported by Firmware"));
4239 return -EINVAL;
4240 }
4241
Dino Mycle6fb96c12014-06-10 11:52:40 +05304242 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4243 data, dataLen,
4244 wlan_hdd_extscan_config_policy)) {
4245 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4246 return -EINVAL;
4247 }
4248
4249 /* Parse and fetch request Id */
4250 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4251 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4252 return -EINVAL;
4253 }
4254
Dino Myclee8843b32014-07-04 14:21:45 +05304255 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304256 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304257 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304258
Dino Myclee8843b32014-07-04 14:21:45 +05304259 reqMsg.sessionId = pAdapter->sessionId;
4260 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304261
Dino Myclee8843b32014-07-04 14:21:45 +05304262 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304263 if (!HAL_STATUS_SUCCESS(status)) {
4264 hddLog(VOS_TRACE_LEVEL_ERROR,
4265 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304266 return -EINVAL;
4267 }
4268
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304269 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304270 return 0;
4271}
4272
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304273static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4274 struct wireless_dev *wdev,
4275 const void *data, int dataLen)
4276{
4277 int ret = 0;
4278
4279 vos_ssr_protect(__func__);
4280 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4281 vos_ssr_unprotect(__func__);
4282
4283 return ret;
4284}
4285
4286static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304287 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304288 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304289{
Dino Myclee8843b32014-07-04 14:21:45 +05304290 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304291 struct net_device *dev = wdev->netdev;
4292 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4293 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4294 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4295 eHalStatus status;
4296
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304297 ENTER();
4298
Dino Mycle6fb96c12014-06-10 11:52:40 +05304299 status = wlan_hdd_validate_context(pHddCtx);
4300 if (0 != status)
4301 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304302 return -EINVAL;
4303 }
Dino Myclee8843b32014-07-04 14:21:45 +05304304 /* check the EXTScan Capability */
4305 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4306 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4307 {
4308 hddLog(VOS_TRACE_LEVEL_ERROR,
4309 FL("EXTScan not enabled/supported by Firmware"));
4310 return -EINVAL;
4311 }
4312
Dino Mycle6fb96c12014-06-10 11:52:40 +05304313 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4314 data, dataLen,
4315 wlan_hdd_extscan_config_policy)) {
4316 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4317 return -EINVAL;
4318 }
4319
4320 /* Parse and fetch request Id */
4321 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4322 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4323 return -EINVAL;
4324 }
4325
Dino Myclee8843b32014-07-04 14:21:45 +05304326 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304327 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304328 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304329
Dino Myclee8843b32014-07-04 14:21:45 +05304330 reqMsg.sessionId = pAdapter->sessionId;
4331 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304332
Dino Myclee8843b32014-07-04 14:21:45 +05304333 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304334 if (!HAL_STATUS_SUCCESS(status)) {
4335 hddLog(VOS_TRACE_LEVEL_ERROR,
4336 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304337 return -EINVAL;
4338 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304339 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304340 return 0;
4341}
4342
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304343static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4344 struct wireless_dev *wdev,
4345 const void *data, int dataLen)
4346{
4347 int ret = 0;
4348
4349 vos_ssr_protect(__func__);
4350 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4351 vos_ssr_unprotect(__func__);
4352
4353 return ret;
4354}
4355
4356static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304357 struct wiphy *wiphy,
4358 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304359 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304360{
Dino Myclee8843b32014-07-04 14:21:45 +05304361 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304362 struct net_device *dev = wdev->netdev;
4363 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4364 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4365 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4366 eHalStatus status;
4367
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304368 ENTER();
4369
Dino Mycle6fb96c12014-06-10 11:52:40 +05304370 status = wlan_hdd_validate_context(pHddCtx);
4371 if (0 != status)
4372 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304373 return -EINVAL;
4374 }
Dino Myclee8843b32014-07-04 14:21:45 +05304375 /* check the EXTScan Capability */
4376 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4377 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4378 {
4379 hddLog(VOS_TRACE_LEVEL_ERROR,
4380 FL("EXTScan not enabled/supported by Firmware"));
4381 return -EINVAL;
4382 }
4383
Dino Mycle6fb96c12014-06-10 11:52:40 +05304384 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4385 data, dataLen,
4386 wlan_hdd_extscan_config_policy)) {
4387 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4388 return -EINVAL;
4389 }
4390
4391 /* Parse and fetch request Id */
4392 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4393 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4394 return -EINVAL;
4395 }
4396
Dino Mycle6fb96c12014-06-10 11:52:40 +05304397
Dino Myclee8843b32014-07-04 14:21:45 +05304398 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304399 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304400 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304401
Dino Myclee8843b32014-07-04 14:21:45 +05304402 reqMsg.sessionId = pAdapter->sessionId;
4403 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304404
Dino Myclee8843b32014-07-04 14:21:45 +05304405 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304406 if (!HAL_STATUS_SUCCESS(status)) {
4407 hddLog(VOS_TRACE_LEVEL_ERROR,
4408 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304409 return -EINVAL;
4410 }
4411
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304412 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304413 return 0;
4414}
4415
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304416static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4417 struct wiphy *wiphy,
4418 struct wireless_dev *wdev,
4419 const void *data, int dataLen)
4420{
4421 int ret = 0;
4422
4423 vos_ssr_protect(__func__);
4424 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4425 wdev, data,
4426 dataLen);
4427 vos_ssr_unprotect(__func__);
4428
4429 return ret;
4430}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304431#endif /* WLAN_FEATURE_EXTSCAN */
4432
Atul Mittal115287b2014-07-08 13:26:33 +05304433/*EXT TDLS*/
4434static const struct nla_policy
4435wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4436{
4437 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4438 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4439 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4440 {.type = NLA_S32 },
4441 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4442 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4443
4444};
4445
4446static const struct nla_policy
4447wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4448{
4449 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4450
4451};
4452
4453static const struct nla_policy
4454wlan_hdd_tdls_config_state_change_policy[
4455 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4456{
4457 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4458 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4459 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304460 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4461 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4462 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304463
4464};
4465
4466static const struct nla_policy
4467wlan_hdd_tdls_config_get_status_policy[
4468 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4469{
4470 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4471 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4472 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304473 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4474 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4475 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304476
4477};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304478
4479static const struct nla_policy
4480wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4481{
4482 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4483};
4484
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304485static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304486 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304487 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304488 int data_len)
4489{
4490
4491 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4492 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4493
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304494 ENTER();
4495
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304496 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304497 return -EINVAL;
4498 }
4499 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
4500 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN disabled in ini"));
4501 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304502 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304503 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
4504 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN not supported by FW"));
4505 return -ENOTSUPP;
4506 }
4507
4508 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4509 data, data_len, wlan_hdd_mac_config)) {
4510 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4511 return -EINVAL;
4512 }
4513
4514 /* Parse and fetch mac address */
4515 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4517 return -EINVAL;
4518 }
4519
4520 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4521 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4522 VOS_MAC_ADDR_LAST_3_BYTES);
4523
Siddharth Bhal76972212014-10-15 16:22:51 +05304524 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4525
4526 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304527 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4528 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304529 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4530 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4531 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4532 {
4533 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4534 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4535 VOS_MAC_ADDRESS_LEN);
4536 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304537 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304538
Siddharth Bhal76972212014-10-15 16:22:51 +05304539 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4540 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304541 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4542 }
4543
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304544 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304545 return 0;
4546}
4547
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304548static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4549 struct wireless_dev *wdev,
4550 const void *data,
4551 int data_len)
4552{
4553 int ret = 0;
4554
4555 vos_ssr_protect(__func__);
4556 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4557 vos_ssr_unprotect(__func__);
4558
4559 return ret;
4560}
4561
4562static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304563 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304564 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304565 int data_len)
4566{
4567 u8 peer[6] = {0};
4568 struct net_device *dev = wdev->netdev;
4569 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4570 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4571 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4572 eHalStatus ret;
4573 tANI_S32 state;
4574 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304575 tANI_S32 global_operating_class = 0;
4576 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304577 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304578 int retVal;
4579
4580 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304581
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304582 if (!pAdapter) {
4583 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4584 return -EINVAL;
4585 }
4586
Atul Mittal115287b2014-07-08 13:26:33 +05304587 ret = wlan_hdd_validate_context(pHddCtx);
4588 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304589 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304590 return -EINVAL;
4591 }
4592 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304593 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304594 return -ENOTSUPP;
4595 }
4596 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4597 data, data_len,
4598 wlan_hdd_tdls_config_get_status_policy)) {
4599 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4600 return -EINVAL;
4601 }
4602
4603 /* Parse and fetch mac address */
4604 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4605 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4606 return -EINVAL;
4607 }
4608
4609 memcpy(peer, nla_data(
4610 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4611 sizeof(peer));
4612 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4613
4614 ret = wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
4615
4616 if (0 != ret) {
4617 hddLog(VOS_TRACE_LEVEL_ERROR,
4618 FL("get status Failed"));
4619 return -EINVAL;
4620 }
4621 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304622 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304623 NLMSG_HDRLEN);
4624
4625 if (!skb) {
4626 hddLog(VOS_TRACE_LEVEL_ERROR,
4627 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4628 return -EINVAL;
4629 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304630 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 +05304631 reason,
4632 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304633 global_operating_class,
4634 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304635 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304636 if (nla_put_s32(skb,
4637 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4638 state) ||
4639 nla_put_s32(skb,
4640 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4641 reason) ||
4642 nla_put_s32(skb,
4643 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4644 global_operating_class) ||
4645 nla_put_s32(skb,
4646 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4647 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304648
4649 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4650 goto nla_put_failure;
4651 }
4652
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304653 retVal = cfg80211_vendor_cmd_reply(skb);
4654 EXIT();
4655 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304656
4657nla_put_failure:
4658 kfree_skb(skb);
4659 return -EINVAL;
4660}
4661
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304662static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4663 struct wireless_dev *wdev,
4664 const void *data,
4665 int data_len)
4666{
4667 int ret = 0;
4668
4669 vos_ssr_protect(__func__);
4670 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4671 vos_ssr_unprotect(__func__);
4672
4673 return ret;
4674}
4675
Atul Mittal115287b2014-07-08 13:26:33 +05304676static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac,
4677 tANI_S32 state,
4678 tANI_S32 reason,
4679 void *ctx)
4680{
4681 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304682 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304683 tANI_S32 global_operating_class = 0;
4684 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304685 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304686
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304687 ENTER();
4688
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304689 if (!pAdapter) {
4690 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4691 return -EINVAL;
4692 }
4693
4694 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304695 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304696 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304697 return -EINVAL;
4698 }
4699
4700 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304701 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304702 return -ENOTSUPP;
4703 }
4704 skb = cfg80211_vendor_event_alloc(
4705 pHddCtx->wiphy,
4706 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4707 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4708 GFP_KERNEL);
4709
4710 if (!skb) {
4711 hddLog(VOS_TRACE_LEVEL_ERROR,
4712 FL("cfg80211_vendor_event_alloc failed"));
4713 return -EINVAL;
4714 }
4715 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304716 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4717 reason,
4718 state,
4719 global_operating_class,
4720 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304721 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4722 MAC_ADDR_ARRAY(mac));
4723
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304724 if (nla_put(skb,
4725 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4726 VOS_MAC_ADDR_SIZE, mac) ||
4727 nla_put_s32(skb,
4728 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4729 state) ||
4730 nla_put_s32(skb,
4731 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4732 reason) ||
4733 nla_put_s32(skb,
4734 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4735 channel) ||
4736 nla_put_s32(skb,
4737 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4738 global_operating_class)
4739 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304740 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4741 goto nla_put_failure;
4742 }
4743
4744 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304745 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304746 return (0);
4747
4748nla_put_failure:
4749 kfree_skb(skb);
4750 return -EINVAL;
4751}
4752
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304753static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304754 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304755 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304756 int data_len)
4757{
4758 u8 peer[6] = {0};
4759 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304760 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4761 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4762 eHalStatus status;
4763 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304764 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304765 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304766
4767 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304768
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304769 if (!dev) {
4770 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4771 return -EINVAL;
4772 }
4773
4774 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4775 if (!pAdapter) {
4776 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4777 return -EINVAL;
4778 }
4779
Atul Mittal115287b2014-07-08 13:26:33 +05304780 status = wlan_hdd_validate_context(pHddCtx);
4781 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304782 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304783 return -EINVAL;
4784 }
4785 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304786 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304787 return -ENOTSUPP;
4788 }
4789 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4790 data, data_len,
4791 wlan_hdd_tdls_config_enable_policy)) {
4792 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4793 return -EINVAL;
4794 }
4795
4796 /* Parse and fetch mac address */
4797 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4798 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4799 return -EINVAL;
4800 }
4801
4802 memcpy(peer, nla_data(
4803 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4804 sizeof(peer));
4805 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4806
4807 /* Parse and fetch channel */
4808 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4809 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4810 return -EINVAL;
4811 }
4812 pReqMsg.channel = nla_get_s32(
4813 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4814 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4815
4816 /* Parse and fetch global operating class */
4817 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4819 return -EINVAL;
4820 }
4821 pReqMsg.global_operating_class = nla_get_s32(
4822 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4823 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4824 pReqMsg.global_operating_class);
4825
4826 /* Parse and fetch latency ms */
4827 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4828 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4829 return -EINVAL;
4830 }
4831 pReqMsg.max_latency_ms = nla_get_s32(
4832 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4833 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4834 pReqMsg.max_latency_ms);
4835
4836 /* Parse and fetch required bandwidth kbps */
4837 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4838 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4839 return -EINVAL;
4840 }
4841
4842 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4843 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4844 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4845 pReqMsg.min_bandwidth_kbps);
4846
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304847 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304848 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304849 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304850 wlan_hdd_cfg80211_exttdls_callback);
4851
4852 EXIT();
4853 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304854}
4855
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304856static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4857 struct wireless_dev *wdev,
4858 const void *data,
4859 int data_len)
4860{
4861 int ret = 0;
4862
4863 vos_ssr_protect(__func__);
4864 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4865 vos_ssr_unprotect(__func__);
4866
4867 return ret;
4868}
4869
4870static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304871 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304872 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304873 int data_len)
4874{
4875 u8 peer[6] = {0};
4876 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304877 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4878 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4879 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304880 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304881 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304882
4883 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304884
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304885 if (!dev) {
4886 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4887 return -EINVAL;
4888 }
4889
4890 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4891 if (!pAdapter) {
4892 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4893 return -EINVAL;
4894 }
4895
Atul Mittal115287b2014-07-08 13:26:33 +05304896 status = wlan_hdd_validate_context(pHddCtx);
4897 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304898 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304899 return -EINVAL;
4900 }
4901 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304902 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304903 return -ENOTSUPP;
4904 }
4905 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4906 data, data_len,
4907 wlan_hdd_tdls_config_disable_policy)) {
4908 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4909 return -EINVAL;
4910 }
4911 /* Parse and fetch mac address */
4912 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4913 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4914 return -EINVAL;
4915 }
4916
4917 memcpy(peer, nla_data(
4918 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4919 sizeof(peer));
4920 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4921
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304922 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
4923
4924 EXIT();
4925 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304926}
4927
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304928static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4929 struct wireless_dev *wdev,
4930 const void *data,
4931 int data_len)
4932{
4933 int ret = 0;
4934
4935 vos_ssr_protect(__func__);
4936 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
4937 vos_ssr_unprotect(__func__);
4938
4939 return ret;
4940}
4941
Dasari Srinivas7875a302014-09-26 17:50:57 +05304942static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304943__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05304944 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304945 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05304946{
4947 struct net_device *dev = wdev->netdev;
4948 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4949 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4950 struct sk_buff *skb = NULL;
4951 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304952 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05304953
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304954 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304955
4956 ret = wlan_hdd_validate_context(pHddCtx);
4957 if (0 != ret)
4958 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304959 return ret;
4960 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304961 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4962 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4963 fset |= WIFI_FEATURE_INFRA;
4964 }
4965
4966 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4967 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4968 fset |= WIFI_FEATURE_INFRA_5G;
4969 }
4970
4971#ifdef WLAN_FEATURE_P2P
4972 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4973 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4974 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4975 fset |= WIFI_FEATURE_P2P;
4976 }
4977#endif
4978
4979 /* Soft-AP is supported currently by default */
4980 fset |= WIFI_FEATURE_SOFT_AP;
4981
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05304982 /* HOTSPOT is a supplicant feature, enable it by default */
4983 fset |= WIFI_FEATURE_HOTSPOT;
4984
Dasari Srinivas7875a302014-09-26 17:50:57 +05304985#ifdef WLAN_FEATURE_EXTSCAN
4986 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4987 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4988 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4989 fset |= WIFI_FEATURE_EXTSCAN;
4990 }
4991#endif
4992
Dasari Srinivas7875a302014-09-26 17:50:57 +05304993 if (sme_IsFeatureSupportedByFW(NAN)) {
4994 hddLog(LOG1, FL("NAN is supported by firmware"));
4995 fset |= WIFI_FEATURE_NAN;
4996 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304997
4998 /* D2D RTT is not supported currently by default */
4999 if (sme_IsFeatureSupportedByFW(RTT)) {
5000 hddLog(LOG1, FL("RTT is supported by firmware"));
5001 fset |= WIFI_FEATURE_D2AP_RTT;
5002 }
5003
5004#ifdef FEATURE_WLAN_BATCH_SCAN
5005 if (fset & WIFI_FEATURE_EXTSCAN) {
5006 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5007 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5008 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5009 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5010 fset |= WIFI_FEATURE_BATCH_SCAN;
5011 }
5012#endif
5013
5014#ifdef FEATURE_WLAN_SCAN_PNO
5015 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5016 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5017 hddLog(LOG1, FL("PNO is supported by firmware"));
5018 fset |= WIFI_FEATURE_PNO;
5019 }
5020#endif
5021
5022 /* STA+STA is supported currently by default */
5023 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5024
5025#ifdef FEATURE_WLAN_TDLS
5026 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5027 sme_IsFeatureSupportedByFW(TDLS)) {
5028 hddLog(LOG1, FL("TDLS is supported by firmware"));
5029 fset |= WIFI_FEATURE_TDLS;
5030 }
5031
5032 /* TDLS_OFFCHANNEL is not supported currently by default */
5033#endif
5034
5035#ifdef WLAN_AP_STA_CONCURRENCY
5036 /* AP+STA concurrency is supported currently by default */
5037 fset |= WIFI_FEATURE_AP_STA;
5038#endif
5039
5040 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5041 NLMSG_HDRLEN);
5042
5043 if (!skb) {
5044 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5045 return -EINVAL;
5046 }
5047 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5048
5049 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5050 hddLog(LOGE, FL("nla put fail"));
5051 goto nla_put_failure;
5052 }
5053
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305054 ret = cfg80211_vendor_cmd_reply(skb);
5055 EXIT();
5056 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305057
5058nla_put_failure:
5059 kfree_skb(skb);
5060 return -EINVAL;
5061}
5062
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305063static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305064wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5065 struct wireless_dev *wdev,
5066 const void *data, int data_len)
5067{
5068 int ret = 0;
5069
5070 vos_ssr_protect(__func__);
5071 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5072 vos_ssr_unprotect(__func__);
5073
5074 return ret;
5075}
5076
5077static int
5078__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305079 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305080 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305081{
5082 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5083 uint8_t i, feature_sets, max_feature_sets;
5084 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5085 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305086 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5087 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305088
5089 ENTER();
5090
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305091 ret = wlan_hdd_validate_context(pHddCtx);
5092 if (0 != ret)
5093 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305094 return ret;
5095 }
5096
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305097 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5098 data, data_len, NULL)) {
5099 hddLog(LOGE, FL("Invalid ATTR"));
5100 return -EINVAL;
5101 }
5102
5103 /* Parse and fetch max feature set */
5104 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5105 hddLog(LOGE, FL("Attr max feature set size failed"));
5106 return -EINVAL;
5107 }
5108 max_feature_sets = nla_get_u32(
5109 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5110 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5111
5112 /* Fill feature combination matrix */
5113 feature_sets = 0;
5114 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5115 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5116 WIFI_FEATURE_P2P;
5117
5118 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5119 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5120 WIFI_FEATURE_SOFT_AP;
5121
5122 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5123 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5124 WIFI_FEATURE_SOFT_AP;
5125
5126 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5127 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5128 WIFI_FEATURE_SOFT_AP |
5129 WIFI_FEATURE_P2P;
5130
5131 /* Add more feature combinations here */
5132
5133 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5134 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5135 hddLog(LOG1, "Feature set matrix");
5136 for (i = 0; i < feature_sets; i++)
5137 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5138
5139 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5140 sizeof(u32) * feature_sets +
5141 NLMSG_HDRLEN);
5142
5143 if (reply_skb) {
5144 if (nla_put_u32(reply_skb,
5145 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5146 feature_sets) ||
5147 nla_put(reply_skb,
5148 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5149 sizeof(u32) * feature_sets, feature_set_matrix)) {
5150 hddLog(LOGE, FL("nla put fail"));
5151 kfree_skb(reply_skb);
5152 return -EINVAL;
5153 }
5154
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305155 ret = cfg80211_vendor_cmd_reply(reply_skb);
5156 EXIT();
5157 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305158 }
5159 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5160 return -ENOMEM;
5161
5162max_buffer_err:
5163 hddLog(LOGE, FL("Feature set max buffer size reached. feature_sets(%d) max(%d)"),
5164 feature_sets, WLAN_HDD_MAX_FEATURE_SET);
5165 return -EINVAL;
5166}
5167
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305168static int
5169wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5170 struct wireless_dev *wdev,
5171 const void *data, int data_len)
5172{
5173 int ret = 0;
5174
5175 vos_ssr_protect(__func__);
5176 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5177 data_len);
5178 vos_ssr_unprotect(__func__);
5179
5180 return ret;
5181}
5182
Agarwal Ashish738843c2014-09-25 12:27:56 +05305183static const struct nla_policy
5184wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5185 +1] =
5186{
5187 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5188};
5189
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305190static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305191 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305192 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305193 int data_len)
5194{
5195 struct net_device *dev = wdev->netdev;
5196 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5197 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5198 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5199 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5200 eHalStatus status;
5201 u32 dfsFlag = 0;
5202
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305203 ENTER();
5204
Agarwal Ashish738843c2014-09-25 12:27:56 +05305205 status = wlan_hdd_validate_context(pHddCtx);
5206 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305207 return -EINVAL;
5208 }
5209 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5210 data, data_len,
5211 wlan_hdd_set_no_dfs_flag_config_policy)) {
5212 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5213 return -EINVAL;
5214 }
5215
5216 /* Parse and fetch required bandwidth kbps */
5217 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5218 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5219 return -EINVAL;
5220 }
5221
5222 dfsFlag = nla_get_u32(
5223 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5224 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5225 dfsFlag);
5226
5227 pHddCtx->disable_dfs_flag = dfsFlag;
5228
5229 sme_disable_dfs_channel(hHal, dfsFlag);
5230 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305231
5232 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305233 return 0;
5234}
Atul Mittal115287b2014-07-08 13:26:33 +05305235
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305236static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5237 struct wireless_dev *wdev,
5238 const void *data,
5239 int data_len)
5240{
5241 int ret = 0;
5242
5243 vos_ssr_protect(__func__);
5244 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5245 vos_ssr_unprotect(__func__);
5246
5247 return ret;
5248
5249}
5250
Mukul Sharma2a271632014-10-13 14:59:01 +05305251const struct
5252nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5253{
5254 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5255 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5256};
5257
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305258static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305259 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305260{
5261
5262 u8 bssid[6] = {0};
5263 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5264 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5265 eHalStatus status = eHAL_STATUS_SUCCESS;
5266 v_U32_t isFwrRoamEnabled = FALSE;
5267 int ret;
5268
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305269 ENTER();
5270
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305271 ret = wlan_hdd_validate_context(pHddCtx);
5272 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305273 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305274 }
5275
5276 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5277 data, data_len,
5278 qca_wlan_vendor_attr);
5279 if (ret){
5280 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5281 return -EINVAL;
5282 }
5283
5284 /* Parse and fetch Enable flag */
5285 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5286 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5287 return -EINVAL;
5288 }
5289
5290 isFwrRoamEnabled = nla_get_u32(
5291 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5292
5293 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5294
5295 /* Parse and fetch bssid */
5296 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5297 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5298 return -EINVAL;
5299 }
5300
5301 memcpy(bssid, nla_data(
5302 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5303 sizeof(bssid));
5304 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5305
5306 //Update roaming
5307 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305308 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305309 return status;
5310}
5311
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305312static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5313 struct wireless_dev *wdev, const void *data, int data_len)
5314{
5315 int ret = 0;
5316
5317 vos_ssr_protect(__func__);
5318 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5319 vos_ssr_unprotect(__func__);
5320
5321 return ret;
5322}
5323
Sunil Duttc69bccb2014-05-26 21:30:20 +05305324const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5325{
Mukul Sharma2a271632014-10-13 14:59:01 +05305326 {
5327 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5328 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5329 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5330 WIPHY_VENDOR_CMD_NEED_NETDEV |
5331 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305332 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305333 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305334
5335 {
5336 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5337 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5338 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5339 WIPHY_VENDOR_CMD_NEED_NETDEV |
5340 WIPHY_VENDOR_CMD_NEED_RUNNING,
5341 .doit = wlan_hdd_cfg80211_nan_request
5342 },
5343
Sunil Duttc69bccb2014-05-26 21:30:20 +05305344#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5345 {
5346 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5347 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5348 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5349 WIPHY_VENDOR_CMD_NEED_NETDEV |
5350 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305351 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305352 },
5353
5354 {
5355 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5356 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5357 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5358 WIPHY_VENDOR_CMD_NEED_NETDEV |
5359 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305360 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305361 },
5362
5363 {
5364 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5365 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5366 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5367 WIPHY_VENDOR_CMD_NEED_NETDEV |
5368 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305369 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305370 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305371#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305372#ifdef WLAN_FEATURE_EXTSCAN
5373 {
5374 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5375 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5376 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5377 WIPHY_VENDOR_CMD_NEED_NETDEV |
5378 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305379 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305380 },
5381 {
5382 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5383 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5384 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5385 WIPHY_VENDOR_CMD_NEED_NETDEV |
5386 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305387 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305388 },
5389 {
5390 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5391 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5392 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5393 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305394 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305395 },
5396 {
5397 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5398 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5399 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5400 WIPHY_VENDOR_CMD_NEED_NETDEV |
5401 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305402 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305403 },
5404 {
5405 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5406 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5407 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5408 WIPHY_VENDOR_CMD_NEED_NETDEV |
5409 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305410 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305411 },
5412 {
5413 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5414 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5415 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5416 WIPHY_VENDOR_CMD_NEED_NETDEV |
5417 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305418 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305419 },
5420 {
5421 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5422 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5423 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5424 WIPHY_VENDOR_CMD_NEED_NETDEV |
5425 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305426 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305427 },
5428 {
5429 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5430 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5431 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5432 WIPHY_VENDOR_CMD_NEED_NETDEV |
5433 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305434 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305435 },
5436 {
5437 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5438 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5439 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5440 WIPHY_VENDOR_CMD_NEED_NETDEV |
5441 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305442 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305443 },
5444#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305445/*EXT TDLS*/
5446 {
5447 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5448 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5449 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5450 WIPHY_VENDOR_CMD_NEED_NETDEV |
5451 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305452 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305453 },
5454 {
5455 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5456 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5457 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5458 WIPHY_VENDOR_CMD_NEED_NETDEV |
5459 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305460 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305461 },
5462 {
5463 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5464 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5465 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5466 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305467 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305468 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305469 {
5470 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5471 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5472 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5473 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305474 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305475 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305476 {
5477 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5478 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5479 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5480 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305481 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305482 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305483 {
5484 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5485 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5486 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5487 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305488 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305489 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305490 {
5491 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5492 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5493 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5494 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305495 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305496 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305497};
5498
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005499/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305500static const
5501struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005502{
5503#ifdef FEATURE_WLAN_CH_AVOID
5504 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305505 .vendor_id = QCA_NL80211_VENDOR_ID,
5506 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005507 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305508#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5509#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5510 {
5511 /* Index = 1*/
5512 .vendor_id = QCA_NL80211_VENDOR_ID,
5513 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5514 },
5515 {
5516 /* Index = 2*/
5517 .vendor_id = QCA_NL80211_VENDOR_ID,
5518 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5519 },
5520 {
5521 /* Index = 3*/
5522 .vendor_id = QCA_NL80211_VENDOR_ID,
5523 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5524 },
5525 {
5526 /* Index = 4*/
5527 .vendor_id = QCA_NL80211_VENDOR_ID,
5528 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5529 },
5530 {
5531 /* Index = 5*/
5532 .vendor_id = QCA_NL80211_VENDOR_ID,
5533 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5534 },
5535 {
5536 /* Index = 6*/
5537 .vendor_id = QCA_NL80211_VENDOR_ID,
5538 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5539 },
5540#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305541#ifdef WLAN_FEATURE_EXTSCAN
5542 {
5543 .vendor_id = QCA_NL80211_VENDOR_ID,
5544 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5545 },
5546 {
5547 .vendor_id = QCA_NL80211_VENDOR_ID,
5548 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5549 },
5550 {
5551 .vendor_id = QCA_NL80211_VENDOR_ID,
5552 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5553 },
5554 {
5555 .vendor_id = QCA_NL80211_VENDOR_ID,
5556 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5557 },
5558 {
5559 .vendor_id = QCA_NL80211_VENDOR_ID,
5560 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5561 },
5562 {
5563 .vendor_id = QCA_NL80211_VENDOR_ID,
5564 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5565 },
5566 {
5567 .vendor_id = QCA_NL80211_VENDOR_ID,
5568 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5569 },
5570 {
5571 .vendor_id = QCA_NL80211_VENDOR_ID,
5572 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5573 },
5574 {
5575 .vendor_id = QCA_NL80211_VENDOR_ID,
5576 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5577 },
5578 {
5579 .vendor_id = QCA_NL80211_VENDOR_ID,
5580 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5581 },
5582 {
5583 .vendor_id = QCA_NL80211_VENDOR_ID,
5584 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5585 },
5586 {
5587 .vendor_id = QCA_NL80211_VENDOR_ID,
5588 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5589 },
5590 {
5591 .vendor_id = QCA_NL80211_VENDOR_ID,
5592 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5593 },
5594#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305595/*EXT TDLS*/
5596 {
5597 .vendor_id = QCA_NL80211_VENDOR_ID,
5598 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5599 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305600
5601 {
5602 .vendor_id = QCA_NL80211_VENDOR_ID,
5603 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5604 },
5605
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005606};
5607
Jeff Johnson295189b2012-06-20 16:38:30 -07005608/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305609 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305610 * This function is called by hdd_wlan_startup()
5611 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305612 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305614struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005615{
5616 struct wiphy *wiphy;
5617 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305618 /*
5619 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 */
5621 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5622
5623 if (!wiphy)
5624 {
5625 /* Print error and jump into err label and free the memory */
5626 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5627 return NULL;
5628 }
5629
Sunil Duttc69bccb2014-05-26 21:30:20 +05305630
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 return wiphy;
5632}
5633
5634/*
5635 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305636 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 * private ioctl to change the band value
5638 */
5639int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5640{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305641 int i, j;
5642 eNVChannelEnabledType channelEnabledState;
5643
Jeff Johnsone7245742012-09-05 17:12:55 -07005644 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305645
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305646 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305648
5649 if (NULL == wiphy->bands[i])
5650 {
5651 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5652 __func__, i);
5653 continue;
5654 }
5655
5656 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5657 {
5658 struct ieee80211_supported_band *band = wiphy->bands[i];
5659
5660 channelEnabledState = vos_nv_getChannelEnabledState(
5661 band->channels[j].hw_value);
5662
5663 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5664 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305665 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305666 continue;
5667 }
5668 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5669 {
5670 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5671 continue;
5672 }
5673
5674 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5675 NV_CHANNEL_INVALID == channelEnabledState)
5676 {
5677 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5678 }
5679 else if (NV_CHANNEL_DFS == channelEnabledState)
5680 {
5681 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5682 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5683 }
5684 else
5685 {
5686 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5687 |IEEE80211_CHAN_RADAR);
5688 }
5689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 }
5691 return 0;
5692}
5693/*
5694 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305695 * This function is called by hdd_wlan_startup()
5696 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005697 * This function is used to initialize and register wiphy structure.
5698 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305699int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005700 struct wiphy *wiphy,
5701 hdd_config_t *pCfg
5702 )
5703{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305704 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305705 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5706
Jeff Johnsone7245742012-09-05 17:12:55 -07005707 ENTER();
5708
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 /* Now bind the underlying wlan device with wiphy */
5710 set_wiphy_dev(wiphy, dev);
5711
5712 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005713
Kiet Lam6c583332013-10-14 05:37:09 +05305714#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005715 /* the flag for the other case would be initialzed in
5716 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005717 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305718#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005719
Amar Singhalfddc28c2013-09-05 13:03:40 -07005720 /* This will disable updating of NL channels from passive to
5721 * active if a beacon is received on passive channel. */
5722 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07005723
Amar Singhalfddc28c2013-09-05 13:03:40 -07005724
Amar Singhala49cbc52013-10-08 18:37:44 -07005725
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005726#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005727 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5728 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5729 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005730 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05305731 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005732#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005733
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005734#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005735 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005736#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005737 || pCfg->isFastRoamIniFeatureEnabled
5738#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005739#ifdef FEATURE_WLAN_ESE
5740 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005741#endif
5742 )
5743 {
5744 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5745 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005746#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005747#ifdef FEATURE_WLAN_TDLS
5748 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5749 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5750#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305751#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305752 if (pCfg->configPNOScanSupport)
5753 {
5754 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5755 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5756 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5757 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5758 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305759#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005760
Amar Singhalfddc28c2013-09-05 13:03:40 -07005761#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005762 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5763 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005764 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005765 driver need to determine what to do with both
5766 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005767
5768 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005769#else
5770 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005771#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005772
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305773 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5774
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305775 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005776
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305777 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5778
Jeff Johnson295189b2012-06-20 16:38:30 -07005779 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305780 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -07005782 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5783 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 | BIT(NL80211_IFTYPE_AP);
5785
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305786 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005787 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305788#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5789 if( pCfg->enableMCC )
5790 {
5791 /* Currently, supports up to two channels */
5792 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005793
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305794 if( !pCfg->allowMCCGODiffBI )
5795 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005796
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305797 }
5798 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5799 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005800#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305801 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005802
Jeff Johnson295189b2012-06-20 16:38:30 -07005803 /* Before registering we need to update the ht capabilitied based
5804 * on ini values*/
5805 if( !pCfg->ShortGI20MhzEnable )
5806 {
5807 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5808 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5809 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5810 }
5811
5812 if( !pCfg->ShortGI40MhzEnable )
5813 {
5814 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5815 }
5816
5817 if( !pCfg->nChannelBondingMode5GHz )
5818 {
5819 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5820 }
5821
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305822 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305823 if (true == hdd_is_5g_supported(pHddCtx))
5824 {
5825 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
5826 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305827
5828 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
5829 {
5830
5831 if (NULL == wiphy->bands[i])
5832 {
5833 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5834 __func__, i);
5835 continue;
5836 }
5837
5838 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5839 {
5840 struct ieee80211_supported_band *band = wiphy->bands[i];
5841
5842 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
5843 {
5844 // Enable social channels for P2P
5845 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
5846 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5847 else
5848 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5849 continue;
5850 }
5851 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
5852 {
5853 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5854 continue;
5855 }
5856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 }
5858 /*Initialise the supported cipher suite details*/
5859 wiphy->cipher_suites = hdd_cipher_suites;
5860 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5861
5862 /*signal strength in mBm (100*dBm) */
5863 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
5864
5865#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05305866 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07005867#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005868
Sunil Duttc69bccb2014-05-26 21:30:20 +05305869 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
5870 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005871 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
5872 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
5873
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305874 EXIT();
5875 return 0;
5876}
5877
5878/* In this function we are registering wiphy. */
5879int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
5880{
5881 ENTER();
5882 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 if (0 > wiphy_register(wiphy))
5884 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305885 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
5887 return -EIO;
5888 }
5889
5890 EXIT();
5891 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305892}
Jeff Johnson295189b2012-06-20 16:38:30 -07005893
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305894/* In this function we are updating channel list when,
5895 regulatory domain is FCC and country code is US.
5896 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5897 As per FCC smart phone is not a indoor device.
5898 GO should not opeate on indoor channels */
5899void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5900{
5901 int j;
5902 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5903 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5904 //Default counrtycode from NV at the time of wiphy initialization.
5905 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5906 &defaultCountryCode[0]))
5907 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005908 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305909 }
5910 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5911 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305912 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5913 {
5914 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5915 return;
5916 }
5917 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5918 {
5919 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5920 // Mark UNII -1 band channel as passive
5921 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5922 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5923 }
5924 }
5925}
5926
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305927/* This function registers for all frame which supplicant is interested in */
5928void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005929{
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5931 /* Register for all P2P action, public action etc frames */
5932 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5933
Jeff Johnsone7245742012-09-05 17:12:55 -07005934 ENTER();
5935
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 /* Right now we are registering these frame when driver is getting
5937 initialized. Once we will move to 2.6.37 kernel, in which we have
5938 frame register ops, we will move this code as a part of that */
5939 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305940 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5942
5943 /* GAS Initial Response */
5944 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5945 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305946
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 /* GAS Comeback Request */
5948 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5949 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5950
5951 /* GAS Comeback Response */
5952 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5953 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5954
5955 /* P2P Public Action */
5956 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305957 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 P2P_PUBLIC_ACTION_FRAME_SIZE );
5959
5960 /* P2P Action */
5961 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5962 (v_U8_t*)P2P_ACTION_FRAME,
5963 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07005964
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05305965 /* WNM BSS Transition Request frame */
5966 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5967 (v_U8_t*)WNM_BSS_ACTION_FRAME,
5968 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005969
5970 /* WNM-Notification */
5971 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5972 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5973 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005974}
5975
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305976void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005977{
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5979 /* Register for all P2P action, public action etc frames */
5980 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5981
Jeff Johnsone7245742012-09-05 17:12:55 -07005982 ENTER();
5983
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 /* Right now we are registering these frame when driver is getting
5985 initialized. Once we will move to 2.6.37 kernel, in which we have
5986 frame register ops, we will move this code as a part of that */
5987 /* GAS Initial Request */
5988
5989 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5990 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5991
5992 /* GAS Initial Response */
5993 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5994 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305995
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 /* GAS Comeback Request */
5997 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5998 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5999
6000 /* GAS Comeback Response */
6001 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6002 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6003
6004 /* P2P Public Action */
6005 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306006 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006007 P2P_PUBLIC_ACTION_FRAME_SIZE );
6008
6009 /* P2P Action */
6010 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6011 (v_U8_t*)P2P_ACTION_FRAME,
6012 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006013 /* WNM-Notification */
6014 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6015 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6016 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006017}
6018
6019#ifdef FEATURE_WLAN_WAPI
6020void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
6021 const u8 *mac_addr, u8 *key , int key_Len)
6022{
6023 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6024 tCsrRoamSetKey setKey;
6025 v_BOOL_t isConnected = TRUE;
6026 int status = 0;
6027 v_U32_t roamId= 0xFF;
6028 tANI_U8 *pKeyPtr = NULL;
6029 int n = 0;
6030
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306031 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6032 __func__, hdd_device_modetoString(pAdapter->device_mode),
6033 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006034
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306035 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 setKey.keyId = key_index; // Store Key ID
6037 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6038 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6039 setKey.paeRole = 0 ; // the PAE role
6040 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6041 {
6042 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6043 }
6044 else
6045 {
6046 isConnected = hdd_connIsConnected(pHddStaCtx);
6047 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6048 }
6049 setKey.keyLength = key_Len;
6050 pKeyPtr = setKey.Key;
6051 memcpy( pKeyPtr, key, key_Len);
6052
Arif Hussain6d2a3322013-11-17 19:50:10 -08006053 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 __func__, key_Len);
6055 for (n = 0 ; n < key_Len; n++)
6056 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6057 __func__,n,setKey.Key[n]);
6058
6059 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6060 if ( isConnected )
6061 {
6062 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6063 pAdapter->sessionId, &setKey, &roamId );
6064 }
6065 if ( status != 0 )
6066 {
6067 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6068 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6069 __LINE__, status );
6070 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6071 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306072 /* Need to clear any trace of key value in the memory.
6073 * Thus zero out the memory even though it is local
6074 * variable.
6075 */
6076 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006077}
6078#endif /* FEATURE_WLAN_WAPI*/
6079
6080#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306081int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 beacon_data_t **ppBeacon,
6083 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006084#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306085int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006086 beacon_data_t **ppBeacon,
6087 struct cfg80211_beacon_data *params,
6088 int dtim_period)
6089#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306090{
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 int size;
6092 beacon_data_t *beacon = NULL;
6093 beacon_data_t *old = NULL;
6094 int head_len,tail_len;
6095
Jeff Johnsone7245742012-09-05 17:12:55 -07006096 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306098 {
6099 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6100 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006103
6104 old = pAdapter->sessionCtx.ap.beacon;
6105
6106 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306107 {
6108 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6109 FL("session(%d) old and new heads points to NULL"),
6110 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306112 }
6113
6114 if (params->tail && !params->tail_len)
6115 {
6116 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6117 FL("tail_len is zero but tail is not NULL"));
6118 return -EINVAL;
6119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006120
Jeff Johnson295189b2012-06-20 16:38:30 -07006121#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6122 /* Kernel 3.0 is not updating dtim_period for set beacon */
6123 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306124 {
6125 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6126 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006129#endif
6130
6131 if(params->head)
6132 head_len = params->head_len;
6133 else
6134 head_len = old->head_len;
6135
6136 if(params->tail || !old)
6137 tail_len = params->tail_len;
6138 else
6139 tail_len = old->tail_len;
6140
6141 size = sizeof(beacon_data_t) + head_len + tail_len;
6142
6143 beacon = kzalloc(size, GFP_KERNEL);
6144
6145 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306146 {
6147 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6148 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306150 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006151
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006152#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 if(params->dtim_period || !old )
6154 beacon->dtim_period = params->dtim_period;
6155 else
6156 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006157#else
6158 if(dtim_period || !old )
6159 beacon->dtim_period = dtim_period;
6160 else
6161 beacon->dtim_period = old->dtim_period;
6162#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306163
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6165 beacon->tail = beacon->head + head_len;
6166 beacon->head_len = head_len;
6167 beacon->tail_len = tail_len;
6168
6169 if(params->head) {
6170 memcpy (beacon->head,params->head,beacon->head_len);
6171 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306172 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 if(old)
6174 memcpy (beacon->head,old->head,beacon->head_len);
6175 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306176
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 if(params->tail) {
6178 memcpy (beacon->tail,params->tail,beacon->tail_len);
6179 }
6180 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306181 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006182 memcpy (beacon->tail,old->tail,beacon->tail_len);
6183 }
6184
6185 *ppBeacon = beacon;
6186
6187 kfree(old);
6188
6189 return 0;
6190
6191}
Jeff Johnson295189b2012-06-20 16:38:30 -07006192
6193v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
6194{
6195 int left = length;
6196 v_U8_t *ptr = pIes;
6197 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306198
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306200 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 elem_id = ptr[0];
6202 elem_len = ptr[1];
6203 left -= 2;
6204 if(elem_len > left)
6205 {
6206 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006207 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006208 eid,elem_len,left);
6209 return NULL;
6210 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306211 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 {
6213 return ptr;
6214 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306215
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 left -= elem_len;
6217 ptr += (elem_len + 2);
6218 }
6219 return NULL;
6220}
6221
Jeff Johnson295189b2012-06-20 16:38:30 -07006222/* Check if rate is 11g rate or not */
6223static int wlan_hdd_rate_is_11g(u8 rate)
6224{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006225 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006226 u8 i;
6227 for (i = 0; i < 8; i++)
6228 {
6229 if(rate == gRateArray[i])
6230 return TRUE;
6231 }
6232 return FALSE;
6233}
6234
6235/* Check for 11g rate and set proper 11g only mode */
6236static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6237 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6238{
6239 u8 i, num_rates = pIe[0];
6240
6241 pIe += 1;
6242 for ( i = 0; i < num_rates; i++)
6243 {
6244 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6245 {
6246 /* If rate set have 11g rate than change the mode to 11G */
6247 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6248 if (pIe[i] & BASIC_RATE_MASK)
6249 {
6250 /* If we have 11g rate as basic rate, it means mode
6251 is 11g only mode.
6252 */
6253 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6254 *pCheckRatesfor11g = FALSE;
6255 }
6256 }
6257 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6258 {
6259 *require_ht = TRUE;
6260 }
6261 }
6262 return;
6263}
6264
6265static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6266{
6267 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6268 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6269 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6270 u8 checkRatesfor11g = TRUE;
6271 u8 require_ht = FALSE;
6272 u8 *pIe=NULL;
6273
6274 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6275
6276 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6277 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6278 if (pIe != NULL)
6279 {
6280 pIe += 1;
6281 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6282 &pConfig->SapHw_mode);
6283 }
6284
6285 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6286 WLAN_EID_EXT_SUPP_RATES);
6287 if (pIe != NULL)
6288 {
6289
6290 pIe += 1;
6291 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6292 &pConfig->SapHw_mode);
6293 }
6294
6295 if( pConfig->channel > 14 )
6296 {
6297 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6298 }
6299
6300 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6301 WLAN_EID_HT_CAPABILITY);
6302
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306303 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006304 {
6305 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6306 if(require_ht)
6307 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6308 }
6309}
6310
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306311static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6312 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6313{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006314 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306315 v_U8_t *pIe = NULL;
6316 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6317
6318 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6319 pBeacon->tail, pBeacon->tail_len);
6320
6321 if (pIe)
6322 {
6323 ielen = pIe[1] + 2;
6324 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6325 {
6326 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6327 }
6328 else
6329 {
6330 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6331 return -EINVAL;
6332 }
6333 *total_ielen += ielen;
6334 }
6335 return 0;
6336}
6337
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006338static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6339 v_U8_t *genie, v_U8_t *total_ielen)
6340{
6341 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6342 int left = pBeacon->tail_len;
6343 v_U8_t *ptr = pBeacon->tail;
6344 v_U8_t elem_id, elem_len;
6345 v_U16_t ielen = 0;
6346
6347 if ( NULL == ptr || 0 == left )
6348 return;
6349
6350 while (left >= 2)
6351 {
6352 elem_id = ptr[0];
6353 elem_len = ptr[1];
6354 left -= 2;
6355 if (elem_len > left)
6356 {
6357 hddLog( VOS_TRACE_LEVEL_ERROR,
6358 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6359 elem_id, elem_len, left);
6360 return;
6361 }
6362 if (IE_EID_VENDOR == elem_id)
6363 {
6364 /* skipping the VSIE's which we don't want to include or
6365 * it will be included by existing code
6366 */
6367 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6368#ifdef WLAN_FEATURE_WFD
6369 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6370#endif
6371 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6372 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6373 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6374 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6375 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6376 {
6377 ielen = ptr[1] + 2;
6378 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6379 {
6380 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6381 *total_ielen += ielen;
6382 }
6383 else
6384 {
6385 hddLog( VOS_TRACE_LEVEL_ERROR,
6386 "IE Length is too big "
6387 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6388 elem_id, elem_len, *total_ielen);
6389 }
6390 }
6391 }
6392
6393 left -= elem_len;
6394 ptr += (elem_len + 2);
6395 }
6396 return;
6397}
6398
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006399#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006400static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6401 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006402#else
6403static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6404 struct cfg80211_beacon_data *params)
6405#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006406{
6407 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306408 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006410 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006411
6412 genie = vos_mem_malloc(MAX_GENIE_LEN);
6413
6414 if(genie == NULL) {
6415
6416 return -ENOMEM;
6417 }
6418
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306419 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6420 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306422 hddLog(LOGE,
6423 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306424 ret = -EINVAL;
6425 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006426 }
6427
6428#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306429 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6430 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6431 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306432 hddLog(LOGE,
6433 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306434 ret = -EINVAL;
6435 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006436 }
6437#endif
6438
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306439 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6440 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306442 hddLog(LOGE,
6443 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306444 ret = -EINVAL;
6445 goto done;
6446 }
6447
6448 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6449 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006450 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006452
6453 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6454 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6455 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6456 {
6457 hddLog(LOGE,
6458 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006459 ret = -EINVAL;
6460 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006461 }
6462
6463 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6464 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6465 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6466 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6467 ==eHAL_STATUS_FAILURE)
6468 {
6469 hddLog(LOGE,
6470 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006471 ret = -EINVAL;
6472 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006473 }
6474
6475 // Added for ProResp IE
6476 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6477 {
6478 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6479 u8 probe_rsp_ie_len[3] = {0};
6480 u8 counter = 0;
6481 /* Check Probe Resp Length if it is greater then 255 then Store
6482 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6483 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6484 Store More then 255 bytes into One Variable.
6485 */
6486 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6487 {
6488 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6489 {
6490 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6491 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6492 }
6493 else
6494 {
6495 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6496 rem_probe_resp_ie_len = 0;
6497 }
6498 }
6499
6500 rem_probe_resp_ie_len = 0;
6501
6502 if (probe_rsp_ie_len[0] > 0)
6503 {
6504 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6505 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6506 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6507 probe_rsp_ie_len[0], NULL,
6508 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6509 {
6510 hddLog(LOGE,
6511 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006512 ret = -EINVAL;
6513 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 }
6515 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6516 }
6517
6518 if (probe_rsp_ie_len[1] > 0)
6519 {
6520 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6521 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6522 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6523 probe_rsp_ie_len[1], NULL,
6524 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6525 {
6526 hddLog(LOGE,
6527 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006528 ret = -EINVAL;
6529 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006530 }
6531 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6532 }
6533
6534 if (probe_rsp_ie_len[2] > 0)
6535 {
6536 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6537 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6538 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6539 probe_rsp_ie_len[2], NULL,
6540 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6541 {
6542 hddLog(LOGE,
6543 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006544 ret = -EINVAL;
6545 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006546 }
6547 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6548 }
6549
6550 if (probe_rsp_ie_len[1] == 0 )
6551 {
6552 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6553 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6554 eANI_BOOLEAN_FALSE) )
6555 {
6556 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006557 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006558 }
6559 }
6560
6561 if (probe_rsp_ie_len[2] == 0 )
6562 {
6563 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6564 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6565 eANI_BOOLEAN_FALSE) )
6566 {
6567 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006568 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006569 }
6570 }
6571
6572 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6573 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6574 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6575 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6576 == eHAL_STATUS_FAILURE)
6577 {
6578 hddLog(LOGE,
6579 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006580 ret = -EINVAL;
6581 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006582 }
6583 }
6584 else
6585 {
6586 // Reset WNI_CFG_PROBE_RSP Flags
6587 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6588
6589 hddLog(VOS_TRACE_LEVEL_INFO,
6590 "%s: No Probe Response IE received in set beacon",
6591 __func__);
6592 }
6593
6594 // Added for AssocResp IE
6595 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6596 {
6597 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6598 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6599 params->assocresp_ies_len, NULL,
6600 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6601 {
6602 hddLog(LOGE,
6603 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006604 ret = -EINVAL;
6605 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 }
6607
6608 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6609 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6610 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6611 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6612 == eHAL_STATUS_FAILURE)
6613 {
6614 hddLog(LOGE,
6615 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006616 ret = -EINVAL;
6617 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 }
6619 }
6620 else
6621 {
6622 hddLog(VOS_TRACE_LEVEL_INFO,
6623 "%s: No Assoc Response IE received in set beacon",
6624 __func__);
6625
6626 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6627 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6628 eANI_BOOLEAN_FALSE) )
6629 {
6630 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006631 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 }
6633 }
6634
Jeff Johnsone7245742012-09-05 17:12:55 -07006635done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306637 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006638}
Jeff Johnson295189b2012-06-20 16:38:30 -07006639
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306640/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 * FUNCTION: wlan_hdd_validate_operation_channel
6642 * called by wlan_hdd_cfg80211_start_bss() and
6643 * wlan_hdd_cfg80211_set_channel()
6644 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306645 * channel list.
6646 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006647VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006648{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306649
Jeff Johnson295189b2012-06-20 16:38:30 -07006650 v_U32_t num_ch = 0;
6651 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6652 u32 indx = 0;
6653 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306654 v_U8_t fValidChannel = FALSE, count = 0;
6655 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306656
Jeff Johnson295189b2012-06-20 16:38:30 -07006657 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6658
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306659 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306661 /* Validate the channel */
6662 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306664 if ( channel == rfChannels[count].channelNum )
6665 {
6666 fValidChannel = TRUE;
6667 break;
6668 }
6669 }
6670 if (fValidChannel != TRUE)
6671 {
6672 hddLog(VOS_TRACE_LEVEL_ERROR,
6673 "%s: Invalid Channel [%d]", __func__, channel);
6674 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 }
6676 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306677 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006678 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306679 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6680 valid_ch, &num_ch))
6681 {
6682 hddLog(VOS_TRACE_LEVEL_ERROR,
6683 "%s: failed to get valid channel list", __func__);
6684 return VOS_STATUS_E_FAILURE;
6685 }
6686 for (indx = 0; indx < num_ch; indx++)
6687 {
6688 if (channel == valid_ch[indx])
6689 {
6690 break;
6691 }
6692 }
6693
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306694 if (indx >= num_ch)
6695 {
6696 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6697 {
6698 eCsrBand band;
6699 unsigned int freq;
6700
6701 sme_GetFreqBand(hHal, &band);
6702
6703 if (eCSR_BAND_5G == band)
6704 {
6705#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6706 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6707 {
6708 freq = ieee80211_channel_to_frequency(channel,
6709 IEEE80211_BAND_2GHZ);
6710 }
6711 else
6712 {
6713 freq = ieee80211_channel_to_frequency(channel,
6714 IEEE80211_BAND_5GHZ);
6715 }
6716#else
6717 freq = ieee80211_channel_to_frequency(channel);
6718#endif
6719 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6720 return VOS_STATUS_SUCCESS;
6721 }
6722 }
6723
6724 hddLog(VOS_TRACE_LEVEL_ERROR,
6725 "%s: Invalid Channel [%d]", __func__, channel);
6726 return VOS_STATUS_E_FAILURE;
6727 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006728 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306729
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306731
Jeff Johnson295189b2012-06-20 16:38:30 -07006732}
6733
Viral Modi3a32cc52013-02-08 11:14:52 -08006734/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306735 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006736 * This function is used to set the channel number
6737 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306738static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006739 struct ieee80211_channel *chan,
6740 enum nl80211_channel_type channel_type
6741 )
6742{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306743 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006744 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006745 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006746 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306747 hdd_context_t *pHddCtx;
6748 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006749
6750 ENTER();
6751
6752 if( NULL == dev )
6753 {
6754 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006755 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006756 return -ENODEV;
6757 }
6758 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306759
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306760 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6761 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6762 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006763 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306764 "%s: device_mode = %s (%d) freq = %d", __func__,
6765 hdd_device_modetoString(pAdapter->device_mode),
6766 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306767
6768 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6769 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306770 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006771 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306772 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006773 }
6774
6775 /*
6776 * Do freq to chan conversion
6777 * TODO: for 11a
6778 */
6779
6780 channel = ieee80211_frequency_to_channel(freq);
6781
6782 /* Check freq range */
6783 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6784 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6785 {
6786 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006787 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006788 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6789 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6790 return -EINVAL;
6791 }
6792
6793 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6794
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306795 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6796 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006797 {
6798 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6799 {
6800 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006801 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006802 return -EINVAL;
6803 }
6804 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6805 "%s: set channel to [%d] for device mode =%d",
6806 __func__, channel,pAdapter->device_mode);
6807 }
6808 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006809 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08006810 )
6811 {
6812 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6813 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
6814 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6815
6816 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
6817 {
6818 /* Link is up then return cant set channel*/
6819 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006820 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006821 return -EINVAL;
6822 }
6823
6824 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
6825 pHddStaCtx->conn_info.operationChannel = channel;
6826 pRoamProfile->ChannelInfo.ChannelList =
6827 &pHddStaCtx->conn_info.operationChannel;
6828 }
6829 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08006830 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08006831 )
6832 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306833 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6834 {
6835 if(VOS_STATUS_SUCCESS !=
6836 wlan_hdd_validate_operation_channel(pAdapter,channel))
6837 {
6838 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006839 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306840 return -EINVAL;
6841 }
6842 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6843 }
6844 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08006845 {
6846 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
6847
6848 /* If auto channel selection is configured as enable/ 1 then ignore
6849 channel set by supplicant
6850 */
6851 if ( cfg_param->apAutoChannelSelection )
6852 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306853 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6854 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006855 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306856 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6857 __func__, hdd_device_modetoString(pAdapter->device_mode),
6858 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08006859 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306860 else
6861 {
6862 if(VOS_STATUS_SUCCESS !=
6863 wlan_hdd_validate_operation_channel(pAdapter,channel))
6864 {
6865 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006866 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306867 return -EINVAL;
6868 }
6869 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6870 }
Viral Modi3a32cc52013-02-08 11:14:52 -08006871 }
6872 }
6873 else
6874 {
6875 hddLog(VOS_TRACE_LEVEL_FATAL,
6876 "%s: Invalid device mode failed to set valid channel", __func__);
6877 return -EINVAL;
6878 }
6879 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306880 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006881}
6882
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306883static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
6884 struct net_device *dev,
6885 struct ieee80211_channel *chan,
6886 enum nl80211_channel_type channel_type
6887 )
6888{
6889 int ret;
6890
6891 vos_ssr_protect(__func__);
6892 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
6893 vos_ssr_unprotect(__func__);
6894
6895 return ret;
6896}
6897
Jeff Johnson295189b2012-06-20 16:38:30 -07006898#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6899static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6900 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006901#else
6902static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6903 struct cfg80211_beacon_data *params,
6904 const u8 *ssid, size_t ssid_len,
6905 enum nl80211_hidden_ssid hidden_ssid)
6906#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006907{
6908 tsap_Config_t *pConfig;
6909 beacon_data_t *pBeacon = NULL;
6910 struct ieee80211_mgmt *pMgmt_frame;
6911 v_U8_t *pIe=NULL;
6912 v_U16_t capab_info;
6913 eCsrAuthType RSNAuthType;
6914 eCsrEncryptionType RSNEncryptType;
6915 eCsrEncryptionType mcRSNEncryptType;
6916 int status = VOS_STATUS_SUCCESS;
6917 tpWLAN_SAPEventCB pSapEventCallback;
6918 hdd_hostapd_state_t *pHostapdState;
6919 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6920 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306921 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306923 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006925 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306926 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006927 v_BOOL_t MFPCapable = VOS_FALSE;
6928 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05306929 v_BOOL_t sapEnable11AC =
6930 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07006931 ENTER();
6932
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306933 iniConfig = pHddCtx->cfg_ini;
6934
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
6936
6937 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6938
6939 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6940
6941 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6942
6943 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
6944
6945 //channel is already set in the set_channel Call back
6946 //pConfig->channel = pCommitConfig->channel;
6947
6948 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306949 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07006950 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
6951
6952 pConfig->dtim_period = pBeacon->dtim_period;
6953
Arif Hussain6d2a3322013-11-17 19:50:10 -08006954 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07006955 pConfig->dtim_period);
6956
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08006957 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07006958 {
6959 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006960 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05306961 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
6962 {
6963 tANI_BOOLEAN restartNeeded;
6964 pConfig->ieee80211d = 1;
6965 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
6966 sme_setRegInfo(hHal, pConfig->countryCode);
6967 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
6968 }
6969 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006970 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07006971 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006972 pConfig->ieee80211d = 1;
6973 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
6974 sme_setRegInfo(hHal, pConfig->countryCode);
6975 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07006976 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006977 else
6978 {
6979 pConfig->ieee80211d = 0;
6980 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306981 /*
6982 * If auto channel is configured i.e. channel is 0,
6983 * so skip channel validation.
6984 */
6985 if( AUTO_CHANNEL_SELECT != pConfig->channel )
6986 {
6987 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
6988 {
6989 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006990 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306991 return -EINVAL;
6992 }
6993 }
6994 else
6995 {
6996 if(1 != pHddCtx->is_dynamic_channel_range_set)
6997 {
6998 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
6999 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7000 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7001 }
7002 pHddCtx->is_dynamic_channel_range_set = 0;
7003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007004 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007005 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007006 {
7007 pConfig->ieee80211d = 0;
7008 }
7009 pConfig->authType = eSAP_AUTO_SWITCH;
7010
7011 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307012
7013 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007014 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7015
7016 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7017
7018 /*Set wps station to configured*/
7019 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7020
7021 if(pIe)
7022 {
7023 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7024 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007025 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007026 return -EINVAL;
7027 }
7028 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7029 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007030 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007031 /* Check 15 bit of WPS IE as it contain information for wps state
7032 * WPS state
7033 */
7034 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7035 {
7036 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7037 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7038 {
7039 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7040 }
7041 }
7042 }
7043 else
7044 {
7045 pConfig->wps_state = SAP_WPS_DISABLED;
7046 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307047 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007048
c_hpothufe599e92014-06-16 11:38:55 +05307049 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7050 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7051 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7052 eCSR_ENCRYPT_TYPE_NONE;
7053
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 pConfig->RSNWPAReqIELength = 0;
7055 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307056 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007057 WLAN_EID_RSN);
7058 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307059 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7061 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7062 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307063 /* The actual processing may eventually be more extensive than
7064 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 * by the app.
7066 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307067 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007068 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7069 &RSNEncryptType,
7070 &mcRSNEncryptType,
7071 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007072 &MFPCapable,
7073 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007074 pConfig->pRSNWPAReqIE[1]+2,
7075 pConfig->pRSNWPAReqIE );
7076
7077 if( VOS_STATUS_SUCCESS == status )
7078 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307079 /* Now copy over all the security attributes you have
7080 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007081 * */
7082 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7083 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7084 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7085 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307086 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007087 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007088 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7089 }
7090 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307091
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7093 pBeacon->tail, pBeacon->tail_len);
7094
7095 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7096 {
7097 if (pConfig->pRSNWPAReqIE)
7098 {
7099 /*Mixed mode WPA/WPA2*/
7100 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7101 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7102 }
7103 else
7104 {
7105 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7106 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7107 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307108 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007109 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7110 &RSNEncryptType,
7111 &mcRSNEncryptType,
7112 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007113 &MFPCapable,
7114 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 pConfig->pRSNWPAReqIE[1]+2,
7116 pConfig->pRSNWPAReqIE );
7117
7118 if( VOS_STATUS_SUCCESS == status )
7119 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307120 /* Now copy over all the security attributes you have
7121 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007122 * */
7123 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7124 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7125 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7126 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307127 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007128 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007129 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7130 }
7131 }
7132 }
7133
Jeff Johnson4416a782013-03-25 14:17:50 -07007134 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7135 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7136 return -EINVAL;
7137 }
7138
Jeff Johnson295189b2012-06-20 16:38:30 -07007139 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7140
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007141#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 if (params->ssid != NULL)
7143 {
7144 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7145 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7146 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7147 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7148 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007149#else
7150 if (ssid != NULL)
7151 {
7152 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7153 pConfig->SSIDinfo.ssid.length = ssid_len;
7154 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7155 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7156 }
7157#endif
7158
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307159 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007160 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307161
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 /* default value */
7163 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7164 pConfig->num_accept_mac = 0;
7165 pConfig->num_deny_mac = 0;
7166
7167 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7168 pBeacon->tail, pBeacon->tail_len);
7169
7170 /* pIe for black list is following form:
7171 type : 1 byte
7172 length : 1 byte
7173 OUI : 4 bytes
7174 acl type : 1 byte
7175 no of mac addr in black list: 1 byte
7176 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307177 */
7178 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 {
7180 pConfig->SapMacaddr_acl = pIe[6];
7181 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007182 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007183 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307184 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7185 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007186 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7187 for (i = 0; i < pConfig->num_deny_mac; i++)
7188 {
7189 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7190 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307191 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 }
7193 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7194 pBeacon->tail, pBeacon->tail_len);
7195
7196 /* pIe for white list is following form:
7197 type : 1 byte
7198 length : 1 byte
7199 OUI : 4 bytes
7200 acl type : 1 byte
7201 no of mac addr in white list: 1 byte
7202 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307203 */
7204 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007205 {
7206 pConfig->SapMacaddr_acl = pIe[6];
7207 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007208 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307210 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7211 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7213 for (i = 0; i < pConfig->num_accept_mac; i++)
7214 {
7215 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7216 acl_entry++;
7217 }
7218 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307219
Jeff Johnson295189b2012-06-20 16:38:30 -07007220 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7221
Jeff Johnsone7245742012-09-05 17:12:55 -07007222#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007223 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307224 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7225 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307226 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7227 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007228 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7229 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307230 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7231 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007232 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307233 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007234 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307235 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007236
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307237 /* If ACS disable and selected channel <= 14
7238 * OR
7239 * ACS enabled and ACS operating band is choosen as 2.4
7240 * AND
7241 * VHT in 2.4G Disabled
7242 * THEN
7243 * Fallback to 11N mode
7244 */
7245 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7246 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307247 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307248 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007249 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307250 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7251 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007252 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7253 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007254 }
7255#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307256
Jeff Johnson295189b2012-06-20 16:38:30 -07007257 // ht_capab is not what the name conveys,this is used for protection bitmap
7258 pConfig->ht_capab =
7259 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7260
7261 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7262 {
7263 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7264 return -EINVAL;
7265 }
7266
7267 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307268 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007269 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7270 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307271 pConfig->obssProtEnabled =
7272 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007273
Chet Lanctot8cecea22014-02-11 19:09:36 -08007274#ifdef WLAN_FEATURE_11W
7275 pConfig->mfpCapable = MFPCapable;
7276 pConfig->mfpRequired = MFPRequired;
7277 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7278 pConfig->mfpCapable, pConfig->mfpRequired);
7279#endif
7280
Arif Hussain6d2a3322013-11-17 19:50:10 -08007281 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007282 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007283 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7284 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7285 (int)pConfig->channel);
7286 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7287 pConfig->SapHw_mode, pConfig->privacy,
7288 pConfig->authType);
7289 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7290 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7291 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7292 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007293
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307294 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007295 {
7296 //Bss already started. just return.
7297 //TODO Probably it should update some beacon params.
7298 hddLog( LOGE, "Bss Already started...Ignore the request");
7299 EXIT();
7300 return 0;
7301 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307302
Agarwal Ashish51325b52014-06-16 16:50:49 +05307303 if (vos_max_concurrent_connections_reached()) {
7304 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7305 return -EINVAL;
7306 }
7307
Jeff Johnson295189b2012-06-20 16:38:30 -07007308 pConfig->persona = pHostapdAdapter->device_mode;
7309
Peng Xu2446a892014-09-05 17:21:18 +05307310 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7311 if ( NULL != psmeConfig)
7312 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307313 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307314 sme_GetConfigParam(hHal, psmeConfig);
7315 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307316#ifdef WLAN_FEATURE_AP_HT40_24G
7317 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7318 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7319 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7320 {
7321 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7322 sme_UpdateConfig (hHal, psmeConfig);
7323 }
7324#endif
Peng Xu2446a892014-09-05 17:21:18 +05307325 vos_mem_free(psmeConfig);
7326 }
Peng Xuafc34e32014-09-25 13:23:55 +05307327 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307328
Jeff Johnson295189b2012-06-20 16:38:30 -07007329 pSapEventCallback = hdd_hostapd_SAPEventCB;
7330 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7331 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7332 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007333 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 return -EINVAL;
7335 }
7336
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307337 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7339
7340 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307341
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307343 {
7344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007345 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007346 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007347 VOS_ASSERT(0);
7348 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307349
Jeff Johnson295189b2012-06-20 16:38:30 -07007350 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307351 /* Initialize WMM configuation */
7352 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307353 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007354
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007355#ifdef WLAN_FEATURE_P2P_DEBUG
7356 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7357 {
7358 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7359 {
7360 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7361 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007362 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007363 }
7364 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7365 {
7366 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7367 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007368 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007369 }
7370 }
7371#endif
7372
Jeff Johnson295189b2012-06-20 16:38:30 -07007373 pHostapdState->bCommit = TRUE;
7374 EXIT();
7375
7376 return 0;
7377}
7378
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007379#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307380static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307381 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007382 struct beacon_parameters *params)
7383{
7384 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307385 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307386 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007387
7388 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307389
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307390 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7391 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7392 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307393 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7394 hdd_device_modetoString(pAdapter->device_mode),
7395 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007396
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307397 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7398 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307399 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007400 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307401 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007402 }
7403
Agarwal Ashish51325b52014-06-16 16:50:49 +05307404 if (vos_max_concurrent_connections_reached()) {
7405 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7406 return -EINVAL;
7407 }
7408
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307409 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007410 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007411 )
7412 {
7413 beacon_data_t *old,*new;
7414
7415 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307416
Jeff Johnson295189b2012-06-20 16:38:30 -07007417 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307418 {
7419 hddLog(VOS_TRACE_LEVEL_WARN,
7420 FL("already beacon info added to session(%d)"),
7421 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007422 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007424
7425 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7426
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307427 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007428 {
7429 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007430 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007431 return -EINVAL;
7432 }
7433
7434 pAdapter->sessionCtx.ap.beacon = new;
7435
7436 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7437 }
7438
7439 EXIT();
7440 return status;
7441}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307442
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307443static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7444 struct net_device *dev,
7445 struct beacon_parameters *params)
7446{
7447 int ret;
7448
7449 vos_ssr_protect(__func__);
7450 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7451 vos_ssr_unprotect(__func__);
7452
7453 return ret;
7454}
7455
7456static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007457 struct net_device *dev,
7458 struct beacon_parameters *params)
7459{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307460 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307461 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7462 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307463 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007464
7465 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307466
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307467 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7468 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7469 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7470 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7471 __func__, hdd_device_modetoString(pAdapter->device_mode),
7472 pAdapter->device_mode);
7473
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307474 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7475 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307476 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007477 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307478 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007479 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307480
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307481 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307483 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007484 {
7485 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307486
Jeff Johnson295189b2012-06-20 16:38:30 -07007487 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307488
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307490 {
7491 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7492 FL("session(%d) old and new heads points to NULL"),
7493 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007494 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007496
7497 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7498
7499 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307500 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007501 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007502 return -EINVAL;
7503 }
7504
7505 pAdapter->sessionCtx.ap.beacon = new;
7506
7507 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7508 }
7509
7510 EXIT();
7511 return status;
7512}
7513
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307514static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7515 struct net_device *dev,
7516 struct beacon_parameters *params)
7517{
7518 int ret;
7519
7520 vos_ssr_protect(__func__);
7521 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7522 vos_ssr_unprotect(__func__);
7523
7524 return ret;
7525}
7526
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007527#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7528
7529#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307530static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007531 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007532#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307533static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007534 struct net_device *dev)
7535#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007536{
7537 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007538 hdd_context_t *pHddCtx = NULL;
7539 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307540 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307541 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007542
7543 ENTER();
7544
7545 if (NULL == pAdapter)
7546 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307547 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007548 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007549 return -ENODEV;
7550 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007551
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307552 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7553 TRACE_CODE_HDD_CFG80211_STOP_AP,
7554 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307555 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7556 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307557 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007558 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307559 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007560 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007561
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007562 pScanInfo = &pHddCtx->scan_info;
7563
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307564 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7565 __func__, hdd_device_modetoString(pAdapter->device_mode),
7566 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007567
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307568 ret = wlan_hdd_scan_abort(pAdapter);
7569
Girish Gowli4bf7a632014-06-12 13:42:11 +05307570 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007571 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307572 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7573 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307574
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307575 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007576 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7578 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007579
Jeff Johnsone7245742012-09-05 17:12:55 -07007580 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307581 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007582 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307583 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007584 }
7585
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307586 /* Delete all associated STAs before stopping AP/P2P GO */
7587 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307588 hdd_hostapd_stop(dev);
7589
Jeff Johnson295189b2012-06-20 16:38:30 -07007590 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007591 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007592 )
7593 {
7594 beacon_data_t *old;
7595
7596 old = pAdapter->sessionCtx.ap.beacon;
7597
7598 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307599 {
7600 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7601 FL("session(%d) beacon data points to NULL"),
7602 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007605
Jeff Johnson295189b2012-06-20 16:38:30 -07007606 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007607
7608 mutex_lock(&pHddCtx->sap_lock);
7609 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7610 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007611 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 {
7613 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7614
7615 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7616
7617 if (!VOS_IS_STATUS_SUCCESS(status))
7618 {
7619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007620 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007621 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307622 }
7623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007624 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307625 /* BSS stopped, clear the active sessions for this device mode */
7626 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007627 }
7628 mutex_unlock(&pHddCtx->sap_lock);
7629
7630 if(status != VOS_STATUS_SUCCESS)
7631 {
7632 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007633 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 return -EINVAL;
7635 }
7636
Jeff Johnson4416a782013-03-25 14:17:50 -07007637 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7639 ==eHAL_STATUS_FAILURE)
7640 {
7641 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007642 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007643 }
7644
Jeff Johnson4416a782013-03-25 14:17:50 -07007645 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7647 eANI_BOOLEAN_FALSE) )
7648 {
7649 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007650 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007651 }
7652
7653 // Reset WNI_CFG_PROBE_RSP Flags
7654 wlan_hdd_reset_prob_rspies(pAdapter);
7655
7656 pAdapter->sessionCtx.ap.beacon = NULL;
7657 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007658#ifdef WLAN_FEATURE_P2P_DEBUG
7659 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7660 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7661 {
7662 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7663 "GO got removed");
7664 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7665 }
7666#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007667 }
7668 EXIT();
7669 return status;
7670}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007671
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307672#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7673static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7674 struct net_device *dev)
7675{
7676 int ret;
7677
7678 vos_ssr_protect(__func__);
7679 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7680 vos_ssr_unprotect(__func__);
7681
7682 return ret;
7683}
7684#else
7685static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7686 struct net_device *dev)
7687{
7688 int ret;
7689
7690 vos_ssr_protect(__func__);
7691 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7692 vos_ssr_unprotect(__func__);
7693
7694 return ret;
7695}
7696#endif
7697
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007698#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7699
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307700static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307701 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007702 struct cfg80211_ap_settings *params)
7703{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307704 hdd_adapter_t *pAdapter;
7705 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307706 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007707
7708 ENTER();
7709
Girish Gowlib143d7a2015-02-18 19:39:55 +05307710 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007711 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307712 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307713 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307714 return -ENODEV;
7715 }
7716
7717 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7718 if (NULL == pAdapter)
7719 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307720 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307721 "%s: HDD adapter is Null", __func__);
7722 return -ENODEV;
7723 }
7724
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307725 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7726 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7727 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307728 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7729 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307730 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307731 "%s: HDD adapter magic is invalid", __func__);
7732 return -ENODEV;
7733 }
7734
7735 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307736 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307737 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307738 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307739 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307740 }
7741
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307742 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7743 __func__, hdd_device_modetoString(pAdapter->device_mode),
7744 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307745
7746 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007747 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007748 )
7749 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307750 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007751
7752 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307753
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007754 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307755 {
7756 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7757 FL("already beacon info added to session(%d)"),
7758 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007759 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307760 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007761
Girish Gowlib143d7a2015-02-18 19:39:55 +05307762#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7763 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7764 &new,
7765 &params->beacon);
7766#else
7767 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7768 &new,
7769 &params->beacon,
7770 params->dtim_period);
7771#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007772
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307773 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007774 {
7775 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307776 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007777 return -EINVAL;
7778 }
7779 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007780#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007781 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7782#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7783 params->channel, params->channel_type);
7784#else
7785 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7786#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007787#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007788 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
7789 params->ssid_len, params->hidden_ssid);
7790 }
7791
7792 EXIT();
7793 return status;
7794}
7795
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307796static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
7797 struct net_device *dev,
7798 struct cfg80211_ap_settings *params)
7799{
7800 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007801
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307802 vos_ssr_protect(__func__);
7803 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
7804 vos_ssr_unprotect(__func__);
7805
7806 return ret;
7807}
7808
7809static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007810 struct net_device *dev,
7811 struct cfg80211_beacon_data *params)
7812{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307813 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307814 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307815 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007816
7817 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307818
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307819 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7820 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
7821 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007822 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007823 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307824
7825 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7826 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307827 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007828 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307829 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007830 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007831
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307832 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007833 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307834 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007835 {
7836 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307837
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007838 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307839
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007840 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307841 {
7842 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7843 FL("session(%d) beacon data points to NULL"),
7844 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007845 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307846 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007847
7848 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
7849
7850 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307851 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007852 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007853 return -EINVAL;
7854 }
7855
7856 pAdapter->sessionCtx.ap.beacon = new;
7857
7858 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
7859 }
7860
7861 EXIT();
7862 return status;
7863}
7864
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307865static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
7866 struct net_device *dev,
7867 struct cfg80211_beacon_data *params)
7868{
7869 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007870
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307871 vos_ssr_protect(__func__);
7872 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
7873 vos_ssr_unprotect(__func__);
7874
7875 return ret;
7876}
7877
7878#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007879
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307880static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007881 struct net_device *dev,
7882 struct bss_parameters *params)
7883{
7884 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307885 hdd_context_t *pHddCtx;
7886 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007887
7888 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307889
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307890 if (NULL == pAdapter)
7891 {
7892 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7893 "%s: HDD adapter is Null", __func__);
7894 return -ENODEV;
7895 }
7896 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307897 ret = wlan_hdd_validate_context(pHddCtx);
7898 if (0 != ret)
7899 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307900 return ret;
7901 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307902 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7903 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
7904 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307905 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7906 __func__, hdd_device_modetoString(pAdapter->device_mode),
7907 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007908
7909 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007910 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307911 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007912 {
7913 /* ap_isolate == -1 means that in change bss, upper layer doesn't
7914 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307915 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 {
7917 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007919 }
7920
7921 EXIT();
7922 return 0;
7923}
7924
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307925static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
7926 struct net_device *dev,
7927 struct bss_parameters *params)
7928{
7929 int ret;
7930
7931 vos_ssr_protect(__func__);
7932 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
7933 vos_ssr_unprotect(__func__);
7934
7935 return ret;
7936}
Kiet Lam10841362013-11-01 11:36:50 +05307937/* FUNCTION: wlan_hdd_change_country_code_cd
7938* to wait for contry code completion
7939*/
7940void* wlan_hdd_change_country_code_cb(void *pAdapter)
7941{
7942 hdd_adapter_t *call_back_pAdapter = pAdapter;
7943 complete(&call_back_pAdapter->change_country_code);
7944 return NULL;
7945}
7946
Jeff Johnson295189b2012-06-20 16:38:30 -07007947/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307948 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
7950 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307951int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007952 struct net_device *ndev,
7953 enum nl80211_iftype type,
7954 u32 *flags,
7955 struct vif_params *params
7956 )
7957{
7958 struct wireless_dev *wdev;
7959 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007960 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07007961 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 tCsrRoamProfile *pRoamProfile = NULL;
7963 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307964 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007965 eMib_dot11DesiredBssType connectedBssType;
7966 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307967 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007968
7969 ENTER();
7970
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307971 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007972 {
7973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7974 "%s: Adapter context is null", __func__);
7975 return VOS_STATUS_E_FAILURE;
7976 }
7977
7978 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7979 if (!pHddCtx)
7980 {
7981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7982 "%s: HDD context is null", __func__);
7983 return VOS_STATUS_E_FAILURE;
7984 }
7985
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307986 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7987 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
7988 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307989 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307990 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007991 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307992 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 }
7994
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307995 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7996 __func__, hdd_device_modetoString(pAdapter->device_mode),
7997 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007998
Agarwal Ashish51325b52014-06-16 16:50:49 +05307999 if (vos_max_concurrent_connections_reached()) {
8000 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8001 return -EINVAL;
8002 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308003 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008004 wdev = ndev->ieee80211_ptr;
8005
8006#ifdef WLAN_BTAMP_FEATURE
8007 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8008 (NL80211_IFTYPE_ADHOC == type)||
8009 (NL80211_IFTYPE_AP == type)||
8010 (NL80211_IFTYPE_P2P_GO == type))
8011 {
8012 pHddCtx->isAmpAllowed = VOS_FALSE;
8013 // stop AMP traffic
8014 status = WLANBAP_StopAmp();
8015 if(VOS_STATUS_SUCCESS != status )
8016 {
8017 pHddCtx->isAmpAllowed = VOS_TRUE;
8018 hddLog(VOS_TRACE_LEVEL_FATAL,
8019 "%s: Failed to stop AMP", __func__);
8020 return -EINVAL;
8021 }
8022 }
8023#endif //WLAN_BTAMP_FEATURE
8024 /* Reset the current device mode bit mask*/
8025 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8026
8027 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008028 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008029 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008030 )
8031 {
8032 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008033 if (!pWextState)
8034 {
8035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8036 "%s: pWextState is null", __func__);
8037 return VOS_STATUS_E_FAILURE;
8038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008039 pRoamProfile = &pWextState->roamProfile;
8040 LastBSSType = pRoamProfile->BSSType;
8041
8042 switch (type)
8043 {
8044 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008045 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008046 hddLog(VOS_TRACE_LEVEL_INFO,
8047 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8048 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008049#ifdef WLAN_FEATURE_11AC
8050 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8051 {
8052 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8053 }
8054#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308055 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008056 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008057 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008058 //Check for sub-string p2p to confirm its a p2p interface
8059 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308060 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008061 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8062 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8063 }
8064 else
8065 {
8066 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008067 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308070
Jeff Johnson295189b2012-06-20 16:38:30 -07008071 case NL80211_IFTYPE_ADHOC:
8072 hddLog(VOS_TRACE_LEVEL_INFO,
8073 "%s: setting interface Type to ADHOC", __func__);
8074 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8075 pRoamProfile->phyMode =
8076 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008077 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308079 hdd_set_ibss_ops( pAdapter );
8080 hdd_ibss_init_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 break;
8082
8083 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008084 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 {
8086 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8087 "%s: setting interface Type to %s", __func__,
8088 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8089
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008090 //Cancel any remain on channel for GO mode
8091 if (NL80211_IFTYPE_P2P_GO == type)
8092 {
8093 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8094 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008095 if (NL80211_IFTYPE_AP == type)
8096 {
8097 /* As Loading WLAN Driver one interface being created for p2p device
8098 * address. This will take one HW STA and the max number of clients
8099 * that can connect to softAP will be reduced by one. so while changing
8100 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8101 * interface as it is not required in SoftAP mode.
8102 */
8103
8104 // Get P2P Adapter
8105 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8106
8107 if (pP2pAdapter)
8108 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308109 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308110 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008111 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8112 }
8113 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308114 //Disable IMPS & BMPS for SAP/GO
8115 if(VOS_STATUS_E_FAILURE ==
8116 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8117 {
8118 //Fail to Exit BMPS
8119 VOS_ASSERT(0);
8120 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308121
8122 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8123
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308124#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008125
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308126 /* A Mutex Lock is introduced while changing the mode to
8127 * protect the concurrent access for the Adapters by TDLS
8128 * module.
8129 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308130 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308131#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008132 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308133 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008135 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8136 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308137#ifdef FEATURE_WLAN_TDLS
8138 mutex_unlock(&pHddCtx->tdls_lock);
8139#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008140 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8141 (pConfig->apRandomBssidEnabled))
8142 {
8143 /* To meet Android requirements create a randomized
8144 MAC address of the form 02:1A:11:Fx:xx:xx */
8145 get_random_bytes(&ndev->dev_addr[3], 3);
8146 ndev->dev_addr[0] = 0x02;
8147 ndev->dev_addr[1] = 0x1A;
8148 ndev->dev_addr[2] = 0x11;
8149 ndev->dev_addr[3] |= 0xF0;
8150 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8151 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008152 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8153 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008154 }
8155
Jeff Johnson295189b2012-06-20 16:38:30 -07008156 hdd_set_ap_ops( pAdapter->dev );
8157
Kiet Lam10841362013-11-01 11:36:50 +05308158 /* This is for only SAP mode where users can
8159 * control country through ini.
8160 * P2P GO follows station country code
8161 * acquired during the STA scanning. */
8162 if((NL80211_IFTYPE_AP == type) &&
8163 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8164 {
8165 int status = 0;
8166 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8167 "%s: setting country code from INI ", __func__);
8168 init_completion(&pAdapter->change_country_code);
8169 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8170 (void *)(tSmeChangeCountryCallback)
8171 wlan_hdd_change_country_code_cb,
8172 pConfig->apCntryCode, pAdapter,
8173 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308174 eSIR_FALSE,
8175 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308176 if (eHAL_STATUS_SUCCESS == status)
8177 {
8178 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308179 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308180 &pAdapter->change_country_code,
8181 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308182 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308183 {
8184 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308185 FL("SME Timed out while setting country code %ld"),
8186 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008187
8188 if (pHddCtx->isLogpInProgress)
8189 {
8190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8191 "%s: LOGP in Progress. Ignore!!!", __func__);
8192 return -EAGAIN;
8193 }
Kiet Lam10841362013-11-01 11:36:50 +05308194 }
8195 }
8196 else
8197 {
8198 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008199 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308200 return -EINVAL;
8201 }
8202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008203 status = hdd_init_ap_mode(pAdapter);
8204 if(status != VOS_STATUS_SUCCESS)
8205 {
8206 hddLog(VOS_TRACE_LEVEL_FATAL,
8207 "%s: Error initializing the ap mode", __func__);
8208 return -EINVAL;
8209 }
8210 hdd_set_conparam(1);
8211
Jeff Johnson295189b2012-06-20 16:38:30 -07008212 /*interface type changed update in wiphy structure*/
8213 if(wdev)
8214 {
8215 wdev->iftype = type;
8216 pHddCtx->change_iface = type;
8217 }
8218 else
8219 {
8220 hddLog(VOS_TRACE_LEVEL_ERROR,
8221 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8222 return -EINVAL;
8223 }
8224 goto done;
8225 }
8226
8227 default:
8228 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8229 __func__);
8230 return -EOPNOTSUPP;
8231 }
8232 }
8233 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008234 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008235 )
8236 {
8237 switch(type)
8238 {
8239 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008241 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308242
8243 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308244#ifdef FEATURE_WLAN_TDLS
8245
8246 /* A Mutex Lock is introduced while changing the mode to
8247 * protect the concurrent access for the Adapters by TDLS
8248 * module.
8249 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308250 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308251#endif
c_hpothu002231a2015-02-05 14:58:51 +05308252 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008253 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008254 //Check for sub-string p2p to confirm its a p2p interface
8255 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008256 {
8257 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8258 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8259 }
8260 else
8261 {
8262 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008265 hdd_set_conparam(0);
8266 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8268 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308269#ifdef FEATURE_WLAN_TDLS
8270 mutex_unlock(&pHddCtx->tdls_lock);
8271#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308272 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008273 if( VOS_STATUS_SUCCESS != status )
8274 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008275 /* In case of JB, for P2P-GO, only change interface will be called,
8276 * This is the right place to enable back bmps_imps()
8277 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308278 if (pHddCtx->hdd_wlan_suspended)
8279 {
8280 hdd_set_pwrparams(pHddCtx);
8281 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008282 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008283 goto done;
8284 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008285 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008286 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8288 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 goto done;
8290 default:
8291 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8292 __func__);
8293 return -EOPNOTSUPP;
8294
8295 }
8296
8297 }
8298 else
8299 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308300 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8301 __func__, hdd_device_modetoString(pAdapter->device_mode),
8302 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008303 return -EOPNOTSUPP;
8304 }
8305
8306
8307 if(pRoamProfile)
8308 {
8309 if ( LastBSSType != pRoamProfile->BSSType )
8310 {
8311 /*interface type changed update in wiphy structure*/
8312 wdev->iftype = type;
8313
8314 /*the BSS mode changed, We need to issue disconnect
8315 if connected or in IBSS disconnect state*/
8316 if ( hdd_connGetConnectedBssType(
8317 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8318 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8319 {
8320 /*need to issue a disconnect to CSR.*/
8321 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8322 if( eHAL_STATUS_SUCCESS ==
8323 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8324 pAdapter->sessionId,
8325 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8326 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308327 ret = wait_for_completion_interruptible_timeout(
8328 &pAdapter->disconnect_comp_var,
8329 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8330 if (ret <= 0)
8331 {
8332 hddLog(VOS_TRACE_LEVEL_ERROR,
8333 FL("wait on disconnect_comp_var failed %ld"), ret);
8334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008335 }
8336 }
8337 }
8338 }
8339
8340done:
8341 /*set bitmask based on updated value*/
8342 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008343
8344 /* Only STA mode support TM now
8345 * all other mode, TM feature should be disabled */
8346 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8347 (~VOS_STA & pHddCtx->concurrency_mode) )
8348 {
8349 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8350 }
8351
Jeff Johnson295189b2012-06-20 16:38:30 -07008352#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308353 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308354 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008355 {
8356 //we are ok to do AMP
8357 pHddCtx->isAmpAllowed = VOS_TRUE;
8358 }
8359#endif //WLAN_BTAMP_FEATURE
8360 EXIT();
8361 return 0;
8362}
8363
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308364/*
8365 * FUNCTION: wlan_hdd_cfg80211_change_iface
8366 * wrapper function to protect the actual implementation from SSR.
8367 */
8368int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8369 struct net_device *ndev,
8370 enum nl80211_iftype type,
8371 u32 *flags,
8372 struct vif_params *params
8373 )
8374{
8375 int ret;
8376
8377 vos_ssr_protect(__func__);
8378 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8379 vos_ssr_unprotect(__func__);
8380
8381 return ret;
8382}
8383
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008384#ifdef FEATURE_WLAN_TDLS
8385static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
8386 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
8387{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008388 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008389 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308390 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308391 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308392 hdd_adapter_t *pAdapter;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008393
8394 ENTER();
8395
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308396 if (!dev) {
8397 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8398 return -EINVAL;
8399 }
8400
8401 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8402 if (!pAdapter) {
8403 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8404 return -EINVAL;
8405 }
8406
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308407 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008408 {
8409 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8410 "Invalid arguments");
8411 return -EINVAL;
8412 }
Hoonki Lee27511902013-03-14 18:19:06 -07008413
8414 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8415 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8416 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308417 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008418 "%s: TDLS mode is disabled OR not enabled in FW."
8419 MAC_ADDRESS_STR " Request declined.",
8420 __func__, MAC_ADDR_ARRAY(mac));
8421 return -ENOTSUPP;
8422 }
8423
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008424 if (pHddCtx->isLogpInProgress)
8425 {
8426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8427 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308428 wlan_hdd_tdls_set_link_status(pAdapter,
8429 mac,
8430 eTDLS_LINK_IDLE,
8431 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008432 return -EBUSY;
8433 }
8434
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308435 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008436
8437 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308438 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008439 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8440 __func__, MAC_ADDR_ARRAY(mac), update);
8441 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008442 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008443
8444 /* in add station, we accept existing valid staId if there is */
8445 if ((0 == update) &&
8446 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8447 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008448 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308449 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008450 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008451 " link_status %d. staId %d. add station ignored.",
8452 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8453 return 0;
8454 }
8455 /* in change station, we accept only when staId is valid */
8456 if ((1 == update) &&
8457 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8458 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8459 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308460 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008461 "%s: " MAC_ADDRESS_STR
8462 " link status %d. staId %d. change station %s.",
8463 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8464 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8465 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008466 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008467
8468 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308469 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008470 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008471 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8472 "%s: " MAC_ADDRESS_STR
8473 " TDLS setup is ongoing. Request declined.",
8474 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008475 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008476 }
8477
8478 /* first to check if we reached to maximum supported TDLS peer.
8479 TODO: for now, return -EPERM looks working fine,
8480 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308481 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8482 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008483 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008484 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8485 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308486 " TDLS Max peer already connected. Request declined."
8487 " Num of peers (%d), Max allowed (%d).",
8488 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8489 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008490 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008491 }
8492 else
8493 {
8494 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308495 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008496 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008497 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008498 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8499 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8500 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008501 return -EPERM;
8502 }
8503 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008504 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308505 wlan_hdd_tdls_set_link_status(pAdapter,
8506 mac,
8507 eTDLS_LINK_CONNECTING,
8508 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008509
Jeff Johnsond75fe012013-04-06 10:53:06 -07008510 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308511 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008512 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008514 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008515 if(StaParams->htcap_present)
8516 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008518 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008520 "ht_capa->extended_capabilities: %0x",
8521 StaParams->HTCap.extendedHtCapInfo);
8522 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008524 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008526 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008527 if(StaParams->vhtcap_present)
8528 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008530 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8531 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8532 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8533 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008534 {
8535 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008536 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008537 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008539 "[%d]: %x ", i, StaParams->supported_rates[i]);
8540 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008541 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308542 else if ((1 == update) && (NULL == StaParams))
8543 {
8544 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8545 "%s : update is true, but staParams is NULL. Error!", __func__);
8546 return -EPERM;
8547 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008548
8549 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8550
8551 if (!update)
8552 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308553 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008554 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308555 if (ret != eHAL_STATUS_SUCCESS) {
8556 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to add TDLS peer STA"));
8557 return -EPERM;
8558 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008559 }
8560 else
8561 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308562 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008563 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308564 if (ret != eHAL_STATUS_SUCCESS) {
8565 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8566 return -EPERM;
8567 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008568 }
8569
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308570 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008571 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8572
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308573 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008574 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308576 "%s: timeout waiting for tdls add station indication %ld",
8577 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008578 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008579 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308580
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008581 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8582 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008584 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008585 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008586 }
8587
8588 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008589
8590error:
Atul Mittal115287b2014-07-08 13:26:33 +05308591 wlan_hdd_tdls_set_link_status(pAdapter,
8592 mac,
8593 eTDLS_LINK_IDLE,
8594 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008595 return -EPERM;
8596
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008597}
8598#endif
8599
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308600static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008601 struct net_device *dev,
8602 u8 *mac,
8603 struct station_parameters *params)
8604{
8605 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308606 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308607 hdd_context_t *pHddCtx;
8608 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308610 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008611#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008612 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008613 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308614 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008615#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008616
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308617 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308618
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308619 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308620 if ((NULL == pAdapter))
8621 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308623 "invalid adapter ");
8624 return -EINVAL;
8625 }
8626
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308627 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8628 TRACE_CODE_HDD_CHANGE_STATION,
8629 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308630 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308631
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308632 ret = wlan_hdd_validate_context(pHddCtx);
8633 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308634 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308635 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308636 }
8637
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308638 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8639
8640 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008641 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8643 "invalid HDD station context");
8644 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8647
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008648 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8649 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008651 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008652 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308653 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008654 WLANTL_STA_AUTHENTICATED);
8655
Gopichand Nakkala29149562013-05-10 21:43:41 +05308656 if (status != VOS_STATUS_SUCCESS)
8657 {
8658 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8659 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8660 return -EINVAL;
8661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008662 }
8663 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008664 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8665 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308666#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008667 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8668 StaParams.capability = params->capability;
8669 StaParams.uapsd_queues = params->uapsd_queues;
8670 StaParams.max_sp = params->max_sp;
8671
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308672 /* Convert (first channel , number of channels) tuple to
8673 * the total list of channels. This goes with the assumption
8674 * that if the first channel is < 14, then the next channels
8675 * are an incremental of 1 else an incremental of 4 till the number
8676 * of channels.
8677 */
8678 if (0 != params->supported_channels_len) {
8679 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8680 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8681 {
8682 int wifi_chan_index;
8683 StaParams.supported_channels[j] = params->supported_channels[i];
8684 wifi_chan_index =
8685 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8686 no_of_channels = params->supported_channels[i+1];
8687 for(k=1; k <= no_of_channels; k++)
8688 {
8689 StaParams.supported_channels[j+1] =
8690 StaParams.supported_channels[j] + wifi_chan_index;
8691 j+=1;
8692 }
8693 }
8694 StaParams.supported_channels_len = j;
8695 }
8696 vos_mem_copy(StaParams.supported_oper_classes,
8697 params->supported_oper_classes,
8698 params->supported_oper_classes_len);
8699 StaParams.supported_oper_classes_len =
8700 params->supported_oper_classes_len;
8701
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008702 if (0 != params->ext_capab_len)
8703 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8704 sizeof(StaParams.extn_capability));
8705
8706 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008707 {
8708 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008709 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008710 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008711
8712 StaParams.supported_rates_len = params->supported_rates_len;
8713
8714 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8715 * The supported_rates array , for all the structures propogating till Add Sta
8716 * to the firmware has to be modified , if the supplicant (ieee80211) is
8717 * modified to send more rates.
8718 */
8719
8720 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8721 */
8722 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8723 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8724
8725 if (0 != StaParams.supported_rates_len) {
8726 int i = 0;
8727 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8728 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008729 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008730 "Supported Rates with Length %d", StaParams.supported_rates_len);
8731 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008733 "[%d]: %0x", i, StaParams.supported_rates[i]);
8734 }
8735
8736 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008737 {
8738 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008739 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008740 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008741
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008742 if (0 != params->ext_capab_len ) {
8743 /*Define A Macro : TODO Sunil*/
8744 if ((1<<4) & StaParams.extn_capability[3]) {
8745 isBufSta = 1;
8746 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308747 /* TDLS Channel Switching Support */
8748 if ((1<<6) & StaParams.extn_capability[3]) {
8749 isOffChannelSupported = 1;
8750 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008751 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308752 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
8753 &StaParams, isBufSta,
8754 isOffChannelSupported);
8755
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308756 if (VOS_STATUS_SUCCESS != status) {
8757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8758 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
8759 return -EINVAL;
8760 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008761 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
8762
8763 if (VOS_STATUS_SUCCESS != status) {
8764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8765 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
8766 return -EINVAL;
8767 }
8768 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008769#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05308770 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008771 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008772 return status;
8773}
8774
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308775static int wlan_hdd_change_station(struct wiphy *wiphy,
8776 struct net_device *dev,
8777 u8 *mac,
8778 struct station_parameters *params)
8779{
8780 int ret;
8781
8782 vos_ssr_protect(__func__);
8783 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
8784 vos_ssr_unprotect(__func__);
8785
8786 return ret;
8787}
8788
Jeff Johnson295189b2012-06-20 16:38:30 -07008789/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308790 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008791 * This function is used to initialize the key information
8792 */
8793#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308794static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 struct net_device *ndev,
8796 u8 key_index, bool pairwise,
8797 const u8 *mac_addr,
8798 struct key_params *params
8799 )
8800#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308801static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008802 struct net_device *ndev,
8803 u8 key_index, const u8 *mac_addr,
8804 struct key_params *params
8805 )
8806#endif
8807{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008808 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008809 tCsrRoamSetKey setKey;
8810 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308811 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008812 v_U32_t roamId= 0xFF;
8813 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008814 hdd_hostapd_state_t *pHostapdState;
8815 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008816 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308817 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008818
8819 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308820
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308821 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8822 TRACE_CODE_HDD_CFG80211_ADD_KEY,
8823 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308824 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8825 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308826 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008827 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308828 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008829 }
8830
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308831 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8832 __func__, hdd_device_modetoString(pAdapter->device_mode),
8833 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008834
8835 if (CSR_MAX_NUM_KEY <= key_index)
8836 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008837 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008838 key_index);
8839
8840 return -EINVAL;
8841 }
8842
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008843 if (CSR_MAX_KEY_LEN < params->key_len)
8844 {
8845 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
8846 params->key_len);
8847
8848 return -EINVAL;
8849 }
8850
8851 hddLog(VOS_TRACE_LEVEL_INFO,
8852 "%s: called with key index = %d & key length %d",
8853 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008854
8855 /*extract key idx, key len and key*/
8856 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8857 setKey.keyId = key_index;
8858 setKey.keyLength = params->key_len;
8859 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
8860
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008861 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07008862 {
8863 case WLAN_CIPHER_SUITE_WEP40:
8864 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8865 break;
8866
8867 case WLAN_CIPHER_SUITE_WEP104:
8868 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
8869 break;
8870
8871 case WLAN_CIPHER_SUITE_TKIP:
8872 {
8873 u8 *pKey = &setKey.Key[0];
8874 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
8875
8876 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
8877
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008878 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07008879
8880 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008881 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008882 |--------------|----------|----------|
8883 <---16bytes---><--8bytes--><--8bytes-->
8884
8885 */
8886 /*Sme expects the 32 bytes key to be in the below order
8887
8888 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008889 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 |--------------|----------|----------|
8891 <---16bytes---><--8bytes--><--8bytes-->
8892 */
8893 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008894 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07008895
8896 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008897 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008898
8899 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008900 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008901
8902
8903 break;
8904 }
8905
8906 case WLAN_CIPHER_SUITE_CCMP:
8907 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
8908 break;
8909
8910#ifdef FEATURE_WLAN_WAPI
8911 case WLAN_CIPHER_SUITE_SMS4:
8912 {
8913 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8914 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
8915 params->key, params->key_len);
8916 return 0;
8917 }
8918#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008919
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008920#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008921 case WLAN_CIPHER_SUITE_KRK:
8922 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
8923 break;
8924#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008925
8926#ifdef WLAN_FEATURE_11W
8927 case WLAN_CIPHER_SUITE_AES_CMAC:
8928 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07008929 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07008930#endif
8931
Jeff Johnson295189b2012-06-20 16:38:30 -07008932 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008933 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07008934 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308935 status = -EOPNOTSUPP;
8936 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008937 }
8938
8939 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
8940 __func__, setKey.encType);
8941
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008942 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07008943#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8944 (!pairwise)
8945#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008946 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07008947#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008948 )
8949 {
8950 /* set group key*/
8951 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8952 "%s- %d: setting Broadcast key",
8953 __func__, __LINE__);
8954 setKey.keyDirection = eSIR_RX_ONLY;
8955 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
8956 }
8957 else
8958 {
8959 /* set pairwise key*/
8960 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8961 "%s- %d: setting pairwise key",
8962 __func__, __LINE__);
8963 setKey.keyDirection = eSIR_TX_RX;
8964 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
8965 }
8966 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
8967 {
8968 setKey.keyDirection = eSIR_TX_RX;
8969 /*Set the group key*/
8970 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8971 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008972
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008973 if ( 0 != status )
8974 {
8975 hddLog(VOS_TRACE_LEVEL_ERROR,
8976 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308977 status = -EINVAL;
8978 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008979 }
8980 /*Save the keys here and call sme_RoamSetKey for setting
8981 the PTK after peer joins the IBSS network*/
8982 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
8983 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308984 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008985 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05308986 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
8987 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
8988 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008989 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008990 if( pHostapdState->bssState == BSS_START )
8991 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008992 status = WLANSAP_SetKeySta( pVosContext, &setKey);
8993
8994 if ( status != eHAL_STATUS_SUCCESS )
8995 {
8996 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8997 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
8998 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308999 status = -EINVAL;
9000 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009001 }
9002 }
9003
9004 /* Saving WEP keys */
9005 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9006 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9007 {
9008 //Save the wep key in ap context. Issue setkey after the BSS is started.
9009 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9010 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9011 }
9012 else
9013 {
9014 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009015 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009016 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9017 }
9018 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009019 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9020 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009021 {
9022 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9023 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9024
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309025#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9026 if (!pairwise)
9027#else
9028 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9029#endif
9030 {
9031 /* set group key*/
9032 if (pHddStaCtx->roam_info.deferKeyComplete)
9033 {
9034 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9035 "%s- %d: Perform Set key Complete",
9036 __func__, __LINE__);
9037 hdd_PerformRoamSetKeyComplete(pAdapter);
9038 }
9039 }
9040
Jeff Johnson295189b2012-06-20 16:38:30 -07009041 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9042
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009043 pWextState->roamProfile.Keys.defaultIndex = key_index;
9044
9045
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009046 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009047 params->key, params->key_len);
9048
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309049
Jeff Johnson295189b2012-06-20 16:38:30 -07009050 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9051
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309052 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009053 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309054 __func__, setKey.peerMac[0], setKey.peerMac[1],
9055 setKey.peerMac[2], setKey.peerMac[3],
9056 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 setKey.keyDirection);
9058
Nirav Shah4f765af2015-01-21 19:51:30 +05309059 /* Wait for EAPOL M4 before setting key.
9060 * No need to consider Dynamic WEP as we will receive M8.
9061 */
9062 if ( (setKey.encType == eCSR_ENCRYPT_TYPE_AES ||
9063 setKey.encType == eCSR_ENCRYPT_TYPE_TKIP) &&
9064 ( 1
9065#if defined WLAN_FEATURE_VOWIFI_11R
9066 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_FT_RSN
9067 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_FT_RSN_PSK
9068#endif
9069#ifdef FEATURE_WLAN_ESE
9070 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_CCKM_WPA
9071 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_CCKM_RSN
9072#endif
9073 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009074 {
Nirav Shah4f765af2015-01-21 19:51:30 +05309075 vos_status = wlan_hdd_check_ula_done(pAdapter);
9076
9077 if ( vos_status != VOS_STATUS_SUCCESS )
9078 {
9079 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009080 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9081 __LINE__, vos_status );
9082
Nirav Shah4f765af2015-01-21 19:51:30 +05309083 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009084
Nirav Shah4f765af2015-01-21 19:51:30 +05309085 status = -EINVAL;
9086 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009087
Nirav Shah4f765af2015-01-21 19:51:30 +05309088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009089 }
9090
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009091#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309092 /* The supplicant may attempt to set the PTK once pre-authentication
9093 is done. Save the key in the UMAC and include it in the ADD BSS
9094 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009095 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309096 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009097 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309098 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9099 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309100 status = 0;
9101 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309102 }
9103 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9104 {
9105 hddLog(VOS_TRACE_LEVEL_ERROR,
9106 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309107 status = -EINVAL;
9108 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009109 }
9110#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009111
9112 /* issue set key request to SME*/
9113 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9114 pAdapter->sessionId, &setKey, &roamId );
9115
9116 if ( 0 != status )
9117 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309118 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009119 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9120 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309121 status = -EINVAL;
9122 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 }
9124
9125
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309126 /* in case of IBSS as there was no information available about WEP keys during
9127 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009128 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309129 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9130 !( ( IW_AUTH_KEY_MGMT_802_1X
9131 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009132 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9133 )
9134 &&
9135 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9136 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9137 )
9138 )
9139 {
9140 setKey.keyDirection = eSIR_RX_ONLY;
9141 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9142
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309143 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009144 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309145 __func__, setKey.peerMac[0], setKey.peerMac[1],
9146 setKey.peerMac[2], setKey.peerMac[3],
9147 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 setKey.keyDirection);
9149
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309150 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009151 pAdapter->sessionId, &setKey, &roamId );
9152
9153 if ( 0 != status )
9154 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309155 hddLog(VOS_TRACE_LEVEL_ERROR,
9156 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009157 __func__, status);
9158 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309159 status = -EINVAL;
9160 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 }
9162 }
9163 }
9164
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309165end:
9166 /* Need to clear any trace of key value in the memory.
9167 * Thus zero out the memory even though it is local
9168 * variable.
9169 */
9170 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309171 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309172 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009173}
9174
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309175#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9176static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9177 struct net_device *ndev,
9178 u8 key_index, bool pairwise,
9179 const u8 *mac_addr,
9180 struct key_params *params
9181 )
9182#else
9183static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9184 struct net_device *ndev,
9185 u8 key_index, const u8 *mac_addr,
9186 struct key_params *params
9187 )
9188#endif
9189{
9190 int ret;
9191 vos_ssr_protect(__func__);
9192#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9193 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9194 mac_addr, params);
9195#else
9196 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9197 params);
9198#endif
9199 vos_ssr_unprotect(__func__);
9200
9201 return ret;
9202}
9203
Jeff Johnson295189b2012-06-20 16:38:30 -07009204/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309205 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009206 * This function is used to get the key information
9207 */
9208#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309209static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309210 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009211 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309212 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009213 const u8 *mac_addr, void *cookie,
9214 void (*callback)(void *cookie, struct key_params*)
9215 )
9216#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309217static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309218 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009219 struct net_device *ndev,
9220 u8 key_index, const u8 *mac_addr, void *cookie,
9221 void (*callback)(void *cookie, struct key_params*)
9222 )
9223#endif
9224{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309225 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309226 hdd_wext_state_t *pWextState = NULL;
9227 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009228 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309229 hdd_context_t *pHddCtx;
9230 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009231
9232 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309233
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309234 if (NULL == pAdapter)
9235 {
9236 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9237 "%s: HDD adapter is Null", __func__);
9238 return -ENODEV;
9239 }
9240
9241 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9242 ret = wlan_hdd_validate_context(pHddCtx);
9243 if (0 != ret)
9244 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309245 return ret;
9246 }
9247
9248 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9249 pRoamProfile = &(pWextState->roamProfile);
9250
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309251 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9252 __func__, hdd_device_modetoString(pAdapter->device_mode),
9253 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309254
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 memset(&params, 0, sizeof(params));
9256
9257 if (CSR_MAX_NUM_KEY <= key_index)
9258 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309259 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009260 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009262
9263 switch(pRoamProfile->EncryptionType.encryptionType[0])
9264 {
9265 case eCSR_ENCRYPT_TYPE_NONE:
9266 params.cipher = IW_AUTH_CIPHER_NONE;
9267 break;
9268
9269 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9270 case eCSR_ENCRYPT_TYPE_WEP40:
9271 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9272 break;
9273
9274 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9275 case eCSR_ENCRYPT_TYPE_WEP104:
9276 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9277 break;
9278
9279 case eCSR_ENCRYPT_TYPE_TKIP:
9280 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9281 break;
9282
9283 case eCSR_ENCRYPT_TYPE_AES:
9284 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9285 break;
9286
9287 default:
9288 params.cipher = IW_AUTH_CIPHER_NONE;
9289 break;
9290 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309291
c_hpothuaaf19692014-05-17 17:01:48 +05309292 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9293 TRACE_CODE_HDD_CFG80211_GET_KEY,
9294 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309295
Jeff Johnson295189b2012-06-20 16:38:30 -07009296 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9297 params.seq_len = 0;
9298 params.seq = NULL;
9299 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9300 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309301 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009302 return 0;
9303}
9304
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309305#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9306static int wlan_hdd_cfg80211_get_key(
9307 struct wiphy *wiphy,
9308 struct net_device *ndev,
9309 u8 key_index, bool pairwise,
9310 const u8 *mac_addr, void *cookie,
9311 void (*callback)(void *cookie, struct key_params*)
9312 )
9313#else
9314static int wlan_hdd_cfg80211_get_key(
9315 struct wiphy *wiphy,
9316 struct net_device *ndev,
9317 u8 key_index, const u8 *mac_addr, void *cookie,
9318 void (*callback)(void *cookie, struct key_params*)
9319 )
9320#endif
9321{
9322 int ret;
9323
9324 vos_ssr_protect(__func__);
9325#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9326 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9327 mac_addr, cookie, callback);
9328#else
9329 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9330 callback);
9331#endif
9332 vos_ssr_unprotect(__func__);
9333
9334 return ret;
9335}
9336
Jeff Johnson295189b2012-06-20 16:38:30 -07009337/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309338 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009339 * This function is used to delete the key information
9340 */
9341#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309342static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309344 u8 key_index,
9345 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009346 const u8 *mac_addr
9347 )
9348#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309349static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 struct net_device *ndev,
9351 u8 key_index,
9352 const u8 *mac_addr
9353 )
9354#endif
9355{
9356 int status = 0;
9357
9358 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309359 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009360 //it is observed that this is invalidating peer
9361 //key index whenever re-key is done. This is affecting data link.
9362 //It should be ok to ignore del_key.
9363#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309364 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9365 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009366 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9367 tCsrRoamSetKey setKey;
9368 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309369
Jeff Johnson295189b2012-06-20 16:38:30 -07009370 ENTER();
9371
9372 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9373 __func__,pAdapter->device_mode);
9374
9375 if (CSR_MAX_NUM_KEY <= key_index)
9376 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309377 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009378 key_index);
9379
9380 return -EINVAL;
9381 }
9382
9383 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9384 setKey.keyId = key_index;
9385
9386 if (mac_addr)
9387 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9388 else
9389 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9390
9391 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9392
9393 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309395 )
9396 {
9397
9398 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009399 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9400 if( pHostapdState->bssState == BSS_START)
9401 {
9402 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309403
Jeff Johnson295189b2012-06-20 16:38:30 -07009404 if ( status != eHAL_STATUS_SUCCESS )
9405 {
9406 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9407 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9408 __LINE__, status );
9409 }
9410 }
9411 }
9412 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309413 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009414 )
9415 {
9416 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9417
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309418 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9419
9420 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009421 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309422 __func__, setKey.peerMac[0], setKey.peerMac[1],
9423 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009424 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309425 if(pAdapter->sessionCtx.station.conn_info.connState ==
9426 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309428 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009429 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309430
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 if ( 0 != status )
9432 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309433 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009434 "%s: sme_RoamSetKey failure, returned %d",
9435 __func__, status);
9436 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9437 return -EINVAL;
9438 }
9439 }
9440 }
9441#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009442 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009443 return status;
9444}
9445
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309446#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9447static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9448 struct net_device *ndev,
9449 u8 key_index,
9450 bool pairwise,
9451 const u8 *mac_addr
9452 )
9453#else
9454static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9455 struct net_device *ndev,
9456 u8 key_index,
9457 const u8 *mac_addr
9458 )
9459#endif
9460{
9461 int ret;
9462
9463 vos_ssr_protect(__func__);
9464#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9465 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9466 mac_addr);
9467#else
9468 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9469#endif
9470 vos_ssr_unprotect(__func__);
9471
9472 return ret;
9473}
9474
Jeff Johnson295189b2012-06-20 16:38:30 -07009475/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309476 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 * This function is used to set the default tx key index
9478 */
9479#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309480static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009481 struct net_device *ndev,
9482 u8 key_index,
9483 bool unicast, bool multicast)
9484#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309485static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009486 struct net_device *ndev,
9487 u8 key_index)
9488#endif
9489{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309490 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309491 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309492 hdd_wext_state_t *pWextState;
9493 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309494 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009495
9496 ENTER();
9497
Gopichand Nakkala29149562013-05-10 21:43:41 +05309498 if ((NULL == pAdapter))
9499 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309501 "invalid adapter");
9502 return -EINVAL;
9503 }
9504
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309505 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9506 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9507 pAdapter->sessionId, key_index));
9508
Gopichand Nakkala29149562013-05-10 21:43:41 +05309509 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9510 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9511
9512 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9513 {
9514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9515 "invalid Wext state or HDD context");
9516 return -EINVAL;
9517 }
9518
Arif Hussain6d2a3322013-11-17 19:50:10 -08009519 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009520 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309521
Jeff Johnson295189b2012-06-20 16:38:30 -07009522 if (CSR_MAX_NUM_KEY <= key_index)
9523 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309524 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009525 key_index);
9526
9527 return -EINVAL;
9528 }
9529
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309530 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9531 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309532 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009533 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309534 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009535 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309536
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309539 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309541 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009542 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309543 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009544 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309546 {
9547 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009548 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309549
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 tCsrRoamSetKey setKey;
9551 v_U32_t roamId= 0xFF;
9552 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309553
9554 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009555 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309556
Jeff Johnson295189b2012-06-20 16:38:30 -07009557 Keys->defaultIndex = (u8)key_index;
9558 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9559 setKey.keyId = key_index;
9560 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309561
9562 vos_mem_copy(&setKey.Key[0],
9563 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009564 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309565
Gopichand Nakkala29149562013-05-10 21:43:41 +05309566 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309567
9568 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009569 &pHddStaCtx->conn_info.bssId[0],
9570 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309571
Gopichand Nakkala29149562013-05-10 21:43:41 +05309572 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9573 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9574 eCSR_ENCRYPT_TYPE_WEP104)
9575 {
9576 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9577 even though ap is configured for WEP-40 encryption. In this canse the key length
9578 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9579 type(104) and switching encryption type to 40*/
9580 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9581 eCSR_ENCRYPT_TYPE_WEP40;
9582 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9583 eCSR_ENCRYPT_TYPE_WEP40;
9584 }
9585
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309586 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009587 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309588
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309590 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309592
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 if ( 0 != status )
9594 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309595 hddLog(VOS_TRACE_LEVEL_ERROR,
9596 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 status);
9598 return -EINVAL;
9599 }
9600 }
9601 }
9602
9603 /* In SoftAp mode setting key direction for default mode */
9604 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9605 {
9606 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9607 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9608 (eCSR_ENCRYPT_TYPE_AES !=
9609 pWextState->roamProfile.EncryptionType.encryptionType[0])
9610 )
9611 {
9612 /* Saving key direction for default key index to TX default */
9613 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9614 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9615 }
9616 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309617 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009618 return status;
9619}
9620
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309621#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9622static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9623 struct net_device *ndev,
9624 u8 key_index,
9625 bool unicast, bool multicast)
9626#else
9627static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9628 struct net_device *ndev,
9629 u8 key_index)
9630#endif
9631{
9632 int ret;
9633 vos_ssr_protect(__func__);
9634#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9635 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9636 multicast);
9637#else
9638 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9639#endif
9640 vos_ssr_unprotect(__func__);
9641
9642 return ret;
9643}
9644
Jeff Johnson295189b2012-06-20 16:38:30 -07009645/*
9646 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9647 * This function is used to inform the BSS details to nl80211 interface.
9648 */
9649static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9650 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9651{
9652 struct net_device *dev = pAdapter->dev;
9653 struct wireless_dev *wdev = dev->ieee80211_ptr;
9654 struct wiphy *wiphy = wdev->wiphy;
9655 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9656 int chan_no;
9657 int ie_length;
9658 const char *ie;
9659 unsigned int freq;
9660 struct ieee80211_channel *chan;
9661 int rssi = 0;
9662 struct cfg80211_bss *bss = NULL;
9663
9664 ENTER();
9665
9666 if( NULL == pBssDesc )
9667 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009668 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009669 return bss;
9670 }
9671
9672 chan_no = pBssDesc->channelId;
9673 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9674 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9675
9676 if( NULL == ie )
9677 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009678 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009679 return bss;
9680 }
9681
9682#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9683 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9684 {
9685 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9686 }
9687 else
9688 {
9689 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9690 }
9691#else
9692 freq = ieee80211_channel_to_frequency(chan_no);
9693#endif
9694
9695 chan = __ieee80211_get_channel(wiphy, freq);
9696
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309697 if (!chan) {
9698 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9699 return NULL;
9700 }
9701
Abhishek Singhaee43942014-06-16 18:55:47 +05309702 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009703
Abhishek Singhaee43942014-06-16 18:55:47 +05309704 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309705 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 pBssDesc->capabilityInfo,
9707 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309708 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009709}
9710
9711
9712
9713/*
9714 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9715 * This function is used to inform the BSS details to nl80211 interface.
9716 */
9717struct cfg80211_bss*
9718wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9719 tSirBssDescription *bss_desc
9720 )
9721{
9722 /*
9723 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9724 already exists in bss data base of cfg80211 for that particular BSS ID.
9725 Using cfg80211_inform_bss_frame to update the bss entry instead of
9726 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9727 now there is no possibility to get the mgmt(probe response) frame from PE,
9728 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9729 cfg80211_inform_bss_frame.
9730 */
9731 struct net_device *dev = pAdapter->dev;
9732 struct wireless_dev *wdev = dev->ieee80211_ptr;
9733 struct wiphy *wiphy = wdev->wiphy;
9734 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009735#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9736 qcom_ie_age *qie_age = NULL;
9737 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
9738#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009739 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009740#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009741 const char *ie =
9742 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
9743 unsigned int freq;
9744 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309745 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009746 struct cfg80211_bss *bss_status = NULL;
9747 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
9748 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07009749 hdd_context_t *pHddCtx;
9750 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07009751#ifdef WLAN_OPEN_SOURCE
9752 struct timespec ts;
9753#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009754
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309755 ENTER();
9756
Wilson Yangf80a0542013-10-07 13:02:37 -07009757 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9758 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -07009759 if (0 != status)
9760 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009761 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009762 }
9763
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309764 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07009765 if (!mgmt)
9766 {
9767 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9768 "%s: memory allocation failed ", __func__);
9769 return NULL;
9770 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009771
Jeff Johnson295189b2012-06-20 16:38:30 -07009772 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07009773
9774#ifdef WLAN_OPEN_SOURCE
9775 /* Android does not want the timestamp from the frame.
9776 Instead it wants a monotonic increasing value */
9777 get_monotonic_boottime(&ts);
9778 mgmt->u.probe_resp.timestamp =
9779 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
9780#else
9781 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07009782 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
9783 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07009784
9785#endif
9786
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
9788 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009789
9790#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9791 /* GPS Requirement: need age ie per entry. Using vendor specific. */
9792 /* Assuming this is the last IE, copy at the end */
9793 ie_length -=sizeof(qcom_ie_age);
9794 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
9795 qie_age->element_id = QCOM_VENDOR_IE_ID;
9796 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
9797 qie_age->oui_1 = QCOM_OUI1;
9798 qie_age->oui_2 = QCOM_OUI2;
9799 qie_age->oui_3 = QCOM_OUI3;
9800 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
9801 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
9802#endif
9803
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05309805 if (bss_desc->fProbeRsp)
9806 {
9807 mgmt->frame_control |=
9808 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
9809 }
9810 else
9811 {
9812 mgmt->frame_control |=
9813 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
9814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009815
9816#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309817 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009818 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
9819 {
9820 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9821 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309822 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009823 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
9824
9825 {
9826 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9827 }
9828 else
9829 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309830 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
9831 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07009832 kfree(mgmt);
9833 return NULL;
9834 }
9835#else
9836 freq = ieee80211_channel_to_frequency(chan_no);
9837#endif
9838 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009839 /*when the band is changed on the fly using the GUI, three things are done
9840 * 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)
9841 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
9842 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
9843 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
9844 * and discards the channels correponding to previous band and calls back with zero bss results.
9845 * 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
9846 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
9847 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
9848 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
9849 * So drop the bss and continue to next bss.
9850 */
9851 if(chan == NULL)
9852 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309853 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07009854 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009855 return NULL;
9856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009857 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309858 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07009859 * */
9860 if (( eConnectionState_Associated ==
9861 pAdapter->sessionCtx.station.conn_info.connState ) &&
9862 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
9863 pAdapter->sessionCtx.station.conn_info.bssId,
9864 WNI_CFG_BSSID_LEN)))
9865 {
9866 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
9867 rssi = (pAdapter->rssi * 100);
9868 }
9869 else
9870 {
9871 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
9872 }
9873
Nirav Shah20ac06f2013-12-12 18:14:06 +05309874 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
9875 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
9876 chan->center_freq, (int)(rssi/100));
9877
Jeff Johnson295189b2012-06-20 16:38:30 -07009878 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
9879 frame_len, rssi, GFP_KERNEL);
9880 kfree(mgmt);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309881 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 return bss_status;
9883}
9884
9885/*
9886 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
9887 * This function is used to update the BSS data base of CFG8011
9888 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309889struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009890 tCsrRoamInfo *pRoamInfo
9891 )
9892{
9893 tCsrRoamConnectedProfile roamProfile;
9894 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9895 struct cfg80211_bss *bss = NULL;
9896
9897 ENTER();
9898
9899 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
9900 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
9901
9902 if (NULL != roamProfile.pBssDesc)
9903 {
Girish Gowlif4b68022014-08-28 23:18:57 +05309904 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9905 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009906
9907 if (NULL == bss)
9908 {
9909 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
9910 __func__);
9911 }
9912
9913 sme_RoamFreeConnectProfile(hHal, &roamProfile);
9914 }
9915 else
9916 {
9917 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
9918 __func__);
9919 }
9920 return bss;
9921}
9922
9923/*
9924 * FUNCTION: wlan_hdd_cfg80211_update_bss
9925 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309926static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
9927 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309929{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309930 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009931 tCsrScanResultInfo *pScanResult;
9932 eHalStatus status = 0;
9933 tScanResultHandle pResult;
9934 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009935 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009936
9937 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309938
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309939 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9940 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
9941 NO_SESSION, pAdapter->sessionId));
9942
Wilson Yangf80a0542013-10-07 13:02:37 -07009943 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9944
9945 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07009946 {
Wilson Yangf80a0542013-10-07 13:02:37 -07009947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9948 "%s:LOGP in Progress. Ignore!!!",__func__);
9949 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009950 }
9951
Wilson Yangf80a0542013-10-07 13:02:37 -07009952
9953 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05309954 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07009955 {
9956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9957 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
9958 return VOS_STATUS_E_PERM;
9959 }
9960
9961
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 /*
9963 * start getting scan results and populate cgf80211 BSS database
9964 */
9965 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
9966
9967 /* no scan results */
9968 if (NULL == pResult)
9969 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309970 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
9971 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009972 return status;
9973 }
9974
9975 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
9976
9977 while (pScanResult)
9978 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309979 /*
9980 * cfg80211_inform_bss() is not updating ie field of bss entry, if
9981 * entry already exists in bss data base of cfg80211 for that
9982 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
9983 * bss entry instead of cfg80211_inform_bss, But this call expects
9984 * mgmt packet as input. As of now there is no possibility to get
9985 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07009986 * ieee80211_mgmt(probe response) and passing to c
9987 * fg80211_inform_bss_frame.
9988 * */
9989
9990 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9991 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309992
Jeff Johnson295189b2012-06-20 16:38:30 -07009993
9994 if (NULL == bss_status)
9995 {
9996 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009997 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009998 }
9999 else
10000 {
Yue Maf49ba872013-08-19 12:04:25 -070010001 cfg80211_put_bss(
10002#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10003 wiphy,
10004#endif
10005 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 }
10007
10008 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10009 }
10010
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010011 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010012
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010013 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010014}
10015
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010016void
10017hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10018{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010019 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010020 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010021} /****** end hddPrintMacAddr() ******/
10022
10023void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010024hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010025{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010026 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010027 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010028 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10029 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10030 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010031} /****** end hddPrintPmkId() ******/
10032
10033//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10034//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10035
10036//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10037//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10038
10039#define dump_bssid(bssid) \
10040 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010041 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10042 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010043 }
10044
10045#define dump_pmkid(pMac, pmkid) \
10046 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010047 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10048 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010049 }
10050
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010051#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010052/*
10053 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10054 * This function is used to notify the supplicant of a new PMKSA candidate.
10055 */
10056int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010057 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010058 int index, bool preauth )
10059{
Jeff Johnsone7245742012-09-05 17:12:55 -070010060#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010061 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010062 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010063
10064 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010065 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010066
10067 if( NULL == pRoamInfo )
10068 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010069 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010070 return -EINVAL;
10071 }
10072
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010073 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10074 {
10075 dump_bssid(pRoamInfo->bssid);
10076 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010077 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010078 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010079#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010080 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010081}
10082#endif //FEATURE_WLAN_LFR
10083
Yue Maef608272013-04-08 23:09:17 -070010084#ifdef FEATURE_WLAN_LFR_METRICS
10085/*
10086 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10087 * 802.11r/LFR metrics reporting function to report preauth initiation
10088 *
10089 */
10090#define MAX_LFR_METRICS_EVENT_LENGTH 100
10091VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10092 tCsrRoamInfo *pRoamInfo)
10093{
10094 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10095 union iwreq_data wrqu;
10096
10097 ENTER();
10098
10099 if (NULL == pAdapter)
10100 {
10101 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10102 return VOS_STATUS_E_FAILURE;
10103 }
10104
10105 /* create the event */
10106 memset(&wrqu, 0, sizeof(wrqu));
10107 memset(metrics_notification, 0, sizeof(metrics_notification));
10108
10109 wrqu.data.pointer = metrics_notification;
10110 wrqu.data.length = scnprintf(metrics_notification,
10111 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10112 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10113
10114 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10115
10116 EXIT();
10117
10118 return VOS_STATUS_SUCCESS;
10119}
10120
10121/*
10122 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10123 * 802.11r/LFR metrics reporting function to report preauth completion
10124 * or failure
10125 */
10126VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10127 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10128{
10129 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10130 union iwreq_data wrqu;
10131
10132 ENTER();
10133
10134 if (NULL == pAdapter)
10135 {
10136 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10137 return VOS_STATUS_E_FAILURE;
10138 }
10139
10140 /* create the event */
10141 memset(&wrqu, 0, sizeof(wrqu));
10142 memset(metrics_notification, 0, sizeof(metrics_notification));
10143
10144 scnprintf(metrics_notification, sizeof(metrics_notification),
10145 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10146 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10147
10148 if (1 == preauth_status)
10149 strncat(metrics_notification, " TRUE", 5);
10150 else
10151 strncat(metrics_notification, " FALSE", 6);
10152
10153 wrqu.data.pointer = metrics_notification;
10154 wrqu.data.length = strlen(metrics_notification);
10155
10156 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10157
10158 EXIT();
10159
10160 return VOS_STATUS_SUCCESS;
10161}
10162
10163/*
10164 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10165 * 802.11r/LFR metrics reporting function to report handover initiation
10166 *
10167 */
10168VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10169 tCsrRoamInfo *pRoamInfo)
10170{
10171 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10172 union iwreq_data wrqu;
10173
10174 ENTER();
10175
10176 if (NULL == pAdapter)
10177 {
10178 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10179 return VOS_STATUS_E_FAILURE;
10180 }
10181
10182 /* create the event */
10183 memset(&wrqu, 0, sizeof(wrqu));
10184 memset(metrics_notification, 0, sizeof(metrics_notification));
10185
10186 wrqu.data.pointer = metrics_notification;
10187 wrqu.data.length = scnprintf(metrics_notification,
10188 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10189 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10190
10191 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10192
10193 EXIT();
10194
10195 return VOS_STATUS_SUCCESS;
10196}
10197#endif
10198
Jeff Johnson295189b2012-06-20 16:38:30 -070010199/*
10200 * FUNCTION: hdd_cfg80211_scan_done_callback
10201 * scanning callback function, called after finishing scan
10202 *
10203 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010204static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010205 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10206{
10207 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010208 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010209 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010210 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010211 struct cfg80211_scan_request *req = NULL;
10212 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010213 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010214 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010215 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010216 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010217
10218 ENTER();
10219
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010220 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10221 if (0 != wlan_hdd_validate_context(pHddCtx)) {
10222 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
10223 goto allow_suspend;
10224 }
10225
10226 pScanInfo = &pHddCtx->scan_info;
10227
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 hddLog(VOS_TRACE_LEVEL_INFO,
10229 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010230 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010231 __func__, halHandle, pContext, (int) scanId, (int) status);
10232
Kiet Lamac06e2c2013-10-23 16:25:07 +053010233 pScanInfo->mScanPendingCounter = 0;
10234
Jeff Johnson295189b2012-06-20 16:38:30 -070010235 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010236 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010237 &pScanInfo->scan_req_completion_event,
10238 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010239 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010240 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010241 hddLog(VOS_TRACE_LEVEL_ERROR,
10242 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010243 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010244 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 }
10246
Yue Maef608272013-04-08 23:09:17 -070010247 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010248 {
10249 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010250 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010251 }
10252
10253 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010254 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010255 {
10256 hddLog(VOS_TRACE_LEVEL_INFO,
10257 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010258 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010259 (int) scanId);
10260 }
10261
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010262 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010263 pAdapter);
10264
10265 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010266 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010267
10268
10269 /* If any client wait scan result through WEXT
10270 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010271 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010272 {
10273 /* The other scan request waiting for current scan finish
10274 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010275 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010276 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010277 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010278 }
10279 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010280 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010281 {
10282 struct net_device *dev = pAdapter->dev;
10283 union iwreq_data wrqu;
10284 int we_event;
10285 char *msg;
10286
10287 memset(&wrqu, '\0', sizeof(wrqu));
10288 we_event = SIOCGIWSCAN;
10289 msg = NULL;
10290 wireless_send_event(dev, we_event, &wrqu, msg);
10291 }
10292 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010293 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010294
10295 /* Get the Scan Req */
10296 req = pAdapter->request;
10297
10298 if (!req)
10299 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010300 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010301 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010302 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010303 }
10304
Jeff Johnson295189b2012-06-20 16:38:30 -070010305 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010306 /* Scan is no longer pending */
10307 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010308
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010309 /* last_scan_timestamp is used to decide if new scan
10310 * is needed or not on station interface. If last station
10311 * scan time and new station scan time is less then
10312 * last_scan_timestamp ; driver will return cached scan.
10313 */
10314 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10315 {
10316 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10317
10318 if ( req->n_channels )
10319 {
10320 for (i = 0; i < req->n_channels ; i++ )
10321 {
10322 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10323 }
10324 /* store no of channel scanned */
10325 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10326 }
10327
10328 }
10329
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010330 /*
10331 * cfg80211_scan_done informing NL80211 about completion
10332 * of scanning
10333 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010334 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10335 {
10336 aborted = true;
10337 }
10338 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010339 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010340
Siddharth Bhal76972212014-10-15 16:22:51 +053010341 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10342 /* Generate new random mac addr for next scan */
10343 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10344 hdd_processSpoofMacAddrRequest(pHddCtx);
10345 }
10346
Jeff Johnsone7245742012-09-05 17:12:55 -070010347allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010348 /* release the wake lock at the end of the scan*/
10349 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -070010350
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010351 /* Acquire wakelock to handle the case where APP's tries to suspend
10352 * immediatly after the driver gets connect request(i.e after scan)
10353 * from supplicant, this result in app's is suspending and not able
10354 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053010355 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010356
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010357#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010358 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010359#endif
10360
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 EXIT();
10362 return 0;
10363}
10364
10365/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010366 * FUNCTION: hdd_isConnectionInProgress
10367 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010368 *
10369 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010370v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010371{
10372 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10373 hdd_station_ctx_t *pHddStaCtx = NULL;
10374 hdd_adapter_t *pAdapter = NULL;
10375 VOS_STATUS status = 0;
10376 v_U8_t staId = 0;
10377 v_U8_t *staMac = NULL;
10378
c_hpothu9b781ba2013-12-30 20:57:45 +053010379 if (TRUE == pHddCtx->btCoexModeSet)
10380 {
10381 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010382 FL("BTCoex Mode operation in progress"));
10383 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010384 }
10385
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010386 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10387
10388 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10389 {
10390 pAdapter = pAdapterNode->pAdapter;
10391
10392 if( pAdapter )
10393 {
10394 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010395 "%s: Adapter with device mode %s (%d) exists",
10396 __func__, hdd_device_modetoString(pAdapter->device_mode),
10397 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010398 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010399 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10400 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10401 (eConnectionState_Connecting ==
10402 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10403 {
10404 hddLog(VOS_TRACE_LEVEL_ERROR,
10405 "%s: %p(%d) Connection is in progress", __func__,
10406 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10407 return VOS_TRUE;
10408 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010409 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010410 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010411 {
10412 hddLog(VOS_TRACE_LEVEL_ERROR,
10413 "%s: %p(%d) Reassociation is in progress", __func__,
10414 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10415 return VOS_TRUE;
10416 }
10417 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010418 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10419 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010420 {
10421 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10422 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010423 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010424 {
10425 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10426 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010427 "%s: client " MAC_ADDRESS_STR
10428 " is in the middle of WPS/EAPOL exchange.", __func__,
10429 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010430 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010431 }
10432 }
10433 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10434 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10435 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010436 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10437 ptSapContext pSapCtx = NULL;
10438 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10439 if(pSapCtx == NULL){
10440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10441 FL("psapCtx is NULL"));
10442 return VOS_FALSE;
10443 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010444 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10445 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010446 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10447 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010448 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010449 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010450
10451 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010452 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10453 "middle of WPS/EAPOL exchange.", __func__,
10454 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010455 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010456 }
10457 }
10458 }
10459 }
10460 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10461 pAdapterNode = pNext;
10462 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010463 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010464}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010465
10466/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010467 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010468 * this scan respond to scan trigger and update cfg80211 scan database
10469 * later, scan dump command can be used to recieve scan results
10470 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010471int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010472#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10473 struct net_device *dev,
10474#endif
10475 struct cfg80211_scan_request *request)
10476{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010477 hdd_adapter_t *pAdapter = NULL;
10478 hdd_context_t *pHddCtx = NULL;
10479 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010480 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010481 tCsrScanRequest scanRequest;
10482 tANI_U8 *channelList = NULL, i;
10483 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010484 int status;
10485 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010486 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010487 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010488
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010489#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10490 struct net_device *dev = NULL;
10491 if (NULL == request)
10492 {
10493 hddLog(VOS_TRACE_LEVEL_ERROR,
10494 "%s: scan req param null", __func__);
10495 return -EINVAL;
10496 }
10497 dev = request->wdev->netdev;
10498#endif
10499
10500 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10501 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10502 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10503
Jeff Johnson295189b2012-06-20 16:38:30 -070010504 ENTER();
10505
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010506 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10507 __func__, hdd_device_modetoString(pAdapter->device_mode),
10508 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010509
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010510 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010511 if (0 != status)
10512 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010513 return status;
10514 }
10515
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010516 if (NULL == pwextBuf)
10517 {
10518 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10519 __func__);
10520 return -EIO;
10521 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010522 cfg_param = pHddCtx->cfg_ini;
10523 pScanInfo = &pHddCtx->scan_info;
10524
Jeff Johnson295189b2012-06-20 16:38:30 -070010525#ifdef WLAN_BTAMP_FEATURE
10526 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010527 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010528 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010529 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010530 "%s: No scanning when AMP is on", __func__);
10531 return -EOPNOTSUPP;
10532 }
10533#endif
10534 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010535 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010536 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010537 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010538 "%s: Not scanning on device_mode = %s (%d)",
10539 __func__, hdd_device_modetoString(pAdapter->device_mode),
10540 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010541 return -EOPNOTSUPP;
10542 }
10543
10544 if (TRUE == pScanInfo->mScanPending)
10545 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010546 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10547 {
10548 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10549 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010550 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 }
10552
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010553 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010554 //Channel and action frame is pending
10555 //Otherwise Cancel Remain On Channel and allow Scan
10556 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010557 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010558 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010559 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010560 return -EBUSY;
10561 }
10562
Jeff Johnson295189b2012-06-20 16:38:30 -070010563 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10564 {
10565 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010566 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010568 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010569 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10570 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010571 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010572 "%s: MAX TM Level Scan not allowed", __func__);
10573 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010574 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010575 }
10576 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10577
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010578 /* Check if scan is allowed at this point of time.
10579 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010580 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010581 {
10582 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10583 return -EBUSY;
10584 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010585
Jeff Johnson295189b2012-06-20 16:38:30 -070010586 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10587
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010588 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
10589 (int)request->n_ssids);
10590
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010591
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010592 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10593 * Becasue of this, driver is assuming that this is not wildcard scan and so
10594 * is not aging out the scan results.
10595 */
10596 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010597 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010598 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010600
10601 if ((request->ssids) && (0 < request->n_ssids))
10602 {
10603 tCsrSSIDInfo *SsidInfo;
10604 int j;
10605 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10606 /* Allocate num_ssid tCsrSSIDInfo structure */
10607 SsidInfo = scanRequest.SSIDs.SSIDList =
10608 ( tCsrSSIDInfo *)vos_mem_malloc(
10609 request->n_ssids*sizeof(tCsrSSIDInfo));
10610
10611 if(NULL == scanRequest.SSIDs.SSIDList)
10612 {
10613 hddLog(VOS_TRACE_LEVEL_ERROR,
10614 "%s: memory alloc failed SSIDInfo buffer", __func__);
10615 return -ENOMEM;
10616 }
10617
10618 /* copy all the ssid's and their length */
10619 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10620 {
10621 /* get the ssid length */
10622 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10623 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10624 SsidInfo->SSID.length);
10625 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10626 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10627 j, SsidInfo->SSID.ssId);
10628 }
10629 /* set the scan type to active */
10630 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10631 }
10632 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010633 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010634 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10635 TRACE_CODE_HDD_CFG80211_SCAN,
10636 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010637 /* set the scan type to active */
10638 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010639 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010640 else
10641 {
10642 /*Set the scan type to default type, in this case it is ACTIVE*/
10643 scanRequest.scanType = pScanInfo->scan_mode;
10644 }
10645 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10646 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010647
10648 /* set BSSType to default type */
10649 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10650
10651 /*TODO: scan the requested channels only*/
10652
10653 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010654 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010655 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010656 hddLog(VOS_TRACE_LEVEL_WARN,
10657 "No of Scan Channels exceeded limit: %d", request->n_channels);
10658 request->n_channels = MAX_CHANNEL;
10659 }
10660
10661 hddLog(VOS_TRACE_LEVEL_INFO,
10662 "No of Scan Channels: %d", request->n_channels);
10663
10664
10665 if( request->n_channels )
10666 {
10667 char chList [(request->n_channels*5)+1];
10668 int len;
10669 channelList = vos_mem_malloc( request->n_channels );
10670 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010671 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010672 hddLog(VOS_TRACE_LEVEL_ERROR,
10673 "%s: memory alloc failed channelList", __func__);
10674 status = -ENOMEM;
10675 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010676 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010677
10678 for( i = 0, len = 0; i < request->n_channels ; i++ )
10679 {
10680 channelList[i] = request->channels[i]->hw_value;
10681 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10682 }
10683
Nirav Shah20ac06f2013-12-12 18:14:06 +053010684 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010685 "Channel-List: %s ", chList);
10686 }
c_hpothu53512302014-04-15 18:49:53 +053010687
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010688 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10689 scanRequest.ChannelInfo.ChannelList = channelList;
10690
10691 /* set requestType to full scan */
10692 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10693
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010694 /* if there is back to back scan happening in driver with in
10695 * nDeferScanTimeInterval interval driver should defer new scan request
10696 * and should provide last cached scan results instead of new channel list.
10697 * This rule is not applicable if scan is p2p scan.
10698 * This condition will work only in case when last request no of channels
10699 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010700 * This should be done only in connected state
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010701 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010702
Agarwal Ashish57e84372014-12-05 18:26:53 +053010703 if ((VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
10704 {
10705 if ( pScanInfo->last_scan_timestamp !=0 &&
10706 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
10707 {
10708 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
10709 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
10710 vos_mem_compare(pScanInfo->last_scan_channelList,
10711 channelList, pScanInfo->last_scan_numChannels))
10712 {
10713 hddLog(VOS_TRACE_LEVEL_WARN,
10714 " New and old station scan time differ is less then %u",
10715 pHddCtx->cfg_ini->nDeferScanTimeInterval);
10716
10717 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010718 pAdapter);
10719
Agarwal Ashish57e84372014-12-05 18:26:53 +053010720 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010721 "Return old cached scan as all channels and no of channels are same");
10722
Agarwal Ashish57e84372014-12-05 18:26:53 +053010723 if (0 > ret)
10724 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010725
Agarwal Ashish57e84372014-12-05 18:26:53 +053010726 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010727
10728 status = eHAL_STATUS_SUCCESS;
10729 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053010730 }
10731 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010732 }
10733
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010734 /* Flush the scan results(only p2p beacons) for STA scan and P2P
10735 * search (Flush on both full scan and social scan but not on single
10736 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
10737 */
10738
10739 /* Supplicant does single channel scan after 8-way handshake
10740 * and in that case driver shoudnt flush scan results. If
10741 * driver flushes the scan results here and unfortunately if
10742 * the AP doesnt respond to our probe req then association
10743 * fails which is not desired
10744 */
10745
10746 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
10747 {
10748 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
10749 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
10750 pAdapter->sessionId );
10751 }
10752
10753 if( request->ie_len )
10754 {
10755 /* save this for future association (join requires this) */
10756 /*TODO: Array needs to be converted to dynamic allocation,
10757 * as multiple ie.s can be sent in cfg80211_scan_request structure
10758 * CR 597966
10759 */
10760 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
10761 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
10762 pScanInfo->scanAddIE.length = request->ie_len;
10763
10764 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10765 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10766 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010767 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053010768 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070010769 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010770 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
10771 memcpy( pwextBuf->roamProfile.addIEScan,
10772 request->ie, request->ie_len);
10773 }
10774 else
10775 {
10776 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
10777 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070010778 }
10779
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010780 }
10781 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
10782 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
10783
10784 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
10785 request->ie_len);
10786 if (pP2pIe != NULL)
10787 {
10788#ifdef WLAN_FEATURE_P2P_DEBUG
10789 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
10790 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
10791 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053010792 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010793 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
10794 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10795 "Go nego completed to Connection is started");
10796 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10797 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053010798 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010799 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
10800 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010801 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010802 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
10803 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10804 "Disconnected state to Connection is started");
10805 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10806 "for 4way Handshake");
10807 }
10808#endif
10809
10810 /* no_cck will be set during p2p find to disable 11b rates */
10811 if(TRUE == request->no_cck)
10812 {
10813 hddLog(VOS_TRACE_LEVEL_INFO,
10814 "%s: This is a P2P Search", __func__);
10815 scanRequest.p2pSearch = 1;
10816
10817 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053010818 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010819 /* set requestType to P2P Discovery */
10820 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
10821 }
10822
10823 /*
10824 Skip Dfs Channel in case of P2P Search
10825 if it is set in ini file
10826 */
10827 if(cfg_param->skipDfsChnlInP2pSearch)
10828 {
10829 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010830 }
10831 else
10832 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010833 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010834 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010835
Agarwal Ashish4f616132013-12-30 23:32:50 +053010836 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010837 }
10838 }
10839
10840 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
10841
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010842#ifdef FEATURE_WLAN_TDLS
10843 /* if tdls disagree scan right now, return immediately.
10844 tdls will schedule the scan when scan is allowed. (return SUCCESS)
10845 or will reject the scan if any TDLS is in progress. (return -EBUSY)
10846 */
10847 status = wlan_hdd_tdls_scan_callback (pAdapter,
10848 wiphy,
10849#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10850 dev,
10851#endif
10852 request);
10853 if(status <= 0)
10854 {
10855 if(!status)
10856 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
10857 "scan rejected %d", __func__, status);
10858 else
10859 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
10860 __func__, status);
10861
10862 return status;
10863 }
10864#endif
10865
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010866 /* acquire the wakelock to avoid the apps suspend during the scan. To
10867 * address the following issues.
10868 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
10869 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
10870 * for long time, this result in apps running at full power for long time.
10871 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
10872 * be stuck in full power because of resume BMPS
10873 */
10874 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -070010875
Nirav Shah20ac06f2013-12-12 18:14:06 +053010876 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10877 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010878 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
10879 scanRequest.requestType, scanRequest.scanType,
10880 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053010881 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
10882
Siddharth Bhal76972212014-10-15 16:22:51 +053010883 if (pHddCtx->spoofMacAddr.isEnabled)
10884 {
10885 hddLog(VOS_TRACE_LEVEL_INFO,
10886 "%s: MAC Spoofing enabled for current scan", __func__);
10887 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
10888 * to fill TxBds for probe request during current scan
10889 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053010890 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053010891 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053010892
10893 if(status != VOS_STATUS_SUCCESS)
10894 {
10895 hdd_allow_suspend();
10896 status = -EFAULT;
10897 goto free_mem;
10898 }
Siddharth Bhal76972212014-10-15 16:22:51 +053010899 }
10900
Jeff Johnsone7245742012-09-05 17:12:55 -070010901 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010902 pAdapter->sessionId, &scanRequest, &scanId,
10903 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070010904
Jeff Johnson295189b2012-06-20 16:38:30 -070010905 if (eHAL_STATUS_SUCCESS != status)
10906 {
10907 hddLog(VOS_TRACE_LEVEL_ERROR,
10908 "%s: sme_ScanRequest returned error %d", __func__, status);
10909 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010910 if(eHAL_STATUS_RESOURCES == status)
10911 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010912 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
10913 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010914 status = -EBUSY;
10915 } else {
10916 status = -EIO;
10917 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010918 hdd_allow_suspend();
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010919
10920#ifdef FEATURE_WLAN_TDLS
10921 wlan_hdd_tdls_scan_done_callback(pAdapter);
10922#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010923 goto free_mem;
10924 }
10925
10926 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010927 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010928 pAdapter->request = request;
10929 pScanInfo->scanId = scanId;
10930
10931 complete(&pScanInfo->scan_req_completion_event);
10932
10933free_mem:
10934 if( scanRequest.SSIDs.SSIDList )
10935 {
10936 vos_mem_free(scanRequest.SSIDs.SSIDList);
10937 }
10938
10939 if( channelList )
10940 vos_mem_free( channelList );
10941
10942 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010943 return status;
10944}
10945
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010946int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
10947#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10948 struct net_device *dev,
10949#endif
10950 struct cfg80211_scan_request *request)
10951{
10952 int ret;
10953
10954 vos_ssr_protect(__func__);
10955 ret = __wlan_hdd_cfg80211_scan(wiphy,
10956#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10957 dev,
10958#endif
10959 request);
10960 vos_ssr_unprotect(__func__);
10961
10962 return ret;
10963}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010964
10965void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
10966{
10967 v_U8_t iniDot11Mode =
10968 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
10969 eHddDot11Mode hddDot11Mode = iniDot11Mode;
10970
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010971 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
10972 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010973 switch ( iniDot11Mode )
10974 {
10975 case eHDD_DOT11_MODE_AUTO:
10976 case eHDD_DOT11_MODE_11ac:
10977 case eHDD_DOT11_MODE_11ac_ONLY:
10978#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053010979 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
10980 sme_IsFeatureSupportedByFW(DOT11AC) )
10981 hddDot11Mode = eHDD_DOT11_MODE_11ac;
10982 else
10983 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010984#else
10985 hddDot11Mode = eHDD_DOT11_MODE_11n;
10986#endif
10987 break;
10988 case eHDD_DOT11_MODE_11n:
10989 case eHDD_DOT11_MODE_11n_ONLY:
10990 hddDot11Mode = eHDD_DOT11_MODE_11n;
10991 break;
10992 default:
10993 hddDot11Mode = iniDot11Mode;
10994 break;
10995 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053010996#ifdef WLAN_FEATURE_AP_HT40_24G
10997 if (operationChannel > SIR_11B_CHANNEL_END)
10998#endif
10999 {
11000 /* This call decides required channel bonding mode */
11001 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011002 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11003 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011004 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011005}
11006
Jeff Johnson295189b2012-06-20 16:38:30 -070011007/*
11008 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011009 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011010 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011011int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011012 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011013{
11014 int status = 0;
11015 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011016 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011017 v_U32_t roamId;
11018 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011019 eCsrAuthType RSNAuthType;
11020
11021 ENTER();
11022
11023 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011024 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11025
11026 status = wlan_hdd_validate_context(pHddCtx);
11027 if (status)
11028 {
Yue Mae36e3552014-03-05 17:06:20 -080011029 return status;
11030 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011031
Jeff Johnson295189b2012-06-20 16:38:30 -070011032 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11033 {
11034 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11035 return -EINVAL;
11036 }
11037
11038 pRoamProfile = &pWextState->roamProfile;
11039
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011040 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011041 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011042 hdd_station_ctx_t *pHddStaCtx;
11043 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011044
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011045 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011046 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11047 {
11048 /*QoS not enabled in cfg file*/
11049 pRoamProfile->uapsd_mask = 0;
11050 }
11051 else
11052 {
11053 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011054 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11056 }
11057
11058 pRoamProfile->SSIDs.numOfSSIDs = 1;
11059 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11060 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011061 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011062 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11063 ssid, ssid_len);
11064
11065 if (bssid)
11066 {
11067 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11068 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11069 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011070 /* Save BSSID in seperate variable as well, as RoamProfile
11071 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011072 case of join failure we should send valid BSSID to supplicant
11073 */
11074 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11075 WNI_CFG_BSSID_LEN);
11076 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011077 else
11078 {
11079 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11080 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011081
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011082 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11083 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011084 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11085 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011086 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011087 /*set gen ie*/
11088 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11089 /*set auth*/
11090 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11091 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011092#ifdef FEATURE_WLAN_WAPI
11093 if (pAdapter->wapi_info.nWapiMode)
11094 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011095 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011096 switch (pAdapter->wapi_info.wapiAuthMode)
11097 {
11098 case WAPI_AUTH_MODE_PSK:
11099 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011100 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011101 pAdapter->wapi_info.wapiAuthMode);
11102 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11103 break;
11104 }
11105 case WAPI_AUTH_MODE_CERT:
11106 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011107 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011108 pAdapter->wapi_info.wapiAuthMode);
11109 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11110 break;
11111 }
11112 } // End of switch
11113 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11114 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11115 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011116 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011117 pRoamProfile->AuthType.numEntries = 1;
11118 pRoamProfile->EncryptionType.numEntries = 1;
11119 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11120 pRoamProfile->mcEncryptionType.numEntries = 1;
11121 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11122 }
11123 }
11124#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011125#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011126 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011127 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11128 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11129 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011130 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11131 sizeof (tSirGtkOffloadParams));
11132 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011133 }
11134#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011135 pRoamProfile->csrPersona = pAdapter->device_mode;
11136
Jeff Johnson32d95a32012-09-10 13:15:23 -070011137 if( operatingChannel )
11138 {
11139 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11140 pRoamProfile->ChannelInfo.numOfChannels = 1;
11141 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011142 else
11143 {
11144 pRoamProfile->ChannelInfo.ChannelList = NULL;
11145 pRoamProfile->ChannelInfo.numOfChannels = 0;
11146 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011147 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11148 {
11149 hdd_select_cbmode(pAdapter,operatingChannel);
11150 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011151
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011152 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
11153 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011154 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011155 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011156 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
11157 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011158 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11159 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011160 {
11161 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11162 "%s: Set HDD connState to eConnectionState_Connecting",
11163 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011164 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11165 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011166 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011167 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011168 pAdapter->sessionId, pRoamProfile, &roamId);
11169
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011170 if ((eHAL_STATUS_SUCCESS != status) &&
11171 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11172 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011173
11174 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011175 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
11176 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
11177 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011178 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011179 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011180 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011181
11182 pRoamProfile->ChannelInfo.ChannelList = NULL;
11183 pRoamProfile->ChannelInfo.numOfChannels = 0;
11184
Jeff Johnson295189b2012-06-20 16:38:30 -070011185 }
11186 else
11187 {
11188 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11189 return -EINVAL;
11190 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011191 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011192 return status;
11193}
11194
11195/*
11196 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11197 * This function is used to set the authentication type (OPEN/SHARED).
11198 *
11199 */
11200static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11201 enum nl80211_auth_type auth_type)
11202{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011203 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011204 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11205
11206 ENTER();
11207
11208 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011209 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011210 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011211 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011212 hddLog(VOS_TRACE_LEVEL_INFO,
11213 "%s: set authentication type to AUTOSWITCH", __func__);
11214 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11215 break;
11216
11217 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011218#ifdef WLAN_FEATURE_VOWIFI_11R
11219 case NL80211_AUTHTYPE_FT:
11220#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011221 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011222 "%s: set authentication type to OPEN", __func__);
11223 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11224 break;
11225
11226 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011227 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011228 "%s: set authentication type to SHARED", __func__);
11229 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11230 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011231#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011232 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011233 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011234 "%s: set authentication type to CCKM WPA", __func__);
11235 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11236 break;
11237#endif
11238
11239
11240 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011241 hddLog(VOS_TRACE_LEVEL_ERROR,
11242 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011243 auth_type);
11244 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11245 return -EINVAL;
11246 }
11247
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011248 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011249 pHddStaCtx->conn_info.authType;
11250 return 0;
11251}
11252
11253/*
11254 * FUNCTION: wlan_hdd_set_akm_suite
11255 * This function is used to set the key mgmt type(PSK/8021x).
11256 *
11257 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011258static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011259 u32 key_mgmt
11260 )
11261{
11262 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11263 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011264 /* Should be in ieee802_11_defs.h */
11265#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11266#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011267 /*set key mgmt type*/
11268 switch(key_mgmt)
11269 {
11270 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011271 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011272#ifdef WLAN_FEATURE_VOWIFI_11R
11273 case WLAN_AKM_SUITE_FT_PSK:
11274#endif
11275 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011276 __func__);
11277 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11278 break;
11279
11280 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011281 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011282#ifdef WLAN_FEATURE_VOWIFI_11R
11283 case WLAN_AKM_SUITE_FT_8021X:
11284#endif
11285 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011286 __func__);
11287 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11288 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011289#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011290#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11291#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11292 case WLAN_AKM_SUITE_CCKM:
11293 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11294 __func__);
11295 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11296 break;
11297#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011298#ifndef WLAN_AKM_SUITE_OSEN
11299#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11300 case WLAN_AKM_SUITE_OSEN:
11301 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11302 __func__);
11303 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11304 break;
11305#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011306
11307 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011308 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011309 __func__, key_mgmt);
11310 return -EINVAL;
11311
11312 }
11313 return 0;
11314}
11315
11316/*
11317 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011318 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011319 * (NONE/WEP40/WEP104/TKIP/CCMP).
11320 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011321static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11322 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011323 bool ucast
11324 )
11325{
11326 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011327 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011328 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11329
11330 ENTER();
11331
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011332 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011333 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011334 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011335 __func__, cipher);
11336 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11337 }
11338 else
11339 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011340
Jeff Johnson295189b2012-06-20 16:38:30 -070011341 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011342 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011343 {
11344 case IW_AUTH_CIPHER_NONE:
11345 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11346 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011347
Jeff Johnson295189b2012-06-20 16:38:30 -070011348 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011349 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011350 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011351
Jeff Johnson295189b2012-06-20 16:38:30 -070011352 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011353 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011354 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011355
Jeff Johnson295189b2012-06-20 16:38:30 -070011356 case WLAN_CIPHER_SUITE_TKIP:
11357 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11358 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011359
Jeff Johnson295189b2012-06-20 16:38:30 -070011360 case WLAN_CIPHER_SUITE_CCMP:
11361 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11362 break;
11363#ifdef FEATURE_WLAN_WAPI
11364 case WLAN_CIPHER_SUITE_SMS4:
11365 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11366 break;
11367#endif
11368
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011369#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011370 case WLAN_CIPHER_SUITE_KRK:
11371 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11372 break;
11373#endif
11374 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011375 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011376 __func__, cipher);
11377 return -EOPNOTSUPP;
11378 }
11379 }
11380
11381 if (ucast)
11382 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011383 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011384 __func__, encryptionType);
11385 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11386 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011387 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011388 encryptionType;
11389 }
11390 else
11391 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011392 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011393 __func__, encryptionType);
11394 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11395 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11396 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11397 }
11398
11399 return 0;
11400}
11401
11402
11403/*
11404 * FUNCTION: wlan_hdd_cfg80211_set_ie
11405 * This function is used to parse WPA/RSN IE's.
11406 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011407int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
11408 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -070011409 size_t ie_len
11410 )
11411{
11412 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11413 u8 *genie = ie;
11414 v_U16_t remLen = ie_len;
11415#ifdef FEATURE_WLAN_WAPI
11416 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11417 u16 *tmp;
11418 v_U16_t akmsuiteCount;
11419 int *akmlist;
11420#endif
11421 ENTER();
11422
11423 /* clear previous assocAddIE */
11424 pWextState->assocAddIE.length = 0;
11425 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011426 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011427
11428 while (remLen >= 2)
11429 {
11430 v_U16_t eLen = 0;
11431 v_U8_t elementId;
11432 elementId = *genie++;
11433 eLen = *genie++;
11434 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011435
Arif Hussain6d2a3322013-11-17 19:50:10 -080011436 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011437 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011438
11439 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011440 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011441 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011442 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 -070011443 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011444 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 "%s: Invalid WPA IE", __func__);
11446 return -EINVAL;
11447 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011448 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011449 {
11450 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011451 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011452 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011453
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011454 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011455 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011456 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11457 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011458 VOS_ASSERT(0);
11459 return -ENOMEM;
11460 }
11461 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11462 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11463 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011464
Jeff Johnson295189b2012-06-20 16:38:30 -070011465 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11466 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11467 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11468 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011469 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11470 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011471 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11472 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11473 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11474 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11475 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11476 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011477 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011478 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011479 {
11480 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011481 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011482 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011483
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011484 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011485 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011486 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11487 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011488 VOS_ASSERT(0);
11489 return -ENOMEM;
11490 }
11491 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11492 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11493 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011494
Jeff Johnson295189b2012-06-20 16:38:30 -070011495 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11496 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11497 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011498#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011499 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11500 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011501 /*Consider WFD IE, only for P2P Client */
11502 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11503 {
11504 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011505 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011506 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011507
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011508 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011509 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011510 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11511 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 VOS_ASSERT(0);
11513 return -ENOMEM;
11514 }
11515 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11516 // WPS IE + P2P IE + WFD IE
11517 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11518 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011519
Jeff Johnson295189b2012-06-20 16:38:30 -070011520 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11521 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11522 }
11523#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011524 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011525 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011526 HS20_OUI_TYPE_SIZE)) )
11527 {
11528 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011529 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011530 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011531
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011532 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011533 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011534 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11535 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011536 VOS_ASSERT(0);
11537 return -ENOMEM;
11538 }
11539 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11540 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011541
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011542 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11543 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11544 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011545 /* Appending OSEN Information Element in Assiciation Request */
11546 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11547 OSEN_OUI_TYPE_SIZE)) )
11548 {
11549 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11550 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11551 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011552
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011553 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011554 {
11555 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11556 "Need bigger buffer space");
11557 VOS_ASSERT(0);
11558 return -ENOMEM;
11559 }
11560 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11561 pWextState->assocAddIE.length += eLen + 2;
11562
11563 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11564 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11565 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11566 }
11567
11568 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011569 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
11570
11571 /* populating as ADDIE in beacon frames */
11572 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11573 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
11574 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11575 {
11576 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11577 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11578 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11579 {
11580 hddLog(LOGE,
11581 "Coldn't pass "
11582 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11583 }
11584 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11585 else
11586 hddLog(LOGE,
11587 "Could not pass on "
11588 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11589
11590 /* IBSS mode doesn't contain params->proberesp_ies still
11591 beaconIE's need to be populated in probe response frames */
11592 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11593 {
11594 u16 rem_probe_resp_ie_len = eLen + 2;
11595 u8 probe_rsp_ie_len[3] = {0};
11596 u8 counter = 0;
11597
11598 /* Check Probe Resp Length if it is greater then 255 then
11599 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11600 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11601 not able Store More then 255 bytes into One Variable */
11602
11603 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11604 {
11605 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11606 {
11607 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11608 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11609 }
11610 else
11611 {
11612 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11613 rem_probe_resp_ie_len = 0;
11614 }
11615 }
11616
11617 rem_probe_resp_ie_len = 0;
11618
11619 if (probe_rsp_ie_len[0] > 0)
11620 {
11621 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11622 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11623 (tANI_U8*)(genie - 2),
11624 probe_rsp_ie_len[0], NULL,
11625 eANI_BOOLEAN_FALSE)
11626 == eHAL_STATUS_FAILURE)
11627 {
11628 hddLog(LOGE,
11629 "Could not pass"
11630 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11631 }
11632 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11633 }
11634
11635 if (probe_rsp_ie_len[1] > 0)
11636 {
11637 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11638 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11639 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11640 probe_rsp_ie_len[1], NULL,
11641 eANI_BOOLEAN_FALSE)
11642 == eHAL_STATUS_FAILURE)
11643 {
11644 hddLog(LOGE,
11645 "Could not pass"
11646 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11647 }
11648 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11649 }
11650
11651 if (probe_rsp_ie_len[2] > 0)
11652 {
11653 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11654 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11655 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11656 probe_rsp_ie_len[2], NULL,
11657 eANI_BOOLEAN_FALSE)
11658 == eHAL_STATUS_FAILURE)
11659 {
11660 hddLog(LOGE,
11661 "Could not pass"
11662 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11663 }
11664 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11665 }
11666
11667 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11668 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11669 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11670 {
11671 hddLog(LOGE,
11672 "Could not pass"
11673 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
11674 }
11675 }
11676 else
11677 {
11678 // Reset WNI_CFG_PROBE_RSP Flags
11679 wlan_hdd_reset_prob_rspies(pAdapter);
11680
11681 hddLog(VOS_TRACE_LEVEL_INFO,
11682 "%s: No Probe Response IE received in set beacon",
11683 __func__);
11684 }
11685 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011686 break;
11687 case DOT11F_EID_RSN:
11688 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
11689 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11690 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
11691 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
11692 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
11693 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053011694
11695 /* Appending Extended Capabilities with Interworking bit set
11696 * in Assoc Req.
11697 *
11698 * In assoc req this EXT Cap will only be taken into account if
11699 * interworkingService bit is set to 1. Currently
11700 * driver is only interested in interworkingService capability
11701 * from supplicant. If in future any other EXT Cap info is
11702 * required from supplicat, it needs to be handled while
11703 * sending Assoc Req in LIM.
11704 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011705 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011706 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011707 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011708 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011709 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011710
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011711 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011712 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011713 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11714 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011715 VOS_ASSERT(0);
11716 return -ENOMEM;
11717 }
11718 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11719 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011720
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011721 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11722 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11723 break;
11724 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011725#ifdef FEATURE_WLAN_WAPI
11726 case WLAN_EID_WAPI:
11727 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011728 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011729 pAdapter->wapi_info.nWapiMode);
11730 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011731 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070011732 akmsuiteCount = WPA_GET_LE16(tmp);
11733 tmp = tmp + 1;
11734 akmlist = (int *)(tmp);
11735 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
11736 {
11737 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
11738 }
11739 else
11740 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011741 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070011742 VOS_ASSERT(0);
11743 return -EINVAL;
11744 }
11745
11746 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
11747 {
11748 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011749 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011750 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011751 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011752 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011753 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011754 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011755 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
11757 }
11758 break;
11759#endif
11760 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011761 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011763 /* when Unknown IE is received we should break and continue
11764 * to the next IE in the buffer instead we were returning
11765 * so changing this to break */
11766 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011767 }
11768 genie += eLen;
11769 remLen -= eLen;
11770 }
11771 EXIT();
11772 return 0;
11773}
11774
11775/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053011776 * FUNCTION: hdd_isWPAIEPresent
11777 * Parse the received IE to find the WPA IE
11778 *
11779 */
11780static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
11781{
11782 v_U8_t eLen = 0;
11783 v_U16_t remLen = ie_len;
11784 v_U8_t elementId = 0;
11785
11786 while (remLen >= 2)
11787 {
11788 elementId = *ie++;
11789 eLen = *ie++;
11790 remLen -= 2;
11791 if (eLen > remLen)
11792 {
11793 hddLog(VOS_TRACE_LEVEL_ERROR,
11794 "%s: IE length is wrong %d", __func__, eLen);
11795 return FALSE;
11796 }
11797 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
11798 {
11799 /* OUI - 0x00 0X50 0XF2
11800 WPA Information Element - 0x01
11801 WPA version - 0x01*/
11802 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
11803 return TRUE;
11804 }
11805 ie += eLen;
11806 remLen -= eLen;
11807 }
11808 return FALSE;
11809}
11810
11811/*
Jeff Johnson295189b2012-06-20 16:38:30 -070011812 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011813 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011814 * parameters during connect operation.
11815 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011816int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011817 struct cfg80211_connect_params *req
11818 )
11819{
11820 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011821 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011822 ENTER();
11823
11824 /*set wpa version*/
11825 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11826
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011827 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011828 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053011829 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011830 {
11831 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11832 }
11833 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
11834 {
11835 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11836 }
11837 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011838
11839 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011840 pWextState->wpaVersion);
11841
11842 /*set authentication type*/
11843 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
11844
11845 if (0 > status)
11846 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011847 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011848 "%s: failed to set authentication type ", __func__);
11849 return status;
11850 }
11851
11852 /*set key mgmt type*/
11853 if (req->crypto.n_akm_suites)
11854 {
11855 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
11856 if (0 > status)
11857 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011858 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070011859 __func__);
11860 return status;
11861 }
11862 }
11863
11864 /*set pairwise cipher type*/
11865 if (req->crypto.n_ciphers_pairwise)
11866 {
11867 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
11868 req->crypto.ciphers_pairwise[0], true);
11869 if (0 > status)
11870 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011871 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011872 "%s: failed to set unicast cipher type", __func__);
11873 return status;
11874 }
11875 }
11876 else
11877 {
11878 /*Reset previous cipher suite to none*/
11879 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
11880 if (0 > status)
11881 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011882 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011883 "%s: failed to set unicast cipher type", __func__);
11884 return status;
11885 }
11886 }
11887
11888 /*set group cipher type*/
11889 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
11890 false);
11891
11892 if (0 > status)
11893 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011894 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070011895 __func__);
11896 return status;
11897 }
11898
Chet Lanctot186b5732013-03-18 10:26:30 -070011899#ifdef WLAN_FEATURE_11W
11900 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
11901#endif
11902
Jeff Johnson295189b2012-06-20 16:38:30 -070011903 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
11904 if (req->ie_len)
11905 {
11906 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
11907 if ( 0 > status)
11908 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011909 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070011910 __func__);
11911 return status;
11912 }
11913 }
11914
11915 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011916 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011917 {
11918 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
11919 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
11920 )
11921 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011922 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070011923 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
11924 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011925 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070011926 __func__);
11927 return -EOPNOTSUPP;
11928 }
11929 else
11930 {
11931 u8 key_len = req->key_len;
11932 u8 key_idx = req->key_idx;
11933
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011934 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011935 && (CSR_MAX_NUM_KEY > key_idx)
11936 )
11937 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011938 hddLog(VOS_TRACE_LEVEL_INFO,
11939 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011940 __func__, key_idx, key_len);
11941 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011942 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011943 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011944 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011945 (u8)key_len;
11946 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
11947 }
11948 }
11949 }
11950 }
11951
11952 return status;
11953}
11954
11955/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011956 * FUNCTION: wlan_hdd_try_disconnect
11957 * This function is used to disconnect from previous
11958 * connection
11959 */
11960static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
11961{
11962 long ret = 0;
11963 hdd_station_ctx_t *pHddStaCtx;
11964 eMib_dot11DesiredBssType connectedBssType;
11965
11966 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11967
11968 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
11969
11970 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
11971 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
11972 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
11973 {
11974 /* Issue disconnect to CSR */
11975 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11976 if( eHAL_STATUS_SUCCESS ==
11977 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
11978 pAdapter->sessionId,
11979 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
11980 {
11981 ret = wait_for_completion_interruptible_timeout(
11982 &pAdapter->disconnect_comp_var,
11983 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11984 if (0 >= ret)
11985 {
11986 hddLog(LOGE, FL("Failed to receive disconnect event"));
11987 return -EALREADY;
11988 }
11989 }
11990 }
11991 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
11992 {
11993 ret = wait_for_completion_interruptible_timeout(
11994 &pAdapter->disconnect_comp_var,
11995 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11996 if (0 >= ret)
11997 {
11998 hddLog(LOGE, FL("Failed to receive disconnect event"));
11999 return -EALREADY;
12000 }
12001 }
12002
12003 return 0;
12004}
12005
12006/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012007 * FUNCTION: __wlan_hdd_cfg80211_connect
12008 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012009 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012010static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012011 struct net_device *ndev,
12012 struct cfg80211_connect_params *req
12013 )
12014{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012015 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012016 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012017 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012018 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012019
12020 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012021
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012022 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12023 TRACE_CODE_HDD_CFG80211_CONNECT,
12024 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012025 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012026 "%s: device_mode = %s (%d)", __func__,
12027 hdd_device_modetoString(pAdapter->device_mode),
12028 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012029
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012030 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012031 if (!pHddCtx)
12032 {
12033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12034 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012035 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012036 }
12037
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012038 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012039 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012040 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012041 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012042 }
12043
Agarwal Ashish51325b52014-06-16 16:50:49 +053012044 if (vos_max_concurrent_connections_reached()) {
12045 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12046 return -ECONNREFUSED;
12047 }
12048
Jeff Johnson295189b2012-06-20 16:38:30 -070012049#ifdef WLAN_BTAMP_FEATURE
12050 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012051 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012053 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012054 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012055 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012056 }
12057#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012058
12059 //If Device Mode is Station Concurrent Sessions Exit BMps
12060 //P2P Mode will be taken care in Open/close adapter
12061 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012062 (vos_concurrent_open_sessions_running())) {
12063 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12064 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012065 }
12066
12067 /*Try disconnecting if already in connected state*/
12068 status = wlan_hdd_try_disconnect(pAdapter);
12069 if ( 0 > status)
12070 {
12071 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12072 " connection"));
12073 return -EALREADY;
12074 }
12075
Jeff Johnson295189b2012-06-20 16:38:30 -070012076 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012077 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012078
12079 if ( 0 > status)
12080 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012081 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 __func__);
12083 return status;
12084 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012085 if ( req->channel )
12086 {
12087 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12088 req->ssid_len, req->bssid,
12089 req->channel->hw_value);
12090 }
12091 else
12092 {
12093 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012094 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012096
Sushant Kaushikd7083982015-03-18 14:33:24 +053012097 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012098 {
12099 //ReEnable BMPS if disabled
12100 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12101 (NULL != pHddCtx))
12102 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012103 if (pHddCtx->hdd_wlan_suspended)
12104 {
12105 hdd_set_pwrparams(pHddCtx);
12106 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012107 //ReEnable Bmps and Imps back
12108 hdd_enable_bmps_imps(pHddCtx);
12109 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012110 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012111 return status;
12112 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012113 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012114 EXIT();
12115 return status;
12116}
12117
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012118static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12119 struct net_device *ndev,
12120 struct cfg80211_connect_params *req)
12121{
12122 int ret;
12123 vos_ssr_protect(__func__);
12124 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12125 vos_ssr_unprotect(__func__);
12126
12127 return ret;
12128}
Jeff Johnson295189b2012-06-20 16:38:30 -070012129
12130/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012131 * FUNCTION: wlan_hdd_disconnect
12132 * This function is used to issue a disconnect request to SME
12133 */
12134int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12135{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012136 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012137 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012138 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012139 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012140
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012141 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012142
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012143 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012144 if (0 != status)
12145 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012146 return status;
12147 }
12148
12149 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012150
Agarwal Ashish47d18112014-08-04 19:55:07 +053012151 /* Need to apply spin lock before decreasing active sessions
12152 * as there can be chance for double decrement if context switch
12153 * Calls hdd_DisConnectHandler.
12154 */
12155
12156 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012157 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12158 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012159 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12160 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012161 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12162 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012163
Abhishek Singhf4669da2014-05-26 15:07:49 +053012164 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012165 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12166
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012167 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012168
Mihir Shete182a0b22014-08-18 16:08:48 +053012169 /*
12170 * stop tx queues before deleting STA/BSS context from the firmware.
12171 * tx has to be disabled because the firmware can get busy dropping
12172 * the tx frames after BSS/STA has been deleted and will not send
12173 * back a response resulting in WDI timeout
12174 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012175 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012176 netif_tx_disable(pAdapter->dev);
12177 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012178
Mihir Shete182a0b22014-08-18 16:08:48 +053012179 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012180 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12181 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012182 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12183 {
12184 hddLog(VOS_TRACE_LEVEL_INFO,
12185 FL("status = %d, already disconnected"),
12186 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012187
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012188 }
12189 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012190 {
12191 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012192 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012193 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012194 result = -EINVAL;
12195 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012196 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012197 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012198 &pAdapter->disconnect_comp_var,
12199 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012200 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012201 {
12202 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012203 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012204 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012205 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012206 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012207 {
12208 hddLog(VOS_TRACE_LEVEL_ERROR,
12209 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012210 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012211 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012212disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012213 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12214 FL("Set HDD connState to eConnectionState_NotConnected"));
12215 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12216
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012217 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012218 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012219}
12220
12221
12222/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012223 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012224 * This function is used to issue a disconnect request to SME
12225 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012226static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012227 struct net_device *dev,
12228 u16 reason
12229 )
12230{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012231 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012232 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012233 tCsrRoamProfile *pRoamProfile;
12234 hdd_station_ctx_t *pHddStaCtx;
12235 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012236#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012237 tANI_U8 staIdx;
12238#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012239
Jeff Johnson295189b2012-06-20 16:38:30 -070012240 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012241
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012242 if (!pAdapter) {
12243 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12244 return -EINVAL;
12245 }
12246
12247 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12248 if (!pHddStaCtx) {
12249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12250 return -EINVAL;
12251 }
12252
12253 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12254 status = wlan_hdd_validate_context(pHddCtx);
12255 if (0 != status)
12256 {
12257 return status;
12258 }
12259
12260 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12261
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012262 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12263 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12264 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012265 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12266 __func__, hdd_device_modetoString(pAdapter->device_mode),
12267 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012268
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012269 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12270 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012271
Jeff Johnson295189b2012-06-20 16:38:30 -070012272 if (NULL != pRoamProfile)
12273 {
12274 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012275 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12276 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012277 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012278 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012279 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012280 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012281 switch(reason)
12282 {
12283 case WLAN_REASON_MIC_FAILURE:
12284 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12285 break;
12286
12287 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12288 case WLAN_REASON_DISASSOC_AP_BUSY:
12289 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12290 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12291 break;
12292
12293 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12294 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012295 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012296 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12297 break;
12298
Jeff Johnson295189b2012-06-20 16:38:30 -070012299 default:
12300 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12301 break;
12302 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012303 pScanInfo = &pHddCtx->scan_info;
12304 if (pScanInfo->mScanPending)
12305 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012306 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012307 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012308 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012309 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012311
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012312#ifdef FEATURE_WLAN_TDLS
12313 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012314 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012315 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012316 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12317 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012318 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012319 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012320 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012322 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012323 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012324 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012325 status = sme_DeleteTdlsPeerSta(
12326 WLAN_HDD_GET_HAL_CTX(pAdapter),
12327 pAdapter->sessionId,
12328 mac);
12329 if (status != eHAL_STATUS_SUCCESS) {
12330 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12331 return -EPERM;
12332 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012333 }
12334 }
12335#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012336 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012337 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12338 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 {
12340 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012341 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012342 __func__, (int)status );
12343 return -EINVAL;
12344 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012345 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012346 else
12347 {
12348 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12349 "called while in %d state", __func__,
12350 pHddStaCtx->conn_info.connState);
12351 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012352 }
12353 else
12354 {
12355 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12356 }
12357
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012358 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012359 return status;
12360}
12361
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012362static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12363 struct net_device *dev,
12364 u16 reason
12365 )
12366{
12367 int ret;
12368 vos_ssr_protect(__func__);
12369 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12370 vos_ssr_unprotect(__func__);
12371
12372 return ret;
12373}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012374
Jeff Johnson295189b2012-06-20 16:38:30 -070012375/*
12376 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012377 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012378 * settings in IBSS mode.
12379 */
12380static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012381 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012382 struct cfg80211_ibss_params *params
12383 )
12384{
12385 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012386 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012387 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12388 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012389
Jeff Johnson295189b2012-06-20 16:38:30 -070012390 ENTER();
12391
12392 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012393 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012394
12395 if (params->ie_len && ( NULL != params->ie) )
12396 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012397 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12398 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012399 {
12400 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12401 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12402 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012403 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012404 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012405 tDot11fIEWPA dot11WPAIE;
12406 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012407 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012408
Wilson Yang00256342013-10-10 23:13:38 -070012409 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012410 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12411 params->ie_len, DOT11F_EID_WPA);
12412 if ( NULL != ie )
12413 {
12414 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12415 // Unpack the WPA IE
12416 //Skip past the EID byte and length byte - and four byte WiFi OUI
12417 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12418 &ie[2+4],
12419 ie[1] - 4,
12420 &dot11WPAIE);
12421 /*Extract the multicast cipher, the encType for unicast
12422 cipher for wpa-none is none*/
12423 encryptionType =
12424 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12425 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012427
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12429
12430 if (0 > status)
12431 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012432 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012433 __func__);
12434 return status;
12435 }
12436 }
12437
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012438 pWextState->roamProfile.AuthType.authType[0] =
12439 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012440 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12441
12442 if (params->privacy)
12443 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012444 /* Security enabled IBSS, At this time there is no information available
12445 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012447 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012448 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012449 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012450 *enable privacy bit in beacons */
12451
12452 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12453 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012454 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12455 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012456 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12457 pWextState->roamProfile.EncryptionType.numEntries = 1;
12458 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012459 return status;
12460}
12461
12462/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012463 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012464 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012466static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012467 struct net_device *dev,
12468 struct cfg80211_ibss_params *params
12469 )
12470{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012471 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12473 tCsrRoamProfile *pRoamProfile;
12474 int status;
krunal sonie9002db2013-11-25 14:24:17 -080012475 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012476 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12477 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012478
12479 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012480
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012481 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12482 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12483 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012484 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012485 "%s: device_mode = %s (%d)", __func__,
12486 hdd_device_modetoString(pAdapter->device_mode),
12487 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012488
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012489 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012490 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012491 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012492 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012493 }
12494
12495 if (NULL == pWextState)
12496 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012497 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012498 __func__);
12499 return -EIO;
12500 }
12501
Agarwal Ashish51325b52014-06-16 16:50:49 +053012502 if (vos_max_concurrent_connections_reached()) {
12503 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12504 return -ECONNREFUSED;
12505 }
12506
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012507 /*Try disconnecting if already in connected state*/
12508 status = wlan_hdd_try_disconnect(pAdapter);
12509 if ( 0 > status)
12510 {
12511 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12512 " IBSS connection"));
12513 return -EALREADY;
12514 }
12515
Jeff Johnson295189b2012-06-20 16:38:30 -070012516 pRoamProfile = &pWextState->roamProfile;
12517
12518 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12519 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012520 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012521 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 return -EINVAL;
12523 }
12524
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012525 /* BSSID is provided by upper layers hence no need to AUTO generate */
12526 if (NULL != params->bssid) {
12527 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12528 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12529 hddLog (VOS_TRACE_LEVEL_ERROR,
12530 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12531 return -EIO;
12532 }
12533 }
krunal sonie9002db2013-11-25 14:24:17 -080012534 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12535 {
12536 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12537 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12538 {
12539 hddLog (VOS_TRACE_LEVEL_ERROR,
12540 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12541 return -EIO;
12542 }
Sachin Ahuja46ff4912015-03-23 22:48:43 +053012543 params->bssid = vos_mem_malloc(VOS_MAC_ADDR_SIZE);
krunal sonie9002db2013-11-25 14:24:17 -080012544 if (!params->bssid)
12545 {
12546 hddLog (VOS_TRACE_LEVEL_ERROR,
12547 "%s:Failed memory allocation", __func__);
12548 return -EIO;
12549 }
12550 vos_mem_copy((v_U8_t *)params->bssid,
12551 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
12552 VOS_MAC_ADDR_SIZE);
12553 alloc_bssid = VOS_TRUE;
12554 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012555
Jeff Johnson295189b2012-06-20 16:38:30 -070012556 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012557 if (NULL !=
12558#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12559 params->chandef.chan)
12560#else
12561 params->channel)
12562#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012563 {
12564 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012565 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12566 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12567 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12568 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012569
12570 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012571 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012572 ieee80211_frequency_to_channel(
12573#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12574 params->chandef.chan->center_freq);
12575#else
12576 params->channel->center_freq);
12577#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012578
12579 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12580 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012581 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012582 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12583 __func__);
12584 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012585 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012586
12587 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012588 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012589 if (channelNum == validChan[indx])
12590 {
12591 break;
12592 }
12593 }
12594 if (indx >= numChans)
12595 {
12596 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 __func__, channelNum);
12598 return -EINVAL;
12599 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012600 /* Set the Operational Channel */
12601 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12602 channelNum);
12603 pRoamProfile->ChannelInfo.numOfChannels = 1;
12604 pHddStaCtx->conn_info.operationChannel = channelNum;
12605 pRoamProfile->ChannelInfo.ChannelList =
12606 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012607 }
12608
12609 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012610 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012611 if (status < 0)
12612 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012613 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012614 __func__);
12615 return status;
12616 }
12617
12618 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012619 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012620 params->ssid_len, params->bssid,
12621 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012622
12623 if (0 > status)
12624 {
12625 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
12626 return status;
12627 }
12628
krunal sonie9002db2013-11-25 14:24:17 -080012629 if (NULL != params->bssid &&
12630 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
12631 alloc_bssid == VOS_TRUE)
12632 {
12633 vos_mem_free(params->bssid);
12634 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012635 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012636 return 0;
12637}
12638
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012639static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12640 struct net_device *dev,
12641 struct cfg80211_ibss_params *params
12642 )
12643{
12644 int ret = 0;
12645
12646 vos_ssr_protect(__func__);
12647 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12648 vos_ssr_unprotect(__func__);
12649
12650 return ret;
12651}
12652
Jeff Johnson295189b2012-06-20 16:38:30 -070012653/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012654 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012655 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012656 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012657static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 struct net_device *dev
12659 )
12660{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012661 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012662 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12663 tCsrRoamProfile *pRoamProfile;
12664 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012665 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012666
12667 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012668
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012669 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12670 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12671 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012672 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012673 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012674 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012675 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012676 }
12677
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012678 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
12679 hdd_device_modetoString(pAdapter->device_mode),
12680 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 if (NULL == pWextState)
12682 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012683 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012684 __func__);
12685 return -EIO;
12686 }
12687
12688 pRoamProfile = &pWextState->roamProfile;
12689
12690 /* Issue disconnect only if interface type is set to IBSS */
12691 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
12692 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012693 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070012694 __func__);
12695 return -EINVAL;
12696 }
12697
12698 /* Issue Disconnect request */
12699 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12700 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12701 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
12702
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012703 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012704 return 0;
12705}
12706
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012707static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
12708 struct net_device *dev
12709 )
12710{
12711 int ret = 0;
12712
12713 vos_ssr_protect(__func__);
12714 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
12715 vos_ssr_unprotect(__func__);
12716
12717 return ret;
12718}
12719
Jeff Johnson295189b2012-06-20 16:38:30 -070012720/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012721 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070012722 * This function is used to set the phy parameters
12723 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
12724 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012725static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 u32 changed)
12727{
12728 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
12729 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012730 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012731
12732 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012733
12734 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012735 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
12736 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012737
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012738 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012739 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012740 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012741 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012742 }
12743
Jeff Johnson295189b2012-06-20 16:38:30 -070012744 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
12745 {
12746 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
12747 WNI_CFG_RTS_THRESHOLD_STAMAX :
12748 wiphy->rts_threshold;
12749
12750 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012751 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070012752 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012753 hddLog(VOS_TRACE_LEVEL_ERROR,
12754 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 __func__, rts_threshold);
12756 return -EINVAL;
12757 }
12758
12759 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
12760 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012761 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012762 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012763 hddLog(VOS_TRACE_LEVEL_ERROR,
12764 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012765 __func__, rts_threshold);
12766 return -EIO;
12767 }
12768
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012769 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 rts_threshold);
12771 }
12772
12773 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
12774 {
12775 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
12776 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
12777 wiphy->frag_threshold;
12778
12779 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012780 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012781 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012782 hddLog(VOS_TRACE_LEVEL_ERROR,
12783 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 frag_threshold);
12785 return -EINVAL;
12786 }
12787
12788 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
12789 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012790 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012791 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012792 hddLog(VOS_TRACE_LEVEL_ERROR,
12793 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012794 __func__, frag_threshold);
12795 return -EIO;
12796 }
12797
12798 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
12799 frag_threshold);
12800 }
12801
12802 if ((changed & WIPHY_PARAM_RETRY_SHORT)
12803 || (changed & WIPHY_PARAM_RETRY_LONG))
12804 {
12805 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
12806 wiphy->retry_short :
12807 wiphy->retry_long;
12808
12809 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
12810 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
12811 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012812 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012813 __func__, retry_value);
12814 return -EINVAL;
12815 }
12816
12817 if (changed & WIPHY_PARAM_RETRY_SHORT)
12818 {
12819 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
12820 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012821 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012822 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012823 hddLog(VOS_TRACE_LEVEL_ERROR,
12824 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 __func__, retry_value);
12826 return -EIO;
12827 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012828 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012829 __func__, retry_value);
12830 }
12831 else if (changed & WIPHY_PARAM_RETRY_SHORT)
12832 {
12833 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
12834 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012835 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012836 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012837 hddLog(VOS_TRACE_LEVEL_ERROR,
12838 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012839 __func__, retry_value);
12840 return -EIO;
12841 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012842 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012843 __func__, retry_value);
12844 }
12845 }
12846
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012847 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012848 return 0;
12849}
12850
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012851static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
12852 u32 changed)
12853{
12854 int ret;
12855
12856 vos_ssr_protect(__func__);
12857 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
12858 vos_ssr_unprotect(__func__);
12859
12860 return ret;
12861}
12862
Jeff Johnson295189b2012-06-20 16:38:30 -070012863/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012864 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070012865 * This function is used to set the txpower
12866 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012867static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070012868#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12869 struct wireless_dev *wdev,
12870#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012871#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012872 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070012873#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012874 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070012875#endif
12876 int dbm)
12877{
12878 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012879 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012880 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
12881 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012882 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012883
12884 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012885
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012886 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12887 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
12888 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012889 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012890 if (0 != status)
12891 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012892 return status;
12893 }
12894
12895 hHal = pHddCtx->hHal;
12896
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012897 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
12898 dbm, ccmCfgSetCallback,
12899 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012900 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012901 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012902 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
12903 return -EIO;
12904 }
12905
12906 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
12907 dbm);
12908
12909 switch(type)
12910 {
12911 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
12912 /* Fall through */
12913 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
12914 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
12915 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012916 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
12917 __func__);
12918 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012919 }
12920 break;
12921 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012922 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012923 __func__);
12924 return -EOPNOTSUPP;
12925 break;
12926 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012927 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
12928 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070012929 return -EIO;
12930 }
12931
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012932 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 return 0;
12934}
12935
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012936static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
12937#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12938 struct wireless_dev *wdev,
12939#endif
12940#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12941 enum tx_power_setting type,
12942#else
12943 enum nl80211_tx_power_setting type,
12944#endif
12945 int dbm)
12946{
12947 int ret;
12948 vos_ssr_protect(__func__);
12949 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
12950#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12951 wdev,
12952#endif
12953#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12954 type,
12955#else
12956 type,
12957#endif
12958 dbm);
12959 vos_ssr_unprotect(__func__);
12960
12961 return ret;
12962}
12963
Jeff Johnson295189b2012-06-20 16:38:30 -070012964/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012965 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 * This function is used to read the txpower
12967 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012968static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070012969#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12970 struct wireless_dev *wdev,
12971#endif
12972 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070012973{
12974
12975 hdd_adapter_t *pAdapter;
12976 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012977 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012978
Jeff Johnsone7245742012-09-05 17:12:55 -070012979 ENTER();
12980
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012981 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012982 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012983 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012984 *dbm = 0;
12985 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012986 }
12987
Jeff Johnson295189b2012-06-20 16:38:30 -070012988 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
12989 if (NULL == pAdapter)
12990 {
12991 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
12992 return -ENOENT;
12993 }
12994
12995 wlan_hdd_get_classAstats(pAdapter);
12996 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
12997
Jeff Johnsone7245742012-09-05 17:12:55 -070012998 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012999 return 0;
13000}
13001
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013002static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13003#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13004 struct wireless_dev *wdev,
13005#endif
13006 int *dbm)
13007{
13008 int ret;
13009
13010 vos_ssr_protect(__func__);
13011 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13012#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13013 wdev,
13014#endif
13015 dbm);
13016 vos_ssr_unprotect(__func__);
13017
13018 return ret;
13019}
13020
13021
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013022static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 u8* mac, struct station_info *sinfo)
13024{
13025 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13026 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13027 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013028 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013029
13030 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13031 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013032
13033 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13034 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13035 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13036 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13037 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13038 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13039 tANI_U16 maxRate = 0;
13040 tANI_U16 myRate;
13041 tANI_U16 currentRate = 0;
13042 tANI_U8 maxSpeedMCS = 0;
13043 tANI_U8 maxMCSIdx = 0;
13044 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013045 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013046 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013047 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013048
Leo Chang6f8870f2013-03-26 18:11:36 -070013049#ifdef WLAN_FEATURE_11AC
13050 tANI_U32 vht_mcs_map;
13051 eDataRate11ACMaxMcs vhtMaxMcs;
13052#endif /* WLAN_FEATURE_11AC */
13053
Jeff Johnsone7245742012-09-05 17:12:55 -070013054 ENTER();
13055
Jeff Johnson295189b2012-06-20 16:38:30 -070013056 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13057 (0 == ssidlen))
13058 {
13059 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13060 " Invalid ssidlen, %d", __func__, ssidlen);
13061 /*To keep GUI happy*/
13062 return 0;
13063 }
13064
Mukul Sharma811205f2014-07-09 21:07:30 +053013065 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13066 {
13067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13068 "%s: Roaming in progress, so unable to proceed this request", __func__);
13069 return 0;
13070 }
13071
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013072 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013073 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013074 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013075 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013076 }
13077
Jeff Johnson295189b2012-06-20 16:38:30 -070013078
Kiet Lam3b17fc82013-09-27 05:24:08 +053013079 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13080 sinfo->filled |= STATION_INFO_SIGNAL;
13081
c_hpothu09f19542014-05-30 21:53:31 +053013082 wlan_hdd_get_station_stats(pAdapter);
13083 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
13084
13085 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013086 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13087 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013088 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013089 {
13090 rate_flags = pAdapter->maxRateFlags;
13091 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013092
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 //convert to the UI units of 100kbps
13094 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13095
13096#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013097 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 -070013098 sinfo->signal,
13099 pCfg->reportMaxLinkSpeed,
13100 myRate,
13101 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013102 (int) pCfg->linkSpeedRssiMid,
13103 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013104 (int) rate_flags,
13105 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013106#endif //LINKSPEED_DEBUG_ENABLED
13107
13108 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13109 {
13110 // we do not want to necessarily report the current speed
13111 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13112 {
13113 // report the max possible speed
13114 rssidx = 0;
13115 }
13116 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13117 {
13118 // report the max possible speed with RSSI scaling
13119 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13120 {
13121 // report the max possible speed
13122 rssidx = 0;
13123 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013124 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013125 {
13126 // report middle speed
13127 rssidx = 1;
13128 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013129 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13130 {
13131 // report middle speed
13132 rssidx = 2;
13133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013134 else
13135 {
13136 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013137 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 }
13139 }
13140 else
13141 {
13142 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13143 hddLog(VOS_TRACE_LEVEL_ERROR,
13144 "%s: Invalid value for reportMaxLinkSpeed: %u",
13145 __func__, pCfg->reportMaxLinkSpeed);
13146 rssidx = 0;
13147 }
13148
13149 maxRate = 0;
13150
13151 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013152 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13153 OperationalRates, &ORLeng))
13154 {
13155 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13156 /*To keep GUI happy*/
13157 return 0;
13158 }
13159
Jeff Johnson295189b2012-06-20 16:38:30 -070013160 for (i = 0; i < ORLeng; i++)
13161 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013162 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013163 {
13164 /* Validate Rate Set */
13165 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13166 {
13167 currentRate = supported_data_rate[j].supported_rate[rssidx];
13168 break;
13169 }
13170 }
13171 /* Update MAX rate */
13172 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13173 }
13174
13175 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013176 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13177 ExtendedRates, &ERLeng))
13178 {
13179 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13180 /*To keep GUI happy*/
13181 return 0;
13182 }
13183
Jeff Johnson295189b2012-06-20 16:38:30 -070013184 for (i = 0; i < ERLeng; i++)
13185 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013186 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 {
13188 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13189 {
13190 currentRate = supported_data_rate[j].supported_rate[rssidx];
13191 break;
13192 }
13193 }
13194 /* Update MAX rate */
13195 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13196 }
c_hpothu79aab322014-07-14 21:11:01 +053013197
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013198 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013199 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013200 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013201 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 {
c_hpothu79aab322014-07-14 21:11:01 +053013203 if (rate_flags & eHAL_TX_RATE_VHT80)
13204 mode = 2;
13205 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13206 mode = 1;
13207 else
13208 mode = 0;
13209
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013210 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13211 MCSRates, &MCSLeng))
13212 {
13213 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13214 /*To keep GUI happy*/
13215 return 0;
13216 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013217 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013218#ifdef WLAN_FEATURE_11AC
13219 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013220 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013221 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013222 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013223 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013224 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013225 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013226 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013227 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013228 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013230 maxMCSIdx = 7;
13231 }
13232 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13233 {
13234 maxMCSIdx = 8;
13235 }
13236 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13237 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013238 //VHT20 is supporting 0~8
13239 if (rate_flags & eHAL_TX_RATE_VHT20)
13240 maxMCSIdx = 8;
13241 else
13242 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013243 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013244
c_hpothu79aab322014-07-14 21:11:01 +053013245 if (0 != rssidx)/*check for scaled */
13246 {
13247 //get middle rate MCS index if rssi=1/2
13248 for (i=0; i <= maxMCSIdx; i++)
13249 {
13250 if (sinfo->signal <= rssiMcsTbl[mode][i])
13251 {
13252 maxMCSIdx = i;
13253 break;
13254 }
13255 }
13256 }
13257
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013258 if (rate_flags & eHAL_TX_RATE_VHT80)
13259 {
13260 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13261 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13262 }
13263 else if (rate_flags & eHAL_TX_RATE_VHT40)
13264 {
13265 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13266 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13267 }
13268 else if (rate_flags & eHAL_TX_RATE_VHT20)
13269 {
13270 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13271 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13272 }
13273
Leo Chang6f8870f2013-03-26 18:11:36 -070013274 maxSpeedMCS = 1;
13275 if (currentRate > maxRate)
13276 {
13277 maxRate = currentRate;
13278 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013279
Leo Chang6f8870f2013-03-26 18:11:36 -070013280 }
13281 else
13282#endif /* WLAN_FEATURE_11AC */
13283 {
13284 if (rate_flags & eHAL_TX_RATE_HT40)
13285 {
13286 rateFlag |= 1;
13287 }
13288 if (rate_flags & eHAL_TX_RATE_SGI)
13289 {
13290 rateFlag |= 2;
13291 }
13292
Girish Gowli01abcee2014-07-31 20:18:55 +053013293 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013294 if (rssidx == 1 || rssidx == 2)
13295 {
13296 //get middle rate MCS index if rssi=1/2
13297 for (i=0; i <= 7; i++)
13298 {
13299 if (sinfo->signal <= rssiMcsTbl[mode][i])
13300 {
13301 temp = i+1;
13302 break;
13303 }
13304 }
13305 }
c_hpothu79aab322014-07-14 21:11:01 +053013306
13307 for (i = 0; i < MCSLeng; i++)
13308 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013309 for (j = 0; j < temp; j++)
13310 {
13311 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13312 {
13313 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
13314 break;
13315 }
13316 }
13317 if ((j < temp) && (currentRate > maxRate))
13318 {
13319 maxRate = currentRate;
13320 maxSpeedMCS = 1;
13321 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
13322 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 }
13324 }
13325 }
13326
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013327 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13328 {
13329 maxRate = myRate;
13330 maxSpeedMCS = 1;
13331 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13332 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013334 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 {
13336 maxRate = myRate;
13337 if (rate_flags & eHAL_TX_RATE_LEGACY)
13338 {
13339 maxSpeedMCS = 0;
13340 }
13341 else
13342 {
13343 maxSpeedMCS = 1;
13344 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13345 }
13346 }
13347
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013348 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013349 {
13350 sinfo->txrate.legacy = maxRate;
13351#ifdef LINKSPEED_DEBUG_ENABLED
13352 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13353#endif //LINKSPEED_DEBUG_ENABLED
13354 }
13355 else
13356 {
13357 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013358#ifdef WLAN_FEATURE_11AC
13359 sinfo->txrate.nss = 1;
13360 if (rate_flags & eHAL_TX_RATE_VHT80)
13361 {
13362 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013363 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013364 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013365 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013366 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013367 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13368 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13369 }
13370 else if (rate_flags & eHAL_TX_RATE_VHT20)
13371 {
13372 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13373 }
13374#endif /* WLAN_FEATURE_11AC */
13375 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13376 {
13377 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13378 if (rate_flags & eHAL_TX_RATE_HT40)
13379 {
13380 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13381 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013382 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013383 if (rate_flags & eHAL_TX_RATE_SGI)
13384 {
13385 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13386 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013387
Jeff Johnson295189b2012-06-20 16:38:30 -070013388#ifdef LINKSPEED_DEBUG_ENABLED
13389 pr_info("Reporting MCS rate %d flags %x\n",
13390 sinfo->txrate.mcs,
13391 sinfo->txrate.flags );
13392#endif //LINKSPEED_DEBUG_ENABLED
13393 }
13394 }
13395 else
13396 {
13397 // report current rate instead of max rate
13398
13399 if (rate_flags & eHAL_TX_RATE_LEGACY)
13400 {
13401 //provide to the UI in units of 100kbps
13402 sinfo->txrate.legacy = myRate;
13403#ifdef LINKSPEED_DEBUG_ENABLED
13404 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13405#endif //LINKSPEED_DEBUG_ENABLED
13406 }
13407 else
13408 {
13409 //must be MCS
13410 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013411#ifdef WLAN_FEATURE_11AC
13412 sinfo->txrate.nss = 1;
13413 if (rate_flags & eHAL_TX_RATE_VHT80)
13414 {
13415 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13416 }
13417 else
13418#endif /* WLAN_FEATURE_11AC */
13419 {
13420 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13421 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 if (rate_flags & eHAL_TX_RATE_SGI)
13423 {
13424 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13425 }
13426 if (rate_flags & eHAL_TX_RATE_HT40)
13427 {
13428 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13429 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013430#ifdef WLAN_FEATURE_11AC
13431 else if (rate_flags & eHAL_TX_RATE_VHT80)
13432 {
13433 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13434 }
13435#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013436#ifdef LINKSPEED_DEBUG_ENABLED
13437 pr_info("Reporting actual MCS rate %d flags %x\n",
13438 sinfo->txrate.mcs,
13439 sinfo->txrate.flags );
13440#endif //LINKSPEED_DEBUG_ENABLED
13441 }
13442 }
13443 sinfo->filled |= STATION_INFO_TX_BITRATE;
13444
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013445 sinfo->tx_packets =
13446 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13447 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13448 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13449 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13450
13451 sinfo->tx_retries =
13452 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13453 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13454 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13455 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13456
13457 sinfo->tx_failed =
13458 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13459 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13460 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13461 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13462
13463 sinfo->filled |=
13464 STATION_INFO_TX_PACKETS |
13465 STATION_INFO_TX_RETRIES |
13466 STATION_INFO_TX_FAILED;
13467
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013468 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13469 TRACE_CODE_HDD_CFG80211_GET_STA,
13470 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013471 EXIT();
13472 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013473}
13474
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013475static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13476 u8* mac, struct station_info *sinfo)
13477{
13478 int ret;
13479
13480 vos_ssr_protect(__func__);
13481 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13482 vos_ssr_unprotect(__func__);
13483
13484 return ret;
13485}
13486
13487static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013488 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013489{
13490 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013491 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013493 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013494
Jeff Johnsone7245742012-09-05 17:12:55 -070013495 ENTER();
13496
Jeff Johnson295189b2012-06-20 16:38:30 -070013497 if (NULL == pAdapter)
13498 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013499 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 return -ENODEV;
13501 }
13502
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013503 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13504 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13505 pAdapter->sessionId, timeout));
13506
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013507 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013508 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013509 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013510 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013511 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013512 }
13513
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013514 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13515 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13516 (pHddCtx->cfg_ini->fhostArpOffload) &&
13517 (eConnectionState_Associated ==
13518 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13519 {
Amar Singhald53568e2013-09-26 11:03:45 -070013520
13521 hddLog(VOS_TRACE_LEVEL_INFO,
13522 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013523 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013524 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13525 {
13526 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013527 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013528 __func__, vos_status);
13529 }
13530 }
13531
Jeff Johnson295189b2012-06-20 16:38:30 -070013532 /**The get power cmd from the supplicant gets updated by the nl only
13533 *on successful execution of the function call
13534 *we are oppositely mapped w.r.t mode in the driver
13535 **/
13536 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13537
13538 if (VOS_STATUS_E_FAILURE == vos_status)
13539 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013540 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13541 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 return -EINVAL;
13543 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013544 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013545 return 0;
13546}
13547
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013548static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13549 struct net_device *dev, bool mode, int timeout)
13550{
13551 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013552
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013553 vos_ssr_protect(__func__);
13554 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13555 vos_ssr_unprotect(__func__);
13556
13557 return ret;
13558}
Jeff Johnson295189b2012-06-20 16:38:30 -070013559#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013560static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13561 struct net_device *netdev,
13562 u8 key_index)
13563{
13564 ENTER();
13565 return 0;
13566}
13567
Jeff Johnson295189b2012-06-20 16:38:30 -070013568static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013569 struct net_device *netdev,
13570 u8 key_index)
13571{
13572 int ret;
13573 vos_ssr_protect(__func__);
13574 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13575 vos_ssr_unprotect(__func__);
13576 return ret;
13577}
13578#endif //LINUX_VERSION_CODE
13579
13580#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13581static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13582 struct net_device *dev,
13583 struct ieee80211_txq_params *params)
13584{
13585 ENTER();
13586 return 0;
13587}
13588#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13589static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13590 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013591{
Jeff Johnsone7245742012-09-05 17:12:55 -070013592 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 return 0;
13594}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013595#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013596
13597#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13598static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013599 struct net_device *dev,
13600 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013601{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013602 int ret;
13603
13604 vos_ssr_protect(__func__);
13605 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13606 vos_ssr_unprotect(__func__);
13607 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013608}
13609#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13610static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13611 struct ieee80211_txq_params *params)
13612{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013613 int ret;
13614
13615 vos_ssr_protect(__func__);
13616 ret = __wlan_hdd_set_txq_params(wiphy, params);
13617 vos_ssr_unprotect(__func__);
13618 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013619}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013620#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013621
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013622static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013623 struct net_device *dev,
13624 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013625{
13626 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013627 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013628 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013629 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013630 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013631 v_CONTEXT_t pVosContext = NULL;
13632 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013633
Jeff Johnsone7245742012-09-05 17:12:55 -070013634 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013635
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013636 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013637 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013638 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 return -EINVAL;
13640 }
13641
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013642 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13643 TRACE_CODE_HDD_CFG80211_DEL_STA,
13644 pAdapter->sessionId, pAdapter->device_mode));
13645
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013646 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13647 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013648 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013649 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013650 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013651 }
13652
Jeff Johnson295189b2012-06-20 16:38:30 -070013653 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013654 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013655 )
13656 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013657 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13658 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13659 if(pSapCtx == NULL){
13660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13661 FL("psapCtx is NULL"));
13662 return -ENOENT;
13663 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013664 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013665 {
13666 v_U16_t i;
13667 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
13668 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013669 if ((pSapCtx->aStaInfo[i].isUsed) &&
13670 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070013671 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013672 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013673 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013674 ETHER_ADDR_LEN);
13675
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013677 "%s: Delete STA with MAC::"
13678 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013679 __func__,
13680 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
13681 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070013682 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013683 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013684 }
13685 }
13686 }
13687 else
13688 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013689
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013690 vos_status = hdd_softap_GetStaId(pAdapter,
13691 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013692 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13693 {
13694 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013695 "%s: Skip this DEL STA as this is not used::"
13696 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013697 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013698 return -ENOENT;
13699 }
13700
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013701 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013702 {
13703 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013704 "%s: Skip this DEL STA as deauth is in progress::"
13705 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013706 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013707 return -ENOENT;
13708 }
13709
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013710 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013711
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 hddLog(VOS_TRACE_LEVEL_INFO,
13713 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013714 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013715 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013716 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013717
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013718 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013719 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13720 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013721 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013722 hddLog(VOS_TRACE_LEVEL_INFO,
13723 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013724 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013725 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013726 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013727 return -ENOENT;
13728 }
13729
Jeff Johnson295189b2012-06-20 16:38:30 -070013730 }
13731 }
13732
13733 EXIT();
13734
13735 return 0;
13736}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013737
13738#ifdef CFG80211_DEL_STA_V2
13739static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13740 struct net_device *dev,
13741 struct station_del_parameters *param)
13742#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013743static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13744 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013745#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013746{
13747 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013748 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070013749
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013750 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013751
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013752#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013753 if (NULL == param) {
13754 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013755 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013756 return -EINVAL;
13757 }
13758
13759 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
13760 param->subtype, &delStaParams);
13761
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013762#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053013763 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013764 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013765#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013766 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
13767
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013768 vos_ssr_unprotect(__func__);
13769
13770 return ret;
13771}
13772
13773static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013774 struct net_device *dev, u8 *mac, struct station_parameters *params)
13775{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013776 hdd_adapter_t *pAdapter;
13777 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013778 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013779#ifdef FEATURE_WLAN_TDLS
13780 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013781
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013782 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013783
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013784 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13785 if (NULL == pAdapter)
13786 {
13787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13788 "%s: Adapter is NULL",__func__);
13789 return -EINVAL;
13790 }
13791 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13792 status = wlan_hdd_validate_context(pHddCtx);
13793 if (0 != status)
13794 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013795 return status;
13796 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013797
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013798 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13799 TRACE_CODE_HDD_CFG80211_ADD_STA,
13800 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013801 mask = params->sta_flags_mask;
13802
13803 set = params->sta_flags_set;
13804
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053013805 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013806 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
13807 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013808
13809 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
13810 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013811 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013812 }
13813 }
13814#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013815 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013816 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013817}
13818
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013819static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
13820 struct net_device *dev, u8 *mac, struct station_parameters *params)
13821{
13822 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013823
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013824 vos_ssr_protect(__func__);
13825 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
13826 vos_ssr_unprotect(__func__);
13827
13828 return ret;
13829}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013830#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070013831
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013832static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070013833 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013834{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013835 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13836 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013837 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013838 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013839 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013840 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070013841
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013842 ENTER();
13843
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013844 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013845 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013846 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013847 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013848 return -EINVAL;
13849 }
13850
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013851 if (!pmksa) {
13852 hddLog(LOGE, FL("pmksa is NULL"));
13853 return -EINVAL;
13854 }
13855
13856 if (!pmksa->bssid || !pmksa->pmkid) {
13857 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
13858 pmksa->bssid, pmksa->pmkid);
13859 return -EINVAL;
13860 }
13861
13862 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
13863 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
13864
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013865 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13866 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013867 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013868 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013869 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013870 }
13871
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013872 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013873 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13874
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013875 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
13876 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013877
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013878 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013879 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013880 &pmk_id, 1, FALSE);
13881
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013882 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13883 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
13884 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013885
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013886 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013887 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013888}
13889
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013890static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
13891 struct cfg80211_pmksa *pmksa)
13892{
13893 int ret;
13894
13895 vos_ssr_protect(__func__);
13896 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
13897 vos_ssr_unprotect(__func__);
13898
13899 return ret;
13900}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013901
Wilson Yang6507c4e2013-10-01 20:11:19 -070013902
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013903static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070013904 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013905{
Wilson Yang6507c4e2013-10-01 20:11:19 -070013906 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13907 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013908 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080013909 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013910
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013911 ENTER();
13912
Wilson Yang6507c4e2013-10-01 20:11:19 -070013913 /* Validate pAdapter */
13914 if (NULL == pAdapter)
13915 {
13916 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
13917 return -EINVAL;
13918 }
13919
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013920 if (!pmksa) {
13921 hddLog(LOGE, FL("pmksa is NULL"));
13922 return -EINVAL;
13923 }
13924
13925 if (!pmksa->bssid) {
13926 hddLog(LOGE, FL("pmksa->bssid is NULL"));
13927 return -EINVAL;
13928 }
13929
Kiet Lam98c46a12014-10-31 15:34:57 -070013930 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
13931 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
13932
Wilson Yang6507c4e2013-10-01 20:11:19 -070013933 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13934 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070013935 if (0 != status)
13936 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070013937 return status;
13938 }
13939
13940 /*Retrieve halHandle*/
13941 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13942
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013943 /* Delete the PMKID CSR cache */
13944 if (eHAL_STATUS_SUCCESS !=
13945 sme_RoamDelPMKIDfromCache(halHandle,
13946 pAdapter->sessionId, pmksa->bssid, FALSE)) {
13947 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
13948 MAC_ADDR_ARRAY(pmksa->bssid));
13949 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013950 }
13951
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013952 EXIT();
13953 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013954}
13955
Wilson Yang6507c4e2013-10-01 20:11:19 -070013956
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013957static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
13958 struct cfg80211_pmksa *pmksa)
13959{
13960 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013961
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013962 vos_ssr_protect(__func__);
13963 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
13964 vos_ssr_unprotect(__func__);
13965
13966 return ret;
13967
13968}
13969
13970static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013971{
Wilson Yang6507c4e2013-10-01 20:11:19 -070013972 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13973 tHalHandle halHandle;
13974 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080013975 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013976
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013977 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070013978
13979 /* Validate pAdapter */
13980 if (NULL == pAdapter)
13981 {
13982 hddLog(VOS_TRACE_LEVEL_ERROR,
13983 "%s: Invalid Adapter" ,__func__);
13984 return -EINVAL;
13985 }
13986
13987 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13988 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070013989 if (0 != status)
13990 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070013991 return status;
13992 }
13993
13994 /*Retrieve halHandle*/
13995 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13996
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013997 /* Flush the PMKID cache in CSR */
13998 if (eHAL_STATUS_SUCCESS !=
13999 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14001 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014002 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014003 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014004 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014005}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014006
14007static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14008{
14009 int ret;
14010
14011 vos_ssr_protect(__func__);
14012 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14013 vos_ssr_unprotect(__func__);
14014
14015 return ret;
14016}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014017#endif
14018
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014019#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014020static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14021 struct net_device *dev,
14022 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014023{
14024 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14025 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014026 hdd_context_t *pHddCtx;
14027 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014028
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014029 ENTER();
14030
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014031 if (NULL == pAdapter)
14032 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014033 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014034 return -ENODEV;
14035 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014036 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14037 ret = wlan_hdd_validate_context(pHddCtx);
14038 if (0 != ret)
14039 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014040 return ret;
14041 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014042 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014043 if (NULL == pHddStaCtx)
14044 {
14045 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14046 return -EINVAL;
14047 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014048
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014049 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14050 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14051 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014052 // Added for debug on reception of Re-assoc Req.
14053 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14054 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014055 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014056 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014057 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014058 }
14059
14060#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014061 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014062 ftie->ie_len);
14063#endif
14064
14065 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014066 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14067 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014068 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014069
14070 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014071 return 0;
14072}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014073
14074static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14075 struct net_device *dev,
14076 struct cfg80211_update_ft_ies_params *ftie)
14077{
14078 int ret;
14079
14080 vos_ssr_protect(__func__);
14081 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14082 vos_ssr_unprotect(__func__);
14083
14084 return ret;
14085}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014086#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014087
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014088#ifdef FEATURE_WLAN_SCAN_PNO
14089
14090void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14091 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14092{
14093 int ret;
14094 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14095 hdd_context_t *pHddCtx;
14096
Nirav Shah80830bf2013-12-31 16:35:12 +053014097 ENTER();
14098
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014099 if (NULL == pAdapter)
14100 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014101 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014102 "%s: HDD adapter is Null", __func__);
14103 return ;
14104 }
14105
14106 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14107 if (NULL == pHddCtx)
14108 {
14109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14110 "%s: HDD context is Null!!!", __func__);
14111 return ;
14112 }
14113
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014114 spin_lock(&pHddCtx->schedScan_lock);
14115 if (TRUE == pHddCtx->isWiphySuspended)
14116 {
14117 pHddCtx->isSchedScanUpdatePending = TRUE;
14118 spin_unlock(&pHddCtx->schedScan_lock);
14119 hddLog(VOS_TRACE_LEVEL_INFO,
14120 "%s: Update cfg80211 scan database after it resume", __func__);
14121 return ;
14122 }
14123 spin_unlock(&pHddCtx->schedScan_lock);
14124
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014125 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14126
14127 if (0 > ret)
14128 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14129
14130 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14132 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014133}
14134
14135/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014136 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014137 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014138 */
14139static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14140{
14141 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14142 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014143 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014144 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14145 int status = 0;
14146 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14147
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014148 /* The current firmware design does not allow PNO during any
14149 * active sessions. Hence, determine the active sessions
14150 * and return a failure.
14151 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014152 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14153 {
14154 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014155 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014156
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014157 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14158 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14159 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14160 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14161 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014162 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014163 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014164 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014165 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014166 }
14167 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14168 pAdapterNode = pNext;
14169 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014170 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014171}
14172
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014173void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14174{
14175 hdd_adapter_t *pAdapter = callbackContext;
14176 hdd_context_t *pHddCtx;
14177
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014178 ENTER();
14179
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014180 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14181 {
14182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14183 FL("Invalid adapter or adapter has invalid magic"));
14184 return;
14185 }
14186
14187 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14188 if (0 != wlan_hdd_validate_context(pHddCtx))
14189 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014190 return;
14191 }
14192
c_hpothub53c45d2014-08-18 16:53:14 +053014193 if (VOS_STATUS_SUCCESS != status)
14194 {
14195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014196 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014197 pHddCtx->isPnoEnable = FALSE;
14198 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014199
14200 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14201 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014202 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014203}
14204
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014205/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014206 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14207 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014208 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014209static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014210 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14211{
14212 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014213 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014214 hdd_context_t *pHddCtx;
14215 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014216 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014217 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14218 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014219 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14220 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014221 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014222 hdd_config_t *pConfig = NULL;
14223 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014224
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014225 ENTER();
14226
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014227 if (NULL == pAdapter)
14228 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014230 "%s: HDD adapter is Null", __func__);
14231 return -ENODEV;
14232 }
14233
14234 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014235 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014236
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014237 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014238 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014239 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014240 }
14241
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014242 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014243 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14244 if (NULL == hHal)
14245 {
14246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14247 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014248 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014249 }
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014250 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014251 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014252 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014253 {
14254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14255 "%s: aborting the existing scan is unsuccessfull", __func__);
14256 return -EBUSY;
14257 }
14258
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014259 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014260 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014262 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014263 return -EBUSY;
14264 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014265
c_hpothu37f21312014-04-09 21:49:54 +053014266 if (TRUE == pHddCtx->isPnoEnable)
14267 {
14268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14269 FL("already PNO is enabled"));
14270 return -EBUSY;
14271 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014272
14273 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14274 {
14275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14276 "%s: abort ROC failed ", __func__);
14277 return -EBUSY;
14278 }
14279
c_hpothu37f21312014-04-09 21:49:54 +053014280 pHddCtx->isPnoEnable = TRUE;
14281
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014282 pnoRequest.enable = 1; /*Enable PNO */
14283 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014284
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014285 if (( !pnoRequest.ucNetworksCount ) ||
14286 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014287 {
14288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014289 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014290 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014291 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014292 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014293 goto error;
14294 }
14295
14296 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14297 {
14298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014299 "%s: Incorrect number of channels %d",
14300 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014301 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014302 goto error;
14303 }
14304
14305 /* Framework provides one set of channels(all)
14306 * common for all saved profile */
14307 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14308 channels_allowed, &num_channels_allowed))
14309 {
14310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14311 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014312 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014313 goto error;
14314 }
14315 /* Checking each channel against allowed channel list */
14316 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014317 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014318 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014319 char chList [(request->n_channels*5)+1];
14320 int len;
14321 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014322 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014323 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014324 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014325 if (request->channels[i]->hw_value == channels_allowed[indx])
14326 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014327 if ((!pConfig->enableDFSPnoChnlScan) &&
14328 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14329 {
14330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14331 "%s : Dropping DFS channel : %d",
14332 __func__,channels_allowed[indx]);
14333 num_ignore_dfs_ch++;
14334 break;
14335 }
14336
Nirav Shah80830bf2013-12-31 16:35:12 +053014337 valid_ch[num_ch++] = request->channels[i]->hw_value;
14338 len += snprintf(chList+len, 5, "%d ",
14339 request->channels[i]->hw_value);
14340 break ;
14341 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014342 }
14343 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014344 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014345
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014346 /*If all channels are DFS and dropped, then ignore the PNO request*/
14347 if (num_ignore_dfs_ch == request->n_channels)
14348 {
14349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14350 "%s : All requested channels are DFS channels", __func__);
14351 ret = -EINVAL;
14352 goto error;
14353 }
14354 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014355
14356 pnoRequest.aNetworks =
14357 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14358 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014359 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014360 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14361 FL("failed to allocate memory aNetworks %u"),
14362 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14363 goto error;
14364 }
14365 vos_mem_zero(pnoRequest.aNetworks,
14366 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14367
14368 /* Filling per profile params */
14369 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14370 {
14371 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014372 request->match_sets[i].ssid.ssid_len;
14373
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014374 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14375 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014376 {
14377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014378 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014379 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014380 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014381 goto error;
14382 }
14383
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014384 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014385 request->match_sets[i].ssid.ssid,
14386 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14388 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014389 i, pnoRequest.aNetworks[i].ssId.ssId);
14390 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14391 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14392 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014393
14394 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014395 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14396 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014397
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014398 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014399 }
14400
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014401 for (i = 0; i < request->n_ssids; i++)
14402 {
14403 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014404 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014405 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014406 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014407 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014408 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014409 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014410 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014411 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014412 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014413 break;
14414 }
14415 j++;
14416 }
14417 }
14418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14419 "Number of hidden networks being Configured = %d",
14420 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014422 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014423
14424 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14425 if (pnoRequest.p24GProbeTemplate == NULL)
14426 {
14427 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14428 FL("failed to allocate memory p24GProbeTemplate %u"),
14429 SIR_PNO_MAX_PB_REQ_SIZE);
14430 goto error;
14431 }
14432
14433 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14434 if (pnoRequest.p5GProbeTemplate == NULL)
14435 {
14436 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14437 FL("failed to allocate memory p5GProbeTemplate %u"),
14438 SIR_PNO_MAX_PB_REQ_SIZE);
14439 goto error;
14440 }
14441
14442 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14443 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14444
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014445 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14446 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014447 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014448 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14449 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14450 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014451
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014452 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14453 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14454 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014455 }
14456
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014457 /* Driver gets only one time interval which is hardcoded in
14458 * supplicant for 10000ms. Taking power consumption into account 6 timers
14459 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14460 * 80,160,320 secs. And number of scan cycle for each timer
14461 * is configurable through INI param gPNOScanTimerRepeatValue.
14462 * If it is set to 0 only one timer will be used and PNO scan cycle
14463 * will be repeated after each interval specified by supplicant
14464 * till PNO is disabled.
14465 */
14466 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014467 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014468 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014469 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014470 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14471
14472 tempInterval = (request->interval)/1000;
14473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14474 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14475 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014476 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014477 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014478 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014479 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014480 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014481 tempInterval *= 2;
14482 }
14483 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014484 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014485
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014486 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014487
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014488 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014489 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14490 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014491 pAdapter->pno_req_status = 0;
14492
Nirav Shah80830bf2013-12-31 16:35:12 +053014493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14494 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014495 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14496 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014497
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014498 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014499 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014500 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14501 if (eHAL_STATUS_SUCCESS != status)
14502 {
14503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014504 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014505 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014506 goto error;
14507 }
14508
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014509 ret = wait_for_completion_timeout(
14510 &pAdapter->pno_comp_var,
14511 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14512 if (0 >= ret)
14513 {
14514 // Did not receive the response for PNO enable in time.
14515 // Assuming the PNO enable was success.
14516 // Returning error from here, because we timeout, results
14517 // in side effect of Wifi (Wifi Setting) not to work.
14518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14519 FL("Timed out waiting for PNO to be Enabled"));
14520 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014521 }
14522
14523 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014524 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014525
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014526error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14528 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014529 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014530 if (pnoRequest.aNetworks)
14531 vos_mem_free(pnoRequest.aNetworks);
14532 if (pnoRequest.p24GProbeTemplate)
14533 vos_mem_free(pnoRequest.p24GProbeTemplate);
14534 if (pnoRequest.p5GProbeTemplate)
14535 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014536
14537 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014538 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014539}
14540
14541/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014542 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14543 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014544 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014545static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14546 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14547{
14548 int ret;
14549
14550 vos_ssr_protect(__func__);
14551 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14552 vos_ssr_unprotect(__func__);
14553
14554 return ret;
14555}
14556
14557/*
14558 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14559 * Function to disable PNO
14560 */
14561static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014562 struct net_device *dev)
14563{
14564 eHalStatus status = eHAL_STATUS_FAILURE;
14565 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14566 hdd_context_t *pHddCtx;
14567 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014568 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014569 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014570
14571 ENTER();
14572
14573 if (NULL == pAdapter)
14574 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014576 "%s: HDD adapter is Null", __func__);
14577 return -ENODEV;
14578 }
14579
14580 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014581
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014582 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014583 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014584 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014585 "%s: HDD context is Null", __func__);
14586 return -ENODEV;
14587 }
14588
14589 /* The return 0 is intentional when isLogpInProgress and
14590 * isLoadUnloadInProgress. We did observe a crash due to a return of
14591 * failure in sched_scan_stop , especially for a case where the unload
14592 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14593 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14594 * success. If it returns a failure , then its next invocation due to the
14595 * clean up of the second interface will have the dev pointer corresponding
14596 * to the first one leading to a crash.
14597 */
14598 if (pHddCtx->isLogpInProgress)
14599 {
14600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14601 "%s: LOGP in Progress. Ignore!!!", __func__);
14602 return ret;
14603 }
14604
Mihir Shete18156292014-03-11 15:38:30 +053014605 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014606 {
14607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14608 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14609 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014610 }
14611
14612 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14613 if (NULL == hHal)
14614 {
14615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14616 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014617 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014618 }
14619
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014620 pnoRequest.enable = 0; /* Disable PNO */
14621 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014622
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014623 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014624 pAdapter->sessionId,
14625 NULL, pAdapter);
14626 if (eHAL_STATUS_SUCCESS != status)
14627 {
14628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14629 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014630 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014631 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014632 }
c_hpothu37f21312014-04-09 21:49:54 +053014633 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014634
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014635error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014636 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014637 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014638
14639 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014640 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014641}
14642
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014643/*
14644 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
14645 * NL interface to disable PNO
14646 */
14647static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
14648 struct net_device *dev)
14649{
14650 int ret;
14651
14652 vos_ssr_protect(__func__);
14653 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
14654 vos_ssr_unprotect(__func__);
14655
14656 return ret;
14657}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014658#endif /*FEATURE_WLAN_SCAN_PNO*/
14659
14660
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014661#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014662#if TDLS_MGMT_VERSION2
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014663static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014664 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014665 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
14666#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014667static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014668 u8 *peer, u8 action_code, u8 dialog_token,
14669 u16 status_code, const u8 *buf, size_t len)
14670#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014671{
14672
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014673 hdd_adapter_t *pAdapter;
14674 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014675 u8 peerMac[6];
14676 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070014677 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080014678 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070014679 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014680 int ret;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014681#if !(TDLS_MGMT_VERSION2)
14682 u32 peer_capability = 0;
14683#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014684 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014685
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014686 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14687 if (NULL == pAdapter)
14688 {
14689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14690 "%s: Adapter is NULL",__func__);
14691 return -EINVAL;
14692 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014693 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14694 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
14695 pAdapter->sessionId, action_code));
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014696 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014697 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014698 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014699 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014700 "Invalid arguments");
14701 return -EINVAL;
14702 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014703 if (pHddCtx->isLogpInProgress)
14704 {
14705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14706 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053014707 wlan_hdd_tdls_set_link_status(pAdapter,
14708 peer,
14709 eTDLS_LINK_IDLE,
14710 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014711 return -EBUSY;
14712 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014713 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
14714 {
14715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14716 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14717 return -EAGAIN;
14718 }
Hoonki Lee27511902013-03-14 18:19:06 -070014719 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014720 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014721 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014722 "%s: TDLS mode is disabled OR not enabled in FW."
14723 MAC_ADDRESS_STR " action %d declined.",
14724 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014725 return -ENOTSUPP;
14726 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014727
Hoonki Lee27511902013-03-14 18:19:06 -070014728 /* other than teardown frame, other mgmt frames are not sent if disabled */
14729 if (SIR_MAC_TDLS_TEARDOWN != action_code)
14730 {
14731 /* if tdls_mode is disabled to respond to peer's request */
14732 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
14733 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014734 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014735 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014736 " TDLS mode is disabled. action %d declined.",
14737 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070014738
14739 return -ENOTSUPP;
14740 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053014741
14742 if (vos_max_concurrent_connections_reached())
14743 {
14744 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14745 return -EINVAL;
14746 }
Hoonki Lee27511902013-03-14 18:19:06 -070014747 }
14748
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014749 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
14750 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053014751 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014752 {
14753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014754 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014755 " TDLS setup is ongoing. action %d declined.",
14756 __func__, MAC_ADDR_ARRAY(peer), action_code);
14757 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014758 }
14759 }
14760
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014761 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
14762 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080014763 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014764 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
14765 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014766 {
14767 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
14768 we return error code at 'add_station()'. Hence we have this
14769 check again in addtion to add_station().
14770 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014771 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014772 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14774 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014775 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
14776 __func__, MAC_ADDR_ARRAY(peer), action_code,
14777 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053014778 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080014779 }
14780 else
14781 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014782 /* maximum reached. tweak to send error code to peer and return
14783 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014784 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014785 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14786 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014787 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
14788 __func__, MAC_ADDR_ARRAY(peer), status_code,
14789 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070014790 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014791 /* fall through to send setup resp with failure status
14792 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014793 }
14794 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014795 else
14796 {
14797 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014798 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014799 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014800 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014801 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014802 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
14803 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014804 return -EPERM;
14805 }
14806 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014807 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014808 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014809
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014810 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014811 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014812 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
14813 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014814
Hoonki Leea34dd892013-02-05 22:56:02 -080014815 /*Except teardown responder will not be used so just make 0*/
14816 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014817 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080014818 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014819
14820 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014821 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014822
14823 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
14824 responder = pTdlsPeer->is_responder;
14825 else
Hoonki Leea34dd892013-02-05 22:56:02 -080014826 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014827 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014828 "%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 -070014829 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
14830 dialog_token, status_code, len);
14831 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080014832 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014833 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014834
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014835 /* For explicit trigger of DIS_REQ come out of BMPS for
14836 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070014837 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014838 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
14839 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070014840 {
14841 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
14842 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014844 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014845 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
14846 if (status != VOS_STATUS_SUCCESS) {
14847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
14848 }
Hoonki Lee14621352013-04-16 17:51:19 -070014849 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014850 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
14851 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED)) {
14852 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
14853 }
14854 }
Hoonki Lee14621352013-04-16 17:51:19 -070014855 }
14856
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014857 /* make sure doesn't call send_mgmt() while it is pending */
14858 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
14859 {
14860 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014861 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014862 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014863 ret = -EBUSY;
14864 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014865 }
14866
14867 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014868 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
14869
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014870 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053014871 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014872
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014873 if (VOS_STATUS_SUCCESS != status)
14874 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14876 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014877 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014878 ret = -EINVAL;
14879 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014880 }
14881
Hoonki Leed37cbb32013-04-20 00:31:14 -070014882 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
14883 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
14884
14885 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014886 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070014887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014888 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070014889 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014890 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080014891
14892 if (pHddCtx->isLogpInProgress)
14893 {
14894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14895 "%s: LOGP in Progress. Ignore!!!", __func__);
14896 return -EAGAIN;
14897 }
14898
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014899 ret = -EINVAL;
14900 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014901 }
14902
Gopichand Nakkala05922802013-03-14 12:23:19 -070014903 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070014904 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014905 ret = max_sta_failed;
14906 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070014907 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014908
Hoonki Leea34dd892013-02-05 22:56:02 -080014909 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
14910 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014911 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE)) {
14912 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
14913 }
Hoonki Leea34dd892013-02-05 22:56:02 -080014914 }
14915 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
14916 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014917 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE)) {
14918 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
14919 }
Hoonki Leea34dd892013-02-05 22:56:02 -080014920 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014921
14922 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014923
14924tx_failed:
14925 /* add_station will be called before sending TDLS_SETUP_REQ and
14926 * TDLS_SETUP_RSP and as part of add_station driver will enable
14927 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
14928 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
14929 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
14930 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
14931 */
14932
14933 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
14934 (SIR_MAC_TDLS_SETUP_RSP == action_code))
14935 wlan_hdd_tdls_check_bmps(pAdapter);
14936 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014937}
14938
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014939#if TDLS_MGMT_VERSION2
14940static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
14941 u8 *peer, u8 action_code, u8 dialog_token,
14942 u16 status_code, u32 peer_capability,
14943 const u8 *buf, size_t len)
14944#else
14945static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
14946 u8 *peer, u8 action_code, u8 dialog_token,
14947 u16 status_code, const u8 *buf, size_t len)
14948#endif
14949{
14950 int ret;
14951
14952 vos_ssr_protect(__func__);
14953#if TDLS_MGMT_VERSION2
14954 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
14955 status_code, peer_capability, buf, len);
14956#else
14957 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
14958 status_code, buf, len);
14959#endif
14960 vos_ssr_unprotect(__func__);
14961
14962 return ret;
14963}
Atul Mittal115287b2014-07-08 13:26:33 +053014964
14965int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
14966 u8 *peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053014967 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053014968 cfg80211_exttdls_callback callback)
14969{
14970
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053014971 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053014972 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053014973 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053014974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14975 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
14976 __func__, MAC_ADDR_ARRAY(peer));
14977
14978 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
14979 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
14980
14981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014982 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
14983 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
14984 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053014985 return -ENOTSUPP;
14986 }
14987
14988 /* To cater the requirement of establishing the TDLS link
14989 * irrespective of the data traffic , get an entry of TDLS peer.
14990 */
14991 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
14992 if (pTdlsPeer == NULL) {
14993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14994 "%s: peer " MAC_ADDRESS_STR " not existing",
14995 __func__, MAC_ADDR_ARRAY(peer));
14996 return -EINVAL;
14997 }
14998
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053014999 /* check FW TDLS Off Channel capability */
15000 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
15001 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015002 {
15003 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15004 pTdlsPeer->peerParams.global_operating_class =
15005 tdls_peer_params->global_operating_class;
15006 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15007 pTdlsPeer->peerParams.min_bandwidth_kbps =
15008 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015009 /* check configured channel is valid, non dfs and
15010 * not current operating channel */
15011 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15012 tdls_peer_params->channel)) &&
15013 (pHddStaCtx) &&
15014 (tdls_peer_params->channel !=
15015 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015016 {
15017 pTdlsPeer->isOffChannelConfigured = TRUE;
15018 }
15019 else
15020 {
15021 pTdlsPeer->isOffChannelConfigured = FALSE;
15022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15023 "%s: Configured Tdls Off Channel is not valid", __func__);
15024
15025 }
15026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015027 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15028 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015029 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015030 pTdlsPeer->isOffChannelConfigured,
15031 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015032 }
15033 else
15034 {
15035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015036 "%s: TDLS off channel FW capability %d or "
15037 "Invalid TDLS Peer Params", __func__,
15038 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015039 }
15040
Atul Mittal115287b2014-07-08 13:26:33 +053015041 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15042
15043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15044 " %s TDLS Add Force Peer Failed",
15045 __func__);
15046 return -EINVAL;
15047 }
15048 /*EXT TDLS*/
15049
15050 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15052 " %s TDLS set callback Failed",
15053 __func__);
15054 return -EINVAL;
15055 }
15056
15057 return(0);
15058
15059}
15060
15061int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer)
15062{
15063
15064 hddTdlsPeer_t *pTdlsPeer;
15065 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15067 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15068 __func__, MAC_ADDR_ARRAY(peer));
15069
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015070 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15071 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15072 return -EINVAL;
15073 }
15074
Atul Mittal115287b2014-07-08 13:26:33 +053015075 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15076 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15077
15078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015079 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15080 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15081 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015082 return -ENOTSUPP;
15083 }
15084
15085
15086 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15087
15088 if ( NULL == pTdlsPeer ) {
15089 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
15090 " peer not exsting",
15091 __func__, MAC_ADDR_ARRAY(peer));
15092 return -EINVAL;
15093 }
15094 else {
15095 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15096 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015097 /* if channel switch is configured, reset
15098 the channel for this peer */
15099 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15100 {
15101 pTdlsPeer->peerParams.channel = 0;
15102 pTdlsPeer->isOffChannelConfigured = FALSE;
15103 }
Atul Mittal115287b2014-07-08 13:26:33 +053015104 }
15105
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015106 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15107 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015108 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015109 }
Atul Mittal115287b2014-07-08 13:26:33 +053015110
15111 /*EXT TDLS*/
15112
15113 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15114
15115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15116 " %s TDLS set callback Failed",
15117 __func__);
15118 return -EINVAL;
15119 }
15120 return(0);
15121
15122}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015123static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015124 u8 *peer, enum nl80211_tdls_operation oper)
15125{
15126 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15127 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015128 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015129 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015130
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015131 ENTER();
15132
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015133 if (!pAdapter) {
15134 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15135 return -EINVAL;
15136 }
15137
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015138 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15139 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15140 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015141 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015142 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015143 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015144 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015145 return -EINVAL;
15146 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015147
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015148 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015149 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015150 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015151 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015152 }
15153
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015154
15155 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015156 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015157 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015158 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015159 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15160 "Cannot process TDLS commands",
15161 pHddCtx->cfg_ini->fEnableTDLSSupport,
15162 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015163 return -ENOTSUPP;
15164 }
15165
15166 switch (oper) {
15167 case NL80211_TDLS_ENABLE_LINK:
15168 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015169 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015170 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015171 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015172 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015173 tANI_U16 numCurrTdlsPeers = 0;
15174 hddTdlsPeer_t *connPeer = NULL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015175
Sunil Dutt41de4e22013-11-14 18:09:02 +053015176 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015177 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015178 if ( NULL == pTdlsPeer ) {
15179 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15180 " (oper %d) not exsting. ignored",
15181 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15182 return -EINVAL;
15183 }
15184
15185 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15186 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15187 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15188 "NL80211_TDLS_ENABLE_LINK");
15189
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015190 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15191 {
15192 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15193 MAC_ADDRESS_STR " failed",
15194 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15195 return -EINVAL;
15196 }
15197
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015198 /* TDLS Off Channel, Disable tdls channel switch,
15199 when there are more than one tdls link */
15200 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015201 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015202 {
15203 /* get connected peer and send disable tdls off chan */
15204 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15205 if (connPeer && (connPeer->isOffChannelConfigured == TRUE))
15206 {
15207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15208 "%s: More then one peer connected, Disable "
15209 "TDLS channel switch", __func__);
15210
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015211 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015212 ret = sme_SendTdlsChanSwitchReq(
15213 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015214 pAdapter->sessionId,
15215 connPeer->peerMac,
15216 connPeer->peerParams.channel,
15217 TDLS_OFF_CHANNEL_BW_OFFSET,
15218 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015219 if (ret != VOS_STATUS_SUCCESS) {
15220 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel request"));
15221 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015222 }
15223 else
15224 {
15225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15226 "%s: No TDLS Connected Peer or "
15227 "isOffChannelConfigured %d",
15228 __func__,
15229 (connPeer ? connPeer->isOffChannelConfigured : -1));
15230 }
15231 }
15232
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015233 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015234 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015235 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015236
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015237 if (0 != wlan_hdd_tdls_get_link_establish_params(
15238 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015239 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015240 return -EINVAL;
15241 }
15242 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015243
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015244 ret = sme_SendTdlsLinkEstablishParams(
15245 WLAN_HDD_GET_HAL_CTX(pAdapter),
15246 pAdapter->sessionId, peer,
15247 &tdlsLinkEstablishParams);
15248 if (ret != VOS_STATUS_SUCCESS) {
15249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15250 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015251 /* Send TDLS peer UAPSD capabilities to the firmware and
15252 * register with the TL on after the response for this operation
15253 * is received .
15254 */
15255 ret = wait_for_completion_interruptible_timeout(
15256 &pAdapter->tdls_link_establish_req_comp,
15257 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15258 if (ret <= 0)
15259 {
15260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15261 "%s: Link Establish Request Faled Status %ld",
15262 __func__, ret);
15263 return -EINVAL;
15264 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015265 }
Atul Mittal115287b2014-07-08 13:26:33 +053015266 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15267 eTDLS_LINK_CONNECTED,
15268 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015269 staDesc.ucSTAId = pTdlsPeer->staId;
15270 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015271 ret = WLANTL_UpdateTdlsSTAClient(
15272 pHddCtx->pvosContext,
15273 &staDesc);
15274 if (ret != VOS_STATUS_SUCCESS) {
15275 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15276 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015277
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015278 /* Mark TDLS client Authenticated .*/
15279 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15280 pTdlsPeer->staId,
15281 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015282 if (VOS_STATUS_SUCCESS == status)
15283 {
Hoonki Lee14621352013-04-16 17:51:19 -070015284 if (pTdlsPeer->is_responder == 0)
15285 {
15286 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15287
15288 wlan_hdd_tdls_timer_restart(pAdapter,
15289 &pTdlsPeer->initiatorWaitTimeoutTimer,
15290 WAIT_TIME_TDLS_INITIATOR);
15291 /* suspend initiator TX until it receives direct packet from the
15292 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015293 ret = WLANTL_SuspendDataTx(
15294 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15295 &staId, NULL);
15296 if (ret != VOS_STATUS_SUCCESS) {
15297 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15298 }
Hoonki Lee14621352013-04-16 17:51:19 -070015299 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015300
15301 /* TDLS Off Channel, Enable tdls channel switch,
15302 when their is only one tdls link and it supports */
15303 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15304 if ((numCurrTdlsPeers == 1) &&
15305 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15306 (TRUE == pTdlsPeer->isOffChannelConfigured))
15307 {
15308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15309 "%s: Send TDLS channel switch request for channel %d",
15310 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015311
15312 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015313 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15314 pAdapter->sessionId,
15315 pTdlsPeer->peerMac,
15316 pTdlsPeer->peerParams.channel,
15317 TDLS_OFF_CHANNEL_BW_OFFSET,
15318 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015319 if (ret != VOS_STATUS_SUCCESS) {
15320 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15321 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015322 }
15323 else
15324 {
15325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15326 "%s: TDLS channel switch request not sent"
15327 " numCurrTdlsPeers %d "
15328 "isOffChannelSupported %d "
15329 "isOffChannelConfigured %d",
15330 __func__, numCurrTdlsPeers,
15331 pTdlsPeer->isOffChannelSupported,
15332 pTdlsPeer->isOffChannelConfigured);
15333 }
15334
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015335 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015336 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015337
15338 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015339 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15340 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015341 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015342 int ac;
15343 uint8 ucAc[4] = { WLANTL_AC_VO,
15344 WLANTL_AC_VI,
15345 WLANTL_AC_BK,
15346 WLANTL_AC_BE };
15347 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15348 for(ac=0; ac < 4; ac++)
15349 {
15350 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15351 pTdlsPeer->staId, ucAc[ac],
15352 tlTid[ac], tlTid[ac], 0, 0,
15353 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015354 if (status != VOS_STATUS_SUCCESS) {
15355 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15356 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015357 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015358 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015359 }
15360
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015361 }
15362 break;
15363 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015364 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015365 tANI_U16 numCurrTdlsPeers = 0;
15366 hddTdlsPeer_t *connPeer = NULL;
15367
Sunil Dutt41de4e22013-11-14 18:09:02 +053015368 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15369
15370 if ( NULL == pTdlsPeer ) {
15371 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15372 " (oper %d) not exsting. ignored",
15373 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15374 return -EINVAL;
15375 }
15376
15377 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15378 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15379 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15380 "NL80211_TDLS_DISABLE_LINK");
15381
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015382 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015383 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015384 long status;
15385
Atul Mittal271a7652014-09-12 13:18:22 +053015386
15387 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15388 eTDLS_LINK_TEARING,
15389 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15390 eTDLS_LINK_UNSPECIFIED:
15391 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015392 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15393
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015394 status = sme_DeleteTdlsPeerSta(
15395 WLAN_HDD_GET_HAL_CTX(pAdapter),
15396 pAdapter->sessionId, peer );
15397 if (status != VOS_STATUS_SUCCESS) {
15398 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15399 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015400
15401 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15402 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015403 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015404 eTDLS_LINK_IDLE,
15405 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015406 if (status <= 0)
15407 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15409 "%s: Del station failed status %ld",
15410 __func__, status);
15411 return -EPERM;
15412 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015413
15414 /* TDLS Off Channel, Enable tdls channel switch,
15415 when their is only one tdls link and it supports */
15416 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15417 if (numCurrTdlsPeers == 1)
15418 {
15419 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15420 if ((connPeer) &&
15421 (connPeer->isOffChannelSupported == TRUE) &&
15422 (connPeer->isOffChannelConfigured == TRUE))
15423 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015424 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015425 status = sme_SendTdlsChanSwitchReq(
15426 WLAN_HDD_GET_HAL_CTX(pAdapter),
15427 pAdapter->sessionId,
15428 connPeer->peerMac,
15429 connPeer->peerParams.channel,
15430 TDLS_OFF_CHANNEL_BW_OFFSET,
15431 TDLS_CHANNEL_SWITCH_ENABLE);
15432 if (status != VOS_STATUS_SUCCESS) {
15433 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15434 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015435 }
15436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15437 "%s: TDLS channel switch "
15438 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015439 "isOffChannelConfigured %d "
15440 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015441 __func__,
15442 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015443 (connPeer ? connPeer->isOffChannelConfigured : -1),
15444 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015445 }
15446 else
15447 {
15448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15449 "%s: TDLS channel switch request not sent "
15450 "numCurrTdlsPeers %d ",
15451 __func__, numCurrTdlsPeers);
15452 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015453 }
15454 else
15455 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15457 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080015458 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015459 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015460 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015461 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015462 {
Atul Mittal115287b2014-07-08 13:26:33 +053015463 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015464
Atul Mittal115287b2014-07-08 13:26:33 +053015465 if (0 != status)
15466 {
15467 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15468 "%s: Error in TDLS Teardown", __func__);
15469 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015470 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053015471 break;
15472 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015473 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015474 {
Atul Mittal115287b2014-07-08 13:26:33 +053015475 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
15476 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015477 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053015478 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015479
Atul Mittal115287b2014-07-08 13:26:33 +053015480 if (0 != status)
15481 {
15482 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15483 "%s: Error in TDLS Setup", __func__);
15484 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053015485 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053015486 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015487 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015488 case NL80211_TDLS_DISCOVERY_REQ:
15489 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
15491 "%s: We don't support in-driver setup/teardown/discovery "
15492 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015493 return -ENOTSUPP;
15494 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015495 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15496 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015497 return -ENOTSUPP;
15498 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015499
15500 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015501 return 0;
15502}
Chilam NG571c65a2013-01-19 12:27:36 +053015503
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015504static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
15505 u8 *peer, enum nl80211_tdls_operation oper)
15506{
15507 int ret;
15508
15509 vos_ssr_protect(__func__);
15510 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
15511 vos_ssr_unprotect(__func__);
15512
15513 return ret;
15514}
15515
Chilam NG571c65a2013-01-19 12:27:36 +053015516int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
15517 struct net_device *dev, u8 *peer)
15518{
Arif Hussaina7c8e412013-11-20 11:06:42 -080015519 hddLog(VOS_TRACE_LEVEL_INFO,
15520 "tdls send discover req: "MAC_ADDRESS_STR,
15521 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053015522
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015523#if TDLS_MGMT_VERSION2
15524 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15525 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15526#else
Chilam NG571c65a2013-01-19 12:27:36 +053015527 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15528 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015529#endif
Chilam NG571c65a2013-01-19 12:27:36 +053015530}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015531#endif
15532
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015533#ifdef WLAN_FEATURE_GTK_OFFLOAD
15534/*
15535 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
15536 * Callback rountine called upon receiving response for
15537 * get offload info
15538 */
15539void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
15540 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
15541{
15542
15543 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015544 tANI_U8 tempReplayCounter[8];
15545 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015546
15547 ENTER();
15548
15549 if (NULL == pAdapter)
15550 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053015551 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015552 "%s: HDD adapter is Null", __func__);
15553 return ;
15554 }
15555
15556 if (NULL == pGtkOffloadGetInfoRsp)
15557 {
15558 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15559 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
15560 return ;
15561 }
15562
15563 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
15564 {
15565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15566 "%s: wlan Failed to get replay counter value",
15567 __func__);
15568 return ;
15569 }
15570
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015571 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15572 /* Update replay counter */
15573 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
15574 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15575
15576 {
15577 /* changing from little to big endian since supplicant
15578 * works on big endian format
15579 */
15580 int i;
15581 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15582
15583 for (i = 0; i < 8; i++)
15584 {
15585 tempReplayCounter[7-i] = (tANI_U8)p[i];
15586 }
15587 }
15588
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015589 /* Update replay counter to NL */
15590 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015591 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015592}
15593
15594/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015595 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015596 * This function is used to offload GTK rekeying job to the firmware.
15597 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015598int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015599 struct cfg80211_gtk_rekey_data *data)
15600{
15601 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15602 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15603 hdd_station_ctx_t *pHddStaCtx;
15604 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015605 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015606 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015607 eHalStatus status = eHAL_STATUS_FAILURE;
15608
15609 ENTER();
15610
15611 if (NULL == pAdapter)
15612 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015613 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015614 "%s: HDD adapter is Null", __func__);
15615 return -ENODEV;
15616 }
15617
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015618 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15619 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
15620 pAdapter->sessionId, pAdapter->device_mode));
15621
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015622 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015623 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015624 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015625 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015626 }
15627
15628 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15629 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15630 if (NULL == hHal)
15631 {
15632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15633 "%s: HAL context is Null!!!", __func__);
15634 return -EAGAIN;
15635 }
15636
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015637 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
15638 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
15639 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
15640 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015641 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015642 {
15643 /* changing from big to little endian since driver
15644 * works on little endian format
15645 */
15646 tANI_U8 *p =
15647 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
15648 int i;
15649
15650 for (i = 0; i < 8; i++)
15651 {
15652 p[7-i] = data->replay_ctr[i];
15653 }
15654 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015655
15656 if (TRUE == pHddCtx->hdd_wlan_suspended)
15657 {
15658 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015659 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
15660 sizeof (tSirGtkOffloadParams));
15661 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015662 pAdapter->sessionId);
15663
15664 if (eHAL_STATUS_SUCCESS != status)
15665 {
15666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15667 "%s: sme_SetGTKOffload failed, returned %d",
15668 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015669
15670 /* Need to clear any trace of key value in the memory.
15671 * Thus zero out the memory even though it is local
15672 * variable.
15673 */
15674 vos_mem_zero(&hddGtkOffloadReqParams,
15675 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015676 return status;
15677 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15679 "%s: sme_SetGTKOffload successfull", __func__);
15680 }
15681 else
15682 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15684 "%s: wlan not suspended GTKOffload request is stored",
15685 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015686 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015687
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015688 /* Need to clear any trace of key value in the memory.
15689 * Thus zero out the memory even though it is local
15690 * variable.
15691 */
15692 vos_mem_zero(&hddGtkOffloadReqParams,
15693 sizeof(hddGtkOffloadReqParams));
15694
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015695 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015696 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015697}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015698
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015699int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
15700 struct cfg80211_gtk_rekey_data *data)
15701{
15702 int ret;
15703
15704 vos_ssr_protect(__func__);
15705 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
15706 vos_ssr_unprotect(__func__);
15707
15708 return ret;
15709}
15710#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015711/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015712 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015713 * This function is used to set access control policy
15714 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015715static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15716 struct net_device *dev,
15717 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015718{
15719 int i;
15720 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15721 hdd_hostapd_state_t *pHostapdState;
15722 tsap_Config_t *pConfig;
15723 v_CONTEXT_t pVosContext = NULL;
15724 hdd_context_t *pHddCtx;
15725 int status;
15726
15727 ENTER();
15728
15729 if (NULL == pAdapter)
15730 {
15731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15732 "%s: HDD adapter is Null", __func__);
15733 return -ENODEV;
15734 }
15735
15736 if (NULL == params)
15737 {
15738 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15739 "%s: params is Null", __func__);
15740 return -EINVAL;
15741 }
15742
15743 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15744 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015745 if (0 != status)
15746 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015747 return status;
15748 }
15749
15750 pVosContext = pHddCtx->pvosContext;
15751 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
15752
15753 if (NULL == pHostapdState)
15754 {
15755 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15756 "%s: pHostapdState is Null", __func__);
15757 return -EINVAL;
15758 }
15759
15760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
15761 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
15762
15763 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
15764 {
15765 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
15766
15767 /* default value */
15768 pConfig->num_accept_mac = 0;
15769 pConfig->num_deny_mac = 0;
15770
15771 /**
15772 * access control policy
15773 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
15774 * listed in hostapd.deny file.
15775 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
15776 * listed in hostapd.accept file.
15777 */
15778 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
15779 {
15780 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
15781 }
15782 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
15783 {
15784 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
15785 }
15786 else
15787 {
15788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15789 "%s:Acl Policy : %d is not supported",
15790 __func__, params->acl_policy);
15791 return -ENOTSUPP;
15792 }
15793
15794 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
15795 {
15796 pConfig->num_accept_mac = params->n_acl_entries;
15797 for (i = 0; i < params->n_acl_entries; i++)
15798 {
15799 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15800 "** Add ACL MAC entry %i in WhiletList :"
15801 MAC_ADDRESS_STR, i,
15802 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
15803
15804 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
15805 sizeof(qcmacaddr));
15806 }
15807 }
15808 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
15809 {
15810 pConfig->num_deny_mac = params->n_acl_entries;
15811 for (i = 0; i < params->n_acl_entries; i++)
15812 {
15813 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15814 "** Add ACL MAC entry %i in BlackList :"
15815 MAC_ADDRESS_STR, i,
15816 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
15817
15818 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
15819 sizeof(qcmacaddr));
15820 }
15821 }
15822
15823 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
15824 {
15825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15826 "%s: SAP Set Mac Acl fail", __func__);
15827 return -EINVAL;
15828 }
15829 }
15830 else
15831 {
15832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015833 "%s: Invalid device_mode = %s (%d)",
15834 __func__, hdd_device_modetoString(pAdapter->device_mode),
15835 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015836 return -EINVAL;
15837 }
15838
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015839 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015840 return 0;
15841}
15842
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015843static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15844 struct net_device *dev,
15845 const struct cfg80211_acl_data *params)
15846{
15847 int ret;
15848 vos_ssr_protect(__func__);
15849 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
15850 vos_ssr_unprotect(__func__);
15851
15852 return ret;
15853}
15854
Leo Chang9056f462013-08-01 19:21:11 -070015855#ifdef WLAN_NL80211_TESTMODE
15856#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070015857void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070015858(
15859 void *pAdapter,
15860 void *indCont
15861)
15862{
Leo Changd9df8aa2013-09-26 13:32:26 -070015863 tSirLPHBInd *lphbInd;
15864 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053015865 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070015866
15867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070015868 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070015869
c_hpothu73f35e62014-04-18 13:40:08 +053015870 if (pAdapter == NULL)
15871 {
15872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15873 "%s: pAdapter is NULL\n",__func__);
15874 return;
15875 }
15876
Leo Chang9056f462013-08-01 19:21:11 -070015877 if (NULL == indCont)
15878 {
15879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070015880 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070015881 return;
15882 }
15883
c_hpothu73f35e62014-04-18 13:40:08 +053015884 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070015885 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070015886 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053015887 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070015888 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070015889 GFP_ATOMIC);
15890 if (!skb)
15891 {
15892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15893 "LPHB timeout, NL buffer alloc fail");
15894 return;
15895 }
15896
Leo Changac3ba772013-10-07 09:47:04 -070015897 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070015898 {
15899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15900 "WLAN_HDD_TM_ATTR_CMD put fail");
15901 goto nla_put_failure;
15902 }
Leo Changac3ba772013-10-07 09:47:04 -070015903 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070015904 {
15905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15906 "WLAN_HDD_TM_ATTR_TYPE put fail");
15907 goto nla_put_failure;
15908 }
Leo Changac3ba772013-10-07 09:47:04 -070015909 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070015910 sizeof(tSirLPHBInd), lphbInd))
15911 {
15912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15913 "WLAN_HDD_TM_ATTR_DATA put fail");
15914 goto nla_put_failure;
15915 }
Leo Chang9056f462013-08-01 19:21:11 -070015916 cfg80211_testmode_event(skb, GFP_ATOMIC);
15917 return;
15918
15919nla_put_failure:
15920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15921 "NLA Put fail");
15922 kfree_skb(skb);
15923
15924 return;
15925}
15926#endif /* FEATURE_WLAN_LPHB */
15927
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015928static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070015929{
15930 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
15931 int err = 0;
15932#ifdef FEATURE_WLAN_LPHB
15933 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070015934 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015935
15936 ENTER();
15937
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053015938 err = wlan_hdd_validate_context(pHddCtx);
15939 if (0 != err)
15940 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053015941 return err;
15942 }
Leo Chang9056f462013-08-01 19:21:11 -070015943#endif /* FEATURE_WLAN_LPHB */
15944
15945 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
15946 if (err)
15947 {
15948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15949 "%s Testmode INV ATTR", __func__);
15950 return err;
15951 }
15952
15953 if (!tb[WLAN_HDD_TM_ATTR_CMD])
15954 {
15955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15956 "%s Testmode INV CMD", __func__);
15957 return -EINVAL;
15958 }
15959
15960 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
15961 {
15962#ifdef FEATURE_WLAN_LPHB
15963 /* Low Power Heartbeat configuration request */
15964 case WLAN_HDD_TM_CMD_WLAN_HB:
15965 {
15966 int buf_len;
15967 void *buf;
15968 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080015969 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070015970
15971 if (!tb[WLAN_HDD_TM_ATTR_DATA])
15972 {
15973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15974 "%s Testmode INV DATA", __func__);
15975 return -EINVAL;
15976 }
15977
15978 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
15979 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080015980
15981 hb_params_temp =(tSirLPHBReq *)buf;
15982 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
15983 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
15984 return -EINVAL;
15985
Leo Chang9056f462013-08-01 19:21:11 -070015986 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
15987 if (NULL == hb_params)
15988 {
15989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15990 "%s Request Buffer Alloc Fail", __func__);
15991 return -EINVAL;
15992 }
15993
15994 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070015995 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
15996 hb_params,
15997 wlan_hdd_cfg80211_lphb_ind_handler);
15998 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070015999 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016000 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16001 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016002 vos_mem_free(hb_params);
16003 }
Leo Chang9056f462013-08-01 19:21:11 -070016004 return 0;
16005 }
16006#endif /* FEATURE_WLAN_LPHB */
16007 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16009 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016010 return -EOPNOTSUPP;
16011 }
16012
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016013 EXIT();
16014 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016015}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016016
16017static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
16018{
16019 int ret;
16020
16021 vos_ssr_protect(__func__);
16022 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16023 vos_ssr_unprotect(__func__);
16024
16025 return ret;
16026}
Leo Chang9056f462013-08-01 19:21:11 -070016027#endif /* CONFIG_NL80211_TESTMODE */
16028
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016029static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016030 struct net_device *dev,
16031 int idx, struct survey_info *survey)
16032{
16033 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16034 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016035 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016036 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016037 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016038 v_S7_t snr,rssi;
16039 int status, i, j, filled = 0;
16040
16041 ENTER();
16042
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016043 if (NULL == pAdapter)
16044 {
16045 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16046 "%s: HDD adapter is Null", __func__);
16047 return -ENODEV;
16048 }
16049
16050 if (NULL == wiphy)
16051 {
16052 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16053 "%s: wiphy is Null", __func__);
16054 return -ENODEV;
16055 }
16056
16057 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16058 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016059 if (0 != status)
16060 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016061 return status;
16062 }
16063
Mihir Sheted9072e02013-08-21 17:02:29 +053016064 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16065
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016066 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016067 0 != pAdapter->survey_idx ||
16068 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016069 {
16070 /* The survey dump ops when implemented completely is expected to
16071 * return a survey of all channels and the ops is called by the
16072 * kernel with incremental values of the argument 'idx' till it
16073 * returns -ENONET. But we can only support the survey for the
16074 * operating channel for now. survey_idx is used to track
16075 * that the ops is called only once and then return -ENONET for
16076 * the next iteration
16077 */
16078 pAdapter->survey_idx = 0;
16079 return -ENONET;
16080 }
16081
16082 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16083
16084 wlan_hdd_get_snr(pAdapter, &snr);
16085 wlan_hdd_get_rssi(pAdapter, &rssi);
16086
16087 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16088 hdd_wlan_get_freq(channel, &freq);
16089
16090
16091 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16092 {
16093 if (NULL == wiphy->bands[i])
16094 {
16095 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16096 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16097 continue;
16098 }
16099
16100 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16101 {
16102 struct ieee80211_supported_band *band = wiphy->bands[i];
16103
16104 if (band->channels[j].center_freq == (v_U16_t)freq)
16105 {
16106 survey->channel = &band->channels[j];
16107 /* The Rx BDs contain SNR values in dB for the received frames
16108 * while the supplicant expects noise. So we calculate and
16109 * return the value of noise (dBm)
16110 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16111 */
16112 survey->noise = rssi - snr;
16113 survey->filled = SURVEY_INFO_NOISE_DBM;
16114 filled = 1;
16115 }
16116 }
16117 }
16118
16119 if (filled)
16120 pAdapter->survey_idx = 1;
16121 else
16122 {
16123 pAdapter->survey_idx = 0;
16124 return -ENONET;
16125 }
16126
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016127 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016128 return 0;
16129}
16130
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016131static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16132 struct net_device *dev,
16133 int idx, struct survey_info *survey)
16134{
16135 int ret;
16136
16137 vos_ssr_protect(__func__);
16138 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16139 vos_ssr_unprotect(__func__);
16140
16141 return ret;
16142}
16143
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016144/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016145 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016146 * this is called when cfg80211 driver resume
16147 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16148 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016149int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016150{
16151 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16152 hdd_adapter_t *pAdapter;
16153 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16154 VOS_STATUS status = VOS_STATUS_SUCCESS;
16155
16156 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016157
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016158 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016159 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016160 return 0;
16161 }
16162
16163 spin_lock(&pHddCtx->schedScan_lock);
16164 pHddCtx->isWiphySuspended = FALSE;
16165 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16166 {
16167 spin_unlock(&pHddCtx->schedScan_lock);
16168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16169 "%s: Return resume is not due to PNO indication", __func__);
16170 return 0;
16171 }
16172 // Reset flag to avoid updatating cfg80211 data old results again
16173 pHddCtx->isSchedScanUpdatePending = FALSE;
16174 spin_unlock(&pHddCtx->schedScan_lock);
16175
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016176
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016177 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16178
16179 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16180 {
16181 pAdapter = pAdapterNode->pAdapter;
16182 if ( (NULL != pAdapter) &&
16183 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16184 {
16185 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016186 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16188 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016189 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016190 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016191 {
16192 /* Acquire wakelock to handle the case where APP's tries to
16193 * suspend immediately after updating the scan results. Whis
16194 * results in app's is in suspended state and not able to
16195 * process the connect request to AP
16196 */
16197 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016198 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016199 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016200
16201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16202 "%s : cfg80211 scan result database updated", __func__);
16203
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016204 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016205 return 0;
16206
16207 }
16208 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16209 pAdapterNode = pNext;
16210 }
16211
16212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16213 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016214 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016215 return 0;
16216}
16217
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016218int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16219{
16220 int ret;
16221
16222 vos_ssr_protect(__func__);
16223 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16224 vos_ssr_unprotect(__func__);
16225
16226 return ret;
16227}
16228
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016229/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016230 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016231 * this is called when cfg80211 driver suspends
16232 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016233int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016234 struct cfg80211_wowlan *wow)
16235{
16236 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016237 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016238
16239 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016240
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016241 ret = wlan_hdd_validate_context(pHddCtx);
16242 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016243 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016244 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016245 }
16246
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016247
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016248 pHddCtx->isWiphySuspended = TRUE;
16249
16250 EXIT();
16251
16252 return 0;
16253}
16254
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016255int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16256 struct cfg80211_wowlan *wow)
16257{
16258 int ret;
16259
16260 vos_ssr_protect(__func__);
16261 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16262 vos_ssr_unprotect(__func__);
16263
16264 return ret;
16265}
Jeff Johnson295189b2012-06-20 16:38:30 -070016266/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016267static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016268{
16269 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16270 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16271 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16272 .change_station = wlan_hdd_change_station,
16273#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16274 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16275 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16276 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016277#else
16278 .start_ap = wlan_hdd_cfg80211_start_ap,
16279 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16280 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016281#endif
16282 .change_bss = wlan_hdd_cfg80211_change_bss,
16283 .add_key = wlan_hdd_cfg80211_add_key,
16284 .get_key = wlan_hdd_cfg80211_get_key,
16285 .del_key = wlan_hdd_cfg80211_del_key,
16286 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016287#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016288 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016289#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016290 .scan = wlan_hdd_cfg80211_scan,
16291 .connect = wlan_hdd_cfg80211_connect,
16292 .disconnect = wlan_hdd_cfg80211_disconnect,
16293 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16294 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16295 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16296 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16297 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016298 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16299 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016300 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016301#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16302 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16303 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16304 .set_txq_params = wlan_hdd_set_txq_params,
16305#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016306 .get_station = wlan_hdd_cfg80211_get_station,
16307 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16308 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016309 .add_station = wlan_hdd_cfg80211_add_station,
16310#ifdef FEATURE_WLAN_LFR
16311 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16312 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16313 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16314#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016315#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16316 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16317#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016318#ifdef FEATURE_WLAN_TDLS
16319 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16320 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16321#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016322#ifdef WLAN_FEATURE_GTK_OFFLOAD
16323 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16324#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016325#ifdef FEATURE_WLAN_SCAN_PNO
16326 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16327 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16328#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016329 .resume = wlan_hdd_cfg80211_resume_wlan,
16330 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016331 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016332#ifdef WLAN_NL80211_TESTMODE
16333 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16334#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016335 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016336};
16337