blob: 41ba21f4a9ec04eb7e96f763d8fd1228dc3fa785 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Hanumanth Reddy Pothula94bd51a2017-12-01 13:34:48 +05302 * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Anand N Sunkad0a3436f2015-05-01 14:22:19 +053053#include <linux/wcnss_wlan.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053054#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include <wlan_hdd_includes.h>
56#include <wlan_btc_svc.h>
57#include <wlan_nlink_common.h>
58#ifdef WLAN_BTAMP_FEATURE
59#include <bap_hdd_main.h>
60#endif
61#include <vos_api.h>
62#include <net/arp.h>
63#include "ccmApi.h"
64#include "sirParams.h"
65#include "csrApi.h"
66#include "csrInsideApi.h"
67#if defined WLAN_FEATURE_VOWIFI
68#include "smeRrmInternal.h"
69#endif
70#include <aniGlobal.h>
71#include "dot11f.h"
72#include <wlan_hdd_wowl.h>
73#include <wlan_hdd_cfg.h>
74#include <wlan_hdd_wmm.h>
75#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080
81#ifdef CONFIG_HAS_EARLYSUSPEND
82#include <linux/earlysuspend.h>
83#endif
84#include "wlan_hdd_power.h"
85#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070086#include "wlan_hdd_host_offload.h"
87#include "wlan_hdd_keep_alive.h"
88#ifdef WLAN_FEATURE_PACKET_FILTERING
89#include "wlan_hdd_packet_filtering.h"
90#endif
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070094#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053095#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#include "wlan_hdd_misc.h"
98#include "bap_hdd_misc.h"
99
100#include "wlan_hdd_dev_pwr.h"
101#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530102#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700103#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530104#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Mukul Sharma84f27252014-07-14 18:11:42 +0530106#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530107#include "sapInternal.h"
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530108#include "wlan_hdd_request_manager.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530109
Jeff Johnson295189b2012-06-20 16:38:30 -0700110#ifdef CONFIG_HAS_EARLYSUSPEND
111extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
112extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
113#endif
114
Jeff Johnsone7245742012-09-05 17:12:55 -0700115#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800116#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700117#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700118
119#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530120#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122
Atul Mittalc0f739f2014-07-31 13:47:47 +0530123// tdlsoffchan
124#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530125static int tdlsOffCh = 1;
126static int tdlsOffChBwOffset = 0;
127#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530128
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700129static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700130module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
131
Jeff Johnson295189b2012-06-20 16:38:30 -0700132/* To Validate Channel against the Frequency and Vice-Versa */
133static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
134 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
135 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
136 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
137 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
138 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
139 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
140 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800141 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
142 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700143
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800144#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700145
146/* Private ioctls and their sub-ioctls */
147#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
148#define WE_SET_11D_STATE 1
149#define WE_WOWL 2
150#define WE_SET_POWER 3
151#define WE_SET_MAX_ASSOC 4
152#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
153#define WE_SET_DATA_INACTIVITY_TO 6
154#define WE_SET_MAX_TX_POWER 7
155#define WE_SET_HIGHER_DTIM_TRANSITION 8
156#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530157#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700158#define WE_SET_MAX_TX_POWER_2_4 11
159#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800160/* Private IOCTL for debug connection issues */
161#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530162// tdlsoffchan
163#ifdef FEATURE_WLAN_TDLS
164#define WE_SET_TDLS_OFF_CHAN 14
165#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
166#define WE_SET_TDLS_OFF_CHAN_MODE 16
167#endif
Peng Xu2446a892014-09-05 17:21:18 +0530168#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530169#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530170#define WE_GET_FRAME_LOG 19
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530171#ifdef FEATURE_WLAN_TDLS
172#define WE_SET_TDLS_2040_BSS_COEXISTENCE 20
173#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +0530174#define WE_SET_RTS_CTS_HTVHT 21
Katya Nigamf0511f62015-05-05 16:40:57 +0530175#define WE_SET_MONITOR_STATE 22
Sushant Kaushik33200572015-08-05 16:46:20 +0530176#define WE_SET_PKT_STATS_ENABLE_DISABLE 23
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530177#define WE_SET_PROXIMITY_ENABLE 24
Manjeet Singh3ed79242017-01-11 19:04:32 +0530178#define WE_CAP_TSF 25
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +0530179#define WE_SET_MODULATED_DTIM 26
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +0530180#define WLAN_SET_DYNNAMIC_AGGREGATION 27
Jeff Johnson295189b2012-06-20 16:38:30 -0700181
182/* Private ioctls and their sub-ioctls */
183#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
184#define WE_GET_11D_STATE 1
185#define WE_IBSS_STATUS 2
186#define WE_PMC_STATE 3
187#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700188#define WE_GET_MAX_ASSOC 6
189#define WE_GET_WDI_DBG 7
190#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
191#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530192#define WE_GET_SCAN_BAND_PREFERENCE 10
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +0530193#define WE_GET_ANTENA_DIVERSITY_SELECTION 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700194/* Private ioctls and their sub-ioctls */
195#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
196
197/* Private ioctls and their sub-ioctls */
198#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
199#define WE_WOWL_ADD_PTRN 1
200#define WE_WOWL_DEL_PTRN 2
201#if defined WLAN_FEATURE_VOWIFI
202#define WE_NEIGHBOR_REPORT_REQUEST 3
203#endif
204#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
205#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530206#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700207
208/* Private ioctls and their sub-ioctls */
209#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
210#define WE_SET_WLAN_DBG 1
211#define WE_SET_WDI_DBG 2
212#define WE_SET_SAP_CHANNELS 3
213
214/* Private ioctls and their sub-ioctls */
215#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
216#define WE_WLAN_VERSION 1
217#define WE_GET_STATS 2
218#define WE_GET_CFG 3
219#define WE_GET_WMM_STATUS 4
220#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700221#ifdef WLAN_FEATURE_11AC
222#define WE_GET_RSSI 6
223#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800224#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800225#ifdef FEATURE_WLAN_TDLS
226#define WE_GET_TDLS_PEERS 8
227#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700228#ifdef WLAN_FEATURE_11W
229#define WE_GET_11W_INFO 9
230#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530231#define WE_GET_STATES 10
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530232#ifdef WLAN_FEATURE_RMC
233#define WE_GET_IBSS_STA_INFO 11
234#endif
235#define WE_GET_SNR 12
Jeff Johnson295189b2012-06-20 16:38:30 -0700236
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +0530237#ifdef FEATURE_OEM_DATA_SUPPORT
238#define WE_GET_OEM_DATA_CAP 13
239#endif
240
Jeff Johnson295189b2012-06-20 16:38:30 -0700241/* Private ioctls and their sub-ioctls */
242#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
243#define WE_CLEAR_STATS 1
244#define WE_INIT_AP 2
245#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530246#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700247#define WE_ENABLE_AMP 4
248#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530249#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700250#define WE_ENABLE_DXE_STALL_DETECT 6
251#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700252#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530253#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530254#ifdef WLAN_FEATURE_RMC
255#define WE_IBSS_GET_PEER_INFO_ALL 10
256#endif
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530257#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530258#define WE_DUMP_ROAM_TIMER_LOG 12
259#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530260#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530261#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530262
Jeff Johnson295189b2012-06-20 16:38:30 -0700263/* Private ioctls and their sub-ioctls */
264#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
265#define WE_LOG_DUMP_CMD 1
266
Jeff Johnson295189b2012-06-20 16:38:30 -0700267#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800268//IOCTL to configure MCC params
269#define WE_MCC_CONFIG_CREDENTIAL 3
270#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700271
Chilam NG571c65a2013-01-19 12:27:36 +0530272#ifdef FEATURE_WLAN_TDLS
273#define WE_TDLS_CONFIG_PARAMS 5
274#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530275#ifdef WLAN_FEATURE_RMC
276#define WE_IBSS_GET_PEER_INFO 6
277#endif
Chilam NG571c65a2013-01-19 12:27:36 +0530278
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700279#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530280#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530281#define WE_CONFIGURE_MONITOR_MODE 10
282#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700283
Chilam Ng01120412013-02-19 18:32:21 -0800284#ifdef FEATURE_WLAN_TDLS
285#undef MAX_VAR_ARGS
286#define MAX_VAR_ARGS 10
287#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700288#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800289#endif
290
Jeff Johnson295189b2012-06-20 16:38:30 -0700291/* Private ioctls (with no sub-ioctls) */
292/* note that they must be odd so that they have "get" semantics */
293#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
294#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
295#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
296
Girish Gowli464c9c82014-06-09 19:47:53 +0530297/* (SIOCIWFIRSTPRIV + 8) is currently unused */
298/* (SIOCIWFIRSTPRIV + 16) is currently unused */
299/* (SIOCIWFIRSTPRIV + 10) is currently unused */
300/* (SIOCIWFIRSTPRIV + 12) is currently unused */
301/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manjeet Singh3ed79242017-01-11 19:04:32 +0530302#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
303#define WE_GET_TSF 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700304
Jeff Johnsone7245742012-09-05 17:12:55 -0700305#ifdef FEATURE_OEM_DATA_SUPPORT
306/* Private ioctls for setting the measurement configuration */
307#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
308#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
309#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700310
311#ifdef WLAN_FEATURE_VOWIFI_11R
312#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
313#endif
314
315/* Private ioctl for setting the host offload feature */
316#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
317
318/* Private ioctl to get the statistics */
319#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
320
321/* Private ioctl to set the Keep Alive Params */
322#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
323#ifdef WLAN_FEATURE_PACKET_FILTERING
324/* Private ioctl to set the Packet Filtering Params */
325#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
326#endif
327
328#ifdef FEATURE_WLAN_SCAN_PNO
329/* Private ioctl to get the statistics */
330#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
331#endif
332
333#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
334
335#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
336#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700337/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700338
Jeff Johnson295189b2012-06-20 16:38:30 -0700339#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
340#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
341
342#define WLAN_STATS_INVALID 0
343#define WLAN_STATS_RETRY_CNT 1
344#define WLAN_STATS_MUL_RETRY_CNT 2
345#define WLAN_STATS_TX_FRM_CNT 3
346#define WLAN_STATS_RX_FRM_CNT 4
347#define WLAN_STATS_FRM_DUP_CNT 5
348#define WLAN_STATS_FAIL_CNT 6
349#define WLAN_STATS_RTS_FAIL_CNT 7
350#define WLAN_STATS_ACK_FAIL_CNT 8
351#define WLAN_STATS_RTS_SUC_CNT 9
352#define WLAN_STATS_RX_DISCARD_CNT 10
353#define WLAN_STATS_RX_ERROR_CNT 11
354#define WLAN_STATS_TX_BYTE_CNT 12
355
356#define WLAN_STATS_RX_BYTE_CNT 13
357#define WLAN_STATS_RX_RATE 14
358#define WLAN_STATS_TX_RATE 15
359
Jeff Johnsone7245742012-09-05 17:12:55 -0700360#define WLAN_STATS_RX_UC_BYTE_CNT 16
361#define WLAN_STATS_RX_MC_BYTE_CNT 17
362#define WLAN_STATS_RX_BC_BYTE_CNT 18
363#define WLAN_STATS_TX_UC_BYTE_CNT 19
364#define WLAN_STATS_TX_MC_BYTE_CNT 20
365#define WLAN_STATS_TX_BC_BYTE_CNT 21
366
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800367#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
368 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
369 { \
370 *__p++ = __type; \
371 *__p++ = __size; \
372 memcpy(__p, __val, __size); \
373 __p += __size; \
374 __tlen += __size + 2; \
375 } \
376 else \
377 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800378 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800379 } \
380 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700381
382#define VERSION_VALUE_MAX_LEN 32
383
384#define TX_PER_TRACKING_DEFAULT_RATIO 5
385#define TX_PER_TRACKING_MAX_RATIO 10
386#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
387
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530388#define WLAN_ADAPTER 0
389#define P2P_ADAPTER 1
390
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530391#define TX_PWR_MIN 6
392#define TX_PWR_MAX 22
393#define TX_PWR_DEF 50
394
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +0530395/* Dynamic Aggregation */
396#define DISABLE_AGGREGATION 0
397#define ENABLE_AGGREGATION 1
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530398/*
399 * When supplicant sends SETBAND ioctl it queries for channels from
400 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
401 * This is not required if the return type from ioctl is
402 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
403 * event as part of regulatory_hint.
404 */
405enum {
406 SEND_CHANNEL_CHANGE_EVENT = 0,
407 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
408};
409
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800410/*MCC Configuration parameters */
411enum {
412 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
413 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
414 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
415 MCC_RX_DRAIN_TIME_CFG_PARAM,
416 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
417 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
418 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
419 MCC_MIN_AFTER_DTIM_CFG_PARAM,
420 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
421};
422
423int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
424 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
425
Jeff Johnson295189b2012-06-20 16:38:30 -0700426#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +0530427int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest);
Jeff Johnson295189b2012-06-20 16:38:30 -0700428#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530429static int get_fwr_memdump(struct net_device *,
430 struct iw_request_info *,
431 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700432/**---------------------------------------------------------------------------
433
Arif Hussain0273cba2014-01-07 20:58:29 -0800434 \brief mem_alloc_copy_from_user_helper -
435
436 Helper function to allocate buffer and copy user data.
437
438 \param - wrqu - Pointer to IOCTL Data.
439 len - size
440
441 \return - On Success pointer to buffer, On failure NULL
442
443 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530444void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800445{
446 u8 *ptr = NULL;
447
448 /* in order to protect the code, an extra byte is post appended to the buffer
449 * and the null termination is added. However, when allocating (len+1) byte
450 * of memory, we need to make sure that there is no uint overflow when doing
451 * addition. In theory check len < UINT_MAX protects the uint overflow. For
452 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
453 * guess, now, it is assumed that the private command buffer size is no
454 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
455 */
456 if (len > MAX_USER_COMMAND_SIZE)
457 {
458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
459 "Invalid length");
460 return NULL;
461 }
462
463 ptr = kmalloc(len + 1, GFP_KERNEL);
464 if (NULL == ptr)
465 {
466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
467 "unable to allocate memory");
468 return NULL;
469 }
470
471 if (copy_from_user(ptr, wrqu_data, len))
472 {
473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
474 "%s: failed to copy data to user buffer", __func__);
475 kfree(ptr);
476 return NULL;
477 }
478 ptr[len] = '\0';
479 return ptr;
480}
481
Girish Gowli488ef492014-06-12 18:44:33 +0530482// Function to handle and get compatible struct iw_point passed to ioctl.
483int hdd_priv_get_data(struct iw_point *p_priv_data,
484 union iwreq_data *wrqu)
485{
486 if ((NULL == p_priv_data) || (NULL == wrqu))
487 {
488 return -EINVAL;
489 }
490
491#ifdef CONFIG_COMPAT
492 if (is_compat_task())
493 {
494 struct compat_iw_point *p_compat_priv_data;
495
496 // Compat task: typecast to campat structure and copy the members.
497 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
498
499 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
500 p_priv_data->length = p_compat_priv_data->length;
501 p_priv_data->flags = p_compat_priv_data->flags;
502 }//if(is_compat_task())
503 else
504 {
505#endif //#ifdef CONFIG_COMPAT
506
507 // Non compat task: directly copy the structure.
508 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
509
510#ifdef CONFIG_COMPAT
511 }//else of - if(is_compat_task())
512#endif //#ifdef CONFIG_COMPAT
513
514 return 0;
515}
516
Arif Hussain0273cba2014-01-07 20:58:29 -0800517/**---------------------------------------------------------------------------
518
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 \brief hdd_wlan_get_version() -
520
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800521 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700522
523 \param - pAdapter Pointer to the adapter.
524 wrqu - Pointer to IOCTL REQUEST Data.
525 extra - Pointer to char
526
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800527 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700528
529 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800530void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
531 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700532{
533 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800534 tSirVersionString wcnss_SW_version;
535 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530536 tSirVersionString iris_name;
537 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800538 char *pSWversion;
539 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700541
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800542 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
543 sizeof(wcnss_SW_version));
544 if (VOS_IS_STATUS_SUCCESS(status))
545 {
546 pSWversion = wcnss_SW_version;
547 }
548 else
549 {
550 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 }
552
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800553 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
554 sizeof(wcnss_HW_version));
555 if (VOS_IS_STATUS_SUCCESS(status))
556 {
557 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800559 else
560 {
561 pHWversion = "Unknown";
562 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700563
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530564 status = wcnss_get_iris_name(iris_name);
565
566 if (!status) {
567 pIRISversion = iris_name;
568 } else {
569 pIRISversion = "Unknown";
570 }
571
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700572 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530573 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800574 QWLAN_VERSIONSTR,
575 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530576 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800577
578 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700579}
580
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530581#ifdef WLAN_FEATURE_RMC
582void hdd_get_ibss_peer_info_cb(v_VOID_t *pUserData, v_VOID_t *pPeerInfoRsp)
583{
584 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pUserData;
585 tSirPeerInfoRspParams *pPeerInfo = (tSirPeerInfoRspParams *)pPeerInfoRsp;
586 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
587 v_U8_t i;
588
589 if (NULL != pPeerInfo && eHAL_STATUS_SUCCESS == pPeerInfo->status)
590 {
591 pStaCtx->ibss_peer_info.status = pPeerInfo->status;
592 pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numPeers;
593 for (i = 0; i < pPeerInfo->numPeers; i++)
594 {
595 memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i],
596 &pPeerInfo->peerInfoParams[i], sizeof(hdd_ibss_peer_info_params_t));
597 }
598 }
599 else
600 {
601 hddLog(LOGE,
602 FL("PEER_INFO_CMD_STATUS is not SUCCESS"));
603 }
604
605 complete(&pAdapter->ibss_peer_info_comp);
606}
607
608v_MACADDR_t* hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter, v_U8_t staIdx)
609{
610 v_U8_t idx;
611 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
612
613 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
614 {
615 if ( 0 != pHddStaCtx->conn_info.staId[ idx ] &&
616 staIdx == pHddStaCtx->conn_info.staId[ idx ])
617 {
618 return (&pHddStaCtx->conn_info.peerMacAddress[ idx ]);
619 }
620 }
621 return NULL;
622}
623
624eHalStatus hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter, v_U8_t staIdx)
625{
626 eHalStatus status = eHAL_STATUS_FAILURE;
627 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
628 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
629 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
630
631 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
632 VOS_FALSE, staIdx);
633
634 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
635
636 if (eHAL_STATUS_SUCCESS == status)
637 {
638 long ret;
639 ret = wait_for_completion_interruptible_timeout
640 (&pAdapter->ibss_peer_info_comp,
641 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
642 if (ret <= 0)
643 {
644 hddLog(VOS_TRACE_LEVEL_ERROR,
645 FL("failed wait on ibss_peer_info_comp %ld"), ret);
646 return eHAL_STATUS_FAILURE;
647 }
648
649 /** Print the peer info */
650 pr_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numIBSSPeers);
651 pr_info("============================================================");
652 {
653 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
654 staIdx);
655 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
656
657 if (NULL != macAddr)
658 {
659 pr_info("PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
660 MAC_ADDR_ARRAY(macAddr->bytes),
661 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[0].rssi);
662 }
663 else
664 {
665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
666 " ERROR: PEER MAC ADDRESS NOT FOUND ");
667 }
668 }
669 }
670 else
671 {
672 hddLog(VOS_TRACE_LEVEL_WARN,
673 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
674 }
675
676 return status;
677}
678
679eHalStatus hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
680{
681 eHalStatus status = eHAL_STATUS_FAILURE;
682 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
683 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
684 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
685 int i;
686
687 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
688 VOS_TRUE, 0xFF);
689 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
690
691 if (eHAL_STATUS_SUCCESS == status)
692 {
693 long ret;
694 ret = wait_for_completion_interruptible_timeout
695 (&pAdapter->ibss_peer_info_comp,
696 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
697 if (ret <= 0)
698 {
699 hddLog(VOS_TRACE_LEVEL_ERROR,
700 FL("failed wait on ibss_peer_info_comp %ld"), ret);
701 return eHAL_STATUS_FAILURE;
702 }
703
704 /** Print the peer info */
705 pr_info("pPeerInfo->numIBSSPeers = %d ", (int)pPeerInfo->numIBSSPeers);
706 pr_info("============================================================");
707 for (i = 0; i < pPeerInfo->numIBSSPeers; i++)
708 {
709 v_U8_t staIdx = pPeerInfo->ibssPeerList[i].staIdx;
710 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
711 staIdx);
712 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
713
714 pr_info("STAIDX:%d ", (int)pPeerInfo->ibssPeerList[i].staIdx);
715 if (NULL != macAddr)
716 {
717 pr_info(" PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
718 MAC_ADDR_ARRAY(macAddr->bytes),
719 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[i].rssi);
720 }
721 else
722 {
723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
724 " ERROR: PEER MAC ADDRESS NOT FOUND ");
725 }
726 }
727 }
728 else
729 {
730 hddLog(VOS_TRACE_LEVEL_WARN,
731 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
732 }
733
734 return status;
735}
736#endif /* WLAN_FEATURE_RMC */
737
Jeff Johnson295189b2012-06-20 16:38:30 -0700738int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
739{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530740 tHalHandle hHal;
741 hdd_context_t *pHddCtx;
742 v_U32_t threshold = 0;
743 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700744
745 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530746 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530747 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
749 "%s: Adapter is NULL",__func__);
750 return -EINVAL;
751 }
752
753 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
754 ret = wlan_hdd_validate_context(pHddCtx);
755 if (0 != ret)
756 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530757 return ret;
758 }
759
760 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
761 if (NULL == hHal)
762 {
763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
764 "%s: Hal Context is NULL",__func__);
765 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700766 }
767
768 if ( eHAL_STATUS_SUCCESS !=
769 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
770 {
c_hpothub8245442013-11-20 23:41:09 +0530771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
772 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 return -EIO;
774 }
775 wrqu->rts.value = threshold;
776
777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800778 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700779
780 EXIT();
781
782 return 0;
783}
784
785int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
786{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530787 tHalHandle hHal;
788 hdd_context_t *pHddCtx;
789 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700790
791 ENTER();
792
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530793 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530794 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
796 "%s: Adapter is NULL",__func__);
797 return -EINVAL;
798 }
799
800 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
801 status = wlan_hdd_validate_context(pHddCtx);
802 if (0 != status)
803 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530804 return status;
805 }
806
807 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
808 if (NULL == hHal)
809 {
810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
811 "%s: Hal Context is NULL",__func__);
812 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 }
814
815 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
816 != eHAL_STATUS_SUCCESS )
817 {
c_hpothub8245442013-11-20 23:41:09 +0530818 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
819 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 return -EIO;
821 }
822 wrqu->frag.value = threshold;
823
824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800825 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700826
827 EXIT();
828
829 return 0;
830}
831
832int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
833{
Jeff Johnsone7245742012-09-05 17:12:55 -0700834 int i;
835 if (channel > 0)
836 {
837 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
838 {
839 if (channel == freq_chan_map[i].chan)
840 {
841 *pfreq = freq_chan_map[i].freq;
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +0530842 return 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700843 }
844 }
845 }
846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800847 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700848 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700849}
850
851static v_BOOL_t
852hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
853{
854 v_BOOL_t rsnType = VOS_FALSE;
855 // is the authType supported?
856 switch (authType)
857 {
858 case eCSR_AUTH_TYPE_NONE: //never used
859 rsnType = eANI_BOOLEAN_FALSE;
860 break;
861 // MAC layer authentication types
862 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
863 rsnType = eANI_BOOLEAN_FALSE;
864 break;
865 case eCSR_AUTH_TYPE_SHARED_KEY:
866 rsnType = eANI_BOOLEAN_FALSE;
867 break;
868 case eCSR_AUTH_TYPE_AUTOSWITCH:
869 rsnType = eANI_BOOLEAN_FALSE;
870 break;
871
872 // Upper layer authentication types
873 case eCSR_AUTH_TYPE_WPA:
874 rsnType = eANI_BOOLEAN_TRUE;
875 break;
876 case eCSR_AUTH_TYPE_WPA_PSK:
877 rsnType = eANI_BOOLEAN_TRUE;
878 break;
879 case eCSR_AUTH_TYPE_WPA_NONE:
880 rsnType = eANI_BOOLEAN_TRUE;
881 break;
882#ifdef WLAN_FEATURE_VOWIFI_11R
883 case eCSR_AUTH_TYPE_FT_RSN:
884#endif
885 case eCSR_AUTH_TYPE_RSN:
886 rsnType = eANI_BOOLEAN_TRUE;
887 break;
888#ifdef WLAN_FEATURE_VOWIFI_11R
889 case eCSR_AUTH_TYPE_FT_RSN_PSK:
890#endif
891 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700892#ifdef WLAN_FEATURE_11W
893 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530894 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700895#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 rsnType = eANI_BOOLEAN_TRUE;
897 break;
898 //case eCSR_AUTH_TYPE_FAILED:
899 case eCSR_AUTH_TYPE_UNKNOWN:
900 rsnType = eANI_BOOLEAN_FALSE;
901 break;
902 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800903 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
904 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 rsnType = eANI_BOOLEAN_FALSE;
906 break;
907 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800908 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700909 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 return rsnType;
911}
912
Jeff Johnson295189b2012-06-20 16:38:30 -0700913
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530914struct snr_priv {
915 int8_t snr;
916};
917
918/**
919 * hdd_get_snr_cb() - "Get SNR" callback function
920 * @snr: Current SNR of the station
921 * @sta_id: ID of the station
922 * @context: opaque context originally passed to SME. HDD always passes
923 * a cookie for the request context
924 *
925 * Return: None
926 */
927static void hdd_get_snr_cb(tANI_S8 snr, tANI_U32 staId, void *context)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530928{
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530929 struct hdd_request *request;
930 struct snr_priv *priv;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530931
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530932 request = hdd_request_get(context);
933 if (!request) {
934 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
935 return;
936 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530937
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530938 /* propagate response back to requesting thread */
939 priv = hdd_request_priv(request);
940 priv->snr = snr;
941 hdd_request_complete(request);
942 hdd_request_put(request);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530943}
944
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +0530945struct rssi_priv {
946 v_S7_t rssi;
947};
948
949static void hdd_get_rssi_cb( v_S7_t rssi, tANI_U32 staId, void *context )
950{
951 struct hdd_request *request;
952 struct rssi_priv *priv;
953
954 if (ioctl_debug) {
955 pr_info("%s: rssi [%d] STA [%d] context [%pK]\n",
956 __func__, (int)rssi, (int)staId, context);
957 }
958
959 request = hdd_request_get(context);
960 if (!request) {
961 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
962 return;
963 }
964
965 priv = hdd_request_priv(request);
966 priv->rssi = rssi;
967
968 hdd_request_complete(request);
969 hdd_request_put(request);
970}
971
Jeff Johnson295189b2012-06-20 16:38:30 -0700972VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
973{
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 hdd_context_t *pHddCtx;
975 hdd_station_ctx_t *pHddStaCtx;
976 eHalStatus hstatus;
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +0530977 int ret;
978 void *cookie;
979 struct hdd_request *request;
980 struct rssi_priv *priv;
981 static const struct hdd_request_params params = {
982 .priv_size = sizeof(*priv),
983 .timeout_ms = WLAN_WAIT_TIME_STATS,
984 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700985
986 if (NULL == pAdapter)
987 {
988 hddLog(VOS_TRACE_LEVEL_WARN,
989 "%s: Invalid context, pAdapter", __func__);
990 return VOS_STATUS_E_FAULT;
991 }
992 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
993 {
994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
995 /* return a cached value */
996 *rssi_value = pAdapter->rssi;
997 return VOS_STATUS_SUCCESS;
998 }
999
1000 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1001 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1002
mukul sharma8aec69b2015-06-10 22:28:43 +05301003 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1004 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
1006 __func__, pAdapter->rssi_on_disconnect);
1007 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +05301008 return VOS_STATUS_SUCCESS;
1009 }
1010
1011 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1012 {
1013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1014 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1015 *rssi_value = pAdapter->rssi;
1016 return VOS_STATUS_SUCCESS;
1017 }
1018
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301019 request = hdd_request_alloc(&params);
1020 if (!request) {
1021 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1022 return VOS_STATUS_E_NOMEM;
1023 }
1024 cookie = hdd_request_cookie(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07001025
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301026 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_get_rssi_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 pHddStaCtx->conn_info.staId[ 0 ],
1028 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301029 cookie, pHddCtx->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 if (eHAL_STATUS_SUCCESS != hstatus)
1031 {
1032 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001033 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 /* we'll returned a cached value below */
1035 }
1036 else
1037 {
1038 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301039 ret = hdd_request_wait_for_response(request);
1040 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 {
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301042 hddLog(VOS_TRACE_LEVEL_ERROR,
1043 FL("SME timeout while retrieving RSSI"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 /* we'll now returned a cached value below */
1045 }
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301046 else
1047 {
1048 priv = hdd_request_priv(request);
1049 pAdapter->rssi = priv->rssi;
1050 /*
1051 * copy over the rssi.FW will return RSSI as -100 if
1052 * there are no samples to calculate the averag RSSI
1053 */
1054 if (priv->rssi != -100)
1055 pAdapter->rssi = priv->rssi;
Jeff Johnson72a40512013-12-19 10:14:15 -08001056
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301057 if (pAdapter->rssi > 0)
1058 pAdapter->rssi = 0;
1059 }
1060 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001061
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 *rssi_value = pAdapter->rssi;
Rajeev Kumar Sirasanagandla4819c182016-11-28 22:25:48 +05301063 hddLog(VOS_TRACE_LEVEL_INFO,
1064 "%s: RSSI = %d", __func__, *rssi_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07001065
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301066 /*
1067 * either we never sent a request, we sent a request and received a
1068 * response or we sent a request and timed out. Regardless we are
1069 * done with the request.
1070 */
1071 hdd_request_put(request);
1072
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 return VOS_STATUS_SUCCESS;
1074}
Siddharth Bhal64246172015-02-27 01:04:37 +05301075/**---------------------------------------------------------------------------
1076
1077 \brief wlan_hdd_get_frame_logs() -
1078
1079 This function use to get Frames log.
1080
1081 \param - pAdapter Pointer to the adapter.
1082 flag - Specify type of request. Clear and Send request are
1083 supported.
1084
1085 \return - none
1086
1087 --------------------------------------------------------------------------*/
1088VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
1089{
Siddharth Bhal64246172015-02-27 01:04:37 +05301090 hdd_context_t *pHddCtx;
1091 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +05301092
1093 if (NULL == pAdapter)
1094 {
1095 hddLog(VOS_TRACE_LEVEL_WARN,
1096 "%s: Invalid context, pAdapter", __func__);
1097 return VOS_STATUS_E_FAULT;
1098 }
1099
1100 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1101 if (!pHddCtx->mgmt_frame_logging)
1102 {
Abhishek Singha7d80b12016-02-03 15:27:20 +05301103 hddLog(LOGW, FL("Frame Logging not init!"));
Siddharth Bhal64246172015-02-27 01:04:37 +05301104 return VOS_STATUS_E_AGAIN;
1105 }
1106
Siddharth Bhal4507c262015-04-29 20:20:42 +05301107 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
1108 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
1109 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +05301110 {
1111 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
1112 return VOS_STATUS_E_INVAL;
1113 }
1114
Siddharth Bhal4507c262015-04-29 20:20:42 +05301115 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
1116 (!pHddCtx->cfg_ini->enableBMUHWtracing))
1117 {
1118 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
1119 return VOS_STATUS_E_INVAL;
1120 }
1121
Abhishek Singh611295e2015-07-09 11:11:54 +05301122 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +05301123 if (eHAL_STATUS_SUCCESS != hstatus)
1124 {
1125 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +05301126 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +05301127 }
Siddharth Bhal64246172015-02-27 01:04:37 +05301128
1129 return VOS_STATUS_SUCCESS;
1130}
1131
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301132
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301133VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1134{
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301135 hdd_context_t *pHddCtx;
1136 hdd_station_ctx_t *pHddStaCtx;
1137 eHalStatus hstatus;
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301138 int ret;
1139 void *cookie;
1140 struct hdd_request *request;
1141 struct snr_priv *priv;
1142 static const struct hdd_request_params params = {
1143 .priv_size = sizeof(*priv),
1144 .timeout_ms = WLAN_WAIT_TIME_STATS,
1145 };
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301146
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301147 ENTER();
1148
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301149 if (NULL == pAdapter)
1150 {
1151 hddLog(VOS_TRACE_LEVEL_ERROR,
1152 "%s: Invalid context, pAdapter", __func__);
1153 return VOS_STATUS_E_FAULT;
1154 }
1155
1156 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1157
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301158 ret = wlan_hdd_validate_context(pHddCtx);
1159 if (0 != ret)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301160 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301161 return VOS_STATUS_E_FAULT;
1162 }
1163
1164 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1165 if (NULL == pHddStaCtx)
1166 {
1167 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1168 return VOS_STATUS_E_FAULT;
1169 }
1170
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301171 request = hdd_request_alloc(&params);
1172 if (!request) {
1173 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1174 return VOS_STATUS_E_FAULT;
1175 }
1176 cookie = hdd_request_cookie(request);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301177
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301178 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_get_snr_cb,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301179 pHddStaCtx->conn_info.staId[ 0 ],
1180 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301181 cookie);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301182 if (eHAL_STATUS_SUCCESS != hstatus)
1183 {
1184 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1185 __func__);
1186 /* we'll returned a cached value below */
1187 }
1188 else
1189 {
1190 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301191 ret = hdd_request_wait_for_response(request);
1192 if (ret) {
1193 hddLog(VOS_TRACE_LEVEL_ERROR,
1194 FL("SME timed out while retrieving SNR"));
1195 /* we'll now returned a cached value below */
1196 } else {
1197 /* update the adapter with the fresh results */
1198 priv = hdd_request_priv(request);
1199 pAdapter->snr = priv->snr;
1200 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301201 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001202
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301203 /*
1204 * either we never sent a request, we sent a request and
1205 * received a response or we sent a request and timed out.
1206 * regardless we are done with the request.
1207 */
1208 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08001209
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301210 *snr = pAdapter->snr;
1211
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301212 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301213 return VOS_STATUS_SUCCESS;
1214}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301215
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001216#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001217
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001218VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1219{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001220 hdd_context_t *pHddCtx = NULL;
1221 hdd_station_ctx_t *pHddStaCtx = NULL;
1222 eHalStatus hstatus;
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301223 int ret;
1224 void *cookie;
1225 struct hdd_request *request;
1226 struct rssi_priv *priv;
1227 static const struct hdd_request_params params = {
1228 .priv_size = sizeof(*priv),
1229 .timeout_ms = WLAN_WAIT_TIME_STATS,
1230 };
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001231
1232 if (NULL == pAdapter)
1233 {
1234 hddLog(VOS_TRACE_LEVEL_WARN,
1235 "%s: Invalid context, pAdapter", __func__);
1236 return VOS_STATUS_E_FAULT;
1237 }
1238 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1239 {
1240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1241 /* return a cached value */
1242 *rssi_value = pAdapter->rssi;
1243 return VOS_STATUS_SUCCESS;
1244 }
1245
1246 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1247 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1248
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301249 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001250 {
1251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1252 /* return a cached value */
1253 *rssi_value = 0;
1254 return VOS_STATUS_SUCCESS;
1255 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301256
1257 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1258 {
1259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1260 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1261 *rssi_value = pAdapter->rssi;
1262 return VOS_STATUS_SUCCESS;
1263 }
1264
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301265 request = hdd_request_alloc(&params);
1266 if (!request) {
1267 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1268 return VOS_STATUS_E_NOMEM;
1269 }
1270 cookie = hdd_request_cookie(request);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001271
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301272 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_get_rssi_cb,
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001273 pHddStaCtx->conn_info.staId[ 0 ],
1274 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301275 cookie, pHddCtx->pvosContext);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001276 if (eHAL_STATUS_SUCCESS != hstatus)
1277 {
1278 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1279 __func__);
1280 /* we'll returned a cached value below */
1281 }
1282 else
1283 {
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301284 ret = hdd_request_wait_for_response(request);
1285 if(ret)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001286 /* request was sent -- wait for the response */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001287 {
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301288 hddLog(VOS_TRACE_LEVEL_ERROR,
1289 FL(" SME timeout while retrieving RSSI"));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001290 /* we'll now returned a cached value below */
1291 }
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301292 else
1293 {
1294 priv = hdd_request_priv(request);
1295 pAdapter->rssi = priv->rssi;
1296 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001297 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001298
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301299 /*
1300 * either we never sent a request, we sent a request and received a
1301 * response or we sent a request and timed out. Regardless we are
1302 * done with the request.
1303 */
1304 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08001305
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001306 *rssi_value = pAdapter->rssi;
1307
1308 return VOS_STATUS_SUCCESS;
1309}
1310#endif
1311
1312
Jeff Johnson295189b2012-06-20 16:38:30 -07001313void hdd_StatisticsCB( void *pStats, void *pContext )
1314{
1315 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1316 hdd_stats_t *pStatsCache = NULL;
1317 hdd_wext_state_t *pWextState;
1318 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1319
1320 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1321 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1322 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1323 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1324 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1325 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1326
1327 if (pAdapter!= NULL)
1328 pStatsCache = &pAdapter->hdd_stats;
1329
1330
1331 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1332 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1333 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1334 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1335 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1336 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1337
1338 if (pStatsCache!=NULL)
1339 {
1340 // and copy the stats into the cache we keep in the adapter instance structure
1341 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1342 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1343 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1344 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1345 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1346 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1347 }
1348
1349 if(pAdapter)
1350 {
1351 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1352 if(pWextState)
1353 {
1354 vos_status = vos_event_set(&pWextState->vosevent);
1355 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1356 {
1357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001358 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 return;
1360 }
1361 }
1362 }
1363}
1364
1365void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1366{
1367 v_CONTEXT_t pVosContext;
1368 hdd_context_t *pHddCtx;
1369 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1370#if 0
1371 hdd_wext_state_t *pWextState;
1372 v_U32_t roamId;
1373#endif
1374
1375 ENTER();
1376
1377 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1378
1379 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1380 if (NULL == pHddCtx)
1381 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001382 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 return;
1384 }
1385#if 0
1386 pWextState = pAdapter->pWextState;
1387#endif
1388
1389 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1390 {
1391 //TODO Verify is this is really used. If yes need to fix it.
1392 hdd_reconnect_all_adapters( pHddCtx );
1393#if 0
1394 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1395 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1396 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1397
1398 if(VOS_STATUS_SUCCESS == vosStatus)
1399 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1400 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1401
1402 sme_RoamConnect(halHandle,
1403 pAdapter->sessionId, &(pWextState->roamProfile),
1404 &roamId);
1405#endif
1406 }
1407
1408 EXIT();
1409
1410}
1411
1412void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1413{
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1415
1416 /* clear WPA/RSN/WSC IE information in the profile */
1417 pWextState->roamProfile.nWPAReqIELength = 0;
1418 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1419 pWextState->roamProfile.nRSNReqIELength = 0;
1420 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1421
Chet Lanctot186b5732013-03-18 10:26:30 -07001422#ifdef FEATURE_WLAN_WAPI
1423 pWextState->roamProfile.nWAPIReqIELength = 0;
1424 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1425#endif
1426
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001428 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301430 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1432 pWextState->roamProfile.nAddIEAssocLength = 0;
1433
1434 pWextState->roamProfile.EncryptionType.numEntries = 1;
1435 pWextState->roamProfile.EncryptionType.encryptionType[0]
1436 = eCSR_ENCRYPT_TYPE_NONE;
1437
1438 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1439 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1440 = eCSR_ENCRYPT_TYPE_NONE;
1441
1442 pWextState->roamProfile.AuthType.numEntries = 1;
1443 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1444
Abhishek Singhb3e376c2017-01-04 15:27:13 +05301445 vos_mem_zero((pWextState->roamProfile.bssid_hint), WNI_CFG_BSSID_LEN);
Chet Lanctot186b5732013-03-18 10:26:30 -07001446#ifdef WLAN_FEATURE_11W
1447 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1448 pWextState->roamProfile.MFPRequired = 0;
1449 pWextState->roamProfile.MFPCapable = 0;
1450#endif
1451
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 pWextState->authKeyMgmt = 0;
1453
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301454 vos_mem_zero(&pWextState->roamProfile.Keys,
1455 sizeof(pWextState->roamProfile.Keys));
1456
Jeff Johnson295189b2012-06-20 16:38:30 -07001457#ifdef FEATURE_WLAN_WAPI
1458 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1459 pAdapter->wapi_info.nWapiMode = 0;
1460#endif
1461
1462 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1463
1464}
1465
1466void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1467{
1468 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001469
Nirav Shahf6bd2672015-03-11 12:53:15 +05301470 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001471 {
1472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301473 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001474 }
1475 else
1476 {
1477 complete(&pAdapter->ula_complete);
1478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001479}
1480
1481VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1482{
1483 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001485 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001486
1487 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1488 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001489 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001490
1491 /*To avoid race condition between the set key and the last EAPOL
1492 packet, notify TL to finish upper layer authentication incase if the
1493 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001494 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001495
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001496 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 {
1498 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1499 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1500 __LINE__, vos_status );
1501 return vos_status;
1502
1503 }
1504
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001505 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301507 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001508 {
1509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301510 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001511 /* we'll still fall through and return success since the
1512 * connection may still get established but is just taking
1513 * too long for us to wait */
1514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 }
1516 return VOS_STATUS_SUCCESS;
1517}
1518
1519v_U8_t* wlan_hdd_get_vendor_oui_ie_ptr(v_U8_t *oui, v_U8_t oui_size, v_U8_t *ie, int ie_len)
1520{
1521
1522 int left = ie_len;
1523 v_U8_t *ptr = ie;
1524 v_U8_t elem_id,elem_len;
1525 v_U8_t eid = 0xDD;
1526
1527 if ( NULL == ie || 0 == ie_len )
1528 return NULL;
1529
1530 while(left >= 2)
1531 {
1532 elem_id = ptr[0];
1533 elem_len = ptr[1];
1534 left -= 2;
1535 if(elem_len > left)
1536 {
1537 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001538 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001539 eid,elem_len,left);
1540 return NULL;
1541 }
SaidiReddy Yenuga764a9d22017-05-26 18:37:53 +05301542 if ((elem_id == eid) && (elem_len >= oui_size))
Jeff Johnson295189b2012-06-20 16:38:30 -07001543 {
1544 if(memcmp( &ptr[2], oui, oui_size)==0)
1545 return ptr;
1546 }
1547
1548 left -= elem_len;
1549 ptr += (elem_len + 2);
1550 }
1551 return NULL;
1552}
1553
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301554static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001555 union iwreq_data *wrqu, char *extra)
1556{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301557 hdd_adapter_t *pAdapter;
1558 hdd_context_t *pHddCtx;
1559 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301560
1561 ENTER();
1562
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301563 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1564 if (NULL == pAdapter)
1565 {
1566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1567 "%s: pAdapter is NULL\n", __func__);
1568 return -EINVAL;
1569 }
1570 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1571 ret = wlan_hdd_validate_context(pHddCtx);
1572 if (0 != ret)
1573 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301574 return ret;
1575 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301576
Jeff Johnson295189b2012-06-20 16:38:30 -07001577 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301578
1579 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301580 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001581}
1582
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301583static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1584 union iwreq_data *wrqu, char *extra)
1585{
1586 int ret;
1587
1588 vos_ssr_protect(__func__);
1589 ret = __iw_set_commit(dev, info, wrqu, extra);
1590 vos_ssr_unprotect(__func__);
1591
1592 return ret;
1593}
1594
1595static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 struct iw_request_info *info,
1597 char *wrqu, char *extra)
1598{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301599 hdd_adapter_t *pAdapter;
1600 hdd_context_t *pHddCtx;
1601 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301602
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301604 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1605 if (NULL == pAdapter)
1606 {
1607 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1608 "%s: pAdapter is NULL\n", __func__);
1609 return -EINVAL;
1610 }
1611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1612 ret = wlan_hdd_validate_context(pHddCtx);
1613 if (0 != ret)
1614 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301615 return ret;
1616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1618 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301619 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001620}
1621
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301622static int iw_get_name(struct net_device *dev,
1623 struct iw_request_info *info,
1624 char *wrqu, char *extra)
1625{
1626 int ret;
1627
1628 vos_ssr_protect(__func__);
1629 ret = __iw_get_name(dev, info, wrqu, extra);
1630 vos_ssr_unprotect(__func__);
1631
1632 return ret;
1633}
1634
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301635static int __iw_set_freq(struct net_device *dev,
1636 struct iw_request_info *info,
1637 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001638{
1639 v_U32_t numChans = 0;
1640 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1641 v_U32_t indx = 0;
1642 v_U32_t status = 0;
1643
1644 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301645 hdd_adapter_t *pAdapter;
1646 hdd_context_t *pHddCtx;
1647 tHalHandle hHal;
1648 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301650
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 ENTER();
1652
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301653 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1654 if (NULL == pAdapter)
1655 {
1656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1657 "%s:Invalid Adapter",__func__);
1658 return -EINVAL;
1659 }
1660
1661 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1662 status = wlan_hdd_validate_context(pHddCtx);
1663 if (0 != status)
1664 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 return status;
1666 }
1667
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301668 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1669 if (NULL == hHal)
1670 {
1671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1672 "%s: Hal Context is NULL",__func__);
1673 return -EINVAL;
1674 }
1675
1676 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1677 if (NULL == pHddStaCtx)
1678 {
1679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1680 "%s:STA context is NULL",__func__);
1681 return -EINVAL;
1682 }
1683
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301685 if (NULL == pWextState)
1686 {
1687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1688 "%s: pWextState is NULL",__func__);
1689 return -EINVAL;
1690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001691
1692 pRoamProfile = &pWextState->roamProfile;
1693
Arif Hussain6d2a3322013-11-17 19:50:10 -08001694 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001695
1696 /* Link is up then return cant set channel*/
1697 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1698 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1699 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001700 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 return -EOPNOTSUPP;
1702 }
1703
1704 /* Settings by Frequency as input */
1705 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1706 (wrqu->freq.m <= (tANI_U32)5.825e8))
1707 {
1708 tANI_U32 freq = wrqu->freq.m / 100000;
1709
1710 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1711 indx++;
1712 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1713 {
1714 return -EINVAL;
1715 }
1716 wrqu->freq.e = 0;
1717 wrqu->freq.m = freq_chan_map[indx].chan;
1718
1719 }
1720
1721 if (wrqu->freq.e == 0)
1722 {
1723 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1724 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1725 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001726 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001727 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1729 return -EINVAL;
1730 }
1731
1732 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1733
1734 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1735 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1737 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 return -EIO;
1739 }
1740
1741 for (indx = 0; indx < numChans; indx++) {
1742 if (wrqu->freq.m == validChan[indx]){
1743 break;
1744 }
1745 }
1746 }
1747 else{
1748
1749 return -EINVAL;
1750 }
1751
1752 if(indx >= numChans)
1753 {
1754 return -EINVAL;
1755 }
1756
1757 /* Set the Operational Channel */
1758 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1759 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1760 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1761
Arif Hussain6d2a3322013-11-17 19:50:10 -08001762 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001763
1764 EXIT();
1765
1766 return status;
1767}
1768
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301769static int iw_set_freq(struct net_device *dev,
1770 struct iw_request_info *info,
1771 union iwreq_data *wrqu, char *extra)
1772{
1773 int ret;
1774
1775 vos_ssr_protect(__func__);
1776 ret = __iw_set_freq(dev, info, wrqu, extra);
1777 vos_ssr_unprotect(__func__);
1778
1779 return ret;
1780}
1781
1782static int __iw_get_freq(struct net_device *dev,
1783 struct iw_request_info *info,
1784 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001785{
Jeff Johnsone7245742012-09-05 17:12:55 -07001786 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301787 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 tHalHandle hHal;
1789 hdd_wext_state_t *pWextState;
1790 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301791 hdd_station_ctx_t *pHddStaCtx;
1792 hdd_context_t *pHddCtx;
1793 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001794
1795 ENTER();
1796
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301797 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1798 if (NULL == pAdapter)
1799 {
1800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1801 "%s: Adapter is NULL", __func__);
1802 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301804 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1805 ret = wlan_hdd_validate_context(pHddCtx);
1806 if (0 != ret)
1807 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301808 return ret;
1809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301811 if (NULL == hHal)
1812 {
1813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1814 "%s: Hal Context is NULL",__func__);
1815 return -EINVAL;
1816 }
1817 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1818 if (NULL == pHddStaCtx)
1819 {
1820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1821 "%s: HddStaCtx is NULL", __func__);
1822 return -EINVAL;
1823 }
1824 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1825 if (NULL == pWextState)
1826 {
1827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1828 "%s: pWextState is NULL",__func__);
1829 return -EINVAL;
1830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 pRoamProfile = &pWextState->roamProfile;
1832
1833 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1834 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001835 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 {
c_hpothub8245442013-11-20 23:41:09 +05301837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1838 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 return -EIO;
1840 }
1841 else
1842 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001843 status = hdd_wlan_get_freq(channel, &freq);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +05301844 if( 0 == status )
Jeff Johnsone7245742012-09-05 17:12:55 -07001845 {
1846 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1847 * iwlist & iwconfig command shows frequency into proper
1848 * format (2.412 GHz instead of 246.2 MHz)*/
1849 fwrq->m = freq;
1850 fwrq->e = MHZ;
1851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 }
1853 }
1854 else
1855 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001856 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1857 * iwlist & iwconfig command shows frequency into proper
1858 * format (2.412 GHz instead of 246.2 MHz)*/
1859 fwrq->m = 0;
1860 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301862
1863 EXIT();
1864 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001865}
1866
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301867static int iw_get_freq(struct net_device *dev,
1868 struct iw_request_info *info,
1869 struct iw_freq *fwrq, char *extra)
1870{
1871 int ret;
1872
1873 vos_ssr_protect(__func__);
1874 ret = __iw_get_freq(dev, info, fwrq, extra);
1875 vos_ssr_unprotect(__func__);
1876
1877 return ret;
1878}
1879
1880static int __iw_get_tx_power(struct net_device *dev,
1881 struct iw_request_info *info,
1882 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001883{
1884
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301885 hdd_adapter_t *pAdapter;
1886 hdd_context_t *pHddCtx;
1887 hdd_station_ctx_t *pHddStaCtx;
1888 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001889
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301890 ENTER();
1891
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301892 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1893 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1896 "%s: Adapter is NULL",__func__);
1897 return -EINVAL;
1898 }
1899 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1900 ret = wlan_hdd_validate_context(pHddCtx);
1901 if (0 != ret)
1902 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301903 return ret;
1904 }
1905
1906 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1907 if (NULL == pHddStaCtx)
1908 {
1909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1910 "%s: STA Context is NULL",__func__);
1911 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 }
1913
1914 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1915 {
1916 wrqu->txpower.value = 0;
1917 return 0;
1918 }
1919 wlan_hdd_get_classAstats(pAdapter);
1920 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1921
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301922 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 return 0;
1924}
1925
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301926static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 struct iw_request_info *info,
1928 union iwreq_data *wrqu, char *extra)
1929{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301930 int ret;
1931
1932 vos_ssr_protect(__func__);
1933 ret = __iw_get_tx_power(dev, info, wrqu, extra);
1934 vos_ssr_unprotect(__func__);
1935
1936 return ret;
1937}
1938
1939static int __iw_set_tx_power(struct net_device *dev,
1940 struct iw_request_info *info,
1941 union iwreq_data *wrqu, char *extra)
1942{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301943 hdd_adapter_t *pAdapter;
1944 tHalHandle hHal;
1945 hdd_context_t *pHddCtx;
1946 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001947
1948 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301949 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1950 if (NULL == pAdapter)
1951 {
1952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1953 "%s: Adapter is NULL",__func__);
1954 return -EINVAL;
1955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001956
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301957 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1958 ret = wlan_hdd_validate_context(pHddCtx);
1959 if (0 != ret)
1960 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301961 return ret;
1962 }
1963
1964 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1965 if (NULL == hHal)
1966 {
1967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1968 "%s: Hal Context is NULL",__func__);
1969 return -EINVAL;
1970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1972 {
c_hpothub8245442013-11-20 23:41:09 +05301973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1974 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001975 return -EIO;
1976 }
1977
1978 EXIT();
1979
1980 return 0;
1981}
1982
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301983static int iw_set_tx_power(struct net_device *dev,
1984 struct iw_request_info *info,
1985 union iwreq_data *wrqu, char *extra)
1986{
1987 int ret;
1988
1989 vos_ssr_protect(__func__);
1990 ret = __iw_set_tx_power(dev, info, wrqu, extra);
1991 vos_ssr_unprotect(__func__);
1992
1993 return ret;
1994}
1995
1996static int __iw_get_bitrate(struct net_device *dev,
1997 struct iw_request_info *info,
1998 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001999{
2000 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2001 eHalStatus status = eHAL_STATUS_SUCCESS;
2002 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302003 hdd_adapter_t *pAdapter;
2004 hdd_context_t *pHddCtx;
2005 hdd_station_ctx_t *pHddStaCtx;
2006 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002007
2008 ENTER();
2009
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302010 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2011 if (NULL == pAdapter)
2012 {
2013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2014 "%s: Adapter is NULL",__func__);
2015 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 }
2017
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302018 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2019 ret = wlan_hdd_validate_context(pHddCtx);
2020 if (0 != ret)
2021 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302022 return ret;
2023 }
2024
2025 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2026 if (NULL == pHddStaCtx)
2027 {
2028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2029 "%s: STA Context is NULL",__func__);
2030 return -EINVAL;
2031 }
2032
2033 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 wrqu->bitrate.value = 0;
2035 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302036 else
2037 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2039 SME_SUMMARY_STATS |
2040 SME_GLOBAL_CLASSA_STATS |
2041 SME_GLOBAL_CLASSB_STATS |
2042 SME_GLOBAL_CLASSC_STATS |
2043 SME_GLOBAL_CLASSD_STATS |
2044 SME_PER_STA_STATS,
2045 hdd_StatisticsCB, 0, FALSE,
2046 pHddStaCtx->conn_info.staId[0], pAdapter );
2047
2048 if(eHAL_STATUS_SUCCESS != status)
2049 {
2050 hddLog(VOS_TRACE_LEVEL_ERROR,
2051 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002052 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 return status;
2054 }
2055
2056 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302057 if (NULL == pWextState)
2058 {
2059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2060 "%s: pWextState is NULL",__func__);
2061 return -EINVAL;
2062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002063
2064 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2065
2066 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2067 {
2068 hddLog(VOS_TRACE_LEVEL_ERROR,
2069 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002070 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 return VOS_STATUS_E_FAILURE;
2072 }
2073
2074 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2075 }
2076
2077 EXIT();
2078
2079 return vos_status;
2080}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302081
2082static int iw_get_bitrate(struct net_device *dev,
2083 struct iw_request_info *info,
2084 union iwreq_data *wrqu, char *extra)
2085{
2086 int ret;
2087
2088 vos_ssr_protect(__func__);
2089 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2090 vos_ssr_unprotect(__func__);
2091
2092 return ret;
2093}
2094
2095
Jeff Johnson295189b2012-06-20 16:38:30 -07002096/* ccm call back function */
2097
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302098static int __iw_set_bitrate(struct net_device *dev,
2099 struct iw_request_info *info,
2100 union iwreq_data *wrqu,
2101 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002102{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302103 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302105 hdd_station_ctx_t *pHddStaCtx;
2106 hdd_context_t *pHddCtx;
Ashish Kumar Dhanotiyaaa9e38c2018-05-23 20:23:24 +05302107 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN +
2108 WNI_CFG_SUPPORTED_RATES_11B_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2110 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2111 v_U32_t i, rate;
2112 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302113 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002114
2115 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302116 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2117 if (NULL == pAdapter)
2118 {
2119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2120 "%s: Adapter is NULL",__func__);
2121 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 }
2123
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302124 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2125 ret = wlan_hdd_validate_context(pHddCtx);
2126 if (0 != ret)
2127 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302128 return ret;
2129 }
2130
2131 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2132 if (NULL == pHddStaCtx)
2133 {
2134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2135 "%s: STA Context is NULL",__func__);
2136 return -EINVAL;
2137 }
2138
2139
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302141 if (NULL == pWextState)
2142 {
2143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2144 "%s: pWextState is NULL",__func__);
2145 return -EINVAL;
2146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002147
2148 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2149 {
2150 return -ENXIO ;
2151 }
2152
2153 rate = wrqu->bitrate.value;
2154
2155 if (rate == -1)
2156 {
2157 rate = WNI_CFG_FIXED_RATE_AUTO;
2158 valid_rate = TRUE;
2159 }
2160 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2161 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2162 {
2163 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2164 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2165 {
2166 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2167 WNI_CFG_SUPPORTED_RATES_11A,
2168 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2169 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2170 WNI_CFG_SUPPORTED_RATES_11B,
Ashish Kumar Dhanotiyaaa9e38c2018-05-23 20:23:24 +05302171 supp_rates + a_len, &b_len) == eHAL_STATUS_SUCCESS))
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 {
2173 for (i = 0; i < (b_len + a_len); ++i)
2174 {
2175 /* supported rates returned is double the actual rate so we divide it by 2 */
2176 if ((supp_rates[i]&0x7F)/2 == rate)
2177 {
2178 valid_rate = TRUE;
2179 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2180 break;
2181 }
2182 }
2183 }
2184 }
2185 }
2186 if (valid_rate != TRUE)
2187 {
2188 return -EINVAL;
2189 }
2190 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2191 WNI_CFG_FIXED_RATE, rate,
2192 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2193 {
c_hpothub8245442013-11-20 23:41:09 +05302194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2195 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 return -EIO;
2197 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302198
2199 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 return 0;
2201}
2202
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302203static int iw_set_bitrate(struct net_device *dev,
2204 struct iw_request_info *info,
2205 union iwreq_data *wrqu,
2206 char *extra)
2207{
2208 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002209
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302210 vos_ssr_protect(__func__);
2211 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2212 vos_ssr_unprotect(__func__);
2213
2214 return ret;
2215}
2216
2217static int __iw_set_genie(struct net_device *dev,
2218 struct iw_request_info *info,
2219 union iwreq_data *wrqu,
2220 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002221{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302222 hdd_adapter_t *pAdapter;
2223 hdd_context_t *pHddCtx;
2224 hdd_wext_state_t *pWextState;
2225 u_int8_t *genie = NULL;
2226 u_int8_t *base_genie = NULL;
2227 v_U16_t remLen;
2228 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002229
2230 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002231
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302232 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2233 if (NULL == pAdapter)
2234 {
2235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2236 "%s: Adapter is NULL",__func__);
2237 return -EINVAL;
2238 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002239
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302240 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2241 ret = wlan_hdd_validate_context(pHddCtx);
2242 if (0 != ret)
2243 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302244 return ret;
2245 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002246
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302247 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2248 if (NULL == pWextState)
2249 {
2250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2251 "%s: pWextState is NULL",__func__);
2252 return -EINVAL;
2253 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002254
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302255 if (!wrqu->data.length) {
2256 hdd_clearRoamProfileIe(pAdapter);
2257 EXIT();
2258 return 0;
2259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002260
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302261 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2262 wrqu->data.length);
2263 if (NULL == base_genie)
2264 {
2265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2266 "mem_alloc_copy_from_user_helper fail");
2267 return -ENOMEM;
2268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002269
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302270 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002271
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302272 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002273
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302274 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2275
2276 /* clear any previous genIE before this call */
2277 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2278
2279 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 {
2281 v_U16_t eLen = 0;
2282 v_U8_t elementId;
2283 elementId = *genie++;
2284 eLen = *genie++;
2285 remLen -= 2;
2286
Arif Hussain6d2a3322013-11-17 19:50:10 -08002287 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 __func__, elementId, eLen);
2289
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302290 if (remLen < eLen) {
2291 hddLog(LOGE, "Remaining len: %u less than ie len: %u",
2292 remLen, eLen);
2293 ret = -EINVAL;
2294 goto exit;
2295 }
2296
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 switch ( elementId )
2298 {
2299 case IE_EID_VENDOR:
2300 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002301 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302302 ret = -EINVAL;
2303 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002305
2306 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2307 {
2308 v_U16_t curGenIELen = pWextState->genIE.length;
2309 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2310 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2311
2312 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2313 {
2314 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002315 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302317 ret = -EINVAL;
2318 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 }
2320 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2321 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2322 pWextState->genIE.length += eLen + 2;
2323 }
2324 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2325 {
2326 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302327 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2328 {
2329 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2330 "Need bigger buffer space");
2331 ret = -EINVAL;
2332 VOS_ASSERT(0);
2333 goto exit;
2334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002335 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2336 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2337 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2338 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2339 }
2340 else /* any vendorId except WPA IE should be accumulated to genIE */
2341 {
2342 v_U16_t curGenIELen = pWextState->genIE.length;
2343 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2344 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2345
2346 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2347 {
2348 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002349 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302351 ret = -ENOMEM;
2352 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 }
2354 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2355 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2356 pWextState->genIE.length += eLen + 2;
2357 }
2358 break;
2359 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002360 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302361 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2362 {
2363 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2364 "Need bigger buffer space");
2365 ret = -EINVAL;
2366 VOS_ASSERT(0);
2367 goto exit;
2368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002369 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2370 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2371 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2372 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2373 break;
2374
2375 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002376 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302377 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 remLen -= eLen;
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302380
2381 /* Move genie only if next element is present */
2382 if (remLen >= 2)
2383 genie += eLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302385
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302386exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002388 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302389 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002390}
2391
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302392static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002393 struct iw_request_info *info,
2394 union iwreq_data *wrqu,
2395 char *extra)
2396{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302397 int ret;
2398
2399 vos_ssr_protect(__func__);
2400 ret = __iw_set_genie(dev, info, wrqu, extra);
2401 vos_ssr_unprotect(__func__);
2402
2403 return ret;
2404}
2405
2406static int __iw_get_genie(struct net_device *dev,
2407 struct iw_request_info *info,
2408 union iwreq_data *wrqu,
2409 char *extra)
2410{
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302412 hdd_context_t *pHddCtx;
2413 hdd_adapter_t *pAdapter;
2414 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 eHalStatus status;
2416 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2417 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2418
2419 ENTER();
2420
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302421 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2422 if (NULL == pAdapter)
2423 {
2424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2425 "%s: Adapter is NULL",__func__);
2426 return -EINVAL;
2427 }
2428 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2429 status = wlan_hdd_validate_context(pHddCtx);
2430 if (0 != status)
2431 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302432 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 }
2434
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302436 if (NULL == pWextState)
2437 {
2438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2439 "%s: pWextState is NULL",__func__);
2440 return -EINVAL;
2441 }
2442
2443 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2444 if (NULL == pHddStaCtx)
2445 {
2446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2447 "%s: STA Context is NULL",__func__);
2448 return -EINVAL;
2449 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002450
2451 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2452 {
2453 return -ENXIO;
2454 }
2455
2456 // Return something ONLY if we are associated with an RSN or WPA network
2457 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2458 pWextState->roamProfile.negotiatedAuthType))
2459 {
2460 return -ENXIO;
2461 }
2462
2463 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2464 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2465 pAdapter->sessionId,
2466 &length,
2467 genIeBytes);
Manjeet Singh715d47e2016-08-02 19:08:02 +05302468 if (eHAL_STATUS_SUCCESS != status) {
2469 hddLog(LOGE, FL("failed to get WPA-RSN IE data"));
Arif Hussain7adce1b2013-11-11 22:59:34 -08002470 return -EFAULT;
2471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002472
Manjeet Singh715d47e2016-08-02 19:08:02 +05302473 wrqu->data.length = length;
2474 if (length > DOT11F_IE_RSN_MAX_LEN) {
2475 hddLog(LOGE,
2476 FL("invalid buffer length length:%d"), length);
2477 return -E2BIG;
2478 }
2479
2480 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
2481
2482 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002483
2484 EXIT();
2485
2486 return 0;
2487}
2488
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302489static int iw_get_genie(struct net_device *dev,
2490 struct iw_request_info *info,
2491 union iwreq_data *wrqu,
2492 char *extra)
2493{
2494 int ret;
2495
2496 vos_ssr_protect(__func__);
2497 ret = __iw_get_genie(dev, info, wrqu, extra);
2498 vos_ssr_unprotect(__func__);
2499
2500 return ret;
2501}
2502
2503
2504static int __iw_get_encode(struct net_device *dev,
2505 struct iw_request_info *info,
2506 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002507{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302508 hdd_adapter_t *pAdapter;
2509 hdd_context_t *pHddCtx;
2510 hdd_wext_state_t *pWextState;
2511 tCsrRoamProfile *pRoamProfile;
2512 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002514
2515 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302516 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2517 if (NULL == pAdapter)
2518 {
2519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2520 "%s: Adapter is NULL",__func__);
2521 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 }
2523
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302524 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2525 ret = wlan_hdd_validate_context(pHddCtx);
2526 if (0 != ret)
2527 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302528 return ret;
2529 }
2530 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2531 if (NULL == pWextState)
2532 {
2533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2534 "%s: pWextState is NULL",__func__);
2535 return -EINVAL;
2536 }
2537
2538 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 keyId = pRoamProfile->Keys.defaultIndex;
2540
2541 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2542 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002543 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 return -EINVAL;
2545 }
2546
2547 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2548 {
2549 dwrq->flags |= IW_ENCODE_ENABLED;
2550 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2551 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2552
2553 dwrq->flags |= (keyId + 1);
2554
2555 }
2556 else
2557 {
2558 dwrq->flags |= IW_ENCODE_DISABLED;
2559 }
2560
2561 for(i=0; i < MAX_WEP_KEYS; i++)
2562 {
2563 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2564 {
2565 continue;
2566 }
2567 else
2568 {
2569 break;
2570 }
2571 }
2572
2573 if(MAX_WEP_KEYS == i)
2574 {
2575 dwrq->flags |= IW_ENCODE_NOKEY;
2576 }
2577
2578 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2579
2580 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2581 {
2582 dwrq->flags |= IW_ENCODE_OPEN;
2583 }
2584 else
2585 {
2586 dwrq->flags |= IW_ENCODE_RESTRICTED;
2587 }
2588 EXIT();
2589 return 0;
2590}
2591
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302592static int iw_get_encode(struct net_device *dev,
2593 struct iw_request_info *info,
2594 struct iw_point *dwrq, char *extra)
2595{
2596 int ret;
2597
2598 vos_ssr_protect(__func__);
2599 ret = __iw_get_encode(dev, info, dwrq, extra);
2600 vos_ssr_unprotect(__func__);
2601
2602 return ret;
2603}
2604
Jeff Johnson295189b2012-06-20 16:38:30 -07002605#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2606#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2607
2608
2609/*
2610 * This function sends a single 'key' to LIM at all time.
2611 */
2612
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302613static int __iw_get_rts_threshold(struct net_device *dev,
2614 struct iw_request_info *info,
2615 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002616{
2617 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2618 v_U32_t status = 0;
2619
2620 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2621
2622 return status;
2623}
2624
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302625static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 struct iw_request_info *info,
2627 union iwreq_data *wrqu, char *extra)
2628{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302629 int ret;
2630
2631 vos_ssr_protect(__func__);
2632 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2633 vos_ssr_unprotect(__func__);
2634
2635 return ret;
2636}
2637
2638static int __iw_set_rts_threshold(struct net_device *dev,
2639 struct iw_request_info *info,
2640 union iwreq_data *wrqu, char *extra)
2641{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302642 hdd_adapter_t *pAdapter;
2643 hdd_context_t *pHddCtx;
2644 tHalHandle hHal;
2645 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002646
2647 ENTER();
2648
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302649 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2650 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002651 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2653 "%s: Adapter is NULL",__func__);
2654 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002655 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302656
2657 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2658 ret = wlan_hdd_validate_context(pHddCtx);
2659 if (0 != ret)
2660 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302661 return ret;
2662 }
2663
2664 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2665 if (NULL == hHal)
2666 {
2667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2668 "%s: Hal Context is NULL",__func__);
2669 return -EINVAL;
2670 }
2671
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2673 {
2674 return -EINVAL;
2675 }
2676
2677 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2678 {
c_hpothub8245442013-11-20 23:41:09 +05302679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2680 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 return -EIO;
2682 }
2683
2684 EXIT();
2685
2686 return 0;
2687}
2688
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302689static int iw_set_rts_threshold(struct net_device *dev,
2690 struct iw_request_info *info,
2691 union iwreq_data *wrqu, char *extra)
2692{
2693 int ret;
2694
2695 vos_ssr_protect(__func__);
2696 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2697 vos_ssr_unprotect(__func__);
2698
2699 return ret;
2700}
2701
2702static int __iw_get_frag_threshold(struct net_device *dev,
2703 struct iw_request_info *info,
2704 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002705{
2706 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2707 v_U32_t status = 0;
2708
2709 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2710
2711 return status;
2712}
2713
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302714static int iw_get_frag_threshold(struct net_device *dev,
2715 struct iw_request_info *info,
2716 union iwreq_data *wrqu, char *extra)
2717{
2718 int ret;
2719
2720 vos_ssr_protect(__func__);
2721 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2722 vos_ssr_unprotect(__func__);
2723
2724 return ret;
2725}
2726
2727static int __iw_set_frag_threshold(struct net_device *dev,
2728 struct iw_request_info *info,
2729 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002730{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302731 hdd_adapter_t *pAdapter;
2732 hdd_context_t *pHddCtx;
2733 tHalHandle hHal;
2734 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002735
2736 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302737 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2738 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002739 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2741 "%s: Adapter is NULL",__func__);
2742 return -EINVAL;
2743 }
2744
2745 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2746 ret = wlan_hdd_validate_context(pHddCtx);
2747 if (0 != ret)
2748 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302749 return ret;
2750 }
2751
2752 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2753 if (NULL == hHal)
2754 {
2755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2756 "%s: Hal Context is NULL",__func__);
2757 return -EINVAL;
2758 }
2759
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2761 {
2762 return -EINVAL;
2763 }
2764
2765 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2766 {
c_hpothub8245442013-11-20 23:41:09 +05302767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2768 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 return -EIO;
2770 }
2771
2772 EXIT();
2773
2774 return 0;
2775}
2776
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302777static int iw_set_frag_threshold(struct net_device *dev,
2778 struct iw_request_info *info,
2779 union iwreq_data *wrqu, char *extra)
2780{
2781 int ret;
2782
2783 vos_ssr_protect(__func__);
2784 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2785 vos_ssr_unprotect(__func__);
2786
2787 return ret;
2788}
2789
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302790static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 struct iw_request_info *info,
2792 union iwreq_data *wrqu, char *extra)
2793{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302794 hdd_adapter_t *pAdapter;
2795 hdd_context_t *pHddCtx;
2796 int ret = 0;
2797
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302799 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2800 if (NULL == pAdapter)
2801 {
2802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2803 "%s: Adapter is NULL",__func__);
2804 return -EINVAL;
2805 }
2806 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2807 ret = wlan_hdd_validate_context(pHddCtx);
2808 if (0 != ret)
2809 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302810 return ret;
2811 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302812
2813 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 return -EOPNOTSUPP;
2815}
2816
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302817static int iw_get_power_mode(struct net_device *dev,
2818 struct iw_request_info *info,
2819 union iwreq_data *wrqu, char *extra)
2820{
2821 int ret;
2822
2823 vos_ssr_protect(__func__);
2824 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2825 vos_ssr_unprotect(__func__);
2826
2827 return ret;
2828}
2829static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 struct iw_request_info *info,
2831 union iwreq_data *wrqu, char *extra)
2832{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302833 hdd_adapter_t *pAdapter;
2834 hdd_context_t *pHddCtx;
2835 int ret = 0;
2836
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302838 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2839 if (NULL == pAdapter)
2840 {
2841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2842 "%s: Adapter is NULL",__func__);
2843 return -EINVAL;
2844 }
2845 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2846 ret = wlan_hdd_validate_context(pHddCtx);
2847 if (0 != ret)
2848 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302849 return ret;
2850 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302851
2852 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 return -EOPNOTSUPP;
2854}
2855
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302856static int iw_set_power_mode(struct net_device *dev,
2857 struct iw_request_info *info,
2858 union iwreq_data *wrqu, char *extra)
2859{
2860 int ret;
2861
2862 vos_ssr_protect(__func__);
2863 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2864 vos_ssr_unprotect(__func__);
2865
2866 return ret;
2867}
2868
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302869static int __iw_get_range(struct net_device *dev,
2870 struct iw_request_info *info,
2871 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002872{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302873 hdd_adapter_t *pAdapter;
2874 tHalHandle hHal;
2875 hdd_context_t *pHddCtx;
2876 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 struct iw_range *range = (struct iw_range *) extra;
2878
2879 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2880
2881 v_U32_t num_channels = sizeof(channels);
2882 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2883 v_U32_t a_len;
2884 v_U32_t b_len;
2885 v_U32_t active_phy_mode = 0;
2886 v_U8_t index = 0, i;
2887
2888 ENTER();
2889
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302890 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2891 if (NULL == pAdapter)
2892 {
2893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2894 "%s: pAdapter is NULL", __func__);
2895 return -EINVAL;
2896 }
2897 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2898 ret = wlan_hdd_validate_context(pHddCtx);
2899 if (0 != ret)
2900 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302901 return ret;
2902 }
2903 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2904 if (NULL == hHal)
2905 {
2906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2907 "%s: pAdapter is NULL", __func__);
2908 return -EINVAL;
2909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 wrqu->data.length = sizeof(struct iw_range);
2911 memset(range, 0, sizeof(struct iw_range));
2912
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 /*Get the phy mode*/
2914 if (ccmCfgGetInt(hHal,
2915 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2916 {
2917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002918 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002919
2920 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2921 {
2922 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002923 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 if (ccmCfgGetStr(hHal,
2925 WNI_CFG_SUPPORTED_RATES_11A,
2926 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2927 {
2928 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2929 {
2930 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2931 }
2932 for (i = 0; i < a_len; i++)
2933 {
2934 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2935 }
2936 range->num_bitrates = a_len;
2937 }
2938 else
2939 {
2940 return -EIO;
2941 }
2942 }
2943 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2944 {
2945 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002946 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 if (ccmCfgGetStr(hHal,
2948 WNI_CFG_SUPPORTED_RATES_11B,
2949 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2950 {
2951 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2952 {
2953 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2954 }
2955 for (i = 0; i < b_len; i++)
2956 {
2957 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2958 }
2959 range->num_bitrates = b_len;
2960 }
2961 else
2962 {
2963 return -EIO;
2964 }
2965 }
2966 }
2967
2968 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2969 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2970 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2971
2972 range->encoding_size[0] = 5;
2973 range->encoding_size[1] = 13;
2974 range->num_encoding_sizes = 2;
2975 range->max_encoding_tokens = MAX_WEP_KEYS;
2976
2977 // we support through Wireless Extensions 22
2978 range->we_version_compiled = WIRELESS_EXT;
2979 range->we_version_source = 22;
2980
2981 /*Supported Channels and Frequencies*/
2982 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2983 {
c_hpothub8245442013-11-20 23:41:09 +05302984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2985 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 return -EIO;
2987 }
2988 if (num_channels > IW_MAX_FREQUENCIES)
2989 {
2990 num_channels = IW_MAX_FREQUENCIES;
2991 }
2992
2993 range->num_channels = num_channels;
2994 range->num_frequency = num_channels;
2995
2996 for (index=0; index < num_channels; index++)
2997 {
2998 v_U32_t frq_indx = 0;
2999
3000 range->freq[index].i = channels[index];
3001 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3002 {
3003 if(channels[index] == freq_chan_map[frq_indx].chan)
3004 {
3005 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3006 range->freq[index].e = 1;
3007 break;
3008 }
3009 frq_indx++;
3010 }
3011 }
3012
3013 /* Event capability (kernel + driver) */
3014 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3015 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3016 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3017 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3018
3019 /*Encryption capability*/
3020 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3021 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3022
3023 /* Txpower capability */
3024 range->txpower_capa = IW_TXPOW_MWATT;
3025
3026 /*Scanning capability*/
3027 #if WIRELESS_EXT >= 22
3028 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3029 #endif
3030
3031 EXIT();
3032 return 0;
3033}
3034
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303035static int iw_get_range(struct net_device *dev,
3036 struct iw_request_info *info,
3037 union iwreq_data *wrqu, char *extra)
3038{
3039 int ret;
3040
3041 vos_ssr_protect(__func__);
3042 ret = __iw_get_range(dev, info, wrqu, extra);
3043 vos_ssr_unprotect(__func__);
3044
3045 return ret;
3046}
3047
Jeff Johnson295189b2012-06-20 16:38:30 -07003048/* Callback function for tx per hit */
3049void hdd_tx_per_hit_cb (void *pCallbackContext)
3050{
3051 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3052 unsigned char tx_fail[16];
3053 union iwreq_data wrqu;
3054
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303055 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003057 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 return;
3059 }
3060 memset(&wrqu, 0, sizeof(wrqu));
3061 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3062 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3063}
3064
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303065void hdd_get_class_a_statistics_cb(void *stats, void *context)
3066{
3067 struct hdd_request *request;
3068 struct stats_class_a_ctx *priv;
3069
3070 if (ioctl_debug) {
3071 pr_info("%s: stats [%pK] context [%pK]\n",
3072 __func__, stats, context);
3073 }
3074
3075 if (NULL == stats) {
3076 hddLog(VOS_TRACE_LEVEL_ERROR,
3077 "%s: Bad param, stats [%pK]",
3078 __func__, stats);
3079 return;
3080 }
3081
3082 request = hdd_request_get(context);
3083 if (!request) {
3084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
3085 return;
3086 }
3087
3088 priv = hdd_request_priv(request);
3089
3090 /* copy over the stats. do so as a struct copy */
3091 priv->class_a_stats = *(tCsrGlobalClassAStatsInfo *)stats;
3092
3093 hdd_request_complete(request);
3094 hdd_request_put(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07003095}
3096
3097VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3098{
3099 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3100 eHalStatus hstatus;
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303101 int ret;
3102 void *cookie;
3103 struct hdd_request *request;
3104 struct stats_class_a_ctx *priv;
3105 static const struct hdd_request_params params = {
3106 .priv_size = sizeof(*priv),
3107 .timeout_ms = WLAN_WAIT_TIME_STATS,
3108 };
3109
Jeff Johnson295189b2012-06-20 16:38:30 -07003110
3111 if (NULL == pAdapter)
3112 {
3113 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3114 return VOS_STATUS_E_FAULT;
3115 }
3116 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3117 {
3118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3119 return VOS_STATUS_SUCCESS;
3120 }
3121
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303122 request = hdd_request_alloc(&params);
3123 if (!request) {
3124 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3125 return VOS_STATUS_E_NOMEM;
3126 }
3127 cookie = hdd_request_cookie(request);
3128
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 /* query only for Class A statistics (which include link speed) */
3130 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3131 eCSR_HDD,
3132 SME_GLOBAL_CLASSA_STATS,
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303133 hdd_get_class_a_statistics_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 0, // not periodic
3135 FALSE, //non-cached results
3136 pHddStaCtx->conn_info.staId[0],
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303137 cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 if (eHAL_STATUS_SUCCESS != hstatus)
3139 {
3140 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003141 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003142 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 /* we'll returned a cached value below */
3144 }
3145 else
3146 {
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303147 /* request was sent -- wait for the response */
3148 ret = hdd_request_wait_for_response(request);
3149 if (ret)
3150 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303152 FL("SME timeout while retrieving Class A statistics"));
3153 }
3154 else
3155 {
3156 priv = hdd_request_priv(request);
3157 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
3158
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 }
3160 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003161
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303162 /*
3163 * either we never sent a request, we sent a request and received a
3164 * response or we sent a request and timed out. Regardless we are
3165 * done with the request.
3166 */
3167 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003168
3169 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 return VOS_STATUS_SUCCESS;
3171}
3172
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303173struct stats_ctx {
3174 tCsrSummaryStatsInfo summary_stats;
3175 tCsrGlobalClassAStatsInfo class_a_stats;
3176};
3177
3178static void hdd_get_station_statistics_cb(void *stats, void *context)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003179{
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303180 tCsrSummaryStatsInfo *summary_stats;
3181 tCsrGlobalClassAStatsInfo *class_a_stats;
3182 struct hdd_request *request;
3183 struct stats_ctx *priv;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003184
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003185
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303186 if (ioctl_debug) {
3187 pr_info("%s: stats [%pK] context [%pK]\n",
3188 __func__, stats, context);
3189 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003190
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303191 if (NULL == stats) {
3192 hddLog(VOS_TRACE_LEVEL_ERROR,
3193 "%s: Bad param, stats [%pK]",
3194 __func__, stats);
3195 return;
3196 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003197
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303198 request = hdd_request_get(context);
3199 if (!request) {
3200 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
3201 return;
3202 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003203
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303204 summary_stats = (tCsrSummaryStatsInfo *)stats;
3205 class_a_stats = (tCsrGlobalClassAStatsInfo *)(summary_stats + 1);
Jeff Johnson72a40512013-12-19 10:14:15 -08003206
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303207 priv = hdd_request_priv(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003208
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303209 /* copy over the stats. do so as a struct copy */
3210 priv->summary_stats = *summary_stats;
3211 priv->class_a_stats = *class_a_stats;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003212
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303213 hdd_request_complete(request);
3214 hdd_request_put(request);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003215}
3216
3217VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3218{
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303219 hdd_station_ctx_t *pHddStaCtx;
3220 hdd_ap_ctx_t *sap_ctx;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003221 eHalStatus hstatus;
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303222 tANI_U8 sta_id;
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303223 int ret;
3224 void *cookie;
3225 struct hdd_request *request;
3226 struct stats_ctx *priv;
3227 static const struct hdd_request_params params = {
3228 .priv_size = sizeof(*priv),
3229 .timeout_ms = WLAN_WAIT_TIME_STATS,
3230 };
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003231
3232 if (NULL == pAdapter)
3233 {
3234 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3235 return VOS_STATUS_SUCCESS;
3236 }
3237
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303238 if (pAdapter->device_mode == WLAN_HDD_SOFTAP) {
3239 sap_ctx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3240 sta_id = sap_ctx->uBCStaId;
3241 } else {
3242 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3243 sta_id = pHddStaCtx->conn_info.staId[0];
3244 }
3245
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303246 request = hdd_request_alloc(&params);
3247 if (!request) {
3248 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3249 return VOS_STATUS_E_NOMEM;
3250 }
3251 cookie = hdd_request_cookie(request);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003252
3253 /* query only for Summary & Class A statistics */
3254 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3255 eCSR_HDD,
3256 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303257 SME_GLOBAL_CLASSA_STATS |
3258 SME_PER_PKT_STATS,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303259 hdd_get_station_statistics_cb,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003260 0, // not periodic
3261 FALSE, //non-cached results
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303262 sta_id,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303263 cookie);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003264 if (eHAL_STATUS_SUCCESS != hstatus)
3265 {
3266 hddLog(VOS_TRACE_LEVEL_ERROR,
3267 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003268 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003269 /* we'll return with cached values */
3270 }
3271 else
3272 {
3273 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303274 ret = hdd_request_wait_for_response(request);
3275 if (ret)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003276 {
3277 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303278 FL("SME timeout while retrieving statistics"));
3279 }
3280 else
3281 {
3282 priv = hdd_request_priv(request);
3283 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
3284 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003285 }
3286 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003287
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303288 /*
3289 * either we never sent a request, we sent a request and received a
3290 * response or we sent a request and timed out. Regardless we are
3291 * done with the request.
3292 */
3293 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003294
3295 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003296 return VOS_STATUS_SUCCESS;
3297}
3298
Jeff Johnson295189b2012-06-20 16:38:30 -07003299/*
3300 * Support for the LINKSPEED private command
3301 * Per the WiFi framework the response must be of the form
3302 * "LinkSpeed xx"
3303 */
3304static int iw_get_linkspeed(struct net_device *dev,
3305 struct iw_request_info *info,
3306 union iwreq_data *wrqu, char *extra)
3307{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303308 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303309 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303311 int len = sizeof(v_U32_t) + 1;
3312 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303313 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303314 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303315 int rc, valid = 0;
3316
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303317 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303318 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3319 if (NULL == pAdapter)
3320 {
3321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3322 "%s: Adapter is NULL",__func__);
3323 return -EINVAL;
3324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003325
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303326 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303327 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303328 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003329 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303330 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003331 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303332 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3333 if (NULL == pHddStaCtx)
3334 {
3335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3336 "%s: STA Context is NULL",__func__);
3337 return -EINVAL;
3338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3340 {
3341 /* we are not connected so we don't have a classAstats */
3342 link_speed = 0;
3343 }
3344 else
3345 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303346 status = wlan_hdd_get_classAstats(pAdapter);
3347
3348 if (!VOS_IS_STATUS_SUCCESS(status ))
3349 {
3350 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3351 return -EINVAL;
3352 }
3353
3354 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3355 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3356 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3357 &link_speed);
3358
3359 link_speed = link_speed / 10;
3360
3361 if (0 == link_speed)
3362 {
3363 /* The linkspeed returned by HAL is in units of 500kbps.
3364 * converting it to mbps.
3365 * This is required to support legacy firmware which does
3366 * not return link capacity.
3367 */
3368 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3369 }
3370
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 }
3372
3373 wrqu->data.length = len;
3374 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003375 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 if ((rc < 0) || (rc >= len))
3377 {
3378 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303379 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 return -EIO;
3381 }
3382
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303383 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003385 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003386}
3387
Arif Hussain695279c2014-03-24 14:06:07 -07003388/*
3389 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3390 *
3391 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303392static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003393 struct iw_request_info *info,
3394 union iwreq_data *wrqu, char *extra)
3395{
3396 int rc;
3397
3398 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3399
3400 if (rc < 0)
3401 return rc;
3402
3403 /* a value is being successfully returned */
3404 return 0;
3405}
Jeff Johnson295189b2012-06-20 16:38:30 -07003406
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303407static int iw_get_linkspeed_priv(struct net_device *dev,
3408 struct iw_request_info *info,
3409 union iwreq_data *wrqu, char *extra)
3410{
3411 int ret;
3412
3413 vos_ssr_protect(__func__);
3414 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3415 vos_ssr_unprotect(__func__);
3416
3417 return ret;
3418}
3419
Jeff Johnson295189b2012-06-20 16:38:30 -07003420/*
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303421 * Support for the RSSI & RSSI-APPROX private commands
3422 * Per the WiFi framework the response must be of the form
3423 * "<ssid> rssi <xx>"
3424 * unless we are not associated, in which case the response is
3425 * "OK"
3426 */
3427static int iw_get_rssi(struct net_device *dev,
3428 struct iw_request_info *info,
3429 union iwreq_data *wrqu, char *extra)
3430{
3431 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3432 char *cmd = extra;
3433 int len = wrqu->data.length;
3434 v_S7_t s7Rssi = 0;
3435 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3436 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3437 VOS_STATUS vosStatus;
3438 int rc;
3439
3440 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3441 (0 == ssidlen) || (ssidlen >= len))
3442 {
3443 /* we are not connected or our SSID is too long
3444 so we cannot report an rssi */
3445 rc = scnprintf(cmd, len, "OK");
3446 }
3447 else
3448 {
3449 /* we are connected with a valid SSID
3450 so we can write the SSID into the return buffer
3451 (note that it is not NUL-terminated) */
3452 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3453
Hanumanth Reddy Pothula01abc502016-08-30 15:34:43 +05303454 wlan_hdd_get_station_stats(pAdapter);
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303455 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3456
3457 if (VOS_STATUS_SUCCESS == vosStatus)
3458 {
3459 /* append the rssi to the ssid in the format required by
3460 the WiFI Framework */
3461 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3462 rc += ssidlen;
3463 }
3464 else
3465 {
3466 rc = -1;
3467 }
3468 }
3469
3470 /* verify that we wrote a valid response */
3471 if ((rc < 0) || (rc >= len))
3472 {
3473 // encoding or length error?
3474 hddLog(VOS_TRACE_LEVEL_ERROR,
3475 "%s: Unable to encode RSSI, got [%s]",
3476 __func__, cmd);
3477 return -EIO;
3478 }
3479
3480 /* a value is being successfully returned */
3481 return rc;
3482}
3483
3484/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 * Support for SoftAP channel range private command
3486 */
3487static int iw_softap_set_channel_range( struct net_device *dev,
3488 int startChannel,
3489 int endChannel,
3490 int band)
3491{
Jeff Johnson43971f52012-07-17 12:26:56 -07003492 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003493 int ret = 0;
3494 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3495 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003496 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3497
Jeff Johnson295189b2012-06-20 16:38:30 -07003498
3499 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3500 if (VOS_STATUS_SUCCESS != status)
3501 {
3502 ret = -EINVAL;
3503 }
Yathish9f22e662012-12-10 14:21:35 -08003504 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 return ret;
3506}
3507
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303508static uint8 chartohex(char c)
3509{
3510 uint8 val = 0;
3511 if (c >= '0' && c <= '9')
3512 val = c - '0';
3513 else if (c >= 'a' && c <= 'f')
3514 val = c - 'a' + 10;
3515 else if (c >= 'A' && c <= 'F')
3516 val = c - 'A' + 10;
3517 else
3518 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3519
3520 return val;
3521}
3522
3523uint8 getByte(char **buf)
3524{
3525 uint8 byte = 0;
3526 char *temp = *buf;
3527 byte = chartohex(*temp) * 16;
3528 temp++;
3529 byte += chartohex(*temp);
3530 temp++;
3531 *buf = temp;
3532 return byte;
3533}
3534
3535static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3536{
3537 tSir80211Header *macHeader;
3538 int i = 0, j = 0, length = 0;
3539 uint8 byte = 0;
3540 char *temp = pBuffer;
3541 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303542 char *pHeader;
3543 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303544
3545 macHeader = &pkt->macHeader;
3546
3547 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3548
3549 temp++;
3550
3551 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3552 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3553 pkt->encParams.keyParams.key[0].keyId);
3554
3555 for (i = 0; i< 16; i++) {
3556 pkt->encParams.keyParams.key[0].key[i]
3557 = getByte(&temp);
3558 }
3559
3560 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3561 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3562
3563 for (i = 0; i< 6; i++) {
3564 pkt->encParams.pn[i]
3565 = getByte(&temp);
3566 }
3567
3568 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3569 &pkt->encParams.pn[0], 6, 0);
3570
3571 for (i = 0, j= 5; i< 3; i++, j--) {
3572 byte = pkt->encParams.pn[i];
3573 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3574 pkt->encParams.pn[j] = byte;
3575 }
3576
3577 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303578 if (length > sizeof(tSir80211Header))
3579 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303580
Srinivas Dasari2382de62015-01-22 15:00:04 +05303581 pHeader = temp;
3582 vos_mem_zero(&header, sizeof(tSir80211Header));
3583 for (i = 0; i < length; i++) {
3584 *((uint8 *)&header + i) = getByte(&pHeader);
3585 }
3586
3587 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3588 (char *)&header, length, 0);
3589
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303590 byte = getByte(&temp);
3591
3592 macHeader->frameCtrl.protVer = byte & 0x3;
3593 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3594 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3595
3596 byte = getByte(&temp);
3597 macHeader->frameCtrl.toDS = (byte) & 0x1;
3598 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3599 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3600 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3601 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3602 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3603 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3604 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3605
3606 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3607 "macHeader->frameCtrl.type : %x "
3608 "macHeader->frameCtrl.subType : %x "
3609 "macHeader->frameCtrl.toDS : %x "
3610 "macHeader->frameCtrl.fromDS : %x "
3611 "macHeader->frameCtrl.moreFrag : %x "
3612 "macHeader->frameCtrl.retry : %x "
3613 "macHeader->frameCtrl.powerMgmt : %x "
3614 "macHeader->frameCtrl.MoreData : %x "
3615 "macHeader->frameCtrl.wep : %x "
3616 "macHeader->frameCtrl.order : %x "
3617 , macHeader->frameCtrl.protVer
3618 , macHeader->frameCtrl.type
3619 , macHeader->frameCtrl.subType
3620 , macHeader->frameCtrl.toDS
3621 , macHeader->frameCtrl.fromDS
3622 , macHeader->frameCtrl.moreFrag
3623 , macHeader->frameCtrl.retry
3624 , macHeader->frameCtrl.powerMgmt
3625 , macHeader->frameCtrl.moreData
3626 , macHeader->frameCtrl.wep
3627 , macHeader->frameCtrl.order);
3628
3629
3630 macHeader->usDurationId = getByte(&temp);
3631 macHeader->usDurationId += getByte(&temp) << 8;
3632
3633 macHeader->vA1[0] = getByte(&temp);
3634 macHeader->vA1[1] = getByte(&temp);
3635 macHeader->vA1[2] = getByte(&temp);
3636 macHeader->vA1[3] = getByte(&temp);
3637 macHeader->vA1[4] = getByte(&temp);
3638 macHeader->vA1[5] = getByte(&temp);
3639
3640 macHeader->vA2[0] = getByte(&temp);
3641 macHeader->vA2[1] = getByte(&temp);
3642 macHeader->vA2[2] = getByte(&temp);
3643 macHeader->vA2[3] = getByte(&temp);
3644 macHeader->vA2[4] = getByte(&temp);
3645 macHeader->vA2[5] = getByte(&temp);
3646
3647 macHeader->vA3[0] = getByte(&temp);
3648 macHeader->vA3[1] = getByte(&temp);
3649 macHeader->vA3[2] = getByte(&temp);
3650 macHeader->vA3[3] = getByte(&temp);
3651 macHeader->vA3[4] = getByte(&temp);
3652 macHeader->vA3[5] = getByte(&temp);
3653
3654 macHeader->sSeqCtrl = getByte(&temp);
3655 fragNum = macHeader->sSeqCtrl & 0xF;
3656 macHeader->sSeqCtrl >>= 4;
3657
3658 macHeader->sSeqCtrl += getByte(&temp) << 4;
3659
3660 macHeader->sSeqCtrl |= fragNum << 12;
3661
3662 if (length == 30 || length == 32) {
3663 macHeader->optvA4[0] = getByte(&temp);
3664 macHeader->optvA4[1] = getByte(&temp);
3665 macHeader->optvA4[2] = getByte(&temp);
3666 macHeader->optvA4[3] = getByte(&temp);
3667 macHeader->optvA4[4] = getByte(&temp);
3668 macHeader->optvA4[5] = getByte(&temp);
3669 }
3670
3671 if (length == 26 || length == 32) {
3672 macHeader->usQosCtrl = getByte(&temp);
3673 macHeader->usQosCtrl += getByte(&temp) << 8;
3674 }
3675
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303676 //parse payload
3677 length = getByte(&temp);
3678 length += getByte(&temp) << 8;
3679 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3680
Manjeet Singh5830f142016-11-21 18:21:17 +05303681 if (length >= WLAN_DISA_MAX_PAYLOAD_SIZE)
3682 length = WLAN_DISA_MAX_PAYLOAD_SIZE;
3683
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303684 pkt->data.length = length;
3685
3686 for (i = 0; i< length; i++) {
3687 pkt->data.data[i] = getByte(&temp);
3688 }
3689
3690 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3691 &pkt->data.data[0], pkt->data.length, 0);
3692}
3693
3694/**---------------------------------------------------------------------------
3695
3696 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3697 encrypt message request
3698 This is an asynchronous callback function from SME when the encrypted data
3699 is received
3700
3701 \pEncInfoRsp -> Encrypted data info
3702
3703 \return - 0 for success non-zero for failure
3704 --------------------------------------------------------------------------*/
3705static void
3706hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3707{
3708 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3709
3710 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3711
3712 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3713 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3714 pEncryptedDataRsp->encryptedPayload.length);
3715 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3716 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3717 pEncryptedDataRsp->encryptedPayload.data,
3718 pEncryptedDataRsp->encryptedPayload.length, 0);
3719}
3720
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05303721/**
3722 * iw_power_callback_func() - Callback function registered with PMC
3723 * @context: cookie originally registered with PMC
3724 * @status: status code indicated by PMC state machine
3725 *
3726 * Return: None
3727 */
3728static void iw_power_callback_func(void *context, eHalStatus status)
3729{
3730 struct hdd_request *request = hdd_request_get(context);
3731
3732 if (!request) {
3733 hddLog(VOS_TRACE_LEVEL_ERROR,
3734 "%s: Obsolete request", __func__);
3735 return;
3736 }
3737
3738 hdd_request_complete(request);
3739 hdd_request_put(request);
3740}
3741
Jeff Johnson295189b2012-06-20 16:38:30 -07003742VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3743{
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 eHalStatus status;
3745 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303746 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303747 int ret;
3748 void *cookie;
3749 struct hdd_request *request;
3750 static const struct hdd_request_params params = {
3751 .priv_size = 0,
3752 .timeout_ms = WLAN_WAIT_TIME_STATS,
3753 };
Jeff Johnson295189b2012-06-20 16:38:30 -07003754
3755 if (NULL == pAdapter)
3756 {
3757 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3758 return VOS_STATUS_E_FAULT;
3759 }
3760
3761 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3762 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303763 if (pHddCtx->isLogpInProgress) {
3764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3765 "%s:LOGP in Progress. Ignore!!!", __func__);
3766 return VOS_STATUS_E_FAILURE;
3767 }
3768
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303769 request = hdd_request_alloc(&params);
3770 if (!request) {
3771 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3772 return VOS_STATUS_E_NOMEM;
3773 }
3774 cookie = hdd_request_cookie(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07003775
Jeff Johnson295189b2012-06-20 16:38:30 -07003776
3777 if (DRIVER_POWER_MODE_ACTIVE == mode)
3778 {
3779 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3780 "Full Power", __func__);
3781 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303782 iw_power_callback_func, cookie,
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 eSME_FULL_PWR_NEEDED_BY_HDD);
3784 // Enter Full power command received from GUI this means we are disconnected
3785 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3786 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3787 if (eHAL_STATUS_PMC_PENDING == status)
3788 {
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303789 ret = hdd_request_wait_for_response(request);
3790 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 {
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303792 hddLog(VOS_TRACE_LEVEL_ERROR,
3793 FL("SME timeout while requesting fullpower"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 }
3795 }
3796 }
3797 else if (DRIVER_POWER_MODE_AUTO == mode)
3798 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303799 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
3800 * was already in BMPS state and thus either STA or P2P-CLI is in
3801 * associated state and authenticated, so even if STA connState is
3802 * not associated it can be assumed that P2P-CLI is associated and
3803 * authenticated. Thus driver can enter BMPS. And even if we try to enter
3804 * BMPS with no adaptor in associated state, pmcRequestBmps will check
3805 * if all condition are satisfied for entering BMPS.
3806 */
3807 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
3808 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303809 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303810 hddLog(LOGE,
3811 FL("Station is associated but, still not Authenticated ignore "
3812 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303813 return VOS_STATUS_E_AGAIN;
3814 }
3815
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3817 {
3818 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3819 __func__);
3820 // Enter BMPS command received from GUI this means DHCP is completed
3821 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3822 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3823 FALSE);
3824 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303825 iw_power_callback_func, cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 if (eHAL_STATUS_PMC_PENDING == status)
3827 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003828 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303829 ret = hdd_request_wait_for_response(request);
3830 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003832 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303833 FL("SME timeout while requesting bmps"));
3834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 }
3836 }
3837 else
3838 {
3839 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3840 "enabled in the cfg");
3841 }
3842 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003843
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303844 /*
3845 * either we never sent a request, we sent a request and received a
3846 * response or we sent a request and timed out. Regardless we are
3847 * done with the request.
3848 */
3849 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003850
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 return VOS_STATUS_SUCCESS;
3852}
3853
3854VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3855 hdd_adapter_t *pAdapter)
3856{
3857 VOS_STATUS vos_Status;
3858
3859 if ((NULL == pAdapter) || (NULL == pHddCtx))
3860 {
3861 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3862 return VOS_STATUS_E_FAULT;
3863 }
3864
3865 /**Exit from Deep sleep or standby if we get the driver
3866 START cmd from android GUI
3867 */
3868 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3869 {
3870 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3871 "from Stand by",__func__);
3872 vos_Status = hdd_exit_standby(pHddCtx);
3873 }
3874 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3875 {
3876 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3877 "from deep sleep",__func__);
3878 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3879 }
3880 else
3881 {
3882 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3883 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3884 vos_Status = VOS_STATUS_SUCCESS;
3885 }
3886
3887 return vos_Status;
3888}
3889
3890VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3891{
3892 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3893
3894 if (NULL == pHddCtx)
3895 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303896 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 return VOS_STATUS_E_FAULT;
3898 }
3899
3900 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3901 {
3902 //Execute standby procedure.
3903 //Executing standby procedure will cause the STA to
3904 //disassociate first and then the chip will be put into standby.
3905 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3906 vos_Status = hdd_enter_standby(pHddCtx);
3907 }
3908 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3909 pHddCtx->cfg_ini->nEnableDriverStop)
3910 {
3911 //Execute deep sleep procedure
3912 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003913 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 //Deep sleep not supported
3915 vos_Status = hdd_enter_standby(pHddCtx);
3916 }
3917 else
3918 {
3919 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3920 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3921 vos_Status = VOS_STATUS_SUCCESS;
3922 }
3923
3924 return vos_Status;
3925}
3926
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003927
3928void* wlan_hdd_change_country_code_callback(void *pAdapter)
3929{
3930
3931 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003932 complete(&call_back_pAdapter->change_country_code);
3933
3934 return NULL;
3935}
3936
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303937static int __iw_set_priv(struct net_device *dev,
3938 struct iw_request_info *info,
3939 union iwreq_data *wrqu, char *extra)
3940{
3941 hdd_adapter_t *pAdapter;
3942 char *cmd = NULL;
3943 int cmd_len = wrqu->data.length;
3944 int rc = 0, ret = 0;
3945 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3946
3947 hdd_context_t *pHddCtx;
3948
3949 ENTER();
3950
3951 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3952 if (NULL == pAdapter)
3953 {
3954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3955 "mem_alloc_copy_from_user_helper fail");
3956 return -EINVAL;
3957 }
3958 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3959 rc = wlan_hdd_validate_context(pHddCtx);
3960 if (0 != rc)
3961 {
3962 return rc;
3963 }
3964
3965 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3966 wrqu->data.length);
3967 if (NULL == cmd)
3968 {
3969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3970 "mem_alloc_copy_from_user_helper fail");
3971 return -ENOMEM;
3972 }
3973
3974 if (ioctl_debug)
3975 {
3976 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
3977 }
3978
3979 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3980 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
3981
3982 if (strncmp(cmd, "CSCAN", 5) == 0 )
3983 {
3984 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3986 "%s: Error in iw_set_scan!", __func__);
3987 rc = -EINVAL;
3988 }
3989 }
3990 else if( strcasecmp(cmd, "start") == 0 ) {
3991
3992 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
3993 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
3994
3995 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3996 if (vos_status == VOS_STATUS_SUCCESS)
3997 {
3998 union iwreq_data wrqu;
3999 char buf[10];
4000
4001 memset(&wrqu, 0, sizeof(wrqu));
4002 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4003 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4004 }
4005 else
4006 {
4007 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4008 rc = -EIO;
4009 }
4010 goto done;
4011 }
4012 else if( strcasecmp(cmd, "stop") == 0 )
4013 {
4014 union iwreq_data wrqu;
4015 char buf[10];
4016
4017 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4018
4019 wlan_hdd_enter_lowpower(pHddCtx);
4020 memset(&wrqu, 0, sizeof(wrqu));
4021 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4022 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4023 goto done;
4024 }
4025 else if (strcasecmp(cmd, "macaddr") == 0)
4026 {
4027 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4028 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4029 }
4030 else if (strcasecmp(cmd, "scan-active") == 0)
4031 {
4032 hddLog(LOG1,
4033 FL("making default scan to active"));
4034 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4035 ret = snprintf(cmd, cmd_len, "OK");
4036 }
4037 else if (strcasecmp(cmd, "scan-passive") == 0)
4038 {
4039 hddLog(LOG1,
4040 FL("making default scan to passive"));
4041 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4042 ret = snprintf(cmd, cmd_len, "OK");
4043 }
4044 else if( strcasecmp(cmd, "scan-mode") == 0 )
4045 {
4046 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4047 }
4048 else if( strcasecmp(cmd, "linkspeed") == 0 )
4049 {
4050 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4051 }
4052 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4053 {
4054 ret = iw_get_rssi(dev, info, wrqu, cmd);
4055 }
4056 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4057 int mode;
4058 char *ptr;
4059
4060 if (9 < cmd_len)
4061 {
4062 ptr = (char*)(cmd + 9);
4063
4064 }else{
4065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4066 "CMD LENGTH %d is not correct",cmd_len);
4067 kfree(cmd);
4068 return -EINVAL;
4069 }
4070
4071 if (1 != sscanf(ptr,"%d",&mode))
4072 {
4073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4074 "powermode input %s is not correct",ptr);
4075 kfree(cmd);
4076 return -EIO;
4077 }
4078
4079 wlan_hdd_enter_bmps(pAdapter, mode);
4080 /*TODO:Set the power mode*/
4081 }
4082 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4083 v_U32_t pmc_state;
4084 v_U16_t value;
4085
4086 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4087 if(pmc_state == BMPS) {
4088 value = DRIVER_POWER_MODE_AUTO;
4089 }
4090 else {
4091 value = DRIVER_POWER_MODE_ACTIVE;
4092 }
4093 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4094 }
4095 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4096 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4097 /*TODO: set the btcoexmode*/
4098 }
4099 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4100
4101 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4102 /*TODO: Return the btcoex status*/
4103 }
4104 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4105
4106 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4107
4108 /*TODO: Enable Rx data Filter*/
4109 }
4110 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4111
4112 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4113
4114 /*TODO: Disable Rx data Filter*/
4115 }
4116 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4117
4118 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4119 /*TODO: rxfilter-statistics*/
4120 }
4121 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4122
4123 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4124 /*TODO: rxfilter-add*/
4125 }
4126 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4127
4128 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4129 /*TODO: rxfilter-remove*/
4130 }
4131#ifdef FEATURE_WLAN_SCAN_PNO
4132 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4133 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4134 /*TODO: support pnosetup*/
4135 }
4136 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4137 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4138 /*TODO: support pnoforce*/
4139 }
4140 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4141
4142 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
4143 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4144 kfree(cmd);
4145 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4146 }
4147 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4148 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4149 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4150 kfree(cmd);
4151 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4152 }
4153#endif /*FEATURE_WLAN_SCAN_PNO*/
4154 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4155 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4156 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4157 kfree(cmd);
4158 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4159 }
4160 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4161 tSirTxPerTrackingParam tTxPerTrackingParam;
4162 char *ptr;
4163
4164 if (18 < cmd_len)
4165 {
4166 ptr = (char*)(cmd + 18);
4167 }else{
4168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4169 "CMD LENGTH %d is not correct",cmd_len);
4170 kfree(cmd);
4171 return -EINVAL;
4172 }
4173
4174 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4175 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4176 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4177 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4178 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4179 {
4180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4181 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4182 kfree(cmd);
4183 return -EIO;
4184 }
4185
4186 // parameters checking
4187 // period has to be larger than 0
4188 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4189 {
4190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4191 kfree(cmd);
4192 return -EIO;
4193 }
4194
4195 // use default value 5 is the input is not reasonable. in unit of 10%
4196 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4197 {
4198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4199 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4200 }
4201
4202 // default is 5
4203 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4204 {
4205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4206 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4207 }
4208
4209 if (eHAL_STATUS_SUCCESS !=
4210 sme_SetTxPerTracking(pHddCtx->hHal,
4211 hdd_tx_per_hit_cb,
4212 (void*)pAdapter, &tTxPerTrackingParam)) {
4213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4214 rc = -EIO;
4215 }
4216 }
4217 else {
4218 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4219 __func__, cmd);
4220 }
4221done:
4222 /* many of the commands write information back into the command
4223 string using snprintf(). check the return value here in one
4224 place */
4225 if ((ret < 0) || (ret >= cmd_len))
4226 {
4227 /* there was an encoding error or overflow */
4228 rc = -EINVAL;
4229 }
4230 else if (ret > 0)
4231 {
4232 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4233 {
4234 hddLog(VOS_TRACE_LEVEL_ERROR,
4235 "%s: failed to copy data to user buffer", __func__);
4236 kfree(cmd);
4237 return -EFAULT;
4238 }
4239 wrqu->data.length = ret;
4240 }
4241
4242 if (ioctl_debug)
4243 {
4244 pr_info("%s: rsp [%s] len [%d] status %d\n",
4245 __func__, cmd, wrqu->data.length, rc);
4246 }
4247 kfree(cmd);
4248 EXIT();
4249 return rc;
4250}
4251
4252static int iw_set_priv(struct net_device *dev,
4253 struct iw_request_info *info,
4254 union iwreq_data *wrqu, char *extra)
4255{
4256 int ret;
4257 vos_ssr_protect(__func__);
4258 ret = __iw_set_priv(dev, info, wrqu, extra);
4259 vos_ssr_unprotect(__func__);
4260
4261 return ret;
4262}
4263
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304264static int __iw_set_nick(struct net_device *dev,
4265 struct iw_request_info *info,
4266 union iwreq_data *wrqu, char *extra)
4267{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304268 hdd_adapter_t *pAdapter;
4269 hdd_context_t *pHddCtx;
4270 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304271
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304272 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304273
4274 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4275 if (NULL == pAdapter)
4276 {
4277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4278 "%s: Adapter is NULL",__func__);
4279 return -EINVAL;
4280 }
4281
4282 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4283 ret = wlan_hdd_validate_context(pHddCtx);
4284 if (0 != ret)
4285 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304286 return ret;
4287 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304288 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304289 return 0;
4290}
4291
Jeff Johnson295189b2012-06-20 16:38:30 -07004292static int iw_set_nick(struct net_device *dev,
4293 struct iw_request_info *info,
4294 union iwreq_data *wrqu, char *extra)
4295{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304296 int ret;
4297
4298 vos_ssr_protect(__func__);
4299 ret = __iw_set_nick(dev, info, wrqu, extra);
4300 vos_ssr_unprotect(__func__);
4301
4302 return ret;
4303}
4304
4305static int __iw_get_nick(struct net_device *dev,
4306 struct iw_request_info *info,
4307 union iwreq_data *wrqu, char *extra)
4308{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304309 hdd_adapter_t *pAdapter;
4310 hdd_context_t *pHddCtx;
4311 int ret = 0;
4312
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304314
4315 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4316 if (NULL == pAdapter)
4317 {
4318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4319 "%s: Adapter is NULL",__func__);
4320 return -EINVAL;
4321 }
4322
4323 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4324 ret = wlan_hdd_validate_context(pHddCtx);
4325 if (0 != ret)
4326 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304327 return ret;
4328 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304329 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 return 0;
4331}
4332
4333static int iw_get_nick(struct net_device *dev,
4334 struct iw_request_info *info,
4335 union iwreq_data *wrqu, char *extra)
4336{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304337 int ret;
4338
4339 vos_ssr_protect(__func__);
4340 ret = __iw_get_nick(dev, info, wrqu, extra);
4341 vos_ssr_unprotect(__func__);
4342
4343 return ret;
4344}
4345
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304346/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304347static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4348{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304349 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4350 hdd_context_t *pHddCtx;
4351 hdd_station_ctx_t *pHddStaCtx;
4352 v_S7_t snr = 0, rssi = 0;
4353 eHalStatus status = eHAL_STATUS_SUCCESS;
4354
4355 ENTER();
4356
4357 if (NULL == pAdapter)
4358 {
4359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4360 "%s: Adapter is NULL",__func__);
4361 return NULL;
4362 }
4363
4364 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4365 status = wlan_hdd_validate_context(pHddCtx);
4366 if (0 != status)
4367 {
4368 return NULL;
4369 }
4370
4371 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4372 if (NULL == pHddStaCtx)
4373 {
4374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4375 "%s: STA Context is NULL",__func__);
4376 return NULL;
4377 }
4378
4379 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4380 {
4381 wlan_hdd_get_station_stats(pAdapter);
4382 wlan_hdd_get_snr(pAdapter, &snr);
4383 wlan_hdd_get_rssi(pAdapter, &rssi);
4384
4385 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4386 pAdapter->iwStats.status = 0;
4387 pAdapter->iwStats.qual.qual = snr;
4388 pAdapter->iwStats.qual.level = rssi;
4389 pAdapter->iwStats.qual.noise = rssi - snr;
4390 pAdapter->iwStats.discard.code = 0;
4391 pAdapter->iwStats.discard.retries= 0;
4392 pAdapter->iwStats.miss.beacon = 0;
4393 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4394 }
4395 else
4396 {
4397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4398 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4399 return NULL;
4400 }
4401
4402 EXIT();
4403 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004404}
4405
4406static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4407{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304408
4409 struct iw_statistics *stats;
4410
4411 vos_ssr_protect(__func__);
4412 stats = __get_wireless_stats(dev);
4413 vos_ssr_unprotect(__func__);
4414
4415 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004416}
4417
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304418static int __iw_set_encode(struct net_device *dev,
4419 struct iw_request_info *info,
4420 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004421
4422{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304423 hdd_adapter_t *pAdapter;
4424 hdd_station_ctx_t *pHddStaCtx;
4425 hdd_wext_state_t *pWextState;
4426 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 struct iw_point *encoderq = &(wrqu->encoding);
4428 v_U32_t keyId;
4429 v_U8_t key_length;
4430 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4431 v_BOOL_t fKeyPresent = 0;
4432 int i;
4433 eHalStatus status = eHAL_STATUS_SUCCESS;
4434
4435
4436 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304437 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4438 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4441 "%s: Adapter is NULL",__func__);
4442 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 }
4444
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304445 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4446 status = wlan_hdd_validate_context(pHddCtx);
4447 if (0 != status)
4448 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304449 return status;
4450 }
4451 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4452 if (NULL == pWextState)
4453 {
4454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4455 "%s: pWextState is NULL ",__func__);
4456 return -EINVAL;
4457 }
4458 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4459 if (NULL == pHddStaCtx)
4460 {
4461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4462 "%s: STA Context is NULL",__func__);
4463 return -EINVAL;
4464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004465
4466 keyId = encoderq->flags & IW_ENCODE_INDEX;
4467
4468 if(keyId)
4469 {
4470 if(keyId > MAX_WEP_KEYS)
4471 {
4472 return -EINVAL;
4473 }
4474
4475 fKeyPresent = 1;
4476 keyId--;
4477 }
4478 else
4479 {
4480 fKeyPresent = 0;
4481 }
4482
4483
4484 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4485 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 if(!fKeyPresent) {
4488
4489 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4490
4491 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4492 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4493 }
4494 }
4495 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4496 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4497 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4498 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4499
4500 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4501 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4502
4503 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4504 {
4505 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4506 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004507 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304508 {
4509 long ret;
4510 ret = wait_for_completion_interruptible_timeout(
4511 &pAdapter->disconnect_comp_var,
4512 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4513 if (ret <= 0)
4514 hddLog(VOS_TRACE_LEVEL_ERROR,
4515 FL("failed wait on disconnect_comp_var %ld"), ret);
4516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 }
4518
4519 return status;
4520
4521 }
4522
4523 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4524 {
4525 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4526
4527 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4528
4529 }
4530
4531
4532 if(wrqu->data.length > 0)
4533 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004534 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004535
4536 key_length = wrqu->data.length;
4537
4538 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4539
4540 if(5 == key_length)
4541 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004542 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004543
4544 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4545 {
4546 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4547 }
4548 else
4549 {
4550 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4551 }
4552 }
4553 else if(13 == key_length)
4554 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004555 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004556
4557 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4558 {
4559 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4560 }
4561 else
4562 {
4563 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4564 }
4565 }
4566 else
4567 {
4568 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004569 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 return -EINVAL;
4571 }
4572
4573 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4574 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4575 pWextState->roamProfile.EncryptionType.numEntries = 1;
4576 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4577 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4578 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4579
4580 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4581 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4582 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4583 {
4584
4585 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4586
4587 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4588 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4589
4590 return status;
4591 }
4592 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304593 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 return 0;
4595}
4596
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304597static int iw_set_encode(struct net_device *dev,
4598 struct iw_request_info *info,
4599 union iwreq_data *wrqu,char *extra)
4600{
4601 int ret;
4602
4603 vos_ssr_protect(__func__);
4604 ret = __iw_set_encode(dev, info, wrqu, extra);
4605 vos_ssr_unprotect(__func__);
4606
4607 return ret;
4608}
4609
4610static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 struct iw_request_info *info,
4612 struct iw_point *dwrq,
4613 char *extra)
4614{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304615 hdd_adapter_t *pAdapter;
4616 hdd_wext_state_t *pWextState;
4617 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 int keyId;
4619 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4620 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304621 int i, ret = 0;
4622 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004623
4624 ENTER();
4625
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304626 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4627 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004628 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4630 "%s: Adapter is NULL",__func__);
4631 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004632 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304633 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4634 ret = wlan_hdd_validate_context(pHddCtx);
4635 if (0 != ret)
4636 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304637 return ret;
4638 }
4639 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4640 if (NULL == pWextState)
4641 {
4642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4643 "%s: pWextState is NULL",__func__);
4644 return -EINVAL;
4645 }
4646 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004647
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 keyId = pRoamProfile->Keys.defaultIndex;
4649
4650 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4651 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004652 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 return -EINVAL;
4654 }
4655
4656 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4657 {
4658 dwrq->flags |= IW_ENCODE_ENABLED;
4659 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304660 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4661 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 }
4663 else
4664 {
4665 dwrq->flags |= IW_ENCODE_DISABLED;
4666 }
4667
4668 for(i=0; i < MAX_WEP_KEYS; i++)
4669 {
4670 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4671 {
4672 continue;
4673 }
4674 else
4675 {
4676 break;
4677 }
4678 }
4679
4680 if(MAX_WEP_KEYS == i)
4681 {
4682 dwrq->flags |= IW_ENCODE_NOKEY;
4683 }
4684 else
4685 {
4686 dwrq->flags |= IW_ENCODE_ENABLED;
4687 }
4688
4689 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4690
4691 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4692 {
4693 dwrq->flags |= IW_ENCODE_DISABLED;
4694 }
4695
4696 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4697
4698 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4699 {
4700 dwrq->flags |= IW_ENCODE_OPEN;
4701 }
4702 else
4703 {
4704 dwrq->flags |= IW_ENCODE_RESTRICTED;
4705 }
4706 EXIT();
4707 return 0;
4708
4709}
4710
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304711static int iw_get_encodeext(struct net_device *dev,
4712 struct iw_request_info *info,
4713 struct iw_point *dwrq,
4714 char *extra)
4715{
4716 int ret;
4717 vos_ssr_protect(__func__);
4718 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4719 vos_ssr_unprotect(__func__);
4720
4721 return ret;
4722}
4723
4724static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004725 struct iw_request_info *info,
4726 union iwreq_data *wrqu, char *extra)
4727{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304728 hdd_adapter_t *pAdapter;
4729 hdd_station_ctx_t *pHddStaCtx;
4730 hdd_wext_state_t *pWextState;
4731 hdd_context_t *pHddCtx;
4732 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004733
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304734 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004735 v_U32_t status = 0;
4736
4737 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4738
4739 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4740
4741 int key_index;
4742 struct iw_point *encoding = &wrqu->encoding;
4743 tCsrRoamSetKey setKey;
4744 v_U32_t roamId= 0xFF;
4745 VOS_STATUS vos_status;
4746
4747 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304748 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4749 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4752 "%s: Adapter is NULL",__func__);
4753 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304755 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4756 status = wlan_hdd_validate_context(pHddCtx);
4757 if (0 != status)
4758 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304759 return status;
4760 }
4761 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4762 if (NULL == pHddStaCtx)
4763 {
4764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4765 "%s: STA Context is NULL",__func__);
4766 return -EINVAL;
4767 }
4768 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4769 if (NULL == pWextState)
4770 {
4771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4772 "%s: pWextState is NULL",__func__);
4773 return -EINVAL;
4774 }
4775 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 key_index = encoding->flags & IW_ENCODE_INDEX;
4777
4778 if(key_index > 0) {
4779
4780 /*Convert from 1-based to 0-based keying*/
4781 key_index--;
4782 }
4783 if(!ext->key_len) {
4784
4785 /*Set the encrytion type to NONE*/
4786 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4787 return status;
4788 }
4789
4790 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4791 (IW_ENCODE_ALG_WEP == ext->alg))
4792 {
4793 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4794
Agarwal Ashish971c2882013-10-30 20:11:12 +05304795 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4796 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004797 return -EINVAL;
4798 }
4799 else {
4800 /*Static wep, update the roam profile with the keys */
4801 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4802 key_index < CSR_MAX_NUM_KEY) {
4803 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4804 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4805
4806 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4807 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4808
4809 }
4810 }
4811 return status;
4812 }
4813
4814 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4815
4816 setKey.keyId = key_index;
4817 setKey.keyLength = ext->key_len;
4818
4819 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4820 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4821 }
4822
4823 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4824 /*Key direction for group is RX only*/
4825 setKey.keyDirection = eSIR_RX_ONLY;
4826 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4827 }
4828 else {
4829
4830 setKey.keyDirection = eSIR_TX_RX;
4831 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4832 }
4833
4834 /*For supplicant pae role is zero*/
4835 setKey.paeRole = 0;
4836
4837 switch(ext->alg)
4838 {
4839 case IW_ENCODE_ALG_NONE:
4840 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4841 break;
4842
4843 case IW_ENCODE_ALG_WEP:
4844 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4845 break;
4846
4847 case IW_ENCODE_ALG_TKIP:
4848 {
4849 v_U8_t *pKey = &setKey.Key[0];
4850
4851 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4852
4853 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4854
4855 /*Supplicant sends the 32bytes key in this order
4856
4857 |--------------|----------|----------|
4858 | Tk1 |TX-MIC | RX Mic |
4859 |--------------|----------|----------|
4860 <---16bytes---><--8bytes--><--8bytes-->
4861
4862 */
4863 /*Sme expects the 32 bytes key to be in the below order
4864
4865 |--------------|----------|----------|
4866 | Tk1 |RX-MIC | TX Mic |
4867 |--------------|----------|----------|
4868 <---16bytes---><--8bytes--><--8bytes-->
4869 */
4870 /* Copy the Temporal Key 1 (TK1) */
4871 vos_mem_copy(pKey,ext->key,16);
4872
4873 /*Copy the rx mic first*/
4874 vos_mem_copy(&pKey[16],&ext->key[24],8);
4875
4876 /*Copy the tx mic */
4877 vos_mem_copy(&pKey[24],&ext->key[16],8);
4878
4879 }
4880 break;
4881
4882 case IW_ENCODE_ALG_CCMP:
4883 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4884 break;
4885
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004886#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004887#define IW_ENCODE_ALG_KRK 6
4888 case IW_ENCODE_ALG_KRK:
4889 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4890 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004891#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004892
4893 default:
4894 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4895 break;
4896 }
4897
4898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004899 ("%s:cipher_alg:%d key_len[%d] *pEncryptionType :%d"),__func__,(int)ext->alg,(int)ext->key_len,setKey.encType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004900
4901#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304902 /* The supplicant may attempt to set the PTK once pre-authentication
4903 is done. Save the key in the UMAC and include it in the ADD
4904 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004905 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304906 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304908 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4909 "%s: Update PreAuth Key success", __func__);
4910 return 0;
4911 }
4912 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
4913 {
4914 hddLog(VOS_TRACE_LEVEL_ERROR,
4915 "%s: Update PreAuth Key failed", __func__);
4916 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 }
4918#endif /* WLAN_FEATURE_VOWIFI_11R */
4919
4920 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4921
4922 vos_status = wlan_hdd_check_ula_done(pAdapter);
4923 if ( vos_status != VOS_STATUS_SUCCESS )
4924 {
4925 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4926 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
4927 __LINE__, vos_status );
4928
4929 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4930 }
4931
4932 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
4933
4934 if ( halStatus != eHAL_STATUS_SUCCESS )
4935 {
4936 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4937 "[%4d] sme_RoamSetKey returned ERROR status= %d",
4938 __LINE__, halStatus );
4939
4940 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4941 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304942 EXIT();
4943 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004944}
4945
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304946static int iw_set_encodeext(struct net_device *dev,
4947 struct iw_request_info *info,
4948 union iwreq_data *wrqu, char *extra)
4949{
4950 int ret;
4951
4952 vos_ssr_protect(__func__);
4953 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4954 vos_ssr_unprotect(__func__);
4955
4956 return ret;
4957}
4958
4959static int __iw_set_retry(struct net_device *dev,
4960 struct iw_request_info *info,
4961 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004962{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304963 hdd_adapter_t *pAdapter;
4964 tHalHandle hHal;
4965 hdd_context_t *pHddCtx;
4966 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004967
4968 ENTER();
4969
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304970 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4971 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004972 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4974 "%s: Adapter is NULL",__func__);
4975 return -EINVAL;
4976 }
4977
4978 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4979 ret = wlan_hdd_validate_context(pHddCtx);
4980 if (0 != ret)
4981 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304982 return ret;
4983 }
4984
4985 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4986 if (NULL == hHal)
4987 {
4988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4989 "%s: Hal Context is NULL",__func__);
4990 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004991 }
4992
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4994 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4995
Arif Hussain6d2a3322013-11-17 19:50:10 -08004996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004997
4998 return -EINVAL;
4999 }
5000
5001 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5002
5003 if((wrqu->retry.flags & IW_RETRY_LONG))
5004 {
5005 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5006 {
c_hpothub8245442013-11-20 23:41:09 +05305007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5008 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005009 return -EIO;
5010 }
5011 }
5012 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5013 {
5014 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5015 {
c_hpothub8245442013-11-20 23:41:09 +05305016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5017 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005018 return -EIO;
5019 }
5020 }
5021 }
5022 else
5023 {
5024 return -EOPNOTSUPP;
5025 }
5026
Arif Hussain6d2a3322013-11-17 19:50:10 -08005027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005028
5029 EXIT();
5030
5031 return 0;
5032
5033}
5034
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305035static int iw_set_retry(struct net_device *dev,
5036 struct iw_request_info *info,
5037 union iwreq_data *wrqu, char *extra)
5038{
5039 int ret;
5040
5041 vos_ssr_protect(__func__);
5042 ret = __iw_set_retry(dev, info, wrqu, extra);
5043 vos_ssr_unprotect(__func__);
5044
5045 return ret;
5046}
5047
5048static int __iw_get_retry(struct net_device *dev,
5049 struct iw_request_info *info,
5050 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005051{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305052 hdd_adapter_t *pAdapter;
5053 hdd_context_t *pHddCtx;
5054 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305056 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005057
5058 ENTER();
5059
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305060 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5061 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005062 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5064 "%s: Adapter is NULL",__func__);
5065 return -EINVAL;
5066 }
5067
5068 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5069 ret = wlan_hdd_validate_context(pHddCtx);
5070 if (0 != ret)
5071 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305072 return ret;
5073 }
5074
5075 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5076 if (NULL == hHal)
5077 {
5078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5079 "%s: Hal Context is NULL",__func__);
5080 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005081 }
5082
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 if((wrqu->retry.flags & IW_RETRY_LONG))
5084 {
5085 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5086
5087 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5088 {
c_hpothub8245442013-11-20 23:41:09 +05305089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5090 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 return -EIO;
5092 }
5093
5094 wrqu->retry.value = retry;
5095 }
5096 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5097 {
5098 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5099
5100 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5101 {
c_hpothub8245442013-11-20 23:41:09 +05305102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5103 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005104 return -EIO;
5105 }
5106
5107 wrqu->retry.value = retry;
5108 }
5109 else {
5110 return -EOPNOTSUPP;
5111 }
5112
Arif Hussain6d2a3322013-11-17 19:50:10 -08005113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005114
5115 EXIT();
5116
5117 return 0;
5118}
5119
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305120static int iw_get_retry(struct net_device *dev,
5121 struct iw_request_info *info,
5122 union iwreq_data *wrqu, char *extra)
5123{
5124 int ret;
5125
5126 vos_ssr_protect(__func__);
5127 ret = __iw_get_retry(dev, info, wrqu, extra);
5128 vos_ssr_unprotect(__func__);
5129
5130 return ret;
5131}
5132
5133static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 struct iw_request_info *info,
5135 union iwreq_data *wrqu,
5136 char *extra)
5137{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305138 hdd_adapter_t *pAdapter;
5139 hdd_context_t *pHddCtx;
5140 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005141 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5142 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305143 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005144
5145 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305146 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5147 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005148 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5150 "%s:Adapter is NULL",__func__);
5151 return -EINVAL;
5152 }
5153 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5154 ret = wlan_hdd_validate_context(pHddCtx);
5155 if (0 != ret)
5156 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305157 return ret;
5158 }
5159 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5160 if (NULL == pHddStaCtx)
5161 {
5162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5163 "%s:STA context is NULL",__func__);
5164 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005165 }
5166
5167 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5168 switch (mlme->cmd) {
5169 case IW_MLME_DISASSOC:
5170 case IW_MLME_DEAUTH:
5171
5172 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5173 {
5174 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5175
5176 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5177 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5178
5179 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5180 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5181
Jeff Johnson43971f52012-07-17 12:26:56 -07005182 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305183 {
5184 long ret;
5185 ret = wait_for_completion_interruptible_timeout(
5186 &pAdapter->disconnect_comp_var,
5187 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5188 if (ret <= 0)
5189 hddLog(VOS_TRACE_LEVEL_ERROR,
5190 FL("failed wait on disconnect_comp_var %ld"), ret);
5191 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005193 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005194 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005195
5196 /* Resetting authKeyMgmt */
5197 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5198
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305199 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 netif_tx_disable(dev);
5201 netif_carrier_off(dev);
5202
5203 }
5204 else
5205 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005206 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 }
5208 break;
5209 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005210 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 return -EINVAL;
5212 }//end of switch
5213
5214 EXIT();
5215
5216 return status;
5217
5218}
5219
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305220static int iw_set_mlme(struct net_device *dev,
5221 struct iw_request_info *info,
5222 union iwreq_data *wrqu,
5223 char *extra)
5224{
5225 int ret;
5226
5227 vos_ssr_protect(__func__);
5228 ret = __iw_set_mlme(dev, info, wrqu, extra);
5229 vos_ssr_unprotect(__func__);
5230
5231 return ret;
5232}
5233
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305234int wlan_hdd_set_proximity(int set_value, tHalHandle hal)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305235{
5236 sHwCalValues hwCalValues;
5237 uint16 hwCalTxPower;
5238 uint8 txPwr = TX_PWR_DEF;
5239
5240 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5241
5242 if (TRUE == set_value) {
5243 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5244 NULL, sizeof(sHwCalValues) )
5245 != VOS_STATUS_SUCCESS) {
5246 return -EINVAL;
5247 }
5248 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5249
5250 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5251 hwCalTxPower, hwCalValues.calData.hwParam7);
5252
5253 txPwr = (int8)(hwCalTxPower & 0x00FF);
5254 txPwr = txPwr/10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305255 if (txPwr == 0)
5256 txPwr = TX_PWR_DEF;
5257 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305258 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305259 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305260 txPwr = TX_PWR_MAX;
5261
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305262 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305263 eHAL_STATUS_SUCCESS) {
5264 hddLog(VOS_TRACE_LEVEL_ERROR,
5265 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5266 return -EIO;
5267 }
5268
5269 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5270 txPwr /= 10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305271 if (txPwr == 0)
5272 txPwr = TX_PWR_DEF;
5273 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305274 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305275 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305276 txPwr = TX_PWR_MAX;
5277
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305278 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305279 eHAL_STATUS_SUCCESS) {
5280 hddLog(VOS_TRACE_LEVEL_ERROR,
5281 FL("setting tx power failed for 5GHz band %d"), txPwr);
5282 return -EIO;
5283 }
5284 }
5285 else if(FALSE == set_value) {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305286 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305287 eHAL_STATUS_SUCCESS) {
5288 hddLog(VOS_TRACE_LEVEL_ERROR,
5289 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5290 return -EIO;
5291 }
5292
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305293 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305294 eHAL_STATUS_SUCCESS) {
5295 hddLog(VOS_TRACE_LEVEL_ERROR,
5296 FL("setting tx power failed for 5GHz band %d"), txPwr);
5297 return -EIO;
5298 }
5299 }
5300 else {
5301 return -EINVAL;
5302 }
5303
5304 return eHAL_STATUS_SUCCESS;
5305}
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05305306
5307static int hdd_set_dynamic_aggregation(int value, hdd_adapter_t *adapter)
5308{
5309 int ret = 0;
5310 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5311 tDelBaParams del_session;
5312
5313 del_session.session_id = adapter->sessionId;
5314 hddLog(LOG1, FL("WLAN_SET_DYNNAMIC_AGGREGATION: %d"), value);
5315
5316 if ((value == DISABLE_AGGREGATION) || (value == ENABLE_AGGREGATION))
5317 {
5318 ret = ccmCfgSetInt(hal, WNI_CFG_ENABLE_TX_RX_AGGREGATION,
5319 value,NULL, eANI_BOOLEAN_FALSE);
5320 if (ret != eHAL_STATUS_SUCCESS)
5321 {
5322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5323 FL("failed to set ini parameter, WNI_CFG_ENABLE_TX_RX_AGGREGATION"));
5324 return -EIO;
5325 }
5326
5327 } else {
5328 hddLog(VOS_TRACE_LEVEL_ERROR,
5329 FL("Invalid command input"));
5330 return -EINVAL;
5331 }
5332 ret = sme_del_sta_ba_session_req(hal, del_session);
5333 if (ret != VOS_STATUS_SUCCESS) {
5334 hddLog(VOS_TRACE_LEVEL_ERROR, FL("send ba session req fail"));
5335 return -EINVAL;
5336 }
5337
5338 EXIT();
5339 return ret;
5340}
5341
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305342static int
5343wlan_hdd_sta_mon_op(hdd_context_t *hdd_ctx, uint32_t set_value,
5344 hdd_adapter_t *mon_adapter, hdd_mon_ctx_t *mon_ctx)
5345{
5346 hdd_station_ctx_t *sta_ctx;
5347 VOS_STATUS disable_bmps_status;
5348 hdd_adapter_t *sta_adapter;
5349 v_CONTEXT_t vos_ctx = (WLAN_HDD_GET_CTX(mon_adapter))->pvosContext;
5350
5351 if (!test_bit(DEVICE_IFACE_OPENED, &mon_adapter->event_flags)) {
5352 hddLog(LOGE, FL("Monitor Interface is not OPENED"));
5353 return -EINVAL;
5354 }
5355
5356 if (set_value == MON_MODE_STOP) {
5357 if (wlan_hdd_check_monitor_state(hdd_ctx))
5358 return 0;
5359 return -EINVAL;
5360 }
5361
5362 sta_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION);
5363 if (!sta_adapter) {
5364 hddLog(LOGE, FL("No Station adapter"));
5365 return -EINVAL;
5366 }
5367
5368 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
5369 if (!sta_ctx || !hdd_connIsConnected(sta_ctx)) {
5370 hddLog(LOGE, FL("STA is not connected"));
5371 return -EINVAL;
5372 }
5373
5374 if (hdd_isConnectionInProgress(hdd_ctx, NULL, NULL)) {
5375 hddLog(LOGE, FL("Roaming or set-key is in progress"));
5376 return -EBUSY;
5377 }
5378
5379 hdd_disable_roaming(hdd_ctx);
5380
5381 hddLog(LOG1, FL("Disable BMPS"));
5382 disable_bmps_status = hdd_disable_bmps_imps(hdd_ctx,
5383 WLAN_HDD_INFRA_STATION);
5384 if (disable_bmps_status != VOS_STATUS_SUCCESS) {
5385 hddLog(LOGE, FL("Cannot start monitor mode"));
5386 hdd_restore_roaming(hdd_ctx);
5387 return -EINVAL;
5388 }
5389
5390 mon_ctx->ChannelNo = sta_ctx->conn_info.operationChannel;
5391
5392 /*
5393 * In STA + Mon mode, firmware should not consider ChannelBW
5394 */
5395 mon_ctx->ChannelBW = 0;
5396 mon_ctx->crcCheckEnabled = 0;
5397 wlan_hdd_mon_set_typesubtype(mon_ctx, 100);
5398 mon_ctx->is80211to803ConReq = 0;
5399 WLANTL_SetIsConversionReq(vos_ctx, 0);
5400 mon_adapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
5401
5402 mon_ctx->state = MON_MODE_START;
5403 return 0;
5404}
5405
5406/* set param sub-ioctls */
5407static int __iw_mon_setint_getnone(struct net_device *dev,
5408 struct iw_request_info *info,
5409 union iwreq_data *wrqu, char *extra)
5410{
5411 hdd_adapter_t *adapter;
5412 hdd_context_t *hdd_ctx;
5413 hdd_mon_ctx_t *mon_ctx;
5414 int *value = (int *)extra;
5415 int sub_cmd = value[0];
5416 int set_value = value[1];
5417 int ret = 0; /* success */
5418 tVOS_CONCURRENCY_MODE concurrency_mode;
5419
5420 ENTER();
5421 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5422 if (!adapter || adapter->device_mode != WLAN_HDD_MONITOR)
5423 return -EINVAL;
5424
5425 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5426 ret = wlan_hdd_validate_context(hdd_ctx);
5427 if (ret)
5428 return ret;
5429
5430 concurrency_mode = hdd_ctx->concurrency_mode;
5431 if (concurrency_mode != VOS_STA_MON) {
5432 hddLog(LOGE, "invalid concurrency mode %d", concurrency_mode);
5433 return -EINVAL;
5434 }
5435
5436 switch(sub_cmd) {
5437
5438 case WE_SET_MONITOR_STATE:
5439 {
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05305440 void *cookie;
5441 struct hdd_request *request;
5442 static const struct hdd_request_params params = {
5443 .priv_size = 0,
5444 .timeout_ms = MON_MODE_MSG_TIMEOUT,
5445 };
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305446
5447 mon_ctx = WLAN_HDD_GET_MONITOR_CTX_PTR(adapter);
5448 if(!mon_ctx) {
5449 hddLog(LOGE, "Monitor Context NULL");
5450 ret = -EIO;
5451 break;
5452 }
5453
5454 if (mon_ctx->state == set_value) {
5455 hddLog(LOGE, FL("already in same mode curr_mode:%d req_mode: %d"),
5456 mon_ctx->state, set_value);
5457 break;
5458 }
5459
5460 ret = wlan_hdd_sta_mon_op(hdd_ctx, set_value,
5461 adapter,mon_ctx);
5462 if (ret)
5463 break;
5464
5465 mon_ctx->state = set_value;
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05305466 request = hdd_request_alloc(&params);
5467 if (!request) {
5468 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
5469 ret = -ENOMEM;
5470 break;
5471 }
5472 cookie = hdd_request_cookie(request);
5473 if (wlan_hdd_mon_postMsg(cookie, mon_ctx,
5474 hdd_mon_post_msg_cb)
5475 != VOS_STATUS_SUCCESS) {
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305476 hddLog(LOGE, FL("failed to post MON MODE REQ"));
5477 mon_ctx->state =
5478 (mon_ctx->state==MON_MODE_START) ?
5479 MON_MODE_STOP : MON_MODE_START;
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305480 ret = -EIO;
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05305481 } else {
5482 ret = hdd_request_wait_for_response(request);
5483 if (ret){
5484 hddLog(LOGE, FL("failed to wait on monitor mode completion %d"),
5485 ret);
5486 } else if (mon_ctx->state == MON_MODE_STOP) {
5487 hddLog(LOG1, FL("Enable BMPS"));
5488 hdd_enable_bmps_imps(hdd_ctx);
5489 hdd_restore_roaming(hdd_ctx);
5490 }
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305491 }
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05305492 hdd_request_put(request);
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305493 }
5494 break;
5495
5496 default:
5497 {
5498 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
5499 sub_cmd, set_value);
5500 }
5501 break;
5502 }
5503
5504 EXIT();
5505 return ret;
5506}
5507
Jeff Johnson295189b2012-06-20 16:38:30 -07005508/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305509static int __iw_setint_getnone(struct net_device *dev,
5510 struct iw_request_info *info,
5511 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005512{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305513 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305514 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305515 hdd_wext_state_t *pWextState;
5516 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305517 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 int *value = (int *)extra;
5519 int sub_cmd = value[0];
5520 int set_value = value[1];
5521 int ret = 0; /* success */
5522 int enable_pbm, enable_mp;
5523#ifdef CONFIG_HAS_EARLYSUSPEND
5524 v_U8_t nEnableSuspendOld;
5525#endif
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305526 void *cookie;
5527 struct hdd_request *request;
Jeff Johnson295189b2012-06-20 16:38:30 -07005528
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305529 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305530 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5531 if (NULL == pAdapter)
5532 {
5533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5534 "%s: Adapter is NULL",__func__);
5535 return -EINVAL;
5536 }
5537 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5538 ret = wlan_hdd_validate_context(pHddCtx);
5539 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005540 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305541 return ret;
5542 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305543
Katya Nigameae74b62015-05-28 17:19:16 +05305544 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305545 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305546 /* In monitor mode hHal is NULL */
5547 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5548 if (NULL == hHal)
5549 {
5550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5551 "%s: Hal Context is NULL",__func__);
5552 return -EINVAL;
5553 }
Katya Nigameae74b62015-05-28 17:19:16 +05305554 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5555 if (NULL == pWextState)
5556 {
5557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5558 "%s: pWextState is NULL",__func__);
5559 return -EINVAL;
5560 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005561
Katya Nigameae74b62015-05-28 17:19:16 +05305562 INIT_COMPLETION(pWextState->completion_var);
5563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 switch(sub_cmd)
5565 {
5566 case WE_SET_11D_STATE:
5567 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005568 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005569 memset(&smeConfig, 0x00, sizeof(smeConfig));
5570
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305571 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5572 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 sme_GetConfigParam(hHal,&smeConfig);
5574 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5575
Arif Hussain6d2a3322013-11-17 19:50:10 -08005576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005577
5578 sme_UpdateConfig(hHal,&smeConfig);
5579 }
5580 else {
5581 return -EINVAL;
5582 }
5583 break;
5584 }
5585
5586 case WE_WOWL:
5587 {
5588 switch (set_value)
5589 {
5590 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305591 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 break;
5593 case 0x01:
5594 case 0x02:
5595 case 0x03:
5596 enable_mp = (set_value & 0x01) ? 1 : 0;
5597 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005598 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005599 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5600 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5601 break;
5602 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005603 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 ret = -EINVAL;
5605 break;
5606 }
5607
5608 break;
5609 }
5610 case WE_SET_POWER:
5611 {
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305612 if (wlan_hdd_check_monitor_state(pHddCtx)) {
5613 hddLog(LOGE, FL("setPower not allowed in STA + MON"));
5614 ret = -EOPNOTSUPP;
5615 break;
5616 }
5617
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 switch (set_value)
5619 {
5620 case 0: //Full Power
5621 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305622 eHalStatus status = eHAL_STATUS_FAILURE;
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305623 static const struct hdd_request_params params = {
5624 .priv_size = 0,
5625 .timeout_ms = WLAN_WAIT_TIME_POWER,
5626 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005627
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305628 if (NULL == hHal)
5629 return -EINVAL;
5630
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305631 request = hdd_request_alloc(&params);
5632 if (!request) {
5633 hddLog(VOS_TRACE_LEVEL_ERROR,
5634 FL("Request allocation failure"));
5635 return VOS_STATUS_E_NOMEM;
5636 }
5637 cookie = hdd_request_cookie(request);
5638
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305640 iw_power_callback_func, cookie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305642
Jeff Johnson72a40512013-12-19 10:14:15 -08005643 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 {
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305645 ret = hdd_request_wait_for_response(request);
5646 if (ret) {
Jeff Johnson72a40512013-12-19 10:14:15 -08005647 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305648 FL("SME timeout while requesting bmps"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 }
5650 }
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305651
5652 /*
5653 * either we never sent a request, we sent a request and
5654 * received a response or we sent a request and timed out.
5655 * Regardless we are done with the request.
5656 */
5657 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08005658
Arif Hussain6d2a3322013-11-17 19:50:10 -08005659 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 break;
5661 }
5662 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305663 if (hHal)
5664 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5665 else
5666 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 break;
5668 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305669 if (hHal)
5670 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5671 else
5672 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005673 break;
5674 case 3: //Request Bmps
5675 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305676 eHalStatus status = eHAL_STATUS_FAILURE;
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305677 static const struct hdd_request_params params = {
5678 .priv_size = 0,
5679 .timeout_ms = WLAN_WAIT_TIME_POWER,
5680 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005681
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305682 if (NULL == hHal)
5683 return -EINVAL;
5684
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305685 request = hdd_request_alloc(&params);
5686 if (!request) {
5687 hddLog(VOS_TRACE_LEVEL_ERROR,
5688 FL("Request allocation failure"));
5689 return VOS_STATUS_E_NOMEM;
5690 }
5691 cookie = hdd_request_cookie(request);
5692
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305694 iw_power_callback_func, cookie);
Jeff Johnson72a40512013-12-19 10:14:15 -08005695 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 {
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305697 ret = hdd_request_wait_for_response(request);
5698 if (ret) {
Jeff Johnson72a40512013-12-19 10:14:15 -08005699 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305700 FL("SME timeout while requesting fullpower"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 }
5702 }
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305703
5704 /*
5705 * either we never sent a request, we sent a request and
5706 * received a response or we sent a request and timed out.
5707 * Regardless we are done with the request.
5708 */
5709 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08005710
Arif Hussain6d2a3322013-11-17 19:50:10 -08005711 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 break;
5713 }
5714 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305715 if (hHal)
5716 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5717 else
5718 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 break;
5720 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305721 if (hHal)
5722 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5723 else
5724 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 break;
5726 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305727 if (hHal)
5728 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5729 else
5730 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 break;
5732 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305733 if (hHal)
5734 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5735 else
5736 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005737 break;
5738 case 8: //Request Standby
5739#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005740#endif
5741 break;
5742 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305743 if (hHal)
5744 sme_StartAutoBmpsTimer(hHal);
5745 else
5746 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 break;
5748 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305749 if (hHal)
5750 sme_StopAutoBmpsTimer(hHal);
5751 else
5752 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005753 break;
5754#ifdef CONFIG_HAS_EARLYSUSPEND
5755 case 11://suspend to standby
5756#ifdef CONFIG_HAS_EARLYSUSPEND
5757 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5758 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5760#endif
5761 break;
5762 case 12://suspend to deep sleep
5763#ifdef CONFIG_HAS_EARLYSUSPEND
5764 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5765 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5767#endif
5768 break;
5769 case 13://resume from suspend
5770#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005771#endif
5772 break;
5773#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005775 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005776 ret = -EINVAL;
5777 break;
5778 }
5779 break;
5780 }
5781
5782 case WE_SET_MAX_ASSOC:
5783 {
5784 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305785 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
5786 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07005787 {
5788 ret = -EINVAL;
5789 }
5790 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5791 set_value, NULL, eANI_BOOLEAN_FALSE)
5792 != eHAL_STATUS_SUCCESS )
5793 {
c_hpothub8245442013-11-20 23:41:09 +05305794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5795 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005796 ret = -EIO;
5797 }
5798 break;
5799 }
5800
5801 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5802 {
5803 if( 0 == set_value )
5804 {
5805 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5806 }
5807 else if ( 1 == set_value )
5808 {
5809 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5810 }
5811 else
5812 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005813 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 ret = -EINVAL;
5815 }
5816 break;
5817 }
5818
5819 case WE_SET_DATA_INACTIVITY_TO:
5820 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305821 if (NULL == hHal)
5822 return -EINVAL;
5823
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5825 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5826 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5827 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5828 set_value,
5829 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5830 {
5831 hddLog(LOGE,"Failure: Could not pass on "
5832 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005833 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 ret = -EINVAL;
5835 }
5836 break;
5837 }
5838 case WE_SET_MAX_TX_POWER:
5839 {
5840 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5841 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5842
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305843 if (NULL == hHal)
5844 return -EINVAL;
5845
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5847 __func__, set_value);
5848 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5849 eHAL_STATUS_SUCCESS )
5850 {
5851 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5852 __func__);
5853 return -EIO;
5854 }
5855
5856 break;
5857 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005858 case WE_SET_MAX_TX_POWER_2_4:
5859 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305860 if (NULL == hHal)
5861 return -EINVAL;
5862
Arif Hussaina5ebce02013-08-09 15:09:58 -07005863 hddLog(VOS_TRACE_LEVEL_INFO,
5864 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5865 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305866 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07005867 eHAL_STATUS_SUCCESS)
5868 {
5869 hddLog(VOS_TRACE_LEVEL_ERROR,
5870 "%s: Setting maximum tx power failed for 2.4 GHz band",
5871 __func__);
5872 return -EIO;
5873 }
5874
5875 break;
5876 }
5877 case WE_SET_MAX_TX_POWER_5_0:
5878 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305879 if (NULL == hHal)
5880 return -EINVAL;
5881
Arif Hussaina5ebce02013-08-09 15:09:58 -07005882 hddLog(VOS_TRACE_LEVEL_INFO,
5883 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5884 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305885 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07005886 eHAL_STATUS_SUCCESS)
5887 {
5888 hddLog(VOS_TRACE_LEVEL_ERROR,
5889 "%s: Setting maximum tx power failed for 5.0 GHz band",
5890 __func__);
5891 return -EIO;
5892 }
5893
5894 break;
5895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 case WE_SET_HIGHER_DTIM_TRANSITION:
5897 {
5898 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5899 (set_value == eANI_BOOLEAN_TRUE)))
5900 {
5901 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5902 ret = -EINVAL;
5903 }
5904 else
5905 {
5906 if(pAdapter->higherDtimTransition != set_value)
5907 {
5908 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005909 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 }
5911 }
5912
5913 break;
5914 }
5915
5916 case WE_SET_TM_LEVEL:
5917 {
5918 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005919 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5921
5922 break;
5923 }
5924
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305925 case WE_ENABLE_STRICT_FCC_REG:
5926 {
5927 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5928 struct wiphy *wiphy = NULL;
5929 long lrc;
5930 int status;
5931
5932 wiphy = hddCtxt->wiphy;
5933 if(wiphy == NULL)
5934 {
5935 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5936 break;
5937 }
5938 init_completion(&hddCtxt->wiphy_channel_update_event);
5939
5940 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5941
5942 status = regulatory_hint(wiphy, "00");
5943 if(status < 0)
5944 {
5945 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5946 break;
5947 }
5948
5949 /* Wait for completion */
5950 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5951 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5952 if (lrc <= 0)
5953 {
5954 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5955 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5956 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5957 }
5958 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5959
5960 break;
5961 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005962 case WE_SET_DEBUG_LOG:
5963 {
5964 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5965 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305966 if (hHal)
5967 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5968 else
5969 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005970 break;
5971 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305972#ifdef FEATURE_WLAN_TDLS
5973 case WE_SET_TDLS_OFF_CHAN:
5974 {
5975 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5977 __func__, set_value);
5978 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5979 break;
5980 }
5981 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5982 {
5983 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5985 __func__, set_value);
5986 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5987 break;
5988 }
5989 case WE_SET_TDLS_OFF_CHAN_MODE:
5990 {
5991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5992 __func__, set_value);
5993 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5994 break;
5995 }
5996#endif
Peng Xu2446a892014-09-05 17:21:18 +05305997 case WE_SET_SCAN_BAND_PREFERENCE:
5998 {
5999 tSmeConfigParams smeConfig;
6000 memset(&smeConfig, 0x00, sizeof(smeConfig));
6001 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
6002 ret = -EINVAL;
6003 break;
6004 }
6005 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
6006
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306007 if ((eCSR_BAND_ALL == set_value ||
6008 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
6009 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306010 sme_GetConfigParam(hHal, &smeConfig);
6011 smeConfig.csrConfig.scanBandPreference = set_value;
6012
6013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6014 "set band scan preference = %d\n",
6015 smeConfig.csrConfig.scanBandPreference);
6016
6017 sme_UpdateConfig(hHal, &smeConfig);
6018 }
6019 else {
6020 ret = -EINVAL;
6021 }
6022 break;
6023 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306024 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6025 * connection happens so that the params can take effect during
6026 * association. Also this should not be used in STA+p2p concurrency
6027 * as the param will also effect the STA mode.
6028 */
6029 case WE_SET_MIRACAST_VENDOR_CONFIG:
6030 {
6031 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306032
Abhishek Singh01c73d12015-03-12 15:13:44 +05306033 hddLog(LOG1, FL(
6034 "Set Miracast vendor tuning %d"), set_value);
6035
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306036 if (NULL == hHal)
6037 return -EINVAL;
6038
Abhishek Singh01c73d12015-03-12 15:13:44 +05306039 if (1 == set_value || 0 == set_value)
6040 {
6041 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6042 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6043 {
6044 hddLog( LOGE, FL("set vendor miracast config failed"));
6045 ret = -EIO;
6046 }
6047 }
6048 else
6049 {
6050 hddLog(LOGE,
6051 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6052 ret = -EINVAL;
6053 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306054 break;
6055 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306056
6057 case WE_GET_FRAME_LOG:
6058 {
6059 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6060 != VOS_STATUS_SUCCESS)
6061 {
6062 ret = -EINVAL;
6063 }
6064 break;
6065 }
6066
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306067 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6068 {
6069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6070 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306071 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306072 {
6073 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6074 set_value);
6075 }
6076 else
6077 ret = -EINVAL;
6078
6079 break;
6080 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306081 /* Bit mask value to enable RTS/CTS for different modes
6082 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6083 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6084 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6085 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6086 * for 5 GHz, VHT80 - 0x1000
6087 */
6088 case WE_SET_RTS_CTS_HTVHT:
6089 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306090
Abhishek Singh41988ba2015-05-25 19:42:29 +05306091 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6092
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306093 if (NULL == hHal)
6094 return -EINVAL;
6095
Abhishek Singh41988ba2015-05-25 19:42:29 +05306096 if (eHAL_STATUS_SUCCESS !=
6097 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6098 {
6099 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6100 ret = -EINVAL;
6101 }
6102 break;
6103 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306104 case WE_SET_MONITOR_STATE:
6105 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306106 tVOS_CON_MODE mode = hdd_get_conparam();
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306107 int ret;
6108 void *cookie;
6109 struct hdd_request *request;
6110 static const struct hdd_request_params params = {
6111 .priv_size = 0,
6112 .timeout_ms = MON_MODE_MSG_TIMEOUT,
6113 };
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306114
6115 if( VOS_MONITOR_MODE != mode)
6116 {
6117 hddLog(LOGE, "invalid mode %d", mode);
6118 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306119 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306120 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306121
6122 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6123 if( pMonCtx == NULL )
6124 {
6125 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306126 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306127 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306128 }
6129 if (pMonCtx->state == set_value)
6130 {
6131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6132 FL("already in same mode curr_mode:%d req_mode: %d"),
6133 pMonCtx->state, set_value);
6134 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306135 }
6136 pMonCtx->state = set_value;
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306137 request = hdd_request_alloc(&params);
6138 if (!request) {
6139 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
6140 ret = -ENOMEM;
6141 break;
6142 }
6143 cookie = hdd_request_cookie(request);
6144
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306145 if (VOS_STATUS_SUCCESS !=
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306146 wlan_hdd_mon_postMsg(cookie, pMonCtx,
6147 hdd_mon_post_msg_cb)) {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6149 FL("failed to post MON MODE REQ"));
6150 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6151 MON_MODE_STOP : MON_MODE_START;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306152 ret = -EIO;
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306153 } else {
6154 ret = hdd_request_wait_for_response(request);
6155 if (ret) {
6156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6157 FL("failed to wait on monitor mode completion %d"),
6158 ret);
6159 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306160 }
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306161 hdd_request_put(request);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306162 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306163 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306164 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6165 {
6166 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6167 tAniWifiStartLog start_log;
6168 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6169 !vos_isPktStatsEnabled())
6170 {
6171 hddLog(LOGE, FL("per pkt stats not enabled"));
6172 return -EINVAL;
6173 }
6174 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6175
6176 if (1 == set_value || 0 == set_value)
6177 {
6178 start_log.ringId = RING_ID_PER_PACKET_STATS;
6179 start_log.flag = 0;
6180 if (set_value)
6181 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6182 else
6183 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6184
6185 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6186 }
6187 else
6188 {
6189 hddLog(LOGE,
6190 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6191 set_value);
6192 ret = -EINVAL;
6193 }
6194 break;
6195 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306196 case WE_SET_PROXIMITY_ENABLE:
6197 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306198 if (NULL == hHal)
6199 return -EINVAL;
6200
6201 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306202 break;
6203 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05306204 case WE_CAP_TSF:
6205 {
6206 if (NULL == hHal)
6207 return -EINVAL;
6208
6209 ret = hdd_capture_tsf(pAdapter, (uint32_t *)&set_value, 1);
6210 break;
6211 }
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306212 case WE_SET_MODULATED_DTIM:
6213 {
6214 if ((set_value < CFG_ENABLE_MODULATED_DTIM_MIN) ||
6215 (set_value > CFG_ENABLE_MODULATED_DTIM_MAX)) {
6216 hddLog(LOGE, FL("Invalid value %d in gEnableModuleDTIM"),
6217 set_value);
6218 return -EINVAL;
6219 } else {
6220 ret = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->
6221 enableModulatedDTIM = set_value;
6222 }
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05306223 }
6224 case WLAN_SET_DYNNAMIC_AGGREGATION:
6225 {
6226 if (NULL == hHal)
6227 return -EINVAL;
6228
6229 ret = hdd_set_dynamic_aggregation(set_value, pAdapter);
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306230 break;
6231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006232 default:
6233 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006234 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 sub_cmd, set_value);
6236 break;
6237 }
6238 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306239 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 return ret;
6241}
6242
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306243static int iw_setint_getnone(struct net_device *dev,
6244 struct iw_request_info *info,
6245 union iwreq_data *wrqu, char *extra)
6246{
6247 int ret;
6248
6249 vos_ssr_protect(__func__);
6250 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6251 vos_ssr_unprotect(__func__);
6252
6253 return 0;
6254}
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306255
6256static
6257int iw_mon_setint_getnone(struct net_device *dev,
6258 struct iw_request_info *info,
6259 union iwreq_data *wrqu, char *extra)
6260{
6261 int ret;
6262
6263 vos_ssr_protect(__func__);
6264 ret = __iw_mon_setint_getnone(dev, info, wrqu, extra);
6265 vos_ssr_unprotect(__func__);
6266
6267 return 0;
6268}
6269
Jeff Johnson295189b2012-06-20 16:38:30 -07006270/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306271static int __iw_setchar_getnone(struct net_device *dev,
6272 struct iw_request_info *info,
6273 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006274{
6275 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306276 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006278 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306279 hdd_adapter_t *pAdapter;
6280 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006281#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306282 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006283#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306284 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306285 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006286
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306287 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306288
6289 if (!capable(CAP_NET_ADMIN))
6290 {
6291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6292 FL("permission check failed"));
6293 return -EPERM;
6294 }
6295
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306296 pAdapter = (netdev_priv(dev));
6297 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006298 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6300 "%s: Adapter is NULL",__func__);
6301 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006302 }
6303
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306304 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6305 ret = wlan_hdd_validate_context(pHddCtx);
6306 if (0 != ret)
6307 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306308 return ret;
6309 }
6310#ifdef WLAN_FEATURE_VOWIFI
6311 pConfig = pHddCtx->cfg_ini;
6312#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306313 /* helper function to get iwreq_data with compat handling. */
6314 if (hdd_priv_get_data(&s_priv_data, wrqu))
6315 {
6316 return -EINVAL;
6317 }
6318
6319 /* make sure all params are correctly passed to function */
6320 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6321 {
6322 return -EINVAL;
6323 }
6324
6325 sub_cmd = s_priv_data.flags;
6326
Arif Hussain0273cba2014-01-07 20:58:29 -08006327 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306328 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6329 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006330 if (NULL == pBuffer)
6331 {
6332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6333 "mem_alloc_copy_from_user_helper fail");
6334 return -ENOMEM;
6335 }
6336
6337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306338 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6340 "%s: Received data %s", __func__, pBuffer);
6341
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 switch(sub_cmd)
6343 {
6344 case WE_WOWL_ADD_PTRN:
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306345 if (wlan_hdd_check_monitor_state(pHddCtx)) {
6346 hddLog(LOGE, FL("wowlAddPtrn not allowed in STA + MON"));
6347 ret = -EOPNOTSUPP;
6348 break;
6349 }
6350
Arif Hussain6d2a3322013-11-17 19:50:10 -08006351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006352 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 break;
6354 case WE_WOWL_DEL_PTRN:
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306355 if (wlan_hdd_check_monitor_state(pHddCtx)) {
6356 hddLog(LOGE, FL("wowlDelPtrn not allowed in STA + MON"));
6357 ret = -EOPNOTSUPP;
6358 break;
6359 }
6360
Arif Hussain6d2a3322013-11-17 19:50:10 -08006361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006362 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 break;
6364#if defined WLAN_FEATURE_VOWIFI
6365 case WE_NEIGHBOR_REPORT_REQUEST:
6366 {
6367 tRrmNeighborReq neighborReq;
6368 tRrmNeighborRspCallbackInfo callbackInfo;
6369
6370 if (pConfig->fRrmEnable)
6371 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306373 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 if( !neighborReq.no_ssid )
6375 {
Girish Gowli552fc072014-06-14 18:26:16 +05306376 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006377 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 }
6379
6380 callbackInfo.neighborRspCallback = NULL;
6381 callbackInfo.neighborRspCallbackContext = NULL;
6382 callbackInfo.timeout = 5000; //5 seconds
6383 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6384 }
6385 else
6386 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006387 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 ret = -EINVAL;
6389 }
6390 }
6391 break;
6392#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 case WE_SET_AP_WPS_IE:
6394 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306395 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006398 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 if (VOS_STATUS_SUCCESS != vstatus)
6400 {
6401 ret = -EINVAL;
6402 }
6403 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306404 case WE_SET_ENCRYPT_MSG:
6405 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6406 if (NULL == pkt)
6407 {
6408 hddLog(VOS_TRACE_LEVEL_ERROR,
6409 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306410 ret = -ENOMEM;
6411 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306412 }
6413
6414 memset(pkt, 0, sizeof(tSirpkt80211));
6415
6416 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6417 hddLog(VOS_TRACE_LEVEL_ERROR,
6418 FL("Firmware is not DISA capable"));
6419 ret = -EINVAL;
6420 vos_mem_free(pkt);
6421 break;
6422 }
6423
6424 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6425
6426 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6427 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6428 if (eHAL_STATUS_SUCCESS != ret) {
6429 hddLog(VOS_TRACE_LEVEL_ERROR,
6430 FL("SENDEncryptMSG: fail to post WDA cmd"));
6431 ret = -EINVAL;
6432 }
6433 vos_mem_free(pkt);
6434
6435 break;
6436
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 default:
6438 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006439 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 ret = -EINVAL;
6441 break;
6442 }
6443 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006444 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306445
6446 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006447 return ret;
6448}
6449
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306450static int iw_setchar_getnone(struct net_device *dev,
6451 struct iw_request_info *info,
6452 union iwreq_data *wrqu, char *extra)
6453{
6454 int ret;
6455
6456 vos_ssr_protect(__func__);
6457 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6458 vos_ssr_unprotect(__func__);
6459
6460 return ret;
6461}
6462
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306463struct get_antenna_idx_priv {
6464 int antenna_id;
6465};
6466
6467static void hdd_get_current_antenna_index_cb(int antenna_id, void *context)
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306468{
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306469 struct hdd_request *request;
6470 struct get_antenna_idx_priv *priv;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306471
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306472 request = hdd_request_get(context);
6473 if (!request) {
6474 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
6475 return;
6476 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306477
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306478 priv = hdd_request_priv(request);
6479 priv->antenna_id = antenna_id;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306480
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306481 hdd_request_complete(request);
6482 hdd_request_put(request);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306483
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306484}
6485
6486static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6487 int *antennaIndex)
6488{
6489 hdd_context_t *pHddCtx;
6490 eHalStatus halStatus;
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306491 int ret;
6492 void *cookie;
6493 struct hdd_request *request;
6494 struct get_antenna_idx_priv *priv;
6495 static const struct hdd_request_params params = {
6496 .priv_size = sizeof(*priv),
6497 .timeout_ms = WLAN_WAIT_TIME_STATS,
6498 };
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306499
6500 ENTER();
6501 if (NULL == pAdapter)
6502 {
6503 hddLog(VOS_TRACE_LEVEL_WARN,
6504 "%s: Invalid context, pAdapter", __func__);
6505 return VOS_STATUS_E_FAULT;
6506 }
6507 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6508 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6509 {
6510 return VOS_STATUS_E_FAULT;
6511 }
6512 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6513 {
6514 hddLog(VOS_TRACE_LEVEL_ERROR,
6515 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6516 __func__);
6517 return VOS_STATUS_E_NOSUPPORT;
6518 }
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306519
6520 request = hdd_request_alloc(&params);
6521 if (!request) {
6522 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
6523 return VOS_STATUS_E_NOMEM;
6524 }
6525 cookie = hdd_request_cookie(request);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306526
6527 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306528 hdd_get_current_antenna_index_cb,
6529 cookie, pAdapter->sessionId);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306530 if (eHAL_STATUS_SUCCESS != halStatus)
6531 {
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306532 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6533 __func__);
6534 /* we'll returned a cached value below */
6535 *antennaIndex = -1;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306536 }
6537 else
6538 {
6539 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula543559a2018-05-02 13:06:40 +05306540 ret = hdd_request_wait_for_response(request);
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306541 if (ret)
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306542 {
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306543 hddLog(VOS_TRACE_LEVEL_ERROR,
6544 FL("SME timeout while retrieving Antenna Index"));
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306545 *antennaIndex = -1;
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306546 }
6547 else
6548 {
6549 priv = hdd_request_priv(request);
6550 pAdapter->antennaIndex = priv->antenna_id;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306551 }
6552 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306553
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306554 if (*antennaIndex != -1)
6555 *antennaIndex = pAdapter->antennaIndex;
6556
6557 /*
6558 * either we never sent a request, we sent a request and received a
6559 * response or we sent a request and timed out. Regardless we are
6560 * done with the request.
6561 */
6562 hdd_request_put(request);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306563
6564 EXIT();
6565 return VOS_STATUS_SUCCESS;
6566}
6567
Jeff Johnson295189b2012-06-20 16:38:30 -07006568/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306569static int __iw_setnone_getint(struct net_device *dev,
6570 struct iw_request_info *info,
6571 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006572{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306573 hdd_adapter_t *pAdapter;
6574 tHalHandle hHal;
6575 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 int *value = (int *)extra;
6577 int ret = 0; /* success */
6578
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306579 ENTER();
6580
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306581 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6582 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006583 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6585 "%s: Adapter is NULL",__func__);
6586 return -EINVAL;
6587 }
6588 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6589 ret = wlan_hdd_validate_context(pHddCtx);
6590 if (0 != ret)
6591 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306592 return ret;
6593 }
6594 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6595 if (NULL == hHal)
6596 {
6597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6598 "%s: Hal Context is NULL",__func__);
6599 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006601
6602 switch (value[0])
6603 {
6604 case WE_GET_11D_STATE:
6605 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006606 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306608
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6610
Arif Hussain6d2a3322013-11-17 19:50:10 -08006611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006612
6613 break;
6614 }
6615
6616 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 break;
6619
6620 case WE_PMC_STATE:
6621 {
6622 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 break;
6625 }
6626 case WE_GET_WLAN_DBG:
6627 {
6628 vos_trace_display();
6629 *value = 0;
6630 break;
6631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 case WE_GET_MAX_ASSOC:
6633 {
6634 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6635 {
c_hpothub8245442013-11-20 23:41:09 +05306636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6637 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006638 ret = -EIO;
6639 }
Girish Gowli385be612014-09-18 11:17:20 +05306640#ifdef WLAN_SOFTAP_VSTA_FEATURE
6641 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6642 {
6643 if (*value > VSTA_NUM_ASSOC_STA)
6644 {
6645 *value = VSTA_NUM_ASSOC_STA;
6646 }
6647 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6648 (*value > (VSTA_NUM_ASSOC_STA -
6649 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6650 {
6651 *value = (VSTA_NUM_ASSOC_STA -
6652 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6653 }
6654 }
6655 else
6656#endif
6657 {
6658 if (*value > NUM_ASSOC_STA)
6659 {
6660 *value = NUM_ASSOC_STA;
6661 }
6662 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6663 (*value > (NUM_ASSOC_STA -
6664 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6665 {
6666 *value = (NUM_ASSOC_STA -
6667 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6668 }
6669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 break;
6671 }
6672
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 case WE_GET_WDI_DBG:
6674 {
6675 wpalTraceDisplay();
6676 *value = 0;
6677 break;
6678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006679
6680 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6681 {
6682 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6683 break;
6684 }
6685 case WE_GET_CONCURRENCY_MODE:
6686 {
6687 *value = hdd_get_concurrency_mode ( );
6688
Arif Hussain6d2a3322013-11-17 19:50:10 -08006689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 break;
6691 }
6692
Peng Xu2446a892014-09-05 17:21:18 +05306693 case WE_GET_SCAN_BAND_PREFERENCE:
6694 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306695 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306696 sme_GetConfigParam(hHal, &smeConfig);
6697 *value = smeConfig.csrConfig.scanBandPreference;
6698
6699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6700 "scanBandPreference = %d\n", *value);
6701 break;
6702 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306703 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6704 {
6705 wlan_hdd_get_current_antenna_index(pAdapter, value);
6706 break;
6707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 default:
6709 {
6710 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6711 break;
6712 }
6713 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306714 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 return ret;
6716}
6717
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306718static int iw_setnone_getint(struct net_device *dev,
6719 struct iw_request_info *info,
6720 union iwreq_data *wrqu, char *extra)
6721{
6722 int ret;
6723
6724 vos_ssr_protect(__func__);
6725 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6726 vos_ssr_unprotect(__func__);
6727
6728 return ret;
6729
6730}
Jeff Johnson295189b2012-06-20 16:38:30 -07006731/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306732int __iw_set_three_ints_getnone(struct net_device *dev,
6733 struct iw_request_info *info,
6734 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006735{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306736 hdd_adapter_t *pAdapter;
6737 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 int *value = (int *)extra;
6739 int sub_cmd = value[0];
6740 int ret = 0;
6741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306742 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306743
6744 if (!capable(CAP_NET_ADMIN))
6745 {
6746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6747 FL("permission check failed"));
6748 return -EPERM;
6749 }
6750
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306751 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6752 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006753 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6755 "%s: Adapter is NULL",__func__);
6756 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006757 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306758 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6759 ret = wlan_hdd_validate_context(pHddCtx);
6760 if (0 != ret)
6761 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306762 return ret;
6763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 switch(sub_cmd)
6765 {
6766 case WE_SET_WLAN_DBG:
6767 {
6768 vos_trace_setValue( value[1], value[2], value[3]);
6769 break;
6770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006771 case WE_SET_WDI_DBG:
6772 {
6773 wpalTraceSetLevel( value[1], value[2], value[3]);
6774 break;
6775 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 case WE_SET_SAP_CHANNELS:
6777 {
6778 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6779 break;
6780 }
6781
6782 default:
6783 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006784 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 break;
6786 }
6787 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306788 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006789 return ret;
6790}
6791
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306792int iw_set_three_ints_getnone(struct net_device *dev,
6793 struct iw_request_info *info,
6794 union iwreq_data *wrqu, char *extra)
6795{
6796 int ret;
6797
6798 vos_ssr_protect(__func__);
6799 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6800 vos_ssr_unprotect(__func__);
6801
6802 return ret;
6803}
6804
6805static int __iw_get_char_setnone(struct net_device *dev,
6806 struct iw_request_info *info,
6807 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006808{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306809 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006810 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306811 hdd_context_t *pHddCtx;
6812 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006813#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006814 hdd_wext_state_t *pWextState;
6815#endif
6816
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306817 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306818 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006819 if (pAdapter == NULL)
6820 {
6821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6822 "%s: pAdapter is NULL!", __func__);
6823 return -EINVAL;
6824 }
Alok Kumar69a8b752017-11-08 15:24:32 +05306825
6826 if (WLAN_HDD_MONITOR == pAdapter->device_mode ||
6827 WLAN_HDD_FTM == pAdapter->device_mode)
6828 return ret;
6829
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306830 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6831 ret = wlan_hdd_validate_context(pHddCtx);
6832 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006833 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306834 return ret;
6835 }
6836#ifdef WLAN_FEATURE_11W
6837 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6838 if (NULL == pWextState)
6839 {
6840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6841 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006842 return -EINVAL;
6843 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306844#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006845
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 switch(sub_cmd)
6847 {
6848 case WE_WLAN_VERSION:
6849 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006850 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 break;
6852 }
6853
6854 case WE_GET_STATS:
6855 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306856 tHalHandle hHal = NULL;
6857 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006858 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6859 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6860 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05306861 hdd_arp_stats_t *parpStats = &pAdapter->hdd_stats.hddArpStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07006862
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306863
Jeff Johnson295189b2012-06-20 16:38:30 -07006864 snprintf(extra, WE_MAX_STR_LEN,
6865 "\nTransmit"
6866 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6867 "\n dropped BK %u, BE %u, VI %u, VO %u"
6868 "\n classified BK %u, BE %u, VI %u, VO %u"
6869 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6870 "\n queued BK %u, BE %u, VI %u, VO %u"
6871 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006872 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006873 "\n fetched BK %u, BE %u, VI %u, VO %u"
6874 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6875 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006876 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 "\n flushed BK %u, BE %u, VI %u, VO %u"
6878 "\n\nReceive"
6879 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6880 "\n\nResetsStats"
6881 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05306882 "\n"
6883 "\n\nARP Transmit"
6884 "\nTransmit Count %u, dropped %u"
6885 "\n\nARP Receive"
6886 "\nReceive Count %u, dropped %u, Delivered %u, Refused %u, Drop Reason %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006887 "\n",
6888 pStats->txXmitCalled,
6889 pStats->txXmitDropped,
6890 pStats->txXmitBackPressured,
6891 pStats->txXmitQueued,
6892
6893 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6894 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6895 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6896 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6897
6898 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6899 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6900 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6901 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6902
6903 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6904 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6905 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6906 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6907
6908 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6909 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6910 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6911 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6912
6913 pStats->txFetched,
6914 pStats->txFetchEmpty,
6915 pStats->txFetchLowResources,
6916 pStats->txFetchDequeueError,
6917
6918 pStats->txFetchDequeued,
6919 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006920 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 pStats->txCompleted,
6922 pStats->txFlushed,
6923
6924 pStats->txFetchedAC[WLANTL_AC_BK],
6925 pStats->txFetchedAC[WLANTL_AC_BE],
6926 pStats->txFetchedAC[WLANTL_AC_VI],
6927 pStats->txFetchedAC[WLANTL_AC_VO],
6928
6929 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6930 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6931 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6932 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6933
6934 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6935 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6936 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6937 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6938
Ravi Joshi41914632013-10-21 23:02:21 -07006939 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6940 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6941 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6942 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6943
Jeff Johnson295189b2012-06-20 16:38:30 -07006944 pStats->txFlushedAC[WLANTL_AC_BK],
6945 pStats->txFlushedAC[WLANTL_AC_BE],
6946 pStats->txFlushedAC[WLANTL_AC_VI],
6947 pStats->txFlushedAC[WLANTL_AC_VO],
6948
6949 pStats->rxChains,
6950 pStats->rxPackets,
6951 pStats->rxDropped,
6952 pStats->rxDelivered,
6953 pStats->rxRefused,
6954
6955 pResetStats->totalLogpResets,
6956 pResetStats->totalCMD53Failures,
6957 pResetStats->totalMutexReadFailures,
6958 pResetStats->totalMIFErrorFailures,
6959 pResetStats->totalFWHearbeatFailures,
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05306960 pResetStats->totalUnknownExceptions,
6961
6962 parpStats->txCount,
6963 parpStats->txDropped,
6964
6965 parpStats->rxCount,
6966 parpStats->rxDropped,
6967 parpStats->rxDelivered,
6968 parpStats->rxRefused,
6969 parpStats->reason
Jeff Johnson295189b2012-06-20 16:38:30 -07006970 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306971 wrqu->data.length = strlen(extra);
6972
6973 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6974
6975 if (hHal)
6976 pMac = PMAC_STRUCT( hHal );
6977
6978 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6979 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6980 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306981 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6982 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6983 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6984 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306985 "\n",
6986 pMac->pmm.BmpscntSleep,
6987 pMac->pmm.BmpscntAwake,
6988 pMac->pmm.BmpsSleeReqFailCnt,
6989 pMac->pmm.BmpsWakeupReqFailCnt,
6990 pMac->pmm.ImpsCntSleep,
6991 pMac->pmm.ImpsCntAwake,
6992 pMac->pmm.ImpsSleepErrCnt,
6993 pMac->pmm.ImpsWakeupErrCnt,
6994 pMac->pmm.ImpsLastErr
6995 );
6996 }
6997
Jeff Johnson295189b2012-06-20 16:38:30 -07006998 wrqu->data.length = strlen(extra)+1;
6999 break;
7000 }
7001
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307002/* The case prints the current state of the HDD, SME, CSR, PE, TL
7003 *it can be extended for WDI Global State as well.
7004 *And currently it only checks P2P_CLIENT adapter.
7005 *P2P_DEVICE and P2P_GO have not been added as of now.
7006*/
7007 case WE_GET_STATES:
7008 {
7009 int buf = 0, len = 0;
7010 int adapter_num = 0;
7011 int count = 0, check = 1;
7012
7013 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007014 tHalHandle hHal = NULL;
7015 tpAniSirGlobal pMac = NULL;
7016 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307017
7018 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7019 hdd_adapter_t *useAdapter = NULL;
7020
7021 /* Print wlan0 or p2p0 states based on the adapter_num
7022 *by using the correct adapter
7023 */
7024 while ( adapter_num < 2 )
7025 {
7026 if ( WLAN_ADAPTER == adapter_num )
7027 {
7028 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007029 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307030 "\n\n wlan0 States:-");
7031 len += buf;
7032 }
7033 else if ( P2P_ADAPTER == adapter_num )
7034 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007035 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307036 "\n\n p2p0 States:-");
7037 len += buf;
7038
7039 if( !pHddCtx )
7040 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007041 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307042 "\n pHddCtx is NULL");
7043 len += buf;
7044 break;
7045 }
7046
7047 /*Printing p2p0 states only in the case when the device is
7048 configured as a p2p_client*/
7049 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7050 if ( !useAdapter )
7051 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007052 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307053 "\n Device not configured as P2P_CLIENT.");
7054 len += buf;
7055 break;
7056 }
7057 }
7058
7059 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007060 if (!hHal) {
7061 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7062 "\n pMac is NULL");
7063 len += buf;
7064 break;
7065 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307066 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007067 if (!pMac) {
7068 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7069 "\n pMac is NULL");
7070 len += buf;
7071 break;
7072 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307073 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7074 if( !pHddStaCtx )
7075 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007076 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307077 "\n pHddStaCtx is NULL");
7078 len += buf;
7079 break;
7080 }
7081
7082 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7083
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007084 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307085 "\n HDD Conn State - %s "
7086 "\n \n SME State:"
7087 "\n Neighbour Roam State - %s"
7088 "\n CSR State - %s"
7089 "\n CSR Substate - %s"
7090 "\n \n TL STA %d State: %s",
7091 macTraceGetHDDWlanConnState(
7092 pHddStaCtx->conn_info.connState),
7093 macTraceGetNeighbourRoamState(
7094 pMac->roam.neighborRoamInfo.neighborRoamState),
7095 macTraceGetcsrRoamState(
7096 pMac->roam.curState[useAdapter->sessionId]),
7097 macTraceGetcsrRoamSubState(
7098 pMac->roam.curSubState[useAdapter->sessionId]),
7099 pHddStaCtx->conn_info.staId[0],
7100 macTraceGetTLState(tlState)
7101 );
7102 len += buf;
7103 adapter_num++;
7104 }
7105
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007106 if (pMac) {
7107 /* Printing Lim State starting with global lim states */
7108 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7109 "\n \n LIM STATES:-"
7110 "\n Global Sme State - %s "\
7111 "\n Global mlm State - %s "\
7112 "\n",
7113 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7114 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7115 );
7116 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307117
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007118 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307119 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307120 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007121 if ( pMac->lim.gpSession[count].valid )
7122 {
7123 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7124 "\n Lim Valid Session %d:-"
7125 "\n PE Sme State - %s "
7126 "\n PE Mlm State - %s "
7127 "\n",
7128 check,
7129 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7130 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7131 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307132
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007133 len += buf;
7134 check++;
7135 }
7136 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307137 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307138 }
7139
7140 wrqu->data.length = strlen(extra)+1;
7141 break;
7142 }
7143
Jeff Johnson295189b2012-06-20 16:38:30 -07007144 case WE_GET_CFG:
7145 {
7146 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7147 wrqu->data.length = strlen(extra)+1;
7148 break;
7149 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007150#ifdef WLAN_FEATURE_11AC
7151 case WE_GET_RSSI:
7152 {
7153 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307154 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007155 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7156 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7157 wrqu->data.length = strlen(extra)+1;
7158 break;
7159 }
7160#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307161
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007162#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007163 case WE_GET_ROAM_RSSI:
7164 {
7165 v_S7_t s7Rssi = 0;
7166 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7167 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7168 wrqu->data.length = strlen(extra)+1;
7169 break;
7170 }
7171#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 case WE_GET_WMM_STATUS:
7173 {
7174 snprintf(extra, WE_MAX_STR_LEN,
7175 "\nDir: 0=up, 1=down, 3=both\n"
7176 "|------------------------|\n"
7177 "|AC | ACM |Admitted| Dir |\n"
7178 "|------------------------|\n"
7179 "|VO | %d | %3s | %d |\n"
7180 "|VI | %d | %3s | %d |\n"
7181 "|BE | %d | %3s | %d |\n"
7182 "|BK | %d | %3s | %d |\n"
7183 "|------------------------|\n",
7184 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7185 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7186 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7187 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7188 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7189 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7190 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7191 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7192 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7193 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7194 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7195 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7196
Jeff Johnsone7245742012-09-05 17:12:55 -07007197
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 wrqu->data.length = strlen(extra)+1;
7199 break;
7200 }
7201 case WE_GET_CHANNEL_LIST:
7202 {
7203 VOS_STATUS status;
7204 v_U8_t i, len;
7205 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307206 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7207 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7208 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 tChannelListInfo channel_list;
7210
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007211 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007213 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007214 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007215 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 return -EINVAL;
7217 }
7218 buf = extra;
7219
7220 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007221 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7222 * needed = 5 * number of channels. Check ifsufficient
7223 * buffer is available and then proceed to fill the buffer.
7224 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007225 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7226 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007227 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007228 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007229 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007230 return -EINVAL;
7231 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007232 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7233 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307234 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7235 {
7236 //Printing Country code in getChannelList
7237 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7238 {
7239 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7240 "%c ", pBuf[i]);
7241 }
7242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 for(i = 0 ; i < channel_list.num_channels; i++)
7244 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007245 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 }
7248 wrqu->data.length = strlen(extra)+1;
7249
7250 break;
7251 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007252#ifdef FEATURE_WLAN_TDLS
7253 case WE_GET_TDLS_PEERS:
7254 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007255 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007256 break;
7257 }
7258#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007259#ifdef WLAN_FEATURE_11W
7260 case WE_GET_11W_INFO:
7261 {
7262 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7263
7264 snprintf(extra, WE_MAX_STR_LEN,
7265 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7266 "\n Number of Unprotected Disassocs %d"
7267 "\n Number of Unprotected Deauths %d",
7268 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7269 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7270 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7271 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7272 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7273
7274 wrqu->data.length = strlen(extra)+1;
7275 break;
7276 }
7277#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307278#ifdef WLAN_FEATURE_RMC
7279 case WE_GET_IBSS_STA_INFO:
7280 {
7281 hdd_station_ctx_t *pHddStaCtx =
7282 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7283 int idx = 0;
7284 int length = 0, buf = 0;
7285
7286 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7287 {
7288 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7289 {
7290 buf = snprintf
7291 (
7292 (extra + length), WE_MAX_STR_LEN - length,
7293 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7294 pHddStaCtx->conn_info.staId[ idx ],
7295 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7296 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7297 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7298 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7299 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7300 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7301 );
7302 length += buf;
7303 }
7304 }
7305 wrqu->data.length = strlen(extra)+1;
7306 break;
7307 }
7308#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307309 case WE_GET_SNR:
7310 {
7311 v_S7_t s7snr = 0;
7312 int status = 0;
7313 hdd_context_t *pHddCtx;
7314 hdd_station_ctx_t *pHddStaCtx;
7315
7316 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7317 status = wlan_hdd_validate_context(pHddCtx);
7318 if (0 != status)
7319 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307320 return status;
7321 }
7322
7323 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7324
7325 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7326 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7327 {
7328 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7329 " ConnectionState-%d", __func__,
7330 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7331 pHddStaCtx->conn_info.connState);
7332 return -ENONET;
7333 }
7334
7335 /*update the stats in TL*/
7336 wlan_hdd_get_station_stats(pAdapter);
7337 wlan_hdd_get_snr(pAdapter, &s7snr);
7338 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7339 wrqu->data.length = strlen(extra) + 1;
7340 break;
7341 }
7342
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307343#ifdef FEATURE_OEM_DATA_SUPPORT
7344 case WE_GET_OEM_DATA_CAP:
7345 {
7346 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7347 }
7348#endif /* FEATURE_OEM_DATA_SUPPORT */
7349
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307350 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007352 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007353 break;
7354 }
7355 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307356 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007357 return 0;
7358}
7359
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307360static int iw_get_char_setnone(struct net_device *dev,
7361 struct iw_request_info *info,
7362 union iwreq_data *wrqu, char *extra)
7363{
7364 int ret;
7365
7366 vos_ssr_protect(__func__);
7367 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7368 vos_ssr_unprotect(__func__);
7369
7370 return ret;
7371}
7372
Jeff Johnson295189b2012-06-20 16:38:30 -07007373/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307374static int __iw_setnone_getnone(struct net_device *dev,
7375 struct iw_request_info *info,
7376 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007377{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307378 hdd_adapter_t *pAdapter;
7379 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307380 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007381 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307382 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007383
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307384 ENTER();
7385
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307386 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7387 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007388 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7390 "%s: Adapter is NULL",__func__);
7391 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007392 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307393 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7394 ret = wlan_hdd_validate_context(pHddCtx);
7395 if (0 != ret)
7396 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307397 return ret;
7398 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307399 /* helper function to get iwreq_data with compat handling. */
7400 if (hdd_priv_get_data(&s_priv_data, wrqu))
7401 {
7402 return -EINVAL;
7403 }
7404
7405 sub_cmd = s_priv_data.flags;
7406
Jeff Johnson295189b2012-06-20 16:38:30 -07007407 switch (sub_cmd)
7408 {
7409 case WE_CLEAR_STATS:
7410 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7413 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7414 break;
7415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007416 case WE_INIT_AP:
7417 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307418 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7419
7420 /* As Soft AP mode might been changed to STA already with
7421 * killing of Hostapd, need to find the adpater by name
7422 * rather than mode */
7423 hdd_adapter_t* pAdapter_to_stop =
7424 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7425 if( pAdapter_to_stop )
7426 {
7427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7428 "Adapter with name softap.0 already "
7429 "exist, ignoring the request.\nRemove the "
7430 "adapter and try again\n");
7431 break;
7432 }
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05307433
7434 if (wlan_hdd_check_monitor_state(pHddCtx)) {
7435 hddLog(LOGE, FL("initAP not allowed in STA + MON"));
7436 ret = -EOPNOTSUPP;
7437 break;
7438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007439 pr_info("Init AP trigger\n");
7440 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7441 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7442 break;
7443 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307444#ifdef WLAN_FEATURE_RMC
7445 case WE_IBSS_GET_PEER_INFO_ALL:
7446 {
7447 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7448 break;
7449 }
7450#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007451 case WE_STOP_AP:
7452 {
7453 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7454 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7455 * this is a dead code and need to find the adpater by name rather than mode */
7456 hdd_adapter_t* pAdapter_to_stop =
7457 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7458 if( pAdapter_to_stop )
7459 {
7460 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7461
7462 pr_info("Stopping AP mode\n");
7463
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307464 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7465 {
7466 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7467 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7468 }
7469
Jeff Johnson295189b2012-06-20 16:38:30 -07007470 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307471 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307472 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007473 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7474
7475 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7476 pAdapter_to_stop->macAddressCurrent.bytes);
7477 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7478 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307479
7480 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7481 {
7482 /* put the device back into BMPS */
7483 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007485 }
7486 else
7487 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007488 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 }
7490
7491 break;
7492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007493#ifdef WLAN_BTAMP_FEATURE
7494 case WE_ENABLE_AMP:
7495 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 WLANBAP_RegisterWithHCI(pAdapter);
7498 break;
7499 }
7500 case WE_DISABLE_AMP:
7501 {
7502 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7503 VOS_STATUS status;
7504
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007506
7507 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7508 status = WLANBAP_StopAmp();
7509 if(VOS_STATUS_SUCCESS != status )
7510 {
7511 pHddCtx->isAmpAllowed = VOS_TRUE;
7512 hddLog(VOS_TRACE_LEVEL_FATAL,
7513 "%s: Failed to stop AMP", __func__);
7514 }
7515 else
7516 {
7517 //a state m/c implementation in PAL is TBD to avoid this delay
7518 msleep(500);
7519 pHddCtx->isAmpAllowed = VOS_FALSE;
7520 WLANBAP_DeregisterFromHCI();
7521 }
7522
7523 break;
7524 }
7525#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007526 case WE_ENABLE_DXE_STALL_DETECT:
7527 {
schang6295e542013-03-12 15:31:23 -07007528 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7529 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007530 break;
7531 }
7532 case WE_DISPLAY_DXE_SNAP_SHOT:
7533 {
schang6295e542013-03-12 15:31:23 -07007534 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7535 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007536 break;
7537 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307538 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7539 {
7540 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7541 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307542 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307543 break;
7544 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307545
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307546 case WE_SET_REASSOC_TRIGGER:
7547 {
7548 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7549 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7550 v_U32_t roamId = 0;
7551 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307552 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7553 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307554 return 0;
7555 }
7556
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307557 case WE_STOP_OBSS_SCAN:
7558 {
7559 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7560 2.OBSS scan is stopped by Firmware during the disassociation
7561 3.OBSS stop comamnd is added for debugging purpose*/
7562 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7563 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007564
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307565 if (pAdapter == NULL)
7566 {
7567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7568 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307569 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307570 }
7571 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7572 if (pMac == NULL)
7573 {
7574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7575 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307576 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307577 }
7578 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7579 }
7580 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307581 case WE_DUMP_ROAM_TIMER_LOG:
7582 {
7583 vos_dump_roam_time_log_service();
7584 break;
7585 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307586
Mukul Sharma84f27252014-07-14 18:11:42 +05307587 case WE_RESET_ROAM_TIMER_LOG:
7588 {
7589 vos_reset_roam_timer_log();
7590 break;
7591 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307592 case WE_GET_FW_LOGS:
7593 {
7594 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7595 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307596 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307597 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307598 break;
7599 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307600 case WE_GET_FW_MEMDUMP:
7601 {
7602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7603 "FW_MEM_DUMP requested ");
7604 get_fwr_memdump(dev,info,wrqu,extra);
7605 break;
7606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007607 default:
7608 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007609 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 break;
7611 }
7612 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307613 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007614 return ret;
7615}
7616
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307617static int iw_setnone_getnone(struct net_device *dev,
7618 struct iw_request_info *info,
7619 union iwreq_data *wrqu, char *extra)
7620{
7621 int ret;
7622
7623 vos_ssr_protect(__func__);
7624 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7625 vos_ssr_unprotect(__func__);
7626
7627 return ret;
7628}
7629
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307630void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7631{
7632 /*
7633 * Function to display HDD WMM information
7634 * for Tx Queues.
7635 * Prints globala as well as per client depending
7636 * whether the clients are registered or not.
7637 */
7638 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307639 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7640 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307641 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7642 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307643 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307644
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307645 for ( i=0; i< NUM_TX_QUEUES; i++)
7646 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307647 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307648 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307649 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307650 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307651
7652 for ( i=0; i< NUM_TX_QUEUES; i++) {
7653 if (tx_queue_count[i]) {
7654 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7655 i, tx_queue_count[i]);
7656 }
7657 }
7658
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307659 if(pSapCtx == NULL){
7660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7661 FL("psapCtx is NULL"));
7662 return;
7663 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307664
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307665 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307666 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7667 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307668 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307669 {
7670 hddLog(LOGE, "******STAIndex: %d*********", i);
7671 for ( j=0; j< NUM_TX_QUEUES; j++)
7672 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307673 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7674 {
7675 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307676 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7677 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307678 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7679 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307680 }
7681 }
7682 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307683 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307684
Katya Nigam1fd24402015-02-16 14:52:19 +05307685 if(pHddStaCtx == NULL){
7686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7687 FL("pHddStaCtx is NULL"));
7688 return;
7689 }
7690
7691 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7692 if(pPeerInfo == NULL){
7693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7694 FL("ppeerinfo is NULL"));
7695 return;
7696 }
7697
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307698 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7699 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7700 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7701 for (j = 0; j < NUM_TX_QUEUES; j++) {
7702 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7703 spin_lock_bh(
7704 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7705 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07007706 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%pK, NextAddress:%pK",
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307707 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7708 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7709 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7710 spin_unlock_bh(
7711 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7712 }
7713 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307714 }
7715 }
7716
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307717}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307718
Girish Gowlifb9758e2014-11-19 15:19:17 +05307719static int __iw_set_var_ints_getnone(struct net_device *dev,
7720 struct iw_request_info *info,
7721 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007722{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307723 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307724 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307725 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307726 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007727 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307728 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307729 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007730 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307731 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007732 int cmd = 0;
7733 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307734 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007735
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307736 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307737 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307738 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7740 "%s: NULL extra buffer pointer", __func__);
7741 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307742 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307743 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7744 if (NULL == pAdapter)
7745 {
7746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7747 "%s: Adapter is NULL",__func__);
7748 return -EINVAL;
7749 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307750 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307751 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7752 ret = wlan_hdd_validate_context(pHddCtx);
7753 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007754 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307755 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007756 }
Katya Nigameae74b62015-05-28 17:19:16 +05307757 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307758 {
Katya Nigameae74b62015-05-28 17:19:16 +05307759 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7760 if (NULL == hHal)
7761 {
7762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7763 "%s: Hal Context is NULL",__func__);
7764 return -EINVAL;
7765 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307766 }
7767 sub_cmd = wrqu->data.flags;
7768
7769 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7770
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007771
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007772 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7773 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7774 {
7775 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7776 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7777 {
7778 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7779 staId = pStaCtx->conn_info.staId[0];
7780 }
7781 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7782 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7783 {
7784 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7785 staId = pAPCtx->uBCStaId;
7786 }
7787 else
7788 {
7789 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7790 return 0;
7791 }
7792 }
7793
Jeff Johnson295189b2012-06-20 16:38:30 -07007794 switch (sub_cmd)
7795 {
7796 case WE_LOG_DUMP_CMD:
7797 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307798 if(apps_args[0] == 26) {
7799 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7800 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7801 return 0;
7802 }
7803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007804 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007805 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307807 if (hHal)
7808 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7809 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007810
7811 }
7812 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307813#ifdef WLAN_FEATURE_RMC
7814 case WE_IBSS_GET_PEER_INFO:
7815 {
7816 pr_info ( "Station ID = %d\n",apps_args[0]);
7817 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7818 }
7819 break;
7820#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007821
Jeff Johnson295189b2012-06-20 16:38:30 -07007822 case WE_P2P_NOA_CMD:
7823 {
7824 p2p_app_setP2pPs_t p2pNoA;
7825
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307826 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7827 hddLog(LOGE,
7828 FL("Setting NoA is not allowed in Device mode:%d"),
7829 pAdapter->device_mode);
7830 return -EINVAL;
7831 }
7832
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 p2pNoA.opp_ps = apps_args[0];
7834 p2pNoA.ctWindow = apps_args[1];
7835 p2pNoA.duration = apps_args[2];
7836 p2pNoA.interval = apps_args[3];
7837 p2pNoA.count = apps_args[4];
7838 p2pNoA.single_noa_duration = apps_args[5];
7839 p2pNoA.psSelection = apps_args[6];
7840
7841 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7842 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007843 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7845
7846 hdd_setP2pPs(dev, &p2pNoA);
7847
7848 }
7849 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007850
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307851 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7852 {
7853 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7854 __func__, apps_args[0], apps_args[1]);
7855 vosTraceEnable(apps_args[0], apps_args[1]);
7856 }
7857 break;
7858
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007859 case WE_MTRACE_DUMP_CMD:
7860 {
7861 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7862 "bitmask_of_module %d ",
7863 __func__, apps_args[0], apps_args[1], apps_args[2],
7864 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307865 if (hHal)
7866 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7867 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007868
7869 }
7870 break;
7871
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007872 case WE_MCC_CONFIG_CREDENTIAL :
7873 {
7874 cmd = 287; //Command should be updated if there is any change
7875 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007876 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007877 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307878 if (hHal)
7879 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
7880 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007881 }
7882 else
7883 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007884 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007885 return 0;
7886 }
7887 }
7888 break;
7889
7890 case WE_MCC_CONFIG_PARAMS :
7891 {
7892 cmd = 288; //command Should be updated if there is any change
7893 // in the Riva dump command
7894 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7895 }
7896 break;
7897
Chilam NG571c65a2013-01-19 12:27:36 +05307898#ifdef FEATURE_WLAN_TDLS
7899 case WE_TDLS_CONFIG_PARAMS :
7900 {
7901 tdls_config_params_t tdlsParams;
7902
Chilam Ng01120412013-02-19 18:32:21 -08007903 tdlsParams.tdls = apps_args[0];
7904 tdlsParams.tx_period_t = apps_args[1];
7905 tdlsParams.tx_packet_n = apps_args[2];
7906 tdlsParams.discovery_period_t = apps_args[3];
7907 tdlsParams.discovery_tries_n = apps_args[4];
7908 tdlsParams.idle_timeout_t = apps_args[5];
7909 tdlsParams.idle_packet_n = apps_args[6];
7910 tdlsParams.rssi_hysteresis = apps_args[7];
7911 tdlsParams.rssi_trigger_threshold = apps_args[8];
7912 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307913
Chilam Ng01120412013-02-19 18:32:21 -08007914 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307915 }
7916 break;
7917#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307918 case WE_CONFIGURE_MONITOR_MODE:
7919 {
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307920 tVOS_CON_MODE mode = hdd_get_conparam();
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307921 int ret;
7922 void *cookie;
7923 struct hdd_request *request;
7924 static const struct hdd_request_params params = {
7925 .priv_size = 0,
7926 .timeout_ms = MON_MODE_MSG_TIMEOUT,
7927 };
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307928
7929 if (VOS_MONITOR_MODE != mode) {
7930 hddLog(LOGE, FL("invalid mode %d"), mode);
7931 return -EIO;
7932 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307933
Katya Nigamf0511f62015-05-05 16:40:57 +05307934 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7935 if( pMonCtx == NULL )
7936 {
7937 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307938 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05307939 }
7940 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7941 __func__, apps_args[0], apps_args[1], apps_args[2],
7942 apps_args[3], apps_args[4]);
7943 /* Input Validation part of FW */
7944 pMonCtx->ChannelNo = apps_args[0];
7945 pMonCtx->ChannelBW = apps_args[1];
7946 pMonCtx->crcCheckEnabled = apps_args[2];
7947 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7948 pMonCtx->is80211to803ConReq = apps_args[4];
7949 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7950 if( pMonCtx->is80211to803ConReq )
7951 pAdapter->dev->type = ARPHRD_ETHER;
7952 else
7953 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7954 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7955 {
7956 hddLog(LOGE, "%s: Filtering data packets as management and control"
7957 " cannot be converted to 802.3 ",__func__);
7958 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7959 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307960 if (MON_MODE_START == pMonCtx->state) {
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307961 request = hdd_request_alloc(&params);
7962 if (!request) {
7963 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
7964 return -ENOMEM;
7965 }
7966 cookie = hdd_request_cookie(request);
7967
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307968 if (VOS_STATUS_SUCCESS !=
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307969 wlan_hdd_mon_postMsg(cookie, pMonCtx,
7970 hdd_mon_post_msg_cb)) {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7972 FL("failed to post MON MODE REQ"));
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307973 ret = -EIO;
7974 } else {
7975 ret = hdd_request_wait_for_response(request);
7976 if (ret)
7977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7978 FL("failed to wait on monitor mode completion %d"),
7979 ret);
7980 }
7981 hdd_request_put(request);
7982 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307983 }
7984 break;
7985
7986 case WE_SET_MONITOR_MODE_FILTER:
7987 {
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307988 tVOS_CON_MODE mode = hdd_get_conparam();
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307989 int ret;
7990 void *cookie;
7991 struct hdd_request *request;
7992 static const struct hdd_request_params params = {
7993 .priv_size = 0,
7994 .timeout_ms = MON_MODE_MSG_TIMEOUT,
7995 };
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307996
7997 if (VOS_MONITOR_MODE != mode) {
7998 hddLog(LOGE, FL("invalid mode %d"), mode);
7999 return -EIO;
8000 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308001
Katya Nigamf0511f62015-05-05 16:40:57 +05308002 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8003 if( pMonCtx == NULL )
8004 {
8005 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308006 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308007 }
8008 /* Input Validation Part of FW */
8009 pMonCtx->numOfMacFilters=1;
8010 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8011 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8012 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8013 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8014 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8015 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8016 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8017 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8018 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8019 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8020 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8021 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308022 if (MON_MODE_START == pMonCtx->state) {
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05308023 request = hdd_request_alloc(&params);
8024 if (!request) {
8025 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
8026 return -ENOMEM;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308027 }
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05308028 cookie = hdd_request_cookie(request);
8029
8030 if (VOS_STATUS_SUCCESS ==
8031 wlan_hdd_mon_postMsg(cookie, pMonCtx,
8032 hdd_mon_post_msg_cb)) {
8033 ret = hdd_request_wait_for_response(request);
8034 if (ret)
8035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8036 FL("failed to wait on monitor mode completion %d"),
8037 ret);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308038 }
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05308039 hdd_request_put(request);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308040 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308041 }
8042 break;
8043
Jeff Johnson295189b2012-06-20 16:38:30 -07008044 default:
8045 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008046 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8047 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 }
8049 break;
8050 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308051 EXIT();
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05308052 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008053}
8054
Girish Gowlifb9758e2014-11-19 15:19:17 +05308055static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8056 struct iw_request_info *info,
8057 union iwreq_data *wrqu, char *extra)
8058{
8059 int ret;
8060 union iwreq_data u_priv_wrqu;
8061 int apps_args[MAX_VAR_ARGS] = {0};
8062 int num_args;
8063
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308064 if (!capable(CAP_NET_ADMIN))
8065 {
8066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8067 FL("permission check failed"));
8068 return -EPERM;
8069 }
8070
Girish Gowlifb9758e2014-11-19 15:19:17 +05308071 /* helper function to get iwreq_data with compat handling. */
8072 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8073 {
8074 return -EINVAL;
8075 }
8076
8077 if (NULL == u_priv_wrqu.data.pointer)
8078 {
8079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8080 "%s: NULL data pointer", __func__);
8081 return -EINVAL;
8082 }
8083
8084 num_args = u_priv_wrqu.data.length;
8085 if (num_args > MAX_VAR_ARGS)
8086 {
8087 num_args = MAX_VAR_ARGS;
8088 }
8089
8090 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8091 (sizeof(int)) * num_args))
8092 {
8093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8094 "%s: failed to copy data from user buffer", __func__);
8095 return -EFAULT;
8096 }
8097
8098 vos_ssr_protect(__func__);
8099 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8100 (char *)&apps_args);
8101 vos_ssr_unprotect(__func__);
8102
8103 return ret;
8104}
8105
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308106int iw_set_var_ints_getnone(struct net_device *dev,
8107 struct iw_request_info *info,
8108 union iwreq_data *wrqu, char *extra)
8109{
8110 int ret;
8111 vos_ssr_protect(__func__);
8112 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8113 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008114
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308115 return ret;
8116}
8117
8118static int __iw_add_tspec(struct net_device *dev,
8119 struct iw_request_info *info,
8120 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008121{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308122 hdd_adapter_t *pAdapter;
8123 hdd_station_ctx_t *pHddStaCtx;
8124 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8126 int params[HDD_WLAN_WMM_PARAM_COUNT];
8127 sme_QosWmmTspecInfo tSpec;
8128 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308129 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308130 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008131
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308132 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308133 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8134 if (NULL == pAdapter)
8135 {
8136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8137 "%s: Adapter is NULL",__func__);
8138 return -EINVAL;
8139 }
8140 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8141 ret = wlan_hdd_validate_context(pHddCtx);
8142 if (0 != ret)
8143 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308144 return ret;
8145 }
8146 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8147 if (NULL == pHddStaCtx)
8148 {
8149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8150 "%s: STA Context is NULL",__func__);
8151 return -EINVAL;
8152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008153 // make sure the application is sufficiently priviledged
8154 // note that the kernel will do this for "set" ioctls, but since
8155 // this ioctl wants to return status to user space it must be
8156 // defined as a "get" ioctl
8157 if (!capable(CAP_NET_ADMIN))
8158 {
8159 return -EPERM;
8160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008161 // we must be associated in order to add a tspec
8162 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8163 {
8164 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8165 return 0;
8166 }
8167
8168 // since we are defined to be a "get" ioctl, and since the number
8169 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308170 // will pass down in the iwreq_data, we must copy the "set" params.
8171 // We must handle the compat for iwreq_data in 32U/64K environment.
8172
8173 // helper fucntion to get iwreq_data with compat handling.
8174 if (hdd_priv_get_data(&s_priv_data, wrqu))
8175 {
8176 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8177 return 0;
8178 }
8179
8180 // make sure all params are correctly passed to function
8181 if ((NULL == s_priv_data.pointer) ||
8182 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8183 {
8184 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8185 return 0;
8186 }
8187
Jeff Johnson295189b2012-06-20 16:38:30 -07008188 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308189 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008190 {
8191 // hmmm, can't get them
8192 return -EIO;
8193 }
8194
8195 // clear the tspec
8196 memset(&tSpec, 0, sizeof(tSpec));
8197
8198 // validate the handle
8199 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8200 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8201 {
8202 // that one is reserved
8203 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8204 return 0;
8205 }
8206
8207 // validate the TID
8208 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8209 {
8210 // out of range
8211 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8212 return 0;
8213 }
8214 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8215
8216 // validate the direction
8217 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8218 {
8219 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8220 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8221 break;
8222
8223 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8224 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8225 break;
8226
8227 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8228 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8229 break;
8230
8231 default:
8232 // unknown
8233 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8234 return 0;
8235 }
8236
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308237 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8238
Jeff Johnson295189b2012-06-20 16:38:30 -07008239 // validate the user priority
8240 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8241 {
8242 // out of range
8243 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8244 return 0;
8245 }
8246 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308247 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8248 {
8249 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8250 return 0;
8251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008252
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8254 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8255 tSpec.ts_info.psb, tSpec.ts_info.up);
8256
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8258 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8259 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8260 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8261 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8262 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8263 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8264 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8265 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8266 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8267 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8268 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8269
8270 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8271
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308272 // Save the expected UAPSD settings by application, this will be needed
8273 // when re-negotiating UAPSD settings during BT Coex cases.
8274 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8275
Jeff Johnson295189b2012-06-20 16:38:30 -07008276 // validate the ts info ack policy
8277 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8278 {
8279 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8280 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8281 break;
8282
8283 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8284 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8285 break;
8286
8287 default:
8288 // unknown
8289 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8290 return 0;
8291 }
8292
8293 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308294
8295 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008296 return 0;
8297}
8298
8299
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308300static int iw_add_tspec(struct net_device *dev,
8301 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008302 union iwreq_data *wrqu, char *extra)
8303{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308304 int ret;
8305
8306 vos_ssr_protect(__func__);
8307 ret = __iw_add_tspec(dev, info, wrqu, extra);
8308 vos_ssr_unprotect(__func__);
8309
8310 return ret;
8311}
8312
8313static int __iw_del_tspec(struct net_device *dev,
8314 struct iw_request_info *info,
8315 union iwreq_data *wrqu, char *extra)
8316{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308317 hdd_adapter_t *pAdapter;
8318 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 int *params = (int *)extra;
8320 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8321 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308322 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008323
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308324 ENTER();
8325
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308326 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8327 if (NULL == pAdapter)
8328 {
8329 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8330 "%s: Adapter is NULL",__func__);
8331 return -EINVAL;
8332 }
8333
8334 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8335 ret = wlan_hdd_validate_context(pHddCtx);
8336 if (0 != ret)
8337 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308338 return ret;
8339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008340 // make sure the application is sufficiently priviledged
8341 // note that the kernel will do this for "set" ioctls, but since
8342 // this ioctl wants to return status to user space it must be
8343 // defined as a "get" ioctl
8344 if (!capable(CAP_NET_ADMIN))
8345 {
8346 return -EPERM;
8347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008348 // although we are defined to be a "get" ioctl, the params we require
8349 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8350 // is no need to copy the params from user space
8351
8352 // validate the handle
8353 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8354 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8355 {
8356 // that one is reserved
8357 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8358 return 0;
8359 }
8360
8361 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308362
8363 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 return 0;
8365}
8366
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308367static int iw_del_tspec(struct net_device *dev,
8368 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 union iwreq_data *wrqu, char *extra)
8370{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308371 int ret;
8372
8373 vos_ssr_protect(__func__);
8374 ret = __iw_del_tspec(dev, info, wrqu, extra);
8375 vos_ssr_unprotect(__func__);
8376
8377 return ret;
8378}
8379
8380
8381static int __iw_get_tspec(struct net_device *dev,
8382 struct iw_request_info *info,
8383 union iwreq_data *wrqu, char *extra)
8384{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308385 hdd_adapter_t *pAdapter;
8386 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008387 int *params = (int *)extra;
8388 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8389 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308390 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008391
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308392 ENTER();
8393
Jeff Johnson295189b2012-06-20 16:38:30 -07008394 // although we are defined to be a "get" ioctl, the params we require
8395 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8396 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308397 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8398 if (NULL == pAdapter)
8399 {
8400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8401 "%s: Adapter is NULL",__func__);
8402 return -EINVAL;
8403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008404
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308405 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8406 ret = wlan_hdd_validate_context(pHddCtx);
8407 if (0 != ret)
8408 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308409 return ret;
8410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008411 // validate the handle
8412 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8413 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8414 {
8415 // that one is reserved
8416 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8417 return 0;
8418 }
8419
8420 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308421 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008422 return 0;
8423}
8424
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308425static int iw_get_tspec(struct net_device *dev,
8426 struct iw_request_info *info,
8427 union iwreq_data *wrqu, char *extra)
8428{
8429 int ret;
8430
8431 vos_ssr_protect(__func__);
8432 ret = __iw_get_tspec(dev, info, wrqu, extra);
8433 vos_ssr_unprotect(__func__);
8434
8435 return ret;
8436}
8437
Manjeet Singh3ed79242017-01-11 19:04:32 +05308438/**
8439 * __iw_setnone_get_threeint() - return three value to up layer.
8440 *
8441 * @dev: pointer of net_device of this wireless card
8442 * @info: meta data about Request sent
8443 * @wrqu: include request info
8444 * @extra: buf used for in/Output
8445 *
8446 * Return: execute result
8447 */
8448static int __iw_setnone_get_threeint(struct net_device *dev,
8449 struct iw_request_info *info,
8450 union iwreq_data *wrqu, char *extra)
8451{
8452 int ret = 0; /* success */
8453 uint32_t *value = (int *)extra;
8454 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8455
8456 hddLog(VOS_TRACE_LEVEL_INFO, FL("param = %d"), value[0]);
8457
8458 switch (value[0]) {
8459 case WE_GET_TSF:
8460 ret = hdd_indicate_tsf(adapter, value, 3);
8461 break;
8462 default:
8463 hddLog(VOS_TRACE_LEVEL_ERROR,
8464 FL("Invalid IOCTL get_value command %d"),
8465 value[0]);
8466 break;
8467 }
8468 return ret;
8469}
8470
8471/**
8472 * iw_setnone_get_threeint() - return three value to up layer.
8473 *
8474 * @dev: pointer of net_device of this wireless card
8475 * @info: meta data about Request sent
8476 * @wrqu: include request info
8477 * @extra: buf used for in/Output
8478 *
8479 * Return: execute result
8480 */
8481static int iw_setnone_get_threeint(struct net_device *dev,
8482 struct iw_request_info *info,
8483 union iwreq_data *wrqu, char *extra)
8484{
8485 int ret;
8486
8487 vos_ssr_protect(__func__);
8488 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8489 vos_ssr_unprotect(__func__);
8490
8491 return ret;
8492}
8493
Jeff Johnson295189b2012-06-20 16:38:30 -07008494#ifdef WLAN_FEATURE_VOWIFI_11R
8495//
8496//
8497// Each time the supplicant has the auth_request or reassoc request
8498// IEs ready. This is pushed to the driver. The driver will inturn use
8499// it to send out the auth req and reassoc req for 11r FT Assoc.
8500//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308501static int __iw_set_fties(struct net_device *dev,
8502 struct iw_request_info *info,
8503 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008504{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308505 hdd_adapter_t *pAdapter;
8506 hdd_station_ctx_t *pHddStaCtx;
8507 hdd_context_t *pHddCtx;
8508 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 //v_CONTEXT_t pVosContext;
8510
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308511 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308512 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8513 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008514 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8516 "%s: Adapter is NULL",__func__);
8517 return -EINVAL;
8518 }
8519 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8520 ret = wlan_hdd_validate_context(pHddCtx);
8521 if (0 != ret)
8522 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308523 return ret;
8524 }
8525 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8526 if (NULL == pHddStaCtx)
8527 {
8528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8529 "%s: STA Context is NULL",__func__);
8530 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008532 if (!wrqu->data.length)
8533 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008534 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008535 return -EINVAL;
8536 }
8537 if (wrqu->data.pointer == NULL)
8538 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008539 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 return -EINVAL;
8541 }
8542
8543 // Added for debug on reception of Re-assoc Req.
8544 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8545 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008546 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008547 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008548 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008549 }
8550
8551#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008552 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008553#endif
8554
8555 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008556 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008557 wrqu->data.length);
8558
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308559 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008560 return 0;
8561}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308562
8563static int iw_set_fties(struct net_device *dev,
8564 struct iw_request_info *info,
8565 union iwreq_data *wrqu, char *extra)
8566{
8567 int ret;
8568
8569 vos_ssr_protect(__func__);
8570 ret = __iw_set_fties(dev, info, wrqu, extra);
8571 vos_ssr_unprotect(__func__);
8572
8573 return ret;
8574}
Jeff Johnson295189b2012-06-20 16:38:30 -07008575#endif
8576
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308577static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008578 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008579 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008580{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308581 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008582 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308583 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008584 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308585 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008586 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8587 int idx;
8588 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008589
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308590 ENTER();
8591
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308592 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8593 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008594 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8596 "%s: Adapter is NULL",__func__);
8597 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008598 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308599 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8600 ret_val = wlan_hdd_validate_context(pHddCtx);
8601 if (0 != ret_val)
8602 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308603 return ret_val;
8604 }
8605 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8606 if (NULL == hHal)
8607 {
8608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8609 "%s: Hal Context is NULL",__func__);
8610 return -EINVAL;
8611 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308612 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8613 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308614#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008615
Amar Singhalf3a6e762013-02-19 15:06:50 -08008616 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8617 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008618 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008619 hddLog(VOS_TRACE_LEVEL_ERROR,
8620 "%s: vos_mem_alloc failed", __func__);
8621 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008622 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008623
8624 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8625
8626 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8627 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8628
8629 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8630 mc_addr_list_ptr->ulMulticastAddrCnt);
8631
8632 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008633 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008634 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8635 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8636
8637 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8638 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008639 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008640
Amar Singhalf3a6e762013-02-19 15:06:50 -08008641 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8642 vos_mem_free(mc_addr_list_ptr);
8643 if (eHAL_STATUS_SUCCESS != ret_val)
8644 {
8645 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8646 __func__);
8647 return -EINVAL;
8648 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308649#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308650 }
8651 else
8652 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008653
Amar Singhalf3a6e762013-02-19 15:06:50 -08008654 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8655 "%s: Set MC BC Filter Config request: %d suspend %d",
8656 __func__, pRequest->mcastBcastFilterSetting,
8657 pHddCtx->hdd_wlan_suspended);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308658 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308659 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308660 spin_unlock(&pHddCtx->filter_lock);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008661
8662 if (pHddCtx->hdd_wlan_suspended)
8663 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008664 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8665 if (NULL == wlanRxpFilterParam)
8666 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308667 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008668 "%s: vos_mem_alloc failed", __func__);
8669 return -EINVAL;
8670 }
8671
Amar Singhalf3a6e762013-02-19 15:06:50 -08008672 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8673 pRequest->mcastBcastFilterSetting;
8674 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308675 /* Fwr expect offload needs to clear before set */
8676 hdd_conf_hostoffload(pAdapter, FALSE);
8677 spin_lock(&pHddCtx->filter_lock);
8678 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
8679 spin_unlock(&pHddCtx->filter_lock);
8680 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8681 {
8682 hddLog(VOS_TRACE_LEVEL_INFO, "%s: pRequest->mcastBcastFilterSetting ", __func__);
8683 pHddCtx->sus_res_mcastbcast_filter =
8684 pRequest->mcastBcastFilterSetting;
8685 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008686
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308687 hdd_conf_hostoffload(pAdapter, TRUE);
8688 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8689 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008690
8691 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8692 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308693 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008694 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8695 wlanRxpFilterParam->setMcstBcstFilter);
8696
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308697 if (eHAL_STATUS_SUCCESS !=
8698 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8699 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008700 {
8701 hddLog(VOS_TRACE_LEVEL_ERROR,
8702 "%s: Failure to execute set HW MC/BC Filter request",
8703 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008704 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008705 return -EINVAL;
8706 }
8707
mukul sharmae4abd892016-11-24 22:03:31 +05308708 /* mc add list cfg item configuration in fwr */
8709 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008710 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008711 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008712
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308713 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 return 0;
8715}
8716
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308717static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8718 struct iw_request_info *info,
8719 union iwreq_data *wrqu, char *extra)
8720{
8721 int ret;
8722
8723 vos_ssr_protect(__func__);
8724 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8725 vos_ssr_unprotect(__func__);
8726
8727 return ret;
8728}
8729
8730static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8731 struct iw_request_info *info,
8732 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008733{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308734 hdd_adapter_t *pAdapter;
8735 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308736 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308737 int ret = 0;
8738
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308739 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008740
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308741 if (!capable(CAP_NET_ADMIN))
8742 {
8743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8744 FL("permission check failed"));
8745 return -EPERM;
8746 }
8747
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308748 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8749 if (NULL == pAdapter)
8750 {
8751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8752 "%s: Adapter is NULL",__func__);
8753 return -EINVAL;
8754 }
8755
8756 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8757 ret = wlan_hdd_validate_context(pHddCtx);
8758 if (0 != ret)
8759 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308760 return ret;
8761 }
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308762 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308763 //Reset the filter to INI value as we have to clear the dynamic filter
8764 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308765 spin_unlock(&pHddCtx->filter_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008766
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308767 //Configure FW with new setting
8768 if (pHddCtx->hdd_wlan_suspended)
8769 {
8770 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8771 if (NULL == wlanRxpFilterParam)
8772 {
8773 hddLog(VOS_TRACE_LEVEL_ERROR,
8774 "%s: vos_mem_alloc failed", __func__);
8775 return -EINVAL;
8776 }
8777
8778 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8779 pHddCtx->configuredMcastBcastFilter;
8780 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308781 /* Fwr expect offload needs to clear before set */
8782 hdd_conf_hostoffload(pAdapter, FALSE);
8783 spin_lock(&pHddCtx->filter_lock);
8784 pHddCtx->configuredMcastBcastFilter =
8785 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8786 spin_unlock(&pHddCtx->filter_lock);
8787
8788 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8789 {
8790 pHddCtx->sus_res_mcastbcast_filter =
8791 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8792 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308793
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308794 hdd_conf_hostoffload(pAdapter, TRUE);
8795 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8796 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308797 if (eHAL_STATUS_SUCCESS !=
8798 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8799 wlanRxpFilterParam))
8800 {
8801 hddLog(VOS_TRACE_LEVEL_ERROR,
8802 "%s: Failure to execute set HW MC/BC Filter request",
8803 __func__);
8804 vos_mem_free(wlanRxpFilterParam);
8805 return -EINVAL;
8806 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308807
mukul sharmae4abd892016-11-24 22:03:31 +05308808 /* mc add list cfg item configuration in fwr */
8809 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308810 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308811 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008812 return 0;
8813}
8814
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308815
8816static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8817 struct iw_request_info *info,
8818 union iwreq_data *wrqu, char *extra)
8819{
8820 int ret;
8821
8822 vos_ssr_protect(__func__);
8823 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8824 vos_ssr_unprotect(__func__);
8825
8826 return ret;
8827}
8828
8829static int __iw_set_host_offload(struct net_device *dev,
8830 struct iw_request_info *info,
8831 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008832{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308833 hdd_adapter_t *pAdapter;
8834 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008835 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008836 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308837 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008838
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308839 ENTER();
8840
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308841 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8842 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008843 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8845 "%s: Adapter is NULL",__func__);
8846 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008847 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308848 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8849 ret = wlan_hdd_validate_context(pHddCtx);
8850 if (0 != ret)
8851 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308852 return ret;
8853 }
8854
Jeff Johnson295189b2012-06-20 16:38:30 -07008855 /* Debug display of request components. */
8856 switch (pRequest->offloadType)
8857 {
8858 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008859 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008860 switch (pRequest->enableOrDisable)
8861 {
8862 case WLAN_OFFLOAD_DISABLE:
8863 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8864 break;
8865 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8866 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8867 case WLAN_OFFLOAD_ENABLE:
8868 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8869 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8870 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8871 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8872 }
8873 break;
8874
8875 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008876 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008877 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008878 switch (pRequest->enableOrDisable)
8879 {
8880 case WLAN_OFFLOAD_DISABLE:
8881 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8882 break;
8883 case WLAN_OFFLOAD_ENABLE:
8884 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8885 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8886 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8887 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8888 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8889 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8890 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8891 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8892 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8893 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8894 }
8895 }
8896
Hanumanth Reddy Pothula94bd51a2017-12-01 13:34:48 +05308897 vos_mem_zero(&offloadRequest, sizeof(offloadRequest));
8898 offloadRequest.offloadType = pRequest->offloadType;
8899 offloadRequest.enableOrDisable = pRequest->enableOrDisable;
8900 vos_mem_copy(&offloadRequest.params, &pRequest->params,
8901 sizeof(pRequest->params));
8902 vos_mem_copy(&offloadRequest.bssId, &pRequest->bssId.bytes,
8903 VOS_MAC_ADDRESS_LEN);
8904
Jeff Johnsone7245742012-09-05 17:12:55 -07008905 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8906 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008908 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 __func__);
8910 return -EINVAL;
8911 }
8912
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308913 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008914 return 0;
8915}
8916
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308917static int iw_set_host_offload(struct net_device *dev,
8918 struct iw_request_info *info,
8919 union iwreq_data *wrqu, char *extra)
8920{
8921 int ret;
8922
8923 vos_ssr_protect(__func__);
8924 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8925 vos_ssr_unprotect(__func__);
8926
8927 return ret;
8928}
8929
8930static int __iw_set_keepalive_params(struct net_device *dev,
8931 struct iw_request_info *info,
8932 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008933{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308934 hdd_adapter_t *pAdapter;
8935 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008936 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008937 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308938 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008939
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308940 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308941 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8942 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8945 "%s: Adapter is NULL",__func__);
8946 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008947 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308948 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8949 ret = wlan_hdd_validate_context(pHddCtx);
8950 if (0 != ret)
8951 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308952 return ret;
8953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008954 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008955 hddLog(VOS_TRACE_LEVEL_INFO,
8956 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8957 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008958
8959 switch (pRequest->packetType)
8960 {
8961 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008962 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008963 break;
8964
8965 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8966
Arif Hussain6d2a3322013-11-17 19:50:10 -08008967 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008968 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008969
8970 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8971 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8972 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8973
8974 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8975 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8976 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8977
8978 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8979 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8980 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8981 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8982 break;
8983
8984 }
8985
8986 /* Execute keep alive request. The reason that we can copy the request information
8987 from the ioctl structure to the SME structure is that they are laid out
8988 exactly the same. Otherwise, each piece of information would have to be
8989 copied individually. */
8990 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8991
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05308992 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
8993 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008994
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008995 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008996 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008997 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008998 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008999 __func__);
9000 return -EINVAL;
9001 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309002 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009003 return 0;
9004}
9005
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309006static int iw_set_keepalive_params(struct net_device *dev,
9007 struct iw_request_info *info,
9008 union iwreq_data *wrqu, char *extra)
9009{
9010 int ret;
9011 vos_ssr_protect(__func__);
9012 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9013 vos_ssr_unprotect(__func__);
9014
9015 return ret;
9016}
9017
Jeff Johnson295189b2012-06-20 16:38:30 -07009018#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309019/**-----------------------------------------------------------------
9020
9021 \brief hdd_pkt_filter_done - callback to be executed on completion
9022 successful/failure) for clear filter request.
9023
9024 \return - None
9025
9026 --------------------------------------------------------------------------*/
9027static void hdd_pkt_filter_done(void *data, v_U32_t status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009028{
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309029 struct hdd_request *request;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309030
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309031 hddLog(VOS_TRACE_LEVEL_INFO,
9032 FL("Pkt Filter Clear Status : %d"), status);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309033
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309034 request = hdd_request_get(data);
9035 if (!request) {
9036 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
9037 if (ioctl_debug)
9038 pr_info("%s: Obsolete request", __func__);
9039 return;
9040 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309041
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309042 hdd_request_complete(request);
9043 hdd_request_put(request);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309044}
9045
9046int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest)
9047{
9048 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309049 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009050 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9051 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309052 int i=0, status;
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309053 void *cookie;
9054 struct hdd_request *request;
9055 static const struct hdd_request_params params = {
9056 .priv_size = 0,
9057 .timeout_ms = PKT_FILTER_TIMEOUT,
9058 };
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309059
9060 status = wlan_hdd_validate_context(pHddCtx);
9061 if (0 != status)
9062 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009063
9064 if (pHddCtx->cfg_ini->disablePacketFilter)
9065 {
9066 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009067 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07009068 return 0;
9069 }
Agrawal Ashisha2662d22016-10-26 12:41:13 +05309070 if (pHddCtx->isLogpInProgress)
9071 {
9072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9073 "%s:LOGP in Progress. Ignore!!!", __func__);
9074 return -EBUSY;
9075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009076 /* Debug display of request components. */
9077 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009078 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07009079
9080 switch (pRequest->filterAction)
9081 {
9082 case HDD_RCV_FILTER_SET:
9083 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009084 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009085
9086 packetFilterSetReq.filterId = pRequest->filterId;
9087 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
9088 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009089 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009090 __func__, pRequest->numParams);
9091 return -EINVAL;
9092 }
9093 packetFilterSetReq.numFieldParams = pRequest->numParams;
9094 packetFilterSetReq.coalesceTime = 0;
9095 packetFilterSetReq.filterType = 1;
9096 for (i=0; i < pRequest->numParams; i++)
9097 {
9098 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9099 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9100 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9101 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9102 packetFilterSetReq.paramsData[i].reserved = 0;
9103
Arif Hussain6d2a3322013-11-17 19:50:10 -08009104 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009105 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9106 packetFilterSetReq.filterType);
9107
Arif Hussain6d2a3322013-11-17 19:50:10 -08009108 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009109 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309110 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9111 (pRequest->paramsData[i].dataLength))
9112 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009113
9114 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9115 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9116 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9117 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9118
Arif Hussain6d2a3322013-11-17 19:50:10 -08009119 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9121 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9122 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9123
Arif Hussain6d2a3322013-11-17 19:50:10 -08009124 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009125 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9126 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9127 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9128 }
9129
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309130 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009132 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009133 __func__);
9134 return -EINVAL;
9135 }
9136
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309137 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9138 pHddStaCtx->conn_info.staId[0], true);
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 break;
9140
9141 case HDD_RCV_FILTER_CLEAR:
9142
Arif Hussain6d2a3322013-11-17 19:50:10 -08009143 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009144 __func__, pRequest->filterId);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309145
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309146 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9147 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) {
9148 WLANTL_ResetRxSSN((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9149 pHddStaCtx->conn_info.staId[0]);
9150 }
9151
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309152 request = hdd_request_alloc(&params);
9153 if (!request) {
9154 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
9155 return VOS_STATUS_E_NOMEM;
9156 }
9157 cookie = hdd_request_cookie(request);
9158
9159 packetFilterClrReq.cbCtx = cookie;
Jeff Johnson295189b2012-06-20 16:38:30 -07009160 packetFilterClrReq.filterId = pRequest->filterId;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309161 packetFilterClrReq.pktFilterCallback = hdd_pkt_filter_done;
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309162 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(
9163 pHddCtx->hHal,
9164 &packetFilterClrReq,
9165 pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009166 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009167 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009168 __func__);
Hanumanth Reddy Pothula249a2b02018-05-30 17:04:25 +05309169 hdd_request_put(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07009170 return -EINVAL;
9171 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309172
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309173 status = hdd_request_wait_for_response(request);
9174 hdd_request_put(request);
9175 if (status)
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309176 {
9177 hddLog(LOGE, FL("failure waiting for pkt_filter_comp_var %d"),
9178 status);
9179 return -EINVAL;
9180 }
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309181
9182 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9183 pHddStaCtx->conn_info.staId[0], false);
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 break;
9185
9186 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009187 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009188 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009189 return -EINVAL;
9190 }
9191 return 0;
9192}
9193
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309194int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9195 tANI_U8 sessionId)
9196{
9197 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9198 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9199
9200 if (NULL == pHddCtx)
9201 {
9202 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9203 return -EINVAL;
9204 }
9205
9206 if (pHddCtx->isLogpInProgress)
9207 {
9208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9209 "%s:LOGP in Progress. Ignore!!!", __func__);
9210 return -EBUSY;
9211 }
9212
9213 if (pHddCtx->cfg_ini->disablePacketFilter)
9214 {
9215 hddLog(VOS_TRACE_LEVEL_ERROR,
9216 "%s: Packet Filtering Disabled. Returning ",
9217 __func__ );
9218 return -EINVAL;
9219 }
9220
9221 switch (filterType)
9222 {
9223 /* For setting IPV6 MC and UC Filter we need to configure
9224 * 2 filters, one for MC and one for UC.
9225 * The Filter ID shouldn't be swapped, which results in making
9226 * UC Filter ineffective.
9227 * We have Hardcode all the values
9228 *
9229 * Reason for a seperate UC filter is because, driver need to
9230 * specify the FW that the specific filter is for unicast
9231 * otherwise FW will not pass the unicast frames by default
9232 * through the filter. This is required to avoid any performance
9233 * hits when no unicast filter is set and only MC/BC are set.
9234 * The way driver informs host is by using the MAC protocol
9235 * layer, CMP flag set to MAX, CMP Data set to 1.
9236 */
9237
9238 case HDD_FILTER_IPV6_MC_UC:
9239 /* Setting IPV6 MC Filter below
9240 */
9241 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9242 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9243 packetFilterSetReq.numFieldParams = 2;
9244 packetFilterSetReq.paramsData[0].protocolLayer =
9245 HDD_FILTER_PROTO_TYPE_MAC;
9246 packetFilterSetReq.paramsData[0].cmpFlag =
9247 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9248 packetFilterSetReq.paramsData[0].dataOffset =
9249 WLAN_HDD_80211_FRM_DA_OFFSET;
9250 packetFilterSetReq.paramsData[0].dataLength = 1;
9251 packetFilterSetReq.paramsData[0].compareData[0] =
9252 HDD_IPV6_MC_CMP_DATA;
9253
9254 packetFilterSetReq.paramsData[1].protocolLayer =
9255 HDD_FILTER_PROTO_TYPE_ARP;
9256 packetFilterSetReq.paramsData[1].cmpFlag =
9257 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9258 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9259 packetFilterSetReq.paramsData[1].dataLength = 2;
9260 packetFilterSetReq.paramsData[1].compareData[0] =
9261 HDD_IPV6_CMP_DATA_0;
9262 packetFilterSetReq.paramsData[1].compareData[1] =
9263 HDD_IPV6_CMP_DATA_1;
9264
9265
9266 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9267 &packetFilterSetReq, sessionId))
9268 {
9269 hddLog(VOS_TRACE_LEVEL_ERROR,
9270 "%s: Failure to execute Set IPv6 Mulicast Filter",
9271 __func__);
9272 return -EINVAL;
9273 }
9274
9275 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9276
9277 /*
9278 * Setting IPV6 UC Filter below
9279 */
9280 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9281 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9282 packetFilterSetReq.numFieldParams = 2;
9283 packetFilterSetReq.paramsData[0].protocolLayer =
9284 HDD_FILTER_PROTO_TYPE_MAC;
9285 packetFilterSetReq.paramsData[0].cmpFlag =
9286 HDD_FILTER_CMP_TYPE_MAX;
9287 packetFilterSetReq.paramsData[0].dataOffset = 0;
9288 packetFilterSetReq.paramsData[0].dataLength = 1;
9289 packetFilterSetReq.paramsData[0].compareData[0] =
9290 HDD_IPV6_UC_CMP_DATA;
9291
9292 packetFilterSetReq.paramsData[1].protocolLayer =
9293 HDD_FILTER_PROTO_TYPE_ARP;
9294 packetFilterSetReq.paramsData[1].cmpFlag =
9295 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9296 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9297 packetFilterSetReq.paramsData[1].dataLength = 2;
9298 packetFilterSetReq.paramsData[1].compareData[0] =
9299 HDD_IPV6_CMP_DATA_0;
9300 packetFilterSetReq.paramsData[1].compareData[1] =
9301 HDD_IPV6_CMP_DATA_1;
9302
9303 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9304 &packetFilterSetReq, sessionId))
9305 {
9306 hddLog(VOS_TRACE_LEVEL_ERROR,
9307 "%s: Failure to execute Set IPv6 Unicast Filter",
9308 __func__);
9309 return -EINVAL;
9310 }
9311
9312 break;
9313
9314 case HDD_FILTER_IPV6_MC:
9315 /*
9316 * IPV6 UC Filter might be already set,
9317 * clear the UC Filter. As the Filter
9318 * IDs are static, we can directly clear it.
9319 */
9320 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9321 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9322 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9323 &packetFilterClrReq, sessionId))
9324 {
9325 hddLog(VOS_TRACE_LEVEL_ERROR,
9326 "%s: Failure to execute Clear IPv6 Unicast Filter",
9327 __func__);
9328 return -EINVAL;
9329 }
9330
9331 /*
9332 * Setting IPV6 MC Filter below
9333 */
9334 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9335 packetFilterSetReq.numFieldParams = 2;
9336 packetFilterSetReq.paramsData[0].protocolLayer =
9337 HDD_FILTER_PROTO_TYPE_MAC;
9338 packetFilterSetReq.paramsData[0].cmpFlag =
9339 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9340 packetFilterSetReq.paramsData[0].dataOffset =
9341 WLAN_HDD_80211_FRM_DA_OFFSET;
9342 packetFilterSetReq.paramsData[0].dataLength = 1;
9343 packetFilterSetReq.paramsData[0].compareData[0] =
9344 HDD_IPV6_MC_CMP_DATA;
9345
9346 packetFilterSetReq.paramsData[1].protocolLayer =
9347 HDD_FILTER_PROTO_TYPE_ARP;
9348 packetFilterSetReq.paramsData[1].cmpFlag =
9349 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9350 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9351 packetFilterSetReq.paramsData[1].dataLength = 2;
9352 packetFilterSetReq.paramsData[1].compareData[0] =
9353 HDD_IPV6_CMP_DATA_0;
9354 packetFilterSetReq.paramsData[1].compareData[1] =
9355 HDD_IPV6_CMP_DATA_1;
9356
9357
9358 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9359 &packetFilterSetReq, sessionId))
9360 {
9361 hddLog(VOS_TRACE_LEVEL_ERROR,
9362 "%s: Failure to execute Set IPv6 Multicast Filter",
9363 __func__);
9364 return -EINVAL;
9365 }
9366 break;
9367
9368 default :
9369 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9370 "%s: Packet Filter Request: Invalid",
9371 __func__);
9372 return -EINVAL;
9373 }
9374 return 0;
9375}
9376
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309377void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009378{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309379 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309380 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009381 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309382 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009383
Yue Ma3ede6052013-08-29 00:33:26 -07009384 if (NULL == pHddCtx)
9385 {
9386 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9387 return;
9388 }
9389
9390 hHal = pHddCtx->hHal;
9391
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309392 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009393 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309394 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9395 return;
9396 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309397
9398 /* Check if INI is enabled or not, other wise just return
9399 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309400 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309401 {
9402 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9403 if (NULL == pMulticastAddrs)
9404 {
9405 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9406 return;
9407 }
9408
Jeff Johnson295189b2012-06-20 16:38:30 -07009409 if (set)
9410 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309411 /* Following pre-conditions should be satisfied before wei
9412 * configure the MC address list.
9413 */
9414 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9415 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9416 && pAdapter->mc_addr_list.mc_cnt
9417 && (eConnectionState_Associated ==
9418 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9419 {
9420 pMulticastAddrs->ulMulticastAddrCnt =
9421 pAdapter->mc_addr_list.mc_cnt;
9422 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9423 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009424 memcpy(pMulticastAddrs->multicastAddr[i],
9425 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309426 sizeof(pAdapter->mc_addr_list.addr[i]));
9427 hddLog(VOS_TRACE_LEVEL_INFO,
9428 "%s: %s multicast filter: addr ="
9429 MAC_ADDRESS_STR,
9430 __func__, set ? "setting" : "clearing",
9431 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9432 }
9433 /* Set multicast filter */
9434 sme_8023MulticastList(hHal, pAdapter->sessionId,
9435 pMulticastAddrs);
9436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009437 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309438 else
9439 {
9440 /* Need to clear only if it was previously configured
9441 */
9442 if (pAdapter->mc_addr_list.isFilterApplied)
9443 {
9444 pMulticastAddrs->ulMulticastAddrCnt = 0;
9445 sme_8023MulticastList(hHal, pAdapter->sessionId,
9446 pMulticastAddrs);
9447 }
9448
9449 }
9450 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009451 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309453 else
9454 {
9455 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309456 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309457 }
9458 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009459}
9460
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309461static int __iw_set_packet_filter_params(struct net_device *dev,
9462 struct iw_request_info *info,
9463 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309464{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309465 hdd_adapter_t *pAdapter;
9466 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009467 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309468 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309469 struct iw_point s_priv_data;
9470
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309471 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309472
9473 if (!capable(CAP_NET_ADMIN))
9474 {
9475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9476 FL("permission check failed"));
9477 return -EPERM;
9478 }
9479
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309480 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9481 if (NULL == pAdapter)
9482 {
9483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9484 "%s: Adapter is NULL",__func__);
9485 return -EINVAL;
9486 }
9487 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9488 ret = wlan_hdd_validate_context(pHddCtx);
9489 if (0 != ret)
9490 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309491 return ret;
9492 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309493 if (hdd_priv_get_data(&s_priv_data, wrqu))
9494 {
9495 return -EINVAL;
9496 }
9497
9498 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9499 {
9500 return -EINVAL;
9501 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009502
Arif Hussain0273cba2014-01-07 20:58:29 -08009503 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309504 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9505 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009506 if (NULL == pRequest)
9507 {
9508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9509 "mem_alloc_copy_from_user_helper fail");
9510 return -ENOMEM;
9511 }
9512
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309513 ret = wlan_hdd_set_filter(pAdapter, pRequest);
Arif Hussain0273cba2014-01-07 20:58:29 -08009514 kfree(pRequest);
9515
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309516 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009517 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009518}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309519
9520static int iw_set_packet_filter_params(struct net_device *dev,
9521 struct iw_request_info *info,
9522 union iwreq_data *wrqu, char *extra)
9523{
9524 int ret;
9525
9526 vos_ssr_protect(__func__);
9527 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9528 vos_ssr_unprotect(__func__);
9529
9530 return ret;
9531}
Jeff Johnson295189b2012-06-20 16:38:30 -07009532#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309533static int __iw_get_statistics(struct net_device *dev,
9534 struct iw_request_info *info,
9535 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009536{
9537
9538 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9539 eHalStatus status = eHAL_STATUS_SUCCESS;
9540 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309541 hdd_adapter_t *pAdapter;
9542 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309544 int tlen = 0, ret = 0;
9545 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009546
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309547 tCsrGlobalClassAStatsInfo *aStats;
9548 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009549
9550 ENTER();
9551
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309552 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9553 if (NULL == pAdapter)
9554 {
9555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9556 "%s: Adapter is NULL",__func__);
9557 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009558 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309559 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9560 ret = wlan_hdd_validate_context(pHddCtx);
9561 if (0 != ret)
9562 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309563 return ret;
9564 }
9565 pStats = &(pAdapter->hdd_stats.summary_stat);
9566 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9567 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9569
9570 wrqu->txpower.value = 0;
9571 }
9572 else {
9573 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9574 SME_SUMMARY_STATS |
9575 SME_GLOBAL_CLASSA_STATS |
9576 SME_GLOBAL_CLASSB_STATS |
9577 SME_GLOBAL_CLASSC_STATS |
9578 SME_GLOBAL_CLASSD_STATS |
9579 SME_PER_STA_STATS,
9580 hdd_StatisticsCB, 0, FALSE,
9581 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9582
9583 if (eHAL_STATUS_SUCCESS != status)
9584 {
9585 hddLog(VOS_TRACE_LEVEL_ERROR,
9586 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009587 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009588 return -EINVAL;
9589 }
9590
9591 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309592 if (NULL == pWextState)
9593 {
9594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9595 "%s: pWextState is NULL",__func__);
9596 return -EINVAL;
9597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009598
9599 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9600 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9601 {
9602 hddLog(VOS_TRACE_LEVEL_ERROR,
9603 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009604 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009605 /*Remove the SME statistics list by passing NULL in callback argument*/
9606 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9607 SME_SUMMARY_STATS |
9608 SME_GLOBAL_CLASSA_STATS |
9609 SME_GLOBAL_CLASSB_STATS |
9610 SME_GLOBAL_CLASSC_STATS |
9611 SME_GLOBAL_CLASSD_STATS |
9612 SME_PER_STA_STATS,
9613 NULL, 0, FALSE,
9614 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9615
9616 return -EINVAL;
9617 }
9618 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9619 (tANI_U8) sizeof (pStats->retry_cnt),
9620 (char*) &(pStats->retry_cnt[0]),
9621 tlen);
9622
9623 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9624 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9625 (char*) &(pStats->multiple_retry_cnt[0]),
9626 tlen);
9627
9628 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9629 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9630 (char*) &(pStats->tx_frm_cnt[0]),
9631 tlen);
9632
9633 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9634 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9635 (char*) &(pStats->rx_frm_cnt),
9636 tlen);
9637
9638 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9639 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9640 (char*) &(pStats->frm_dup_cnt),
9641 tlen);
9642
9643 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9644 (tANI_U8) sizeof (pStats->fail_cnt),
9645 (char*) &(pStats->fail_cnt[0]),
9646 tlen);
9647
9648 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9649 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9650 (char*) &(pStats->rts_fail_cnt),
9651 tlen);
9652
9653 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9654 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9655 (char*) &(pStats->ack_fail_cnt),
9656 tlen);
9657
9658 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9659 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9660 (char*) &(pStats->rts_succ_cnt),
9661 tlen);
9662
9663 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9664 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9665 (char*) &(pStats->rx_discard_cnt),
9666 tlen);
9667
9668 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9669 (tANI_U8) sizeof (pStats->rx_error_cnt),
9670 (char*) &(pStats->rx_error_cnt),
9671 tlen);
9672
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009673 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009674 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009675 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 tlen);
9677
9678 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9679 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9680 (char*) &(dStats->rx_byte_cnt),
9681 tlen);
9682
9683 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9684 (tANI_U8) sizeof (dStats->rx_rate),
9685 (char*) &(dStats->rx_rate),
9686 tlen);
9687
9688 /* Transmit rate, in units of 500 kbit/sec */
9689 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9690 (tANI_U8) sizeof (aStats->tx_rate),
9691 (char*) &(aStats->tx_rate),
9692 tlen);
9693
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009694 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9695 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9696 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009697 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009698 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9699 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9700 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009701 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009702 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9703 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9704 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009705 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009706 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9707 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9708 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009709 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009710 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9711 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9712 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009713 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009714 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9715 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9716 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009717 tlen);
9718
Jeff Johnson295189b2012-06-20 16:38:30 -07009719 wrqu->data.length = tlen;
9720
9721 }
9722
9723 EXIT();
9724
9725 return 0;
9726}
9727
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309728static int iw_get_statistics(struct net_device *dev,
9729 struct iw_request_info *info,
9730 union iwreq_data *wrqu, char *extra)
9731{
9732 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009733
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309734 vos_ssr_protect(__func__);
9735 ret = __iw_get_statistics(dev, info, wrqu, extra);
9736 vos_ssr_unprotect(__func__);
9737
9738 return ret;
9739}
Jeff Johnson295189b2012-06-20 16:38:30 -07009740#ifdef FEATURE_WLAN_SCAN_PNO
9741
9742/*Max Len for PNO notification*/
9743#define MAX_PNO_NOTIFY_LEN 100
9744void found_pref_network_cb (void *callbackContext,
9745 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9746{
9747 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9748 union iwreq_data wrqu;
9749 char buf[MAX_PNO_NOTIFY_LEN+1];
9750
9751 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9752 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9753
9754 // create the event
9755 memset(&wrqu, 0, sizeof(wrqu));
9756 memset(buf, 0, sizeof(buf));
9757
9758 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9759 pPrefNetworkFoundInd->ssId.ssId,
9760 (unsigned int)pPrefNetworkFoundInd->rssi);
9761
9762 wrqu.data.pointer = buf;
9763 wrqu.data.length = strlen(buf);
9764
9765 // send the event
9766
9767 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9768
9769}
9770
9771
9772/*string based input*/
9773VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9774 union iwreq_data *wrqu, char *extra, int nOffset)
9775{
9776 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309777 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009778 /* pnoRequest is a large struct, so we make it static to avoid stack
9779 overflow. This API is only invoked via ioctl, so it is
9780 serialized by the kernel rtnl_lock and hence does not need to be
9781 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309782 tSirPNOScanReq pnoRequest = {0};
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309783 char *ptr, *data;
Jeff Johnson295189b2012-06-20 16:38:30 -07009784 v_U8_t i,j, ucParams, ucMode;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309785 size_t len;
c_hpothu37f21312014-04-09 21:49:54 +05309786 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9788
9789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9790 "PNO data len %d data %s",
9791 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009792 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009793
9794 if (wrqu->data.length <= nOffset )
9795 {
9796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9797 return VOS_STATUS_E_FAILURE;
9798 }
9799
9800 pnoRequest.enable = 0;
9801 pnoRequest.ucNetworksCount = 0;
9802 /*-----------------------------------------------------------------------
9803 Input is string based and expected to be like this:
9804
9805 <enabled> <netw_count>
9806 for each network:
9807 <ssid_len> <ssid> <authentication> <encryption>
9808 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9809 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9810
9811 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009812 1 2 4 test 0 0 3 1 6 11 2 40 5 test2 4 4 6 1 2 3 4 5 6 1 0 2 5 2 300 0
Jeff Johnson295189b2012-06-20 16:38:30 -07009813
9814 this translates into:
9815 -----------------------------
9816 enable PNO
9817 look for 2 networks:
9818 test - with authentication type 0 and encryption type 0,
9819 that can be found on 3 channels: 1 6 and 11 ,
9820 SSID bcast type is unknown (directed probe will be sent if AP not found)
9821 and must meet -40dBm RSSI
9822
9823 test2 - with auth and enrytption type 4/4
9824 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9825 bcast type is non-bcast (directed probe will be sent)
9826 and must not meet any RSSI threshold
9827
Jeff Johnson8301aa12013-03-28 14:27:29 -07009828 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009829 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009830
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309831 /* making sure argument string ends with '\0' */
9832 len = (wrqu->data.length-nOffset) + 1;
9833 data = vos_mem_malloc(len);
9834 if (NULL == data) {
9835 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9836 FL("fail to allocate memory %zu"), len);
9837 return -EINVAL;
9838 }
9839 vos_mem_zero(data, len);
9840 vos_mem_copy(data, &extra[nOffset], (len-1));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309841 ptr = data;
9842
9843 if (1 != sscanf(ptr," %hhu%n", &(pnoRequest.enable), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -07009844 {
9845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9846 "PNO enable input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309847 vos_mem_free(data);
Wilson Yang623f6592013-10-08 16:33:37 -07009848 return VOS_STATUS_E_FAILURE;
9849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009850
9851 if ( 0 == pnoRequest.enable )
9852 {
9853 /*Disable PNO*/
9854 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309855 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9856 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009857 pAdapter->sessionId,
9858 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309859 if (eHAL_STATUS_SUCCESS != status)
9860 {
9861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9862 "%s: failed to disable PNO", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309863 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +05309864 return VOS_STATUS_E_FAILURE;
9865 }
9866 pHddCtx->isPnoEnable = FALSE;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309867 vos_mem_free(data);
Jeff Johnson295189b2012-06-20 16:38:30 -07009868 return VOS_STATUS_SUCCESS;
9869 }
9870
c_hpothu37f21312014-04-09 21:49:54 +05309871 if (TRUE == pHddCtx->isPnoEnable)
9872 {
9873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9874 FL("already PNO is enabled"));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309875 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +05309876 return -EBUSY;
9877 }
9878 pHddCtx->isPnoEnable = TRUE;
9879
Jeff Johnson295189b2012-06-20 16:38:30 -07009880 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009881
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309882 if (1 != sscanf(ptr," %hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -07009883 {
9884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9885 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309886 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009888
9889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9890 "PNO enable %d networks count %d offset %d",
9891 pnoRequest.enable,
9892 pnoRequest.ucNetworksCount,
9893 nOffset);
9894
9895 /* Parameters checking:
9896 ucNetworksCount has to be larger than 0*/
9897 if (( 0 == pnoRequest.ucNetworksCount ) ||
9898 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9899 {
9900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309901 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009902 }
9903
9904 ptr += nOffset;
9905
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309906 pnoRequest.aNetworks =
9907 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9908 if (pnoRequest.aNetworks == NULL)
9909 {
9910 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9911 FL("failed to allocate memory aNetworks %u"),
9912 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9913 goto error;
9914 }
9915 vos_mem_zero(pnoRequest.aNetworks,
9916 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9917
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9919 {
9920
9921 pnoRequest.aNetworks[i].ssId.length = 0;
9922
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309923 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009924 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9925
9926 if (1 != ucParams)
9927 {
9928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9929 "PNO ssid length input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309930 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009932
9933 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9934 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9935 {
9936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9937 "SSID Len %d is not correct for network %d",
9938 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309939 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009940 }
9941
9942 /*Advance to SSID*/
9943 ptr += nOffset;
9944
Jeff Johnson8301aa12013-03-28 14:27:29 -07009945 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009946 pnoRequest.aNetworks[i].ssId.length);
9947 ptr += pnoRequest.aNetworks[i].ssId.length;
9948
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309949 ucParams = sscanf(ptr," %u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009950 &(pnoRequest.aNetworks[i].authentication),
9951 &(pnoRequest.aNetworks[i].encryption),
9952 &(pnoRequest.aNetworks[i].ucChannelCount),
9953 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009954
Wilson Yang623f6592013-10-08 16:33:37 -07009955 if ( 3 != ucParams )
9956 {
9957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9958 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309959 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009960 }
9961
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009963 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009964 "auth %d encry %d channel count %d offset %d",
9965 pnoRequest.aNetworks[i].ssId.length,
9966 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9967 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9968 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9969 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9970 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9971 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9972 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9973 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9974 pnoRequest.aNetworks[i].authentication,
9975 pnoRequest.aNetworks[i].encryption,
9976 pnoRequest.aNetworks[i].ucChannelCount,
9977 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009978
Jeff Johnson295189b2012-06-20 16:38:30 -07009979 /*Advance to channel list*/
9980 ptr += nOffset;
9981
Wilson Yang623f6592013-10-08 16:33:37 -07009982 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 {
9984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9985 "Incorrect number of channels");
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309986 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009987 }
9988
9989 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9990 {
9991 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9992 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309993 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009994 &(pnoRequest.aNetworks[i].aChannels[j]),
9995 &nOffset))
9996 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9997 "PNO network channel input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309998 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009999 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010000 if (!IS_CHANNEL_VALID(pnoRequest.aNetworks[i].aChannels[j])) {
10001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10002 FL("invalid channel: %hhu"),
10003 pnoRequest.aNetworks[i].aChannels[j]);
10004 goto error;
10005 }
10006
Wilson Yang623f6592013-10-08 16:33:37 -070010007 /*Advance to next channel number*/
10008 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010009 }
10010 }
10011
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010012 if (1 != sscanf(ptr," %u %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010013 &(pnoRequest.aNetworks[i].bcastNetwType),
10014 &nOffset))
10015 {
10016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10017 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010018 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010019 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010020 if (pnoRequest.aNetworks[i].bcastNetwType > 2) {
10021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10022 FL("invalid bcast nw type: %u"),
10023 pnoRequest.aNetworks[i].bcastNetwType);
10024 goto error;
10025 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010026
10027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10028 "PNO bcastNetwType %d offset %d",
10029 pnoRequest.aNetworks[i].bcastNetwType,
10030 nOffset );
10031
10032 /*Advance to rssi Threshold*/
10033 ptr += nOffset;
10034
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010035 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010036 &(pnoRequest.aNetworks[i].rssiThreshold),
10037 &nOffset))
10038 {
10039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10040 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010041 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010042 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010043
10044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10045 "PNO rssi %d offset %d",
10046 pnoRequest.aNetworks[i].rssiThreshold,
10047 nOffset );
10048 /*Advance to next network*/
10049 ptr += nOffset;
10050 }/*For ucNetworkCount*/
10051
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010052 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010053 &(pnoRequest.scanTimers.ucScanTimersCount),
10054 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010055
10056 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -070010057 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010058 {
10059 ptr += nOffset;
10060
Jeff Johnson8301aa12013-03-28 14:27:29 -070010061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10062 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010063 pnoRequest.scanTimers.ucScanTimersCount,
10064 nOffset );
10065
10066 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
10067 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010069 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +053010070 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 }
10072
10073 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
10074 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010075 ucParams = sscanf(ptr," %u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
10077 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
10078 &nOffset);
10079
Wilson Yang623f6592013-10-08 16:33:37 -070010080 if (2 != ucParams)
10081 {
10082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10083 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +053010084 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010085 }
10086
Jeff Johnson8301aa12013-03-28 14:27:29 -070010087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10088 "PNO Timer value %d Timer repeat %d offset %d",
10089 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -070010090 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
10091 nOffset );
10092
Jeff Johnson295189b2012-06-20 16:38:30 -070010093 ptr += nOffset;
10094 }
10095
10096 }
10097 else
10098 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10100 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010101 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
10102
10103 /*Scan timers defaults to 5 minutes*/
10104 pnoRequest.scanTimers.ucScanTimersCount = 1;
10105 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
10106 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
10107 }
10108
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010109 ucParams = sscanf(ptr," %hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010110
10111 pnoRequest.modePNO = ucMode;
10112 /*for LA we just expose suspend option*/
10113 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
10114 {
10115 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10116 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010117 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10118 if (pnoRequest.p24GProbeTemplate == NULL){
10119 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10120 FL("failed to allocate memory p24GProbeTemplate %u"),
10121 SIR_PNO_MAX_PB_REQ_SIZE);
10122 goto error;
10123 }
10124
10125 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10126 if (pnoRequest.p5GProbeTemplate == NULL){
10127 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10128 FL("failed to allocate memory p5GProbeTemplate %u"),
10129 SIR_PNO_MAX_PB_REQ_SIZE);
10130 goto error;
10131 }
10132
10133 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
10134 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010135
c_hpothu37f21312014-04-09 21:49:54 +053010136 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010137 pAdapter->sessionId,
10138 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010139 if (eHAL_STATUS_SUCCESS == status)
10140 {
10141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10142 "%s: PNO enabled", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010143 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010144 return VOS_STATUS_SUCCESS;
10145 }
10146error:
10147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10148 "%s: Failed to enable PNO", __func__);
10149 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010150 if (pnoRequest.aNetworks)
10151 vos_mem_free(pnoRequest.aNetworks);
10152 if (pnoRequest.p24GProbeTemplate)
10153 vos_mem_free(pnoRequest.p24GProbeTemplate);
10154 if (pnoRequest.p5GProbeTemplate)
10155 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010156
10157 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010158 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010159}/*iw_set_pno*/
10160
10161VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
10162 union iwreq_data *wrqu, char *extra, int nOffset)
10163{
10164 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10165 v_U8_t rssiThreshold = 0;
10166 v_U8_t nRead;
10167
Arif Hussain7adce1b2013-11-11 22:59:34 -080010168 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010169 &rssiThreshold);
10170
10171 if ( 1 != nRead )
10172 {
10173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10174 "Incorrect format");
10175 return VOS_STATUS_E_FAILURE;
10176 }
10177
10178 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
10179 return VOS_STATUS_SUCCESS;
10180}
10181
10182
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010183static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010184 struct iw_request_info *info,
10185 union iwreq_data *wrqu, char *extra)
10186{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010187 hdd_adapter_t *pAdapter;
10188 hdd_context_t *pHddCtx;
10189 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010190 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010191
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010192 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010193 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10194 if (NULL == pAdapter)
10195 {
10196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10197 "%s: Adapter is NULL",__func__);
10198 return -EINVAL;
10199 }
10200
10201 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10202 ret = wlan_hdd_validate_context(pHddCtx);
10203 if (0 != ret)
10204 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010205 return ret;
10206 }
10207
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010208
10209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010210 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010211
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010212 status = iw_set_pno(dev,info,wrqu,extra,0);
10213
10214 EXIT();
10215 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010216}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010217
10218static int iw_set_pno_priv(struct net_device *dev,
10219 struct iw_request_info *info,
10220 union iwreq_data *wrqu, char *extra)
10221{
10222 int ret;
10223
10224 vos_ssr_protect(__func__);
10225 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
10226 vos_ssr_unprotect(__func__);
10227
10228 return ret;
10229}
Jeff Johnson295189b2012-06-20 16:38:30 -070010230#endif /*FEATURE_WLAN_SCAN_PNO*/
10231
10232//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +053010233int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010234{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010235 hdd_adapter_t *pAdapter;
10236 tHalHandle hHal;
10237 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010238 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +053010239 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010240 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -070010241 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010242 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010243 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010244 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010245
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010246 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010247 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10248 if (NULL == pAdapter)
10249 {
10250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10251 "%s: Adapter is NULL",__func__);
10252 return -EINVAL;
10253 }
10254 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10255 retval = wlan_hdd_validate_context(pHddCtx);
10256 if (0 != retval)
10257 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010258 return retval;
10259 }
10260 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10261 if (NULL == hHal)
10262 {
10263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10264 "%s: Hal Context is NULL",__func__);
10265 return -EINVAL;
10266 }
10267 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010268
Atul Mittal54378cb2014-04-02 16:51:50 +053010269 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010270 {
10271 case WLAN_HDD_UI_BAND_AUTO:
10272 band = eCSR_BAND_ALL;
10273 break;
10274 case WLAN_HDD_UI_BAND_5_GHZ:
10275 band = eCSR_BAND_5G;
10276 break;
10277 case WLAN_HDD_UI_BAND_2_4_GHZ:
10278 band = eCSR_BAND_24;
10279 break;
10280 default:
10281 band = eCSR_BAND_MAX;
10282 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010283 connectedBand =
10284 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -070010285
Atul Mittal54378cb2014-04-02 16:51:50 +053010286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010287 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010288
10289 if (band == eCSR_BAND_MAX)
10290 {
10291 /* Received change band request with invalid band value */
10292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +053010293 "%s: Invalid band value %u", __func__, ui_band);
10294 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010295 }
10296
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010297 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +053010298 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010299 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010301 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010302 band, pHddCtx->cfg_ini->nBandCapability);
10303 return -EIO;
10304 }
10305
Sushant Kaushik1165f872015-03-30 20:25:27 +053010306 if (band == eCSR_BAND_ALL)
10307 {
10308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
10309 "received. Setting band same as ini value %d"),
10310 pHddCtx->cfg_ini->nBandCapability);
10311 band = pHddCtx->cfg_ini->nBandCapability;
10312 }
10313
Jeff Johnson295189b2012-06-20 16:38:30 -070010314 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
10315 {
10316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10317 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010318 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010319 return -EIO;
10320 }
10321
10322 if (currBand != band)
10323 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010324 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010325 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010326 /* Return failure if current country code is world regulatory domain*/
10327 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
10328 pMac->scan.countryCodeCurrent[1] == '0') )
10329 {
10330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10331 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010332 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010333 return -EAGAIN;
10334 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010335 }
10336
Jeff Johnson295189b2012-06-20 16:38:30 -070010337 /* Change band request received.
10338 * Abort pending scan requests, flush the existing scan results,
10339 * and change the band capability
10340 */
10341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10342 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010343 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010344
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010345 /* We need to change the band and flush the scan results here itself
10346 * as we may get timeout for disconnection in which we will return
10347 * with out doing any of these
10348 */
10349 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
10350 {
10351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10352 "%s: failed to set the band value to %u ",
10353 __func__, band);
10354 return -EINVAL;
10355 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010356 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
10357 {
Sachin Ahuja120bf632015-02-24 18:06:34 +053010358 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010359 curr_country[0]=pMac->scan.countryCodeCurrent[0];
10360 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +053010361 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010362 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
10363 * information available in NV so to get the channel information from kernel
10364 * we need to send regulatory hint for the currunt country
10365 * And to set the same country again we need to set the dummy country
10366 * first and then the actual country.
10367 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010368#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Ashish Kumar Dhanotiyaaebbe052017-11-16 14:41:09 +053010369 if(curr_country[0] == '0' && curr_country[1] == '0')
10370 regulatory_hint_user("IN", NL80211_USER_REG_HINT_USER);
10371 else
10372 regulatory_hint_user("OO", NL80211_USER_REG_HINT_USER);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010373#else
Ashish Kumar Dhanotiyaaebbe052017-11-16 14:41:09 +053010374 if(curr_country[0] == '0' && curr_country[1] == '0')
10375 regulatory_hint_user("IN");
10376 else
10377 regulatory_hint_user("00");
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010378#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010379 wait_result = wait_for_completion_interruptible_timeout(
10380 &pHddCtx->linux_reg_req,
10381 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10382
10383 /* if the country information does not exist with the kernel,
10384 then the driver callback would not be called */
10385
10386 if (wait_result >= 0)
10387 {
10388 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10389 "runtime country code is found in kernel db");
10390 }
10391 else
10392 {
10393 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10394 "runtime country code is not found"
10395 " in kernel db");
10396 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010397
10398 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010399
10400 /*
10401 * Update 11dcountry and current country here as the hint
10402 * with 00 results in 11d and current country with 00
10403 */
10404 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
10405 WNI_CFG_COUNTRY_CODE_LEN);
10406 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
10407 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010408#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10409 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
10410#else
10411 regulatory_hint_user(curr_country);
10412#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010413 wait_result = wait_for_completion_interruptible_timeout(
10414 &pHddCtx->linux_reg_req,
10415 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10416
10417 /* if the country information does not exist with the kernel,
10418 then the driver callback would not be called */
10419 if (wait_result >= 0)
10420 {
10421 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10422 "runtime country code is found in kernel db");
10423 }
10424 else
10425 {
10426 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10427 "runtime country code is not found"
10428 " in kernel db");
10429 }
10430
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010431 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010432 }
10433 else
10434 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010435#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010436 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10437 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010438#else
10439 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10440#endif
10441
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010442 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010443 pScanInfo = &pHddCtx->scan_info;
10444 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10445 {
10446 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10447 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10448 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010449 sme_FilterScanResults(hHal, pAdapter->sessionId);
10450
10451 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010452 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10453 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010454 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010455 eHalStatus status = eHAL_STATUS_SUCCESS;
10456 long lrc;
10457
10458 /* STA already connected on current band, So issue disconnect first,
10459 * then change the band*/
10460
10461 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010462 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010463 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010464
Jeff Johnson295189b2012-06-20 16:38:30 -070010465 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10466
10467 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10468 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10469
Jeff Johnson43971f52012-07-17 12:26:56 -070010470 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010471 {
10472 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010473 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010474 __func__, (int)status );
10475 return -EINVAL;
10476 }
10477
10478 lrc = wait_for_completion_interruptible_timeout(
10479 &pAdapter->disconnect_comp_var,
10480 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10481
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010482 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010483
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010484 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010485 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010486
10487 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10488 }
10489 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010490 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010491 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010492 if (TRUE == pHddCtx->isSetBandByNL)
10493 return 0;
10494 else
10495 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010496}
10497
Atul Mittal54378cb2014-04-02 16:51:50 +053010498int hdd_setBand_helper(struct net_device *dev, const char *command)
10499{
10500 u8 band;
10501
10502 /*convert the band value from ascii to integer*/
10503 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10504
10505 return hdd_setBand(dev, band);
10506
10507}
10508
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010509static int __iw_set_band_config(struct net_device *dev,
10510 struct iw_request_info *info,
10511 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010512{
Atul Mittal54378cb2014-04-02 16:51:50 +053010513 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010514
Arif Hussain0273cba2014-01-07 20:58:29 -080010515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010516
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010517 if (!capable(CAP_NET_ADMIN))
10518 {
10519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10520 FL("permission check failed"));
10521 return -EPERM;
10522 }
10523
Atul Mittal54378cb2014-04-02 16:51:50 +053010524 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010525}
10526
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010527static int iw_set_band_config(struct net_device *dev,
10528 struct iw_request_info *info,
10529 union iwreq_data *wrqu, char *extra)
10530{
10531 int ret;
10532
10533 vos_ssr_protect(__func__);
10534 ret = __iw_set_band_config(dev, info, wrqu, extra);
10535 vos_ssr_unprotect(__func__);
10536
10537 return ret;
10538}
10539
c_manjeecfd1efb2015-09-25 19:32:34 +053010540static int get_fwr_memdump(struct net_device *dev,
10541 struct iw_request_info *info,
10542 union iwreq_data *wrqu, char *extra)
10543{
10544 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10545 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10546 int ret;
10547 ENTER();
10548 // HddCtx sanity
10549 ret = wlan_hdd_validate_context(pHddCtx);
10550 if (0 != ret)
10551 {
10552 return ret;
10553 }
10554 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10555 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10556 {
10557 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10558 return -EINVAL;
10559 }
10560 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10561
10562 EXIT();
10563 return ret;
10564}
10565
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010566static int __iw_set_power_params_priv(struct net_device *dev,
10567 struct iw_request_info *info,
10568 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010569{
Arif Hussain0273cba2014-01-07 20:58:29 -080010570 int ret;
10571 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010572
Jeff Johnson295189b2012-06-20 16:38:30 -070010573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10574 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010575
10576 if (!capable(CAP_NET_ADMIN))
10577 {
10578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10579 FL("permission check failed"));
10580 return -EPERM;
10581 }
10582
Arif Hussain0273cba2014-01-07 20:58:29 -080010583 /* ODD number is used for set, copy data using copy_from_user */
10584 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10585 wrqu->data.length);
10586 if (NULL == ptr)
10587 {
10588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10589 "mem_alloc_copy_from_user_helper fail");
10590 return -ENOMEM;
10591 }
10592
10593 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10594 kfree(ptr);
10595 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010596}
10597
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010598static int iw_set_power_params_priv(struct net_device *dev,
10599 struct iw_request_info *info,
10600 union iwreq_data *wrqu, char *extra)
10601{
10602 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010603
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010604 vos_ssr_protect(__func__);
10605 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10606 vos_ssr_unprotect(__func__);
10607
10608 return ret;
10609}
Jeff Johnson295189b2012-06-20 16:38:30 -070010610
10611/*string based input*/
10612VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10613 union iwreq_data *wrqu, char *extra, int nOffset)
10614{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010615 hdd_adapter_t *pAdapter;
10616 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010617 tSirSetPowerParamsReq powerRequest;
10618 char *ptr;
10619 v_U8_t ucType;
10620 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010621 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010622
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010623 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010624 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10625 if (NULL == pAdapter)
10626 {
10627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10628 "%s: Adapter is NULL",__func__);
10629 return -EINVAL;
10630 }
10631
10632 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10633 ret = wlan_hdd_validate_context(pHddCtx);
10634 if (0 != ret)
10635 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010636 return ret;
10637 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10639 "Power Params data len %d data %s",
10640 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010641 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010642
10643 if (wrqu->data.length <= nOffset )
10644 {
10645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10646 return VOS_STATUS_E_FAILURE;
10647 }
10648
10649 uTotalSize = wrqu->data.length - nOffset;
10650
10651 /*-----------------------------------------------------------------------
10652 Input is string based and expected to be like this:
10653
10654 <param_type> <param_value> <param_type> <param_value> ...
10655
10656 e.g:
10657 1 2 2 3 3 0 4 1 5 1
10658
10659 e.g. setting just a few:
10660 1 2 4 1
10661
10662 parameter types:
10663 -----------------------------
10664 1 - Ignore DTIM
10665 2 - Listen Interval
10666 3 - Broadcast Multicas Filter
10667 4 - Beacon Early Termination
10668 5 - Beacon Early Termination Interval
10669 -----------------------------------------------------------------------*/
10670 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10671 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10672 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10673 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10674 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10675
Arif Hussain7adce1b2013-11-11 22:59:34 -080010676 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010677
10678 while ( uTotalSize )
10679 {
Wilson Yang6f971452013-10-08 15:00:00 -070010680 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10681 {
10682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10683 "Invalid input parameter type %s",ptr);
10684 return VOS_STATUS_E_FAILURE;
10685 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010686
10687 uTotalSize -= nOffset;
10688
10689 if (!uTotalSize)
10690 {
10691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010692 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010693 ucType, nOffset);
10694 return VOS_STATUS_E_FAILURE;
10695 }
10696
10697 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010698
Jeff Johnson02797792013-10-26 19:17:13 -070010699 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010700 {
10701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10702 "Invalid input parameter value %s",ptr);
10703 return VOS_STATUS_E_FAILURE;
10704 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010705
10706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10707 "Power request parameter %d value %d offset %d",
10708 ucType, uValue, nOffset);
10709
10710 switch (ucType)
10711 {
10712 case eSIR_IGNORE_DTIM:
10713 powerRequest.uIgnoreDTIM = uValue;
10714 break;
10715 case eSIR_LISTEN_INTERVAL:
10716 powerRequest.uListenInterval = uValue;
10717 break;
10718 case eSIR_MCAST_BCAST_FILTER:
10719 powerRequest.uBcastMcastFilter = uValue;
10720 break;
10721 case eSIR_ENABLE_BET:
10722 powerRequest.uEnableBET = uValue;
10723 break;
10724 case eSIR_BET_INTERVAL:
10725 powerRequest.uBETInterval = uValue;
10726 break;
10727 default:
10728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010729 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010730 ucType, uValue, nOffset);
10731 return VOS_STATUS_E_FAILURE;
10732 }
10733
10734 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10736 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010737 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010738 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010739 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010740 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010741 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10742 {
10743 uTotalSize = 0;
10744 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010745
10746 }/*Go for as long as we have a valid string*/
10747
10748 /* put the device into full power*/
10749 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10750
10751 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010752 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010753
10754 /* put the device back to power save*/
10755 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10756
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010757 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010758 return VOS_STATUS_SUCCESS;
10759}/*iw_set_power_params*/
10760
Atul Mittalc0f739f2014-07-31 13:47:47 +053010761// tdlsoffchan
10762#ifdef FEATURE_WLAN_TDLS
10763
Atul Mittal87ec2422014-09-24 13:12:50 +053010764int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010765{
10766 if (offchannel < 0 || offchannel > 165)
10767 {
10768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10769 __func__, offchannel);
10770 return -1;
10771
10772 }
10773
10774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10775 __func__, tdlsOffCh, offchannel);
10776
10777 tdlsOffCh = offchannel;
10778 return 0;
10779}
10780
Atul Mittal87ec2422014-09-24 13:12:50 +053010781int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010782{
10783 if (offchanoffset == 0)
10784 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010785 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10787 __func__, tdlsOffChBwOffset);
10788
10789 return 0;
10790
10791 }
10792
10793 if ( offchanoffset == 40 )
10794 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010795 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10797 __func__, tdlsOffChBwOffset);
10798
10799 return 0;
10800
10801 }
10802 if (offchanoffset == -40)
10803 {
10804 tdlsOffChBwOffset = 3;
10805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10806 __func__, tdlsOffChBwOffset);
10807
10808 return 0;
10809
10810 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010811
10812 if ((offchanoffset == 80) &&
10813 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10814 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10815 {
10816 tdlsOffChBwOffset = 4;
10817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10818 "%s: change tdls secondary off channel offset to %u",
10819 __func__, tdlsOffChBwOffset);
10820
10821 return 0;
10822 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10824 __func__, offchanoffset);
10825 return -1;
10826}
10827
Atul Mittal87ec2422014-09-24 13:12:50 +053010828int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010829{
10830 hddTdlsPeer_t *connPeer = NULL;
10831 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10832 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010833 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010834 if (offchanmode < 0 || offchanmode > 4)
10835 {
10836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10837 "%s: Invalid tdls off channel mode %d",
10838 __func__, offchanmode);
10839 return -1;
10840 }
10841
10842 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10843 {
10844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10845 "%s: tdls off channel mode req in not associated state %d",
10846 __func__, offchanmode);
10847 return -1;
10848 }
10849
10850 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10851 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10852 {
10853 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010854 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010855 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010856 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010857 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10859 "%s: No TDLS Connected Peer", __func__);
10860 return -1;
10861 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010862 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010863 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010864 }
10865 else
10866 {
10867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10868 "%s: TDLS Connection not supported", __func__);
10869 return -1;
10870 }
10871
10872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10873 ("%s: TDLS Channel Switch in swmode=%d"),
10874 __func__, offchanmode);
10875
10876 switch (offchanmode)
10877 {
10878 case 1:/*Enable*/
10879 case 2:/*Disable*/
10880 {
10881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10882 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10883 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10884 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10885 {
10886
10887 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010888 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053010889 tdlsOffCh, tdlsOffChBwOffset,
10890 offchanmode);
10891 }
10892 else
10893 {
10894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10895 "%s: TDLS Off Channel not supported", __func__);
10896 return -1;
10897 }
10898 break;
10899 }
10900 case 3:
10901 {
10902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10903 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10904 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10905
10906 break;
10907 }
10908 case 4:
10909 {
10910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10911 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10912 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10913 break;
10914 }
10915 default:
10916 {
10917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10918 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10919 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10920 break;
10921 }
10922
10923 }
10924
10925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10926 __func__, offchanmode);
10927 return 0;
10928}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010929#endif
10930
Jeff Johnson295189b2012-06-20 16:38:30 -070010931// Define the Wireless Extensions to the Linux Network Device structure
10932// A number of these routines are NULL (meaning they are not implemented.)
10933
10934static const iw_handler we_handler[] =
10935{
10936 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10937 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10938 (iw_handler) NULL, /* SIOCSIWNWID */
10939 (iw_handler) NULL, /* SIOCGIWNWID */
10940 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10941 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
Ashish Kumar Dhanotiya6b484a82018-04-24 15:11:55 +053010942 (iw_handler) NULL, /* SIOCSIWMODE */
10943 (iw_handler) NULL, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -070010944 (iw_handler) NULL, /* SIOCSIWSENS */
10945 (iw_handler) NULL, /* SIOCGIWSENS */
10946 (iw_handler) NULL, /* SIOCSIWRANGE */
10947 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053010948 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070010949 (iw_handler) NULL, /* SIOCGIWPRIV */
10950 (iw_handler) NULL, /* SIOCSIWSTATS */
10951 (iw_handler) NULL, /* SIOCGIWSTATS */
10952 iw_handler_set_spy, /* SIOCSIWSPY */
10953 iw_handler_get_spy, /* SIOCGIWSPY */
10954 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10955 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10956 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10957 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10958 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10959 (iw_handler) NULL, /* SIOCGIWAPLIST */
10960 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10961 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10962 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10963 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10964 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10965 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10966 (iw_handler) NULL, /* -- hole -- */
10967 (iw_handler) NULL, /* -- hole -- */
10968 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10969 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10970 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10971 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10972 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10973 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10974 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10975 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10976 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10977 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10978 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10979 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10980 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10981 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10982 (iw_handler) NULL, /* -- hole -- */
10983 (iw_handler) NULL, /* -- hole -- */
10984 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10985 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10986 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10987 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10988 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10989 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10990 (iw_handler) NULL, /* SIOCSIWPMKSA */
10991};
10992
10993static const iw_handler we_private[] = {
10994
10995 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10996 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10997 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10998 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10999 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
11000 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053011001 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070011002 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
11003 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
11004 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Manjeet Singh3ed79242017-01-11 19:04:32 +053011005 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
11006 iw_setnone_get_threeint,
Jeff Johnsone7245742012-09-05 17:12:55 -070011007#ifdef FEATURE_OEM_DATA_SUPPORT
11008 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
11009 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
11010#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011011
Jeff Johnson295189b2012-06-20 16:38:30 -070011012#ifdef WLAN_FEATURE_VOWIFI_11R
11013 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
11014#endif
11015 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
11016 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
11017 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
11018#ifdef WLAN_FEATURE_PACKET_FILTERING
11019 ,
11020 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
11021#endif
11022#ifdef FEATURE_WLAN_SCAN_PNO
11023 ,
11024 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
11025#endif
11026 ,
11027 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
11028 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
11029 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
11030 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070011031 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070011032};
11033
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053011034static const iw_handler we_mon_private[] = {
11035 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] =
11036 iw_mon_setint_getnone,
11037};
11038
11039static const struct iw_priv_args we_mon_private_args[] = {
11040 {WE_SET_MONITOR_STATE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11041 0, "monitor"},
11042
11043 /* handlers for main ioctl */
11044 {WLAN_PRIV_SET_INT_GET_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11045 0, "" },
11046};
11047
Jeff Johnson295189b2012-06-20 16:38:30 -070011048/*Maximum command length can be only 15 */
11049static const struct iw_priv_args we_private_args[] = {
11050
Katya Nigamf0511f62015-05-05 16:40:57 +053011051 { WE_SET_MONITOR_STATE,
11052 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11053 0, "monitor" },
11054
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 /* handlers for main ioctl */
11056 { WLAN_PRIV_SET_INT_GET_NONE,
11057 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11058 0,
11059 "" },
11060
11061 /* handlers for sub-ioctl */
11062 { WE_SET_11D_STATE,
11063 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11064 0,
11065 "set11Dstate" },
11066
11067 { WE_WOWL,
11068 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11069 0,
11070 "wowl" },
11071
11072 { WE_SET_POWER,
11073 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11074 0,
11075 "setPower" },
11076
11077 { WE_SET_MAX_ASSOC,
11078 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11079 0,
11080 "setMaxAssoc" },
11081
11082 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
11083 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11084 0,
11085 "setAutoChannel" },
11086
11087 { WE_SET_DATA_INACTIVITY_TO,
11088 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11089 0,
11090 "inactivityTO" },
11091
11092 { WE_SET_MAX_TX_POWER,
11093 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11094 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070011095 "setMaxTxPower" },
11096
11097 { WE_SET_MAX_TX_POWER_2_4,
11098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11099 0,
11100 "setTxMaxPower2G" },
11101
11102 { WE_SET_MAX_TX_POWER_5_0,
11103 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11104 0,
11105 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070011106
11107 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
11108 * as well to keep same syntax as in SAP. Now onwards, STA
11109 * will support both */
11110 { WE_SET_MAX_TX_POWER,
11111 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11112 0,
11113 "setTxMaxPower" },
11114
Jeff Johnson295189b2012-06-20 16:38:30 -070011115 /* set Higher DTIM Transition (DTIM1 to DTIM3)
11116 * 1 = enable and 0 = disable */
11117 {
11118 WE_SET_HIGHER_DTIM_TRANSITION,
11119 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11120 0,
11121 "setHDtimTransn" },
11122
11123 { WE_SET_TM_LEVEL,
11124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011125 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011126 "setTmLevel" },
11127
Kiet Lam46b8e4e2013-11-06 21:49:53 +053011128 { WE_ENABLE_STRICT_FCC_REG,
11129 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11130 0,
11131 "setStrictFCCreg" },
11132
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011133 { WE_SET_DEBUG_LOG,
11134 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11135 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053011136#ifdef FEATURE_WLAN_TDLS
11137 {
11138 WE_SET_TDLS_OFF_CHAN,
11139 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11140 0,
11141 "tdlsoffchan" },
11142 {
11143 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
11144 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11145 0,
11146 "tdlsecchnoffst" },
11147 {
11148 WE_SET_TDLS_OFF_CHAN_MODE,
11149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11150 0,
11151 "tdlsoffchnmode" },
11152#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011153
Peng Xu2446a892014-09-05 17:21:18 +053011154 { WE_SET_SCAN_BAND_PREFERENCE,
11155 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11156 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053011157 {
11158 WE_GET_FRAME_LOG,
11159 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11160 0,
11161 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053011162
Abhishek Singh01c73d12015-03-12 15:13:44 +053011163 { WE_SET_MIRACAST_VENDOR_CONFIG,
11164 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11165 0, "setMiracstConf" },
11166
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053011167#ifdef FEATURE_WLAN_TDLS
11168 {
11169 WE_SET_TDLS_2040_BSS_COEXISTENCE,
11170 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11171 0,
11172 "tdls_2040bsscox" },
11173#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053011174 { WE_SET_RTS_CTS_HTVHT,
11175 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11176 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053011177 { WE_SET_PKT_STATS_ENABLE_DISABLE,
11178 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11179 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053011180 { WE_SET_PROXIMITY_ENABLE,
11181 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11182 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011183
11184#ifdef WLAN_FEATURE_TSF
11185 { WE_CAP_TSF,
11186 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11187 0, "cap_tsf" },
11188#endif
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +053011189 { WE_SET_MODULATED_DTIM,
11190 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11191 0, "setModDTIM" },
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +053011192 {
11193 WLAN_SET_DYNNAMIC_AGGREGATION,
11194 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11195 0, "setAggregation" },
11196
Jeff Johnson295189b2012-06-20 16:38:30 -070011197 /* handlers for main ioctl */
11198 { WLAN_PRIV_SET_NONE_GET_INT,
11199 0,
11200 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11201 "" },
11202
11203 /* handlers for sub-ioctl */
11204 { WE_GET_11D_STATE,
11205 0,
11206 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11207 "get11Dstate" },
11208
11209 { WE_IBSS_STATUS,
11210 0,
11211 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11212 "getAdhocStatus" },
11213
11214 { WE_PMC_STATE,
11215 0,
11216 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11217 "pmcState" },
11218
11219 { WE_GET_WLAN_DBG,
11220 0,
11221 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11222 "getwlandbg" },
11223
Jeff Johnson295189b2012-06-20 16:38:30 -070011224 { WE_GET_MAX_ASSOC,
11225 0,
11226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11227 "getMaxAssoc" },
11228
Jeff Johnson295189b2012-06-20 16:38:30 -070011229 { WE_GET_WDI_DBG,
11230 0,
11231 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11232 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011233
11234 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11235 0,
11236 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11237 "getAutoChannel" },
11238
11239 { WE_GET_CONCURRENCY_MODE,
11240 0,
11241 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11242 "getconcurrency" },
11243
Peng Xu2446a892014-09-05 17:21:18 +053011244 { WE_GET_SCAN_BAND_PREFERENCE,
11245 0,
11246 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11247 "get_scan_pref"},
11248
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053011249 { WE_GET_ANTENA_DIVERSITY_SELECTION,
11250 0,
11251 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11252 "getCurAnt"},
11253
Jeff Johnson295189b2012-06-20 16:38:30 -070011254 /* handlers for main ioctl */
11255 { WLAN_PRIV_SET_CHAR_GET_NONE,
11256 IW_PRIV_TYPE_CHAR| 512,
11257 0,
11258 "" },
11259
11260 /* handlers for sub-ioctl */
11261 { WE_WOWL_ADD_PTRN,
11262 IW_PRIV_TYPE_CHAR| 512,
11263 0,
11264 "wowlAddPtrn" },
11265
11266 { WE_WOWL_DEL_PTRN,
11267 IW_PRIV_TYPE_CHAR| 512,
11268 0,
11269 "wowlDelPtrn" },
11270
11271#if defined WLAN_FEATURE_VOWIFI
11272 /* handlers for sub-ioctl */
11273 { WE_NEIGHBOR_REPORT_REQUEST,
11274 IW_PRIV_TYPE_CHAR | 512,
11275 0,
11276 "neighbor" },
11277#endif
11278 { WE_SET_AP_WPS_IE,
11279 IW_PRIV_TYPE_CHAR| 512,
11280 0,
11281 "set_ap_wps_ie" },
11282
11283 { WE_SET_CONFIG,
11284 IW_PRIV_TYPE_CHAR| 512,
11285 0,
11286 "setConfig" },
11287
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053011288 { WE_SET_ENCRYPT_MSG,
11289 IW_PRIV_TYPE_CHAR| 512,
11290 0,
11291 "encryptMsg" },
11292
11293
Jeff Johnson295189b2012-06-20 16:38:30 -070011294 /* handlers for main ioctl */
11295 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
11296 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11297 0,
11298 "" },
11299
11300 /* handlers for sub-ioctl */
11301 { WE_SET_WLAN_DBG,
11302 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11303 0,
11304 "setwlandbg" },
11305
Jeff Johnson295189b2012-06-20 16:38:30 -070011306 { WE_SET_WDI_DBG,
11307 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11308 0,
11309 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011310
11311 { WE_SET_SAP_CHANNELS,
11312 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11313 0,
11314 "setsapchannels" },
11315
11316 /* handlers for main ioctl */
11317 { WLAN_PRIV_GET_CHAR_SET_NONE,
11318 0,
11319 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11320 "" },
11321
11322 /* handlers for sub-ioctl */
11323 { WE_WLAN_VERSION,
11324 0,
11325 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11326 "version" },
11327 { WE_GET_STATS,
11328 0,
11329 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11330 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011331 { WE_GET_STATES,
11332 0,
11333 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11334 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011335 { WE_GET_CFG,
11336 0,
11337 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11338 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070011339#ifdef WLAN_FEATURE_11AC
11340 { WE_GET_RSSI,
11341 0,
11342 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11343 "getRSSI" },
11344#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011345#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011346 { WE_GET_ROAM_RSSI,
11347 0,
11348 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11349 "getRoamRSSI" },
11350#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011351 { WE_GET_WMM_STATUS,
11352 0,
11353 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11354 "getWmmStatus" },
11355 {
11356 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011357 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011358 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11359 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080011360#ifdef FEATURE_WLAN_TDLS
11361 {
11362 WE_GET_TDLS_PEERS,
11363 0,
11364 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11365 "getTdlsPeers" },
11366#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011367#ifdef WLAN_FEATURE_11W
11368 {
11369 WE_GET_11W_INFO,
11370 0,
11371 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11372 "getPMFInfo" },
11373#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011374#ifdef WLAN_FEATURE_RMC
11375 {
11376 WE_GET_IBSS_STA_INFO,
11377 0,
11378 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11379 "getIbssSTAs" },
11380#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053011381 { WE_GET_SNR,
11382 0,
11383 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11384 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053011385#ifdef FEATURE_OEM_DATA_SUPPORT
11386 {
11387 WE_GET_OEM_DATA_CAP,
11388 0,
11389 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11390 "getOemDataCap" },
11391#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070011392 /* handlers for main ioctl */
11393 { WLAN_PRIV_SET_NONE_GET_NONE,
11394 0,
11395 0,
11396 "" },
11397
11398 /* handlers for sub-ioctl */
11399 { WE_CLEAR_STATS,
11400 0,
11401 0,
11402 "clearStats" },
11403 { WE_INIT_AP,
11404 0,
11405 0,
11406 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011407#ifdef WLAN_FEATURE_RMC
11408 {
11409 WE_IBSS_GET_PEER_INFO_ALL,
11410 0,
11411 0,
11412 "ibssPeerInfoAll" },
11413#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011414 { WE_STOP_AP,
11415 0,
11416 0,
11417 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011418#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 { WE_ENABLE_AMP,
11420 0,
11421 0,
11422 "enableAMP" },
11423 { WE_DISABLE_AMP,
11424 0,
11425 0,
11426 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011427#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070011428 { WE_ENABLE_DXE_STALL_DETECT,
11429 0,
11430 0,
11431 "dxeStallDetect" },
11432 { WE_DISPLAY_DXE_SNAP_SHOT,
11433 0,
11434 0,
11435 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053011436 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
11437 0,
11438 0,
11439 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070011440 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053011441 WE_SET_REASSOC_TRIGGER,
11442 0,
11443 0,
11444 "reassoc" },
11445 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053011446 WE_STOP_OBSS_SCAN,
11447 0,
11448 0,
11449 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053011450 {
11451 WE_DUMP_ROAM_TIMER_LOG,
11452 0,
11453 0,
11454 "dumpRoamDelay" },
11455 {
11456 WE_RESET_ROAM_TIMER_LOG,
11457 0,
11458 0,
11459 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011460 {
11461 WE_GET_FW_LOGS,
11462 0,
11463 0,
11464 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011465 {
11466 WE_GET_FW_MEMDUMP,
11467 0,
11468 0,
11469 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011470 /* handlers for main ioctl */
11471 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11472 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11473 0,
11474 "" },
11475
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011476
11477
Jeff Johnson295189b2012-06-20 16:38:30 -070011478 /* handlers for sub-ioctl */
11479 { WE_LOG_DUMP_CMD,
11480 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11481 0,
11482 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011483#ifdef WLAN_FEATURE_RMC
11484 { WE_IBSS_GET_PEER_INFO,
11485 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11486 0,
11487 "ibssPeerInfo" },
11488#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011489
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011490 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011491 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11492 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11493 0,
11494 "setdumplog" },
11495
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011496 { WE_MTRACE_DUMP_CMD,
11497 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11498 0,
11499 "dumplog" },
11500
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011501 /* handlers for sub ioctl */
11502 {
11503 WE_MCC_CONFIG_CREDENTIAL,
11504 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11505 0,
11506 "setMccCrdnl" },
11507
11508 /* handlers for sub ioctl */
11509 {
11510 WE_MCC_CONFIG_PARAMS,
11511 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11512 0,
11513 "setMccConfig" },
11514
Chilam NG571c65a2013-01-19 12:27:36 +053011515#ifdef FEATURE_WLAN_TDLS
11516 /* handlers for sub ioctl */
11517 {
11518 WE_TDLS_CONFIG_PARAMS,
11519 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11520 0,
11521 "setTdlsConfig" },
11522#endif
11523
Katya Nigamf0511f62015-05-05 16:40:57 +053011524 {
11525 WE_CONFIGURE_MONITOR_MODE,
11526 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11527 0,
11528 "MonitorModeConf" },
11529
11530 {
11531 WE_SET_MONITOR_MODE_FILTER,
11532 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11533 0,
11534 "MonitorFilter" },
11535
Jeff Johnson295189b2012-06-20 16:38:30 -070011536 /* handlers for main ioctl */
11537 { WLAN_PRIV_ADD_TSPEC,
11538 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11539 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11540 "addTspec" },
11541
11542 /* handlers for main ioctl */
11543 { WLAN_PRIV_DEL_TSPEC,
11544 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11545 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11546 "delTspec" },
11547
11548 /* handlers for main ioctl */
11549 { WLAN_PRIV_GET_TSPEC,
11550 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11551 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11552 "getTspec" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011553 /* handlers for main ioctl */
11554 { WLAN_PRIV_SET_NONE_GET_THREE_INT,
11555 0,
11556 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11557 "" },
11558#ifdef WLAN_FEATURE_TSF
11559 { WE_GET_TSF,
11560 0,
11561 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11562 "get_tsf" },
11563#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011564#ifdef FEATURE_OEM_DATA_SUPPORT
11565 /* handlers for main ioctl - OEM DATA */
11566 {
11567 WLAN_PRIV_SET_OEM_DATA_REQ,
11568 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11569 0,
11570 "set_oem_data_req" },
11571
11572 /* handlers for main ioctl - OEM DATA */
11573 {
11574 WLAN_PRIV_GET_OEM_DATA_RSP,
11575 0,
11576 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11577 "get_oem_data_rsp" },
11578#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011579
Jeff Johnson295189b2012-06-20 16:38:30 -070011580 /* handlers for main ioctl - host offload */
11581 {
11582 WLAN_PRIV_SET_HOST_OFFLOAD,
11583 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11584 0,
11585 "setHostOffload" },
11586
11587 {
11588 WLAN_GET_WLAN_STATISTICS,
11589 0,
11590 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11591 "getWlanStats" },
11592
11593 {
11594 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011595 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11596 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011597 0,
11598 "setKeepAlive" },
11599#ifdef WLAN_FEATURE_PACKET_FILTERING
11600 {
11601 WLAN_SET_PACKET_FILTER_PARAMS,
11602 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11603 0,
11604 "setPktFilter" },
11605#endif
11606#ifdef FEATURE_WLAN_SCAN_PNO
11607 {
11608 WLAN_SET_PNO,
11609 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11610 0,
11611 "setpno" },
11612#endif
11613 {
11614 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011615 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011616 0,
11617 "SETBAND" },
11618 /* handlers for dynamic MC BC ioctl */
11619 {
11620 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011621 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011622 0,
11623 "setMCBCFilter" },
11624 {
11625 WLAN_PRIV_CLEAR_MCBC_FILTER,
11626 0,
11627 0,
11628 "clearMCBCFilter" },
11629 {
11630 WLAN_SET_POWER_PARAMS,
11631 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11632 0,
11633 "setpowerparams" },
11634 {
11635 WLAN_GET_LINK_SPEED,
11636 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011637 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Nishank Aggarwal87a36882017-07-11 15:28:27 +053011638 {
11639 WLAN_PRIV_SET_FTIES,
11640 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
11641 0, "set_ft_ies"},
Jeff Johnson295189b2012-06-20 16:38:30 -070011642};
11643
11644
11645
11646const struct iw_handler_def we_handler_def = {
11647 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11648 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11649 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11650
11651 .standard = (iw_handler *)we_handler,
11652 .private = (iw_handler *)we_private,
11653 .private_args = we_private_args,
11654 .get_wireless_stats = get_wireless_stats,
11655};
11656
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053011657const struct iw_handler_def we_mon_handler_def = {
11658 .num_standard = 0,
11659 .num_private = sizeof(we_mon_private) / sizeof(we_mon_private[0]),
11660 .num_private_args =
11661 sizeof(we_mon_private_args) / sizeof(we_mon_private_args[0]),
11662 .standard = NULL,
11663 .private = (iw_handler *)we_mon_private,
11664 .private_args = we_mon_private_args,
11665 .get_wireless_stats = NULL,
11666};
11667
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011668int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11669{
11670 v_U32_t cmd = 288; //Command to RIVA
11671 hdd_context_t *pHddCtx = NULL;
11672 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11673 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11674 /*
11675 *configMccParam : specify the bit which needs to be modified
11676 *allowed to update based on wlan_qcom_cfg.ini
11677 * configuration
11678 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11679 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11680 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11681 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11682 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11683 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11684 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11685 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11686 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11687 * Bit 9 : Reserved
11688 */
11689 switch (arg1)
11690 {
11691 //Update MCC SCHEDULE_TIME_SLICE parameter
11692 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11693 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11694 {
11695 if((arg2 >= 5) && (arg2 <= 20))
11696 {
11697 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11698 }
11699 else
11700 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011701 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011702 return 0;
11703 }
11704 }
11705 break;
11706
11707 //Update MCC MAX_NULL_SEND_TIME parameter
11708 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11709 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11710 {
11711 if((arg2 >= 1) && (arg2 <= 10))
11712 {
11713 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11714 }
11715 else
11716 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011717 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011718 return 0;
11719 }
11720 }
11721 break;
11722
11723 //Update MCC TX_EARLY_STOP_TIME parameter
11724 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11725 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11726 {
11727 if((arg2 >= 1) && (arg2 <= 10))
11728 {
11729 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11730 }
11731 else
11732 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011733 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011734 return 0;
11735 }
11736 }
11737 break;
11738
11739 //Update MCC RX_DRAIN_TIME parameter
11740 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11741 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11742 {
11743 if((arg2 >= 1) && (arg2 <= 10))
11744 {
11745 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11746 }
11747 else
11748 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011749 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011750 return 0;
11751 }
11752 }
11753 break;
11754
11755 //Update MCC CHANNEL_SWITCH_TIME parameter
11756 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11757 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11758 {
11759 if((arg2 >= 1) && (arg2 <= 20))
11760 {
11761 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11762 }
11763 else
11764 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011765 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011766 return 0;
11767 }
11768 }
11769 break;
11770
11771 //Update MCC MIN_CHANNEL_TIME parameter
11772 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11773 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11774 {
11775 if((arg2 >= 5) && (arg2 <= 20))
11776 {
11777 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11778 }
11779 else
11780 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011781 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011782 return 0;
11783 }
11784 }
11785 break;
11786
11787 //Update MCC PARK_BEFORE_TBTT parameter
11788 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11789 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11790 {
11791 if((arg2 >= 1) && (arg2 <= 5))
11792 {
11793 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11794 }
11795 else
11796 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011797 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011798 return 0;
11799 }
11800 }
11801 break;
11802
11803 //Update MCC MIN_AFTER_DTIM parameter
11804 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11805 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11806 {
11807 if((arg2 >= 5) && (arg2 <= 15))
11808 {
11809 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11810 }
11811 else
11812 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011813 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011814 return 0;
11815 }
11816 }
11817 break;
11818
11819 //Update MCC TOO_CLOSE_MARGIN parameter
11820 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11821 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11822 {
11823 if((arg2 >= 1) && (arg2 <= 3))
11824 {
11825 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11826 }
11827 else
11828 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011829 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011830 return 0;
11831 }
11832 }
11833 break;
11834
11835 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011836 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011837 __FUNCTION__,arg1);
11838 break;
11839 }
11840 return 0;
11841}
11842
Jeff Johnson295189b2012-06-20 16:38:30 -070011843int hdd_set_wext(hdd_adapter_t *pAdapter)
11844{
11845 hdd_wext_state_t *pwextBuf;
11846 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011847 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011848
11849 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11850
11851 // Now configure the roaming profile links. To SSID and bssid.
11852 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11853 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11854
11855 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11856 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11857
11858 /*Set the numOfChannels to zero to scan all the channels*/
11859 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11860 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11861
11862 /* Default is no encryption */
11863 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11864 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11865
11866 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11867 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11868
11869 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11870
11871 /* Default is no authentication */
11872 pwextBuf->roamProfile.AuthType.numEntries = 1;
11873 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11874
11875 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11876 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11877
11878 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011879 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011880
11881 hdd_clearRoamProfileIe(pAdapter);
11882
11883 return VOS_STATUS_SUCCESS;
11884
11885 }
11886
11887int hdd_register_wext(struct net_device *dev)
11888 {
11889 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11890 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11891 VOS_STATUS status;
11892
11893 ENTER();
11894
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053011895 if (pAdapter->device_mode == WLAN_HDD_MONITOR &&
11896 hdd_get_conparam() != VOS_MONITOR_MODE) {
11897 // Register as a wireless device
11898 dev->wireless_handlers = (struct iw_handler_def *)&we_mon_handler_def;
11899 return 0;
11900 }
11901
Jeff Johnson295189b2012-06-20 16:38:30 -070011902 // Zero the memory. This zeros the profile structure.
11903 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11904
11905 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11906
11907
11908 status = hdd_set_wext(pAdapter);
11909
11910 if(!VOS_IS_STATUS_SUCCESS(status)) {
11911
Arif Hussain6d2a3322013-11-17 19:50:10 -080011912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011913 return eHAL_STATUS_FAILURE;
11914 }
11915
11916 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11917 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 return eHAL_STATUS_FAILURE;
11920 }
11921
11922 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11923 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011925 return eHAL_STATUS_FAILURE;
11926 }
11927
11928 // Register as a wireless device
11929 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11930
11931 EXIT();
11932 return 0;
11933}
11934
11935int hdd_UnregisterWext(struct net_device *dev)
11936{
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070011937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %pK", __func__, dev);
c_hpothu2a13bc32015-01-21 12:48:54 +053011938 if (dev != NULL)
11939 {
11940 rtnl_lock();
11941 dev->wireless_handlers = NULL;
11942 rtnl_unlock();
11943 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011944
Jeff Johnson295189b2012-06-20 16:38:30 -070011945 return 0;
11946}
11947
11948