blob: 1bb4e182d3c9eb73f1eff897f64705bf01722460 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Yeshwanth Sriram Guntuka88566212019-04-17 15:02:33 +05302 * Copyright (c) 2011-2019 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
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
Jeff Johnson295189b2012-06-20 16:38:30 -0700429/**---------------------------------------------------------------------------
430
Arif Hussain0273cba2014-01-07 20:58:29 -0800431 \brief mem_alloc_copy_from_user_helper -
432
433 Helper function to allocate buffer and copy user data.
434
435 \param - wrqu - Pointer to IOCTL Data.
436 len - size
437
438 \return - On Success pointer to buffer, On failure NULL
439
440 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530441void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800442{
443 u8 *ptr = NULL;
444
445 /* in order to protect the code, an extra byte is post appended to the buffer
446 * and the null termination is added. However, when allocating (len+1) byte
447 * of memory, we need to make sure that there is no uint overflow when doing
448 * addition. In theory check len < UINT_MAX protects the uint overflow. For
449 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
450 * guess, now, it is assumed that the private command buffer size is no
451 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
452 */
453 if (len > MAX_USER_COMMAND_SIZE)
454 {
455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
456 "Invalid length");
457 return NULL;
458 }
459
460 ptr = kmalloc(len + 1, GFP_KERNEL);
461 if (NULL == ptr)
462 {
463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
464 "unable to allocate memory");
465 return NULL;
466 }
467
468 if (copy_from_user(ptr, wrqu_data, len))
469 {
470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
471 "%s: failed to copy data to user buffer", __func__);
472 kfree(ptr);
473 return NULL;
474 }
475 ptr[len] = '\0';
476 return ptr;
477}
478
Girish Gowli488ef492014-06-12 18:44:33 +0530479// Function to handle and get compatible struct iw_point passed to ioctl.
480int hdd_priv_get_data(struct iw_point *p_priv_data,
481 union iwreq_data *wrqu)
482{
483 if ((NULL == p_priv_data) || (NULL == wrqu))
484 {
485 return -EINVAL;
486 }
487
488#ifdef CONFIG_COMPAT
489 if (is_compat_task())
490 {
491 struct compat_iw_point *p_compat_priv_data;
492
493 // Compat task: typecast to campat structure and copy the members.
494 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
495
496 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
497 p_priv_data->length = p_compat_priv_data->length;
498 p_priv_data->flags = p_compat_priv_data->flags;
499 }//if(is_compat_task())
500 else
501 {
502#endif //#ifdef CONFIG_COMPAT
503
504 // Non compat task: directly copy the structure.
505 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
506
507#ifdef CONFIG_COMPAT
508 }//else of - if(is_compat_task())
509#endif //#ifdef CONFIG_COMPAT
510
511 return 0;
512}
513
Arif Hussain0273cba2014-01-07 20:58:29 -0800514/**---------------------------------------------------------------------------
515
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 \brief hdd_wlan_get_version() -
517
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800518 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700519
520 \param - pAdapter Pointer to the adapter.
521 wrqu - Pointer to IOCTL REQUEST Data.
522 extra - Pointer to char
523
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800524 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700525
526 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800527void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
528 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700529{
530 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800531 tSirVersionString wcnss_SW_version;
532 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530533 tSirVersionString iris_name;
534 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800535 char *pSWversion;
536 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700538
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800539 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
540 sizeof(wcnss_SW_version));
541 if (VOS_IS_STATUS_SUCCESS(status))
542 {
543 pSWversion = wcnss_SW_version;
544 }
545 else
546 {
547 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 }
549
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800550 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
551 sizeof(wcnss_HW_version));
552 if (VOS_IS_STATUS_SUCCESS(status))
553 {
554 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800556 else
557 {
558 pHWversion = "Unknown";
559 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700560
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530561 status = wcnss_get_iris_name(iris_name);
562
563 if (!status) {
564 pIRISversion = iris_name;
565 } else {
566 pIRISversion = "Unknown";
567 }
568
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700569 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530570 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800571 QWLAN_VERSIONSTR,
572 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530573 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800574
575 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700576}
577
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530578#ifdef WLAN_FEATURE_RMC
579void hdd_get_ibss_peer_info_cb(v_VOID_t *pUserData, v_VOID_t *pPeerInfoRsp)
580{
581 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pUserData;
582 tSirPeerInfoRspParams *pPeerInfo = (tSirPeerInfoRspParams *)pPeerInfoRsp;
583 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
584 v_U8_t i;
585
586 if (NULL != pPeerInfo && eHAL_STATUS_SUCCESS == pPeerInfo->status)
587 {
588 pStaCtx->ibss_peer_info.status = pPeerInfo->status;
589 pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numPeers;
590 for (i = 0; i < pPeerInfo->numPeers; i++)
591 {
592 memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i],
593 &pPeerInfo->peerInfoParams[i], sizeof(hdd_ibss_peer_info_params_t));
594 }
595 }
596 else
597 {
598 hddLog(LOGE,
599 FL("PEER_INFO_CMD_STATUS is not SUCCESS"));
600 }
601
602 complete(&pAdapter->ibss_peer_info_comp);
603}
604
605v_MACADDR_t* hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter, v_U8_t staIdx)
606{
607 v_U8_t idx;
608 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
609
610 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
611 {
612 if ( 0 != pHddStaCtx->conn_info.staId[ idx ] &&
613 staIdx == pHddStaCtx->conn_info.staId[ idx ])
614 {
615 return (&pHddStaCtx->conn_info.peerMacAddress[ idx ]);
616 }
617 }
618 return NULL;
619}
620
621eHalStatus hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter, v_U8_t staIdx)
622{
623 eHalStatus status = eHAL_STATUS_FAILURE;
624 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
625 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
626 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
627
628 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
629 VOS_FALSE, staIdx);
630
631 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
632
633 if (eHAL_STATUS_SUCCESS == status)
634 {
635 long ret;
636 ret = wait_for_completion_interruptible_timeout
637 (&pAdapter->ibss_peer_info_comp,
638 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
639 if (ret <= 0)
640 {
641 hddLog(VOS_TRACE_LEVEL_ERROR,
642 FL("failed wait on ibss_peer_info_comp %ld"), ret);
643 return eHAL_STATUS_FAILURE;
644 }
645
646 /** Print the peer info */
647 pr_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numIBSSPeers);
648 pr_info("============================================================");
649 {
650 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
651 staIdx);
652 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
653
654 if (NULL != macAddr)
655 {
656 pr_info("PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
657 MAC_ADDR_ARRAY(macAddr->bytes),
658 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[0].rssi);
659 }
660 else
661 {
662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
663 " ERROR: PEER MAC ADDRESS NOT FOUND ");
664 }
665 }
666 }
667 else
668 {
669 hddLog(VOS_TRACE_LEVEL_WARN,
670 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
671 }
672
673 return status;
674}
675
676eHalStatus hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
677{
678 eHalStatus status = eHAL_STATUS_FAILURE;
679 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
680 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
681 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
682 int i;
683
684 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
685 VOS_TRUE, 0xFF);
686 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
687
688 if (eHAL_STATUS_SUCCESS == status)
689 {
690 long ret;
691 ret = wait_for_completion_interruptible_timeout
692 (&pAdapter->ibss_peer_info_comp,
693 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
694 if (ret <= 0)
695 {
696 hddLog(VOS_TRACE_LEVEL_ERROR,
697 FL("failed wait on ibss_peer_info_comp %ld"), ret);
698 return eHAL_STATUS_FAILURE;
699 }
700
701 /** Print the peer info */
702 pr_info("pPeerInfo->numIBSSPeers = %d ", (int)pPeerInfo->numIBSSPeers);
703 pr_info("============================================================");
704 for (i = 0; i < pPeerInfo->numIBSSPeers; i++)
705 {
706 v_U8_t staIdx = pPeerInfo->ibssPeerList[i].staIdx;
707 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
708 staIdx);
709 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
710
711 pr_info("STAIDX:%d ", (int)pPeerInfo->ibssPeerList[i].staIdx);
712 if (NULL != macAddr)
713 {
714 pr_info(" PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
715 MAC_ADDR_ARRAY(macAddr->bytes),
716 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[i].rssi);
717 }
718 else
719 {
720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
721 " ERROR: PEER MAC ADDRESS NOT FOUND ");
722 }
723 }
724 }
725 else
726 {
727 hddLog(VOS_TRACE_LEVEL_WARN,
728 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
729 }
730
731 return status;
732}
733#endif /* WLAN_FEATURE_RMC */
734
Jeff Johnson295189b2012-06-20 16:38:30 -0700735int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
736{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530737 tHalHandle hHal;
738 hdd_context_t *pHddCtx;
739 v_U32_t threshold = 0;
740 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700741
742 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530743 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530744 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
746 "%s: Adapter is NULL",__func__);
747 return -EINVAL;
748 }
749
750 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
751 ret = wlan_hdd_validate_context(pHddCtx);
752 if (0 != ret)
753 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530754 return ret;
755 }
756
757 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
758 if (NULL == hHal)
759 {
760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
761 "%s: Hal Context is NULL",__func__);
762 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 }
764
765 if ( eHAL_STATUS_SUCCESS !=
766 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
767 {
c_hpothub8245442013-11-20 23:41:09 +0530768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
769 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 return -EIO;
771 }
772 wrqu->rts.value = threshold;
773
774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800775 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700776
777 EXIT();
778
779 return 0;
780}
781
782int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
783{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530784 tHalHandle hHal;
785 hdd_context_t *pHddCtx;
786 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700787
788 ENTER();
789
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530790 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530791 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
793 "%s: Adapter is NULL",__func__);
794 return -EINVAL;
795 }
796
797 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
798 status = wlan_hdd_validate_context(pHddCtx);
799 if (0 != status)
800 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530801 return status;
802 }
803
804 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
805 if (NULL == hHal)
806 {
807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
808 "%s: Hal Context is NULL",__func__);
809 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 }
811
812 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
813 != eHAL_STATUS_SUCCESS )
814 {
c_hpothub8245442013-11-20 23:41:09 +0530815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
816 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 return -EIO;
818 }
819 wrqu->frag.value = threshold;
820
821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800822 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700823
824 EXIT();
825
826 return 0;
827}
828
829int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
830{
Jeff Johnsone7245742012-09-05 17:12:55 -0700831 int i;
832 if (channel > 0)
833 {
834 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
835 {
836 if (channel == freq_chan_map[i].chan)
837 {
838 *pfreq = freq_chan_map[i].freq;
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +0530839 return 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700840 }
841 }
842 }
843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800844 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700845 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700846}
847
848static v_BOOL_t
849hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
850{
851 v_BOOL_t rsnType = VOS_FALSE;
852 // is the authType supported?
853 switch (authType)
854 {
855 case eCSR_AUTH_TYPE_NONE: //never used
856 rsnType = eANI_BOOLEAN_FALSE;
857 break;
858 // MAC layer authentication types
859 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
860 rsnType = eANI_BOOLEAN_FALSE;
861 break;
862 case eCSR_AUTH_TYPE_SHARED_KEY:
863 rsnType = eANI_BOOLEAN_FALSE;
864 break;
865 case eCSR_AUTH_TYPE_AUTOSWITCH:
866 rsnType = eANI_BOOLEAN_FALSE;
867 break;
868
869 // Upper layer authentication types
870 case eCSR_AUTH_TYPE_WPA:
871 rsnType = eANI_BOOLEAN_TRUE;
872 break;
873 case eCSR_AUTH_TYPE_WPA_PSK:
874 rsnType = eANI_BOOLEAN_TRUE;
875 break;
876 case eCSR_AUTH_TYPE_WPA_NONE:
877 rsnType = eANI_BOOLEAN_TRUE;
878 break;
879#ifdef WLAN_FEATURE_VOWIFI_11R
880 case eCSR_AUTH_TYPE_FT_RSN:
881#endif
882 case eCSR_AUTH_TYPE_RSN:
883 rsnType = eANI_BOOLEAN_TRUE;
884 break;
885#ifdef WLAN_FEATURE_VOWIFI_11R
886 case eCSR_AUTH_TYPE_FT_RSN_PSK:
887#endif
888 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700889#ifdef WLAN_FEATURE_11W
890 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530891 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700892#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 rsnType = eANI_BOOLEAN_TRUE;
894 break;
895 //case eCSR_AUTH_TYPE_FAILED:
896 case eCSR_AUTH_TYPE_UNKNOWN:
897 rsnType = eANI_BOOLEAN_FALSE;
898 break;
899 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800900 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
901 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 rsnType = eANI_BOOLEAN_FALSE;
903 break;
904 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800905 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700906 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 return rsnType;
908}
909
Jeff Johnson295189b2012-06-20 16:38:30 -0700910
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530911struct snr_priv {
912 int8_t snr;
913};
914
915/**
916 * hdd_get_snr_cb() - "Get SNR" callback function
917 * @snr: Current SNR of the station
918 * @sta_id: ID of the station
919 * @context: opaque context originally passed to SME. HDD always passes
920 * a cookie for the request context
921 *
922 * Return: None
923 */
924static void hdd_get_snr_cb(tANI_S8 snr, tANI_U32 staId, void *context)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530925{
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530926 struct hdd_request *request;
927 struct snr_priv *priv;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530928
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530929 request = hdd_request_get(context);
930 if (!request) {
931 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
932 return;
933 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530934
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530935 /* propagate response back to requesting thread */
936 priv = hdd_request_priv(request);
937 priv->snr = snr;
938 hdd_request_complete(request);
939 hdd_request_put(request);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530940}
941
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +0530942struct rssi_priv {
943 v_S7_t rssi;
944};
945
946static void hdd_get_rssi_cb( v_S7_t rssi, tANI_U32 staId, void *context )
947{
948 struct hdd_request *request;
949 struct rssi_priv *priv;
950
951 if (ioctl_debug) {
952 pr_info("%s: rssi [%d] STA [%d] context [%pK]\n",
953 __func__, (int)rssi, (int)staId, context);
954 }
955
956 request = hdd_request_get(context);
957 if (!request) {
958 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
959 return;
960 }
961
962 priv = hdd_request_priv(request);
963 priv->rssi = rssi;
964
965 hdd_request_complete(request);
966 hdd_request_put(request);
967}
968
Jeff Johnson295189b2012-06-20 16:38:30 -0700969VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
970{
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 hdd_context_t *pHddCtx;
972 hdd_station_ctx_t *pHddStaCtx;
973 eHalStatus hstatus;
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +0530974 int ret;
975 void *cookie;
976 struct hdd_request *request;
977 struct rssi_priv *priv;
978 static const struct hdd_request_params params = {
979 .priv_size = sizeof(*priv),
980 .timeout_ms = WLAN_WAIT_TIME_STATS,
981 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700982
983 if (NULL == pAdapter)
984 {
985 hddLog(VOS_TRACE_LEVEL_WARN,
986 "%s: Invalid context, pAdapter", __func__);
987 return VOS_STATUS_E_FAULT;
988 }
989 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
990 {
991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
992 /* return a cached value */
993 *rssi_value = pAdapter->rssi;
994 return VOS_STATUS_SUCCESS;
995 }
996
997 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
998 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
999
mukul sharma8aec69b2015-06-10 22:28:43 +05301000 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1001 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
1003 __func__, pAdapter->rssi_on_disconnect);
1004 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +05301005 return VOS_STATUS_SUCCESS;
1006 }
1007
1008 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1009 {
1010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1011 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1012 *rssi_value = pAdapter->rssi;
1013 return VOS_STATUS_SUCCESS;
1014 }
1015
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301016 request = hdd_request_alloc(&params);
1017 if (!request) {
1018 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1019 return VOS_STATUS_E_NOMEM;
1020 }
1021 cookie = hdd_request_cookie(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07001022
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301023 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_get_rssi_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 pHddStaCtx->conn_info.staId[ 0 ],
1025 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301026 cookie, pHddCtx->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 if (eHAL_STATUS_SUCCESS != hstatus)
1028 {
1029 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001030 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 /* we'll returned a cached value below */
1032 }
1033 else
1034 {
1035 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301036 ret = hdd_request_wait_for_response(request);
1037 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 {
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301039 hddLog(VOS_TRACE_LEVEL_ERROR,
1040 FL("SME timeout while retrieving RSSI"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 /* we'll now returned a cached value below */
1042 }
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301043 else
1044 {
1045 priv = hdd_request_priv(request);
1046 pAdapter->rssi = priv->rssi;
1047 /*
1048 * copy over the rssi.FW will return RSSI as -100 if
1049 * there are no samples to calculate the averag RSSI
1050 */
1051 if (priv->rssi != -100)
1052 pAdapter->rssi = priv->rssi;
Jeff Johnson72a40512013-12-19 10:14:15 -08001053
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301054 if (pAdapter->rssi > 0)
1055 pAdapter->rssi = 0;
1056 }
1057 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001058
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 *rssi_value = pAdapter->rssi;
Rajeev Kumar Sirasanagandla4819c182016-11-28 22:25:48 +05301060 hddLog(VOS_TRACE_LEVEL_INFO,
1061 "%s: RSSI = %d", __func__, *rssi_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07001062
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301063 /*
1064 * either we never sent a request, we sent a request and received a
1065 * response or we sent a request and timed out. Regardless we are
1066 * done with the request.
1067 */
1068 hdd_request_put(request);
1069
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 return VOS_STATUS_SUCCESS;
1071}
Siddharth Bhal64246172015-02-27 01:04:37 +05301072/**---------------------------------------------------------------------------
1073
1074 \brief wlan_hdd_get_frame_logs() -
1075
1076 This function use to get Frames log.
1077
1078 \param - pAdapter Pointer to the adapter.
1079 flag - Specify type of request. Clear and Send request are
1080 supported.
1081
1082 \return - none
1083
1084 --------------------------------------------------------------------------*/
1085VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
1086{
Siddharth Bhal64246172015-02-27 01:04:37 +05301087 hdd_context_t *pHddCtx;
1088 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +05301089
1090 if (NULL == pAdapter)
1091 {
1092 hddLog(VOS_TRACE_LEVEL_WARN,
1093 "%s: Invalid context, pAdapter", __func__);
1094 return VOS_STATUS_E_FAULT;
1095 }
1096
1097 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1098 if (!pHddCtx->mgmt_frame_logging)
1099 {
Abhishek Singha7d80b12016-02-03 15:27:20 +05301100 hddLog(LOGW, FL("Frame Logging not init!"));
Siddharth Bhal64246172015-02-27 01:04:37 +05301101 return VOS_STATUS_E_AGAIN;
1102 }
1103
Siddharth Bhal4507c262015-04-29 20:20:42 +05301104 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
1105 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
1106 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +05301107 {
1108 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
1109 return VOS_STATUS_E_INVAL;
1110 }
1111
Siddharth Bhal4507c262015-04-29 20:20:42 +05301112 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
1113 (!pHddCtx->cfg_ini->enableBMUHWtracing))
1114 {
1115 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
1116 return VOS_STATUS_E_INVAL;
1117 }
1118
Abhishek Singh611295e2015-07-09 11:11:54 +05301119 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +05301120 if (eHAL_STATUS_SUCCESS != hstatus)
1121 {
1122 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +05301123 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +05301124 }
Siddharth Bhal64246172015-02-27 01:04:37 +05301125
1126 return VOS_STATUS_SUCCESS;
1127}
1128
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301129
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301130VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1131{
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301132 hdd_context_t *pHddCtx;
1133 hdd_station_ctx_t *pHddStaCtx;
1134 eHalStatus hstatus;
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301135 int ret;
1136 void *cookie;
1137 struct hdd_request *request;
1138 struct snr_priv *priv;
1139 static const struct hdd_request_params params = {
1140 .priv_size = sizeof(*priv),
1141 .timeout_ms = WLAN_WAIT_TIME_STATS,
1142 };
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301143
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301144 ENTER();
1145
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301146 if (NULL == pAdapter)
1147 {
1148 hddLog(VOS_TRACE_LEVEL_ERROR,
1149 "%s: Invalid context, pAdapter", __func__);
1150 return VOS_STATUS_E_FAULT;
1151 }
1152
1153 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1154
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301155 ret = wlan_hdd_validate_context(pHddCtx);
1156 if (0 != ret)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301157 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301158 return VOS_STATUS_E_FAULT;
1159 }
1160
1161 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1162 if (NULL == pHddStaCtx)
1163 {
1164 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1165 return VOS_STATUS_E_FAULT;
1166 }
1167
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301168 request = hdd_request_alloc(&params);
1169 if (!request) {
1170 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1171 return VOS_STATUS_E_FAULT;
1172 }
1173 cookie = hdd_request_cookie(request);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301174
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301175 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_get_snr_cb,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301176 pHddStaCtx->conn_info.staId[ 0 ],
1177 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301178 cookie);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301179 if (eHAL_STATUS_SUCCESS != hstatus)
1180 {
1181 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1182 __func__);
1183 /* we'll returned a cached value below */
1184 }
1185 else
1186 {
1187 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301188 ret = hdd_request_wait_for_response(request);
1189 if (ret) {
1190 hddLog(VOS_TRACE_LEVEL_ERROR,
1191 FL("SME timed out while retrieving SNR"));
1192 /* we'll now returned a cached value below */
1193 } else {
1194 /* update the adapter with the fresh results */
1195 priv = hdd_request_priv(request);
1196 pAdapter->snr = priv->snr;
1197 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301198 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001199
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301200 /*
1201 * either we never sent a request, we sent a request and
1202 * received a response or we sent a request and timed out.
1203 * regardless we are done with the request.
1204 */
1205 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08001206
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301207 *snr = pAdapter->snr;
1208
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301209 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301210 return VOS_STATUS_SUCCESS;
1211}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301212
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001213#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001214
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001215VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1216{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001217 hdd_context_t *pHddCtx = NULL;
1218 hdd_station_ctx_t *pHddStaCtx = NULL;
1219 eHalStatus hstatus;
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301220 int ret;
1221 void *cookie;
1222 struct hdd_request *request;
1223 struct rssi_priv *priv;
1224 static const struct hdd_request_params params = {
1225 .priv_size = sizeof(*priv),
1226 .timeout_ms = WLAN_WAIT_TIME_STATS,
1227 };
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001228
1229 if (NULL == pAdapter)
1230 {
1231 hddLog(VOS_TRACE_LEVEL_WARN,
1232 "%s: Invalid context, pAdapter", __func__);
1233 return VOS_STATUS_E_FAULT;
1234 }
1235 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1236 {
1237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1238 /* return a cached value */
1239 *rssi_value = pAdapter->rssi;
1240 return VOS_STATUS_SUCCESS;
1241 }
1242
1243 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1244 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1245
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301246 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001247 {
1248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1249 /* return a cached value */
1250 *rssi_value = 0;
1251 return VOS_STATUS_SUCCESS;
1252 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301253
1254 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1255 {
1256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1257 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1258 *rssi_value = pAdapter->rssi;
1259 return VOS_STATUS_SUCCESS;
1260 }
1261
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301262 request = hdd_request_alloc(&params);
1263 if (!request) {
1264 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1265 return VOS_STATUS_E_NOMEM;
1266 }
1267 cookie = hdd_request_cookie(request);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001268
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301269 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_get_rssi_cb,
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001270 pHddStaCtx->conn_info.staId[ 0 ],
1271 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301272 cookie, pHddCtx->pvosContext);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001273 if (eHAL_STATUS_SUCCESS != hstatus)
1274 {
1275 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1276 __func__);
1277 /* we'll returned a cached value below */
1278 }
1279 else
1280 {
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301281 ret = hdd_request_wait_for_response(request);
1282 if(ret)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001283 /* request was sent -- wait for the response */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001284 {
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301285 hddLog(VOS_TRACE_LEVEL_ERROR,
1286 FL(" SME timeout while retrieving RSSI"));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001287 /* we'll now returned a cached value below */
1288 }
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301289 else
1290 {
1291 priv = hdd_request_priv(request);
1292 pAdapter->rssi = priv->rssi;
1293 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001294 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001295
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301296 /*
1297 * either we never sent a request, we sent a request and received a
1298 * response or we sent a request and timed out. Regardless we are
1299 * done with the request.
1300 */
1301 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08001302
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001303 *rssi_value = pAdapter->rssi;
1304
1305 return VOS_STATUS_SUCCESS;
1306}
1307#endif
1308
1309
Jeff Johnson295189b2012-06-20 16:38:30 -07001310void hdd_StatisticsCB( void *pStats, void *pContext )
1311{
1312 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1313 hdd_stats_t *pStatsCache = NULL;
1314 hdd_wext_state_t *pWextState;
1315 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1316
1317 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1318 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1319 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1320 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1321 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1322 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1323
1324 if (pAdapter!= NULL)
1325 pStatsCache = &pAdapter->hdd_stats;
1326
1327
1328 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1329 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1330 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1331 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1332 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1333 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1334
1335 if (pStatsCache!=NULL)
1336 {
1337 // and copy the stats into the cache we keep in the adapter instance structure
1338 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1339 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1340 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1341 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1342 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1343 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1344 }
1345
1346 if(pAdapter)
1347 {
1348 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1349 if(pWextState)
1350 {
1351 vos_status = vos_event_set(&pWextState->vosevent);
1352 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1353 {
1354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001355 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 return;
1357 }
1358 }
1359 }
1360}
1361
1362void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1363{
1364 v_CONTEXT_t pVosContext;
1365 hdd_context_t *pHddCtx;
1366 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1367#if 0
1368 hdd_wext_state_t *pWextState;
1369 v_U32_t roamId;
1370#endif
1371
1372 ENTER();
1373
1374 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1375
1376 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1377 if (NULL == pHddCtx)
1378 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001379 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 return;
1381 }
1382#if 0
1383 pWextState = pAdapter->pWextState;
1384#endif
1385
1386 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1387 {
1388 //TODO Verify is this is really used. If yes need to fix it.
1389 hdd_reconnect_all_adapters( pHddCtx );
1390#if 0
1391 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1392 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1393 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1394
1395 if(VOS_STATUS_SUCCESS == vosStatus)
1396 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1397 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1398
1399 sme_RoamConnect(halHandle,
1400 pAdapter->sessionId, &(pWextState->roamProfile),
1401 &roamId);
1402#endif
1403 }
1404
1405 EXIT();
1406
1407}
1408
1409void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1410{
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1412
1413 /* clear WPA/RSN/WSC IE information in the profile */
1414 pWextState->roamProfile.nWPAReqIELength = 0;
1415 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1416 pWextState->roamProfile.nRSNReqIELength = 0;
1417 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1418
Chet Lanctot186b5732013-03-18 10:26:30 -07001419#ifdef FEATURE_WLAN_WAPI
1420 pWextState->roamProfile.nWAPIReqIELength = 0;
1421 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1422#endif
1423
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001425 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301427 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1429 pWextState->roamProfile.nAddIEAssocLength = 0;
1430
1431 pWextState->roamProfile.EncryptionType.numEntries = 1;
1432 pWextState->roamProfile.EncryptionType.encryptionType[0]
1433 = eCSR_ENCRYPT_TYPE_NONE;
1434
1435 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1436 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1437 = eCSR_ENCRYPT_TYPE_NONE;
1438
1439 pWextState->roamProfile.AuthType.numEntries = 1;
1440 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1441
Abhishek Singhb3e376c2017-01-04 15:27:13 +05301442 vos_mem_zero((pWextState->roamProfile.bssid_hint), WNI_CFG_BSSID_LEN);
Chet Lanctot186b5732013-03-18 10:26:30 -07001443#ifdef WLAN_FEATURE_11W
1444 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1445 pWextState->roamProfile.MFPRequired = 0;
1446 pWextState->roamProfile.MFPCapable = 0;
1447#endif
1448
Jeff Johnson295189b2012-06-20 16:38:30 -07001449 pWextState->authKeyMgmt = 0;
1450
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301451 vos_mem_zero(&pWextState->roamProfile.Keys,
1452 sizeof(pWextState->roamProfile.Keys));
1453
Jeff Johnson295189b2012-06-20 16:38:30 -07001454#ifdef FEATURE_WLAN_WAPI
1455 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1456 pAdapter->wapi_info.nWapiMode = 0;
1457#endif
1458
1459 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1460
1461}
1462
1463void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1464{
1465 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001466
Nirav Shahf6bd2672015-03-11 12:53:15 +05301467 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001468 {
1469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301470 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001471 }
1472 else
1473 {
1474 complete(&pAdapter->ula_complete);
1475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001476}
1477
1478VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1479{
1480 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001482 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001483
1484 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1485 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001486 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001487
1488 /*To avoid race condition between the set key and the last EAPOL
1489 packet, notify TL to finish upper layer authentication incase if the
1490 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001491 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001492
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001493 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001494 {
1495 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1496 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1497 __LINE__, vos_status );
1498 return vos_status;
1499
1500 }
1501
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001502 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301504 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001505 {
1506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301507 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001508 /* we'll still fall through and return success since the
1509 * connection may still get established but is just taking
1510 * too long for us to wait */
1511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 }
1513 return VOS_STATUS_SUCCESS;
1514}
1515
1516v_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)
1517{
1518
1519 int left = ie_len;
1520 v_U8_t *ptr = ie;
1521 v_U8_t elem_id,elem_len;
1522 v_U8_t eid = 0xDD;
1523
1524 if ( NULL == ie || 0 == ie_len )
1525 return NULL;
1526
1527 while(left >= 2)
1528 {
1529 elem_id = ptr[0];
1530 elem_len = ptr[1];
1531 left -= 2;
1532 if(elem_len > left)
1533 {
1534 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001535 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 eid,elem_len,left);
1537 return NULL;
1538 }
SaidiReddy Yenuga764a9d22017-05-26 18:37:53 +05301539 if ((elem_id == eid) && (elem_len >= oui_size))
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 {
1541 if(memcmp( &ptr[2], oui, oui_size)==0)
1542 return ptr;
1543 }
1544
1545 left -= elem_len;
1546 ptr += (elem_len + 2);
1547 }
1548 return NULL;
1549}
1550
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301551static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 union iwreq_data *wrqu, char *extra)
1553{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301554 hdd_adapter_t *pAdapter;
1555 hdd_context_t *pHddCtx;
1556 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301557
1558 ENTER();
1559
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301560 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1561 if (NULL == pAdapter)
1562 {
1563 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1564 "%s: pAdapter is NULL\n", __func__);
1565 return -EINVAL;
1566 }
1567 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1568 ret = wlan_hdd_validate_context(pHddCtx);
1569 if (0 != ret)
1570 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301571 return ret;
1572 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301573
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301575
1576 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301577 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001578}
1579
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301580static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1581 union iwreq_data *wrqu, char *extra)
1582{
1583 int ret;
1584
1585 vos_ssr_protect(__func__);
1586 ret = __iw_set_commit(dev, info, wrqu, extra);
1587 vos_ssr_unprotect(__func__);
1588
1589 return ret;
1590}
1591
1592static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 struct iw_request_info *info,
1594 char *wrqu, char *extra)
1595{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301596 hdd_adapter_t *pAdapter;
1597 hdd_context_t *pHddCtx;
1598 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301599
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301601 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1602 if (NULL == pAdapter)
1603 {
1604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1605 "%s: pAdapter is NULL\n", __func__);
1606 return -EINVAL;
1607 }
1608 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1609 ret = wlan_hdd_validate_context(pHddCtx);
1610 if (0 != ret)
1611 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301612 return ret;
1613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1615 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301616 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001617}
1618
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301619static int iw_get_name(struct net_device *dev,
1620 struct iw_request_info *info,
1621 char *wrqu, char *extra)
1622{
1623 int ret;
1624
1625 vos_ssr_protect(__func__);
1626 ret = __iw_get_name(dev, info, wrqu, extra);
1627 vos_ssr_unprotect(__func__);
1628
1629 return ret;
1630}
1631
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301632static int __iw_set_freq(struct net_device *dev,
1633 struct iw_request_info *info,
1634 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001635{
1636 v_U32_t numChans = 0;
1637 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1638 v_U32_t indx = 0;
1639 v_U32_t status = 0;
1640
1641 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301642 hdd_adapter_t *pAdapter;
1643 hdd_context_t *pHddCtx;
1644 tHalHandle hHal;
1645 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301647
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 ENTER();
1649
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301650 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1651 if (NULL == pAdapter)
1652 {
1653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1654 "%s:Invalid Adapter",__func__);
1655 return -EINVAL;
1656 }
1657
1658 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1659 status = wlan_hdd_validate_context(pHddCtx);
1660 if (0 != status)
1661 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 return status;
1663 }
1664
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301665 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1666 if (NULL == hHal)
1667 {
1668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1669 "%s: Hal Context is NULL",__func__);
1670 return -EINVAL;
1671 }
1672
1673 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1674 if (NULL == pHddStaCtx)
1675 {
1676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1677 "%s:STA context is NULL",__func__);
1678 return -EINVAL;
1679 }
1680
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301682 if (NULL == pWextState)
1683 {
1684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1685 "%s: pWextState is NULL",__func__);
1686 return -EINVAL;
1687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001688
1689 pRoamProfile = &pWextState->roamProfile;
1690
Arif Hussain6d2a3322013-11-17 19:50:10 -08001691 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001692
1693 /* Link is up then return cant set channel*/
1694 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1695 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1696 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001697 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 return -EOPNOTSUPP;
1699 }
1700
1701 /* Settings by Frequency as input */
1702 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1703 (wrqu->freq.m <= (tANI_U32)5.825e8))
1704 {
1705 tANI_U32 freq = wrqu->freq.m / 100000;
1706
1707 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1708 indx++;
1709 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1710 {
1711 return -EINVAL;
1712 }
1713 wrqu->freq.e = 0;
1714 wrqu->freq.m = freq_chan_map[indx].chan;
1715
1716 }
1717
1718 if (wrqu->freq.e == 0)
1719 {
1720 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1721 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1722 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001723 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001724 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1726 return -EINVAL;
1727 }
1728
1729 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1730
1731 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1732 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1734 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001735 return -EIO;
1736 }
1737
1738 for (indx = 0; indx < numChans; indx++) {
1739 if (wrqu->freq.m == validChan[indx]){
1740 break;
1741 }
1742 }
1743 }
1744 else{
1745
1746 return -EINVAL;
1747 }
1748
1749 if(indx >= numChans)
1750 {
1751 return -EINVAL;
1752 }
1753
1754 /* Set the Operational Channel */
1755 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1756 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1757 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1758
Arif Hussain6d2a3322013-11-17 19:50:10 -08001759 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001760
1761 EXIT();
1762
1763 return status;
1764}
1765
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301766static int iw_set_freq(struct net_device *dev,
1767 struct iw_request_info *info,
1768 union iwreq_data *wrqu, char *extra)
1769{
1770 int ret;
1771
1772 vos_ssr_protect(__func__);
1773 ret = __iw_set_freq(dev, info, wrqu, extra);
1774 vos_ssr_unprotect(__func__);
1775
1776 return ret;
1777}
1778
1779static int __iw_get_freq(struct net_device *dev,
1780 struct iw_request_info *info,
1781 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001782{
Jeff Johnsone7245742012-09-05 17:12:55 -07001783 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301784 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 tHalHandle hHal;
1786 hdd_wext_state_t *pWextState;
1787 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301788 hdd_station_ctx_t *pHddStaCtx;
1789 hdd_context_t *pHddCtx;
1790 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001791
1792 ENTER();
1793
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301794 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1795 if (NULL == pAdapter)
1796 {
1797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1798 "%s: Adapter is NULL", __func__);
1799 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301801 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1802 ret = wlan_hdd_validate_context(pHddCtx);
1803 if (0 != ret)
1804 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301805 return ret;
1806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301808 if (NULL == hHal)
1809 {
1810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1811 "%s: Hal Context is NULL",__func__);
1812 return -EINVAL;
1813 }
1814 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1815 if (NULL == pHddStaCtx)
1816 {
1817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1818 "%s: HddStaCtx is NULL", __func__);
1819 return -EINVAL;
1820 }
1821 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1822 if (NULL == pWextState)
1823 {
1824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1825 "%s: pWextState is NULL",__func__);
1826 return -EINVAL;
1827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 pRoamProfile = &pWextState->roamProfile;
1829
1830 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1831 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001832 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 {
c_hpothub8245442013-11-20 23:41:09 +05301834 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1835 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 return -EIO;
1837 }
1838 else
1839 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001840 status = hdd_wlan_get_freq(channel, &freq);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +05301841 if( 0 == status )
Jeff Johnsone7245742012-09-05 17:12:55 -07001842 {
1843 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1844 * iwlist & iwconfig command shows frequency into proper
1845 * format (2.412 GHz instead of 246.2 MHz)*/
1846 fwrq->m = freq;
1847 fwrq->e = MHZ;
1848 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 }
1850 }
1851 else
1852 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001853 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1854 * iwlist & iwconfig command shows frequency into proper
1855 * format (2.412 GHz instead of 246.2 MHz)*/
1856 fwrq->m = 0;
1857 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301859
1860 EXIT();
1861 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001862}
1863
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301864static int iw_get_freq(struct net_device *dev,
1865 struct iw_request_info *info,
1866 struct iw_freq *fwrq, char *extra)
1867{
1868 int ret;
1869
1870 vos_ssr_protect(__func__);
1871 ret = __iw_get_freq(dev, info, fwrq, extra);
1872 vos_ssr_unprotect(__func__);
1873
1874 return ret;
1875}
1876
1877static int __iw_get_tx_power(struct net_device *dev,
1878 struct iw_request_info *info,
1879 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001880{
1881
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301882 hdd_adapter_t *pAdapter;
1883 hdd_context_t *pHddCtx;
1884 hdd_station_ctx_t *pHddStaCtx;
1885 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001886
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301887 ENTER();
1888
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301889 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1890 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1893 "%s: Adapter is NULL",__func__);
1894 return -EINVAL;
1895 }
1896 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1897 ret = wlan_hdd_validate_context(pHddCtx);
1898 if (0 != ret)
1899 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301900 return ret;
1901 }
1902
1903 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1904 if (NULL == pHddStaCtx)
1905 {
1906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1907 "%s: STA Context is NULL",__func__);
1908 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 }
1910
1911 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1912 {
1913 wrqu->txpower.value = 0;
1914 return 0;
1915 }
1916 wlan_hdd_get_classAstats(pAdapter);
1917 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1918
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301919 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 return 0;
1921}
1922
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301923static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 struct iw_request_info *info,
1925 union iwreq_data *wrqu, char *extra)
1926{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301927 int ret;
1928
1929 vos_ssr_protect(__func__);
1930 ret = __iw_get_tx_power(dev, info, wrqu, extra);
1931 vos_ssr_unprotect(__func__);
1932
1933 return ret;
1934}
1935
1936static int __iw_set_tx_power(struct net_device *dev,
1937 struct iw_request_info *info,
1938 union iwreq_data *wrqu, char *extra)
1939{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301940 hdd_adapter_t *pAdapter;
1941 tHalHandle hHal;
1942 hdd_context_t *pHddCtx;
1943 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001944
1945 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301946 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1947 if (NULL == pAdapter)
1948 {
1949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1950 "%s: Adapter is NULL",__func__);
1951 return -EINVAL;
1952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001953
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301954 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1955 ret = wlan_hdd_validate_context(pHddCtx);
1956 if (0 != ret)
1957 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301958 return ret;
1959 }
1960
1961 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1962 if (NULL == hHal)
1963 {
1964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1965 "%s: Hal Context is NULL",__func__);
1966 return -EINVAL;
1967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1969 {
c_hpothub8245442013-11-20 23:41:09 +05301970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1971 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 return -EIO;
1973 }
1974
1975 EXIT();
1976
1977 return 0;
1978}
1979
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301980static int iw_set_tx_power(struct net_device *dev,
1981 struct iw_request_info *info,
1982 union iwreq_data *wrqu, char *extra)
1983{
1984 int ret;
1985
1986 vos_ssr_protect(__func__);
1987 ret = __iw_set_tx_power(dev, info, wrqu, extra);
1988 vos_ssr_unprotect(__func__);
1989
1990 return ret;
1991}
1992
1993static int __iw_get_bitrate(struct net_device *dev,
1994 struct iw_request_info *info,
1995 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001996{
1997 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1998 eHalStatus status = eHAL_STATUS_SUCCESS;
1999 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302000 hdd_adapter_t *pAdapter;
2001 hdd_context_t *pHddCtx;
2002 hdd_station_ctx_t *pHddStaCtx;
2003 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002004
2005 ENTER();
2006
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302007 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2008 if (NULL == pAdapter)
2009 {
2010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2011 "%s: Adapter is NULL",__func__);
2012 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 }
2014
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302015 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2016 ret = wlan_hdd_validate_context(pHddCtx);
2017 if (0 != ret)
2018 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302019 return ret;
2020 }
2021
2022 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2023 if (NULL == pHddStaCtx)
2024 {
2025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2026 "%s: STA Context is NULL",__func__);
2027 return -EINVAL;
2028 }
2029
2030 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 wrqu->bitrate.value = 0;
2032 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302033 else
2034 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2036 SME_SUMMARY_STATS |
2037 SME_GLOBAL_CLASSA_STATS |
2038 SME_GLOBAL_CLASSB_STATS |
2039 SME_GLOBAL_CLASSC_STATS |
2040 SME_GLOBAL_CLASSD_STATS |
2041 SME_PER_STA_STATS,
2042 hdd_StatisticsCB, 0, FALSE,
2043 pHddStaCtx->conn_info.staId[0], pAdapter );
2044
2045 if(eHAL_STATUS_SUCCESS != status)
2046 {
2047 hddLog(VOS_TRACE_LEVEL_ERROR,
2048 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002049 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 return status;
2051 }
2052
2053 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302054 if (NULL == pWextState)
2055 {
2056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2057 "%s: pWextState is NULL",__func__);
2058 return -EINVAL;
2059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002060
2061 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2062
2063 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2064 {
2065 hddLog(VOS_TRACE_LEVEL_ERROR,
2066 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002067 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002068 return VOS_STATUS_E_FAILURE;
2069 }
2070
2071 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2072 }
2073
2074 EXIT();
2075
2076 return vos_status;
2077}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302078
2079static int iw_get_bitrate(struct net_device *dev,
2080 struct iw_request_info *info,
2081 union iwreq_data *wrqu, char *extra)
2082{
2083 int ret;
2084
2085 vos_ssr_protect(__func__);
2086 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2087 vos_ssr_unprotect(__func__);
2088
2089 return ret;
2090}
2091
2092
Jeff Johnson295189b2012-06-20 16:38:30 -07002093/* ccm call back function */
2094
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302095static int __iw_set_bitrate(struct net_device *dev,
2096 struct iw_request_info *info,
2097 union iwreq_data *wrqu,
2098 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002099{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302100 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302102 hdd_station_ctx_t *pHddStaCtx;
2103 hdd_context_t *pHddCtx;
Ashish Kumar Dhanotiyaaa9e38c2018-05-23 20:23:24 +05302104 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN +
2105 WNI_CFG_SUPPORTED_RATES_11B_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2107 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2108 v_U32_t i, rate;
2109 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302110 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002111
2112 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302113 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2114 if (NULL == pAdapter)
2115 {
2116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2117 "%s: Adapter is NULL",__func__);
2118 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 }
2120
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302121 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2122 ret = wlan_hdd_validate_context(pHddCtx);
2123 if (0 != ret)
2124 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302125 return ret;
2126 }
2127
2128 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2129 if (NULL == pHddStaCtx)
2130 {
2131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2132 "%s: STA Context is NULL",__func__);
2133 return -EINVAL;
2134 }
2135
2136
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302138 if (NULL == pWextState)
2139 {
2140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2141 "%s: pWextState is NULL",__func__);
2142 return -EINVAL;
2143 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002144
2145 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2146 {
2147 return -ENXIO ;
2148 }
2149
2150 rate = wrqu->bitrate.value;
2151
2152 if (rate == -1)
2153 {
2154 rate = WNI_CFG_FIXED_RATE_AUTO;
2155 valid_rate = TRUE;
2156 }
2157 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2158 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2159 {
2160 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2161 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2162 {
2163 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2164 WNI_CFG_SUPPORTED_RATES_11A,
2165 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2166 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2167 WNI_CFG_SUPPORTED_RATES_11B,
Ashish Kumar Dhanotiyaaa9e38c2018-05-23 20:23:24 +05302168 supp_rates + a_len, &b_len) == eHAL_STATUS_SUCCESS))
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 {
2170 for (i = 0; i < (b_len + a_len); ++i)
2171 {
2172 /* supported rates returned is double the actual rate so we divide it by 2 */
2173 if ((supp_rates[i]&0x7F)/2 == rate)
2174 {
2175 valid_rate = TRUE;
2176 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2177 break;
2178 }
2179 }
2180 }
2181 }
2182 }
2183 if (valid_rate != TRUE)
2184 {
2185 return -EINVAL;
2186 }
2187 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2188 WNI_CFG_FIXED_RATE, rate,
2189 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2190 {
c_hpothub8245442013-11-20 23:41:09 +05302191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2192 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 return -EIO;
2194 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302195
2196 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 return 0;
2198}
2199
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302200static int iw_set_bitrate(struct net_device *dev,
2201 struct iw_request_info *info,
2202 union iwreq_data *wrqu,
2203 char *extra)
2204{
2205 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002206
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302207 vos_ssr_protect(__func__);
2208 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2209 vos_ssr_unprotect(__func__);
2210
2211 return ret;
2212}
2213
2214static int __iw_set_genie(struct net_device *dev,
2215 struct iw_request_info *info,
2216 union iwreq_data *wrqu,
2217 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002218{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302219 hdd_adapter_t *pAdapter;
2220 hdd_context_t *pHddCtx;
2221 hdd_wext_state_t *pWextState;
2222 u_int8_t *genie = NULL;
2223 u_int8_t *base_genie = NULL;
2224 v_U16_t remLen;
2225 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002226
2227 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002228
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302229 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2230 if (NULL == pAdapter)
2231 {
2232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2233 "%s: Adapter is NULL",__func__);
2234 return -EINVAL;
2235 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002236
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302237 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2238 ret = wlan_hdd_validate_context(pHddCtx);
2239 if (0 != ret)
2240 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302241 return ret;
2242 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002243
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302244 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2245 if (NULL == pWextState)
2246 {
2247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2248 "%s: pWextState is NULL",__func__);
2249 return -EINVAL;
2250 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002251
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302252 if (!wrqu->data.length) {
2253 hdd_clearRoamProfileIe(pAdapter);
2254 EXIT();
2255 return 0;
2256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002257
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302258 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2259 wrqu->data.length);
2260 if (NULL == base_genie)
2261 {
2262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2263 "mem_alloc_copy_from_user_helper fail");
2264 return -ENOMEM;
2265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002266
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302267 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002268
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302269 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002270
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302271 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2272
2273 /* clear any previous genIE before this call */
2274 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2275
2276 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 {
2278 v_U16_t eLen = 0;
2279 v_U8_t elementId;
2280 elementId = *genie++;
2281 eLen = *genie++;
2282 remLen -= 2;
2283
Arif Hussain6d2a3322013-11-17 19:50:10 -08002284 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 __func__, elementId, eLen);
2286
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302287 if (remLen < eLen) {
2288 hddLog(LOGE, "Remaining len: %u less than ie len: %u",
2289 remLen, eLen);
2290 ret = -EINVAL;
2291 goto exit;
2292 }
2293
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 switch ( elementId )
2295 {
2296 case IE_EID_VENDOR:
2297 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002298 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302299 ret = -EINVAL;
2300 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002302
2303 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2304 {
2305 v_U16_t curGenIELen = pWextState->genIE.length;
2306 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2307 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2308
2309 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2310 {
2311 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002312 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302314 ret = -EINVAL;
2315 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 }
2317 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2318 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2319 pWextState->genIE.length += eLen + 2;
2320 }
2321 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2322 {
2323 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302324 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2325 {
2326 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2327 "Need bigger buffer space");
2328 ret = -EINVAL;
2329 VOS_ASSERT(0);
2330 goto exit;
2331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2333 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2334 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2335 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2336 }
2337 else /* any vendorId except WPA IE should be accumulated to genIE */
2338 {
2339 v_U16_t curGenIELen = pWextState->genIE.length;
2340 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2341 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2342
2343 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2344 {
2345 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002346 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302348 ret = -ENOMEM;
2349 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 }
2351 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2352 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2353 pWextState->genIE.length += eLen + 2;
2354 }
2355 break;
2356 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002357 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302358 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2359 {
2360 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2361 "Need bigger buffer space");
2362 ret = -EINVAL;
2363 VOS_ASSERT(0);
2364 goto exit;
2365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2367 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2368 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2369 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2370 break;
2371
2372 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002373 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302374 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 remLen -= eLen;
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302377
2378 /* Move genie only if next element is present */
2379 if (remLen >= 2)
2380 genie += eLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302382
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302383exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002385 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302386 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002387}
2388
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302389static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 struct iw_request_info *info,
2391 union iwreq_data *wrqu,
2392 char *extra)
2393{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302394 int ret;
2395
2396 vos_ssr_protect(__func__);
2397 ret = __iw_set_genie(dev, info, wrqu, extra);
2398 vos_ssr_unprotect(__func__);
2399
2400 return ret;
2401}
2402
2403static int __iw_get_genie(struct net_device *dev,
2404 struct iw_request_info *info,
2405 union iwreq_data *wrqu,
2406 char *extra)
2407{
Jeff Johnson295189b2012-06-20 16:38:30 -07002408 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302409 hdd_context_t *pHddCtx;
2410 hdd_adapter_t *pAdapter;
2411 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002412 eHalStatus status;
2413 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2414 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2415
2416 ENTER();
2417
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302418 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2419 if (NULL == pAdapter)
2420 {
2421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2422 "%s: Adapter is NULL",__func__);
2423 return -EINVAL;
2424 }
2425 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2426 status = wlan_hdd_validate_context(pHddCtx);
2427 if (0 != status)
2428 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302429 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 }
2431
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302433 if (NULL == pWextState)
2434 {
2435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2436 "%s: pWextState is NULL",__func__);
2437 return -EINVAL;
2438 }
2439
2440 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2441 if (NULL == pHddStaCtx)
2442 {
2443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2444 "%s: STA Context is NULL",__func__);
2445 return -EINVAL;
2446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002447
2448 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2449 {
2450 return -ENXIO;
2451 }
2452
2453 // Return something ONLY if we are associated with an RSN or WPA network
2454 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2455 pWextState->roamProfile.negotiatedAuthType))
2456 {
2457 return -ENXIO;
2458 }
2459
2460 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2461 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2462 pAdapter->sessionId,
2463 &length,
2464 genIeBytes);
Manjeet Singh715d47e2016-08-02 19:08:02 +05302465 if (eHAL_STATUS_SUCCESS != status) {
2466 hddLog(LOGE, FL("failed to get WPA-RSN IE data"));
Arif Hussain7adce1b2013-11-11 22:59:34 -08002467 return -EFAULT;
2468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002469
Manjeet Singh715d47e2016-08-02 19:08:02 +05302470 wrqu->data.length = length;
2471 if (length > DOT11F_IE_RSN_MAX_LEN) {
2472 hddLog(LOGE,
2473 FL("invalid buffer length length:%d"), length);
2474 return -E2BIG;
2475 }
2476
2477 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
2478
2479 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002480
2481 EXIT();
2482
2483 return 0;
2484}
2485
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302486static int iw_get_genie(struct net_device *dev,
2487 struct iw_request_info *info,
2488 union iwreq_data *wrqu,
2489 char *extra)
2490{
2491 int ret;
2492
2493 vos_ssr_protect(__func__);
2494 ret = __iw_get_genie(dev, info, wrqu, extra);
2495 vos_ssr_unprotect(__func__);
2496
2497 return ret;
2498}
2499
2500
2501static int __iw_get_encode(struct net_device *dev,
2502 struct iw_request_info *info,
2503 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002504{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302505 hdd_adapter_t *pAdapter;
2506 hdd_context_t *pHddCtx;
2507 hdd_wext_state_t *pWextState;
2508 tCsrRoamProfile *pRoamProfile;
2509 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002510 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002511
2512 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302513 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2514 if (NULL == pAdapter)
2515 {
2516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2517 "%s: Adapter is NULL",__func__);
2518 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002519 }
2520
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302521 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2522 ret = wlan_hdd_validate_context(pHddCtx);
2523 if (0 != ret)
2524 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302525 return ret;
2526 }
2527 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2528 if (NULL == pWextState)
2529 {
2530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2531 "%s: pWextState is NULL",__func__);
2532 return -EINVAL;
2533 }
2534
2535 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 keyId = pRoamProfile->Keys.defaultIndex;
2537
2538 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2539 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002540 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 return -EINVAL;
2542 }
2543
2544 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2545 {
2546 dwrq->flags |= IW_ENCODE_ENABLED;
2547 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2548 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2549
2550 dwrq->flags |= (keyId + 1);
2551
2552 }
2553 else
2554 {
2555 dwrq->flags |= IW_ENCODE_DISABLED;
2556 }
2557
2558 for(i=0; i < MAX_WEP_KEYS; i++)
2559 {
2560 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2561 {
2562 continue;
2563 }
2564 else
2565 {
2566 break;
2567 }
2568 }
2569
2570 if(MAX_WEP_KEYS == i)
2571 {
2572 dwrq->flags |= IW_ENCODE_NOKEY;
2573 }
2574
2575 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2576
2577 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2578 {
2579 dwrq->flags |= IW_ENCODE_OPEN;
2580 }
2581 else
2582 {
2583 dwrq->flags |= IW_ENCODE_RESTRICTED;
2584 }
2585 EXIT();
2586 return 0;
2587}
2588
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302589static int iw_get_encode(struct net_device *dev,
2590 struct iw_request_info *info,
2591 struct iw_point *dwrq, char *extra)
2592{
2593 int ret;
2594
2595 vos_ssr_protect(__func__);
2596 ret = __iw_get_encode(dev, info, dwrq, extra);
2597 vos_ssr_unprotect(__func__);
2598
2599 return ret;
2600}
2601
Jeff Johnson295189b2012-06-20 16:38:30 -07002602#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2603#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2604
2605
2606/*
2607 * This function sends a single 'key' to LIM at all time.
2608 */
2609
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302610static int __iw_get_rts_threshold(struct net_device *dev,
2611 struct iw_request_info *info,
2612 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002613{
2614 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2615 v_U32_t status = 0;
2616
2617 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2618
2619 return status;
2620}
2621
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302622static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 struct iw_request_info *info,
2624 union iwreq_data *wrqu, char *extra)
2625{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302626 int ret;
2627
2628 vos_ssr_protect(__func__);
2629 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2630 vos_ssr_unprotect(__func__);
2631
2632 return ret;
2633}
2634
2635static int __iw_set_rts_threshold(struct net_device *dev,
2636 struct iw_request_info *info,
2637 union iwreq_data *wrqu, char *extra)
2638{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302639 hdd_adapter_t *pAdapter;
2640 hdd_context_t *pHddCtx;
2641 tHalHandle hHal;
2642 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002643
2644 ENTER();
2645
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302646 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2647 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002648 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2650 "%s: Adapter is NULL",__func__);
2651 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002652 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302653
2654 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2655 ret = wlan_hdd_validate_context(pHddCtx);
2656 if (0 != ret)
2657 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302658 return ret;
2659 }
2660
2661 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2662 if (NULL == hHal)
2663 {
2664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2665 "%s: Hal Context is NULL",__func__);
2666 return -EINVAL;
2667 }
2668
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2670 {
2671 return -EINVAL;
2672 }
2673
2674 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2675 {
c_hpothub8245442013-11-20 23:41:09 +05302676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2677 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 return -EIO;
2679 }
2680
2681 EXIT();
2682
2683 return 0;
2684}
2685
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302686static int iw_set_rts_threshold(struct net_device *dev,
2687 struct iw_request_info *info,
2688 union iwreq_data *wrqu, char *extra)
2689{
2690 int ret;
2691
2692 vos_ssr_protect(__func__);
2693 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2694 vos_ssr_unprotect(__func__);
2695
2696 return ret;
2697}
2698
2699static int __iw_get_frag_threshold(struct net_device *dev,
2700 struct iw_request_info *info,
2701 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002702{
2703 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2704 v_U32_t status = 0;
2705
2706 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2707
2708 return status;
2709}
2710
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302711static int iw_get_frag_threshold(struct net_device *dev,
2712 struct iw_request_info *info,
2713 union iwreq_data *wrqu, char *extra)
2714{
2715 int ret;
2716
2717 vos_ssr_protect(__func__);
2718 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2719 vos_ssr_unprotect(__func__);
2720
2721 return ret;
2722}
2723
2724static int __iw_set_frag_threshold(struct net_device *dev,
2725 struct iw_request_info *info,
2726 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002727{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302728 hdd_adapter_t *pAdapter;
2729 hdd_context_t *pHddCtx;
2730 tHalHandle hHal;
2731 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002732
2733 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302734 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2735 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002736 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2738 "%s: Adapter is NULL",__func__);
2739 return -EINVAL;
2740 }
2741
2742 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2743 ret = wlan_hdd_validate_context(pHddCtx);
2744 if (0 != ret)
2745 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302746 return ret;
2747 }
2748
2749 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2750 if (NULL == hHal)
2751 {
2752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2753 "%s: Hal Context is NULL",__func__);
2754 return -EINVAL;
2755 }
2756
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2758 {
2759 return -EINVAL;
2760 }
2761
2762 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2763 {
c_hpothub8245442013-11-20 23:41:09 +05302764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2765 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 return -EIO;
2767 }
2768
2769 EXIT();
2770
2771 return 0;
2772}
2773
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302774static int iw_set_frag_threshold(struct net_device *dev,
2775 struct iw_request_info *info,
2776 union iwreq_data *wrqu, char *extra)
2777{
2778 int ret;
2779
2780 vos_ssr_protect(__func__);
2781 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2782 vos_ssr_unprotect(__func__);
2783
2784 return ret;
2785}
2786
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302787static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 struct iw_request_info *info,
2789 union iwreq_data *wrqu, char *extra)
2790{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302791 hdd_adapter_t *pAdapter;
2792 hdd_context_t *pHddCtx;
2793 int ret = 0;
2794
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302796 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2797 if (NULL == pAdapter)
2798 {
2799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2800 "%s: Adapter is NULL",__func__);
2801 return -EINVAL;
2802 }
2803 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2804 ret = wlan_hdd_validate_context(pHddCtx);
2805 if (0 != ret)
2806 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302807 return ret;
2808 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302809
2810 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 return -EOPNOTSUPP;
2812}
2813
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302814static int iw_get_power_mode(struct net_device *dev,
2815 struct iw_request_info *info,
2816 union iwreq_data *wrqu, char *extra)
2817{
2818 int ret;
2819
2820 vos_ssr_protect(__func__);
2821 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2822 vos_ssr_unprotect(__func__);
2823
2824 return ret;
2825}
2826static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 struct iw_request_info *info,
2828 union iwreq_data *wrqu, char *extra)
2829{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302830 hdd_adapter_t *pAdapter;
2831 hdd_context_t *pHddCtx;
2832 int ret = 0;
2833
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302835 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2836 if (NULL == pAdapter)
2837 {
2838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2839 "%s: Adapter is NULL",__func__);
2840 return -EINVAL;
2841 }
2842 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2843 ret = wlan_hdd_validate_context(pHddCtx);
2844 if (0 != ret)
2845 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302846 return ret;
2847 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302848
2849 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 return -EOPNOTSUPP;
2851}
2852
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302853static int iw_set_power_mode(struct net_device *dev,
2854 struct iw_request_info *info,
2855 union iwreq_data *wrqu, char *extra)
2856{
2857 int ret;
2858
2859 vos_ssr_protect(__func__);
2860 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2861 vos_ssr_unprotect(__func__);
2862
2863 return ret;
2864}
2865
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302866static int __iw_get_range(struct net_device *dev,
2867 struct iw_request_info *info,
2868 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002869{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302870 hdd_adapter_t *pAdapter;
2871 tHalHandle hHal;
2872 hdd_context_t *pHddCtx;
2873 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 struct iw_range *range = (struct iw_range *) extra;
2875
2876 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2877
2878 v_U32_t num_channels = sizeof(channels);
2879 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2880 v_U32_t a_len;
2881 v_U32_t b_len;
2882 v_U32_t active_phy_mode = 0;
2883 v_U8_t index = 0, i;
2884
2885 ENTER();
2886
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302887 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2888 if (NULL == pAdapter)
2889 {
2890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2891 "%s: pAdapter is NULL", __func__);
2892 return -EINVAL;
2893 }
2894 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2895 ret = wlan_hdd_validate_context(pHddCtx);
2896 if (0 != ret)
2897 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302898 return ret;
2899 }
2900 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2901 if (NULL == hHal)
2902 {
2903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2904 "%s: pAdapter is NULL", __func__);
2905 return -EINVAL;
2906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 wrqu->data.length = sizeof(struct iw_range);
2908 memset(range, 0, sizeof(struct iw_range));
2909
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 /*Get the phy mode*/
2911 if (ccmCfgGetInt(hHal,
2912 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2913 {
2914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002915 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002916
2917 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2918 {
2919 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002920 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 if (ccmCfgGetStr(hHal,
2922 WNI_CFG_SUPPORTED_RATES_11A,
2923 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2924 {
2925 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2926 {
2927 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2928 }
2929 for (i = 0; i < a_len; i++)
2930 {
2931 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2932 }
2933 range->num_bitrates = a_len;
2934 }
2935 else
2936 {
2937 return -EIO;
2938 }
2939 }
2940 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2941 {
2942 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002943 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 if (ccmCfgGetStr(hHal,
2945 WNI_CFG_SUPPORTED_RATES_11B,
2946 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2947 {
2948 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2949 {
2950 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2951 }
2952 for (i = 0; i < b_len; i++)
2953 {
2954 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2955 }
2956 range->num_bitrates = b_len;
2957 }
2958 else
2959 {
2960 return -EIO;
2961 }
2962 }
2963 }
2964
2965 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2966 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2967 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2968
2969 range->encoding_size[0] = 5;
2970 range->encoding_size[1] = 13;
2971 range->num_encoding_sizes = 2;
2972 range->max_encoding_tokens = MAX_WEP_KEYS;
2973
2974 // we support through Wireless Extensions 22
2975 range->we_version_compiled = WIRELESS_EXT;
2976 range->we_version_source = 22;
2977
2978 /*Supported Channels and Frequencies*/
2979 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2980 {
c_hpothub8245442013-11-20 23:41:09 +05302981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2982 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 return -EIO;
2984 }
2985 if (num_channels > IW_MAX_FREQUENCIES)
2986 {
2987 num_channels = IW_MAX_FREQUENCIES;
2988 }
2989
2990 range->num_channels = num_channels;
2991 range->num_frequency = num_channels;
2992
2993 for (index=0; index < num_channels; index++)
2994 {
2995 v_U32_t frq_indx = 0;
2996
2997 range->freq[index].i = channels[index];
2998 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2999 {
3000 if(channels[index] == freq_chan_map[frq_indx].chan)
3001 {
3002 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3003 range->freq[index].e = 1;
3004 break;
3005 }
3006 frq_indx++;
3007 }
3008 }
3009
3010 /* Event capability (kernel + driver) */
3011 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3012 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3013 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3014 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3015
3016 /*Encryption capability*/
3017 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3018 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3019
3020 /* Txpower capability */
3021 range->txpower_capa = IW_TXPOW_MWATT;
3022
3023 /*Scanning capability*/
3024 #if WIRELESS_EXT >= 22
3025 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3026 #endif
3027
3028 EXIT();
3029 return 0;
3030}
3031
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303032static int iw_get_range(struct net_device *dev,
3033 struct iw_request_info *info,
3034 union iwreq_data *wrqu, char *extra)
3035{
3036 int ret;
3037
3038 vos_ssr_protect(__func__);
3039 ret = __iw_get_range(dev, info, wrqu, extra);
3040 vos_ssr_unprotect(__func__);
3041
3042 return ret;
3043}
3044
Jeff Johnson295189b2012-06-20 16:38:30 -07003045/* Callback function for tx per hit */
3046void hdd_tx_per_hit_cb (void *pCallbackContext)
3047{
3048 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3049 unsigned char tx_fail[16];
3050 union iwreq_data wrqu;
3051
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303052 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003054 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003055 return;
3056 }
3057 memset(&wrqu, 0, sizeof(wrqu));
3058 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3059 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3060}
3061
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303062void hdd_get_class_a_statistics_cb(void *stats, void *context)
3063{
3064 struct hdd_request *request;
3065 struct stats_class_a_ctx *priv;
3066
3067 if (ioctl_debug) {
3068 pr_info("%s: stats [%pK] context [%pK]\n",
3069 __func__, stats, context);
3070 }
3071
3072 if (NULL == stats) {
3073 hddLog(VOS_TRACE_LEVEL_ERROR,
3074 "%s: Bad param, stats [%pK]",
3075 __func__, stats);
3076 return;
3077 }
3078
3079 request = hdd_request_get(context);
3080 if (!request) {
3081 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
3082 return;
3083 }
3084
3085 priv = hdd_request_priv(request);
3086
3087 /* copy over the stats. do so as a struct copy */
3088 priv->class_a_stats = *(tCsrGlobalClassAStatsInfo *)stats;
3089
3090 hdd_request_complete(request);
3091 hdd_request_put(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07003092}
3093
3094VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3095{
3096 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3097 eHalStatus hstatus;
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303098 int ret;
3099 void *cookie;
3100 struct hdd_request *request;
3101 struct stats_class_a_ctx *priv;
3102 static const struct hdd_request_params params = {
3103 .priv_size = sizeof(*priv),
3104 .timeout_ms = WLAN_WAIT_TIME_STATS,
3105 };
3106
Jeff Johnson295189b2012-06-20 16:38:30 -07003107
3108 if (NULL == pAdapter)
3109 {
3110 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3111 return VOS_STATUS_E_FAULT;
3112 }
3113 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3114 {
3115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3116 return VOS_STATUS_SUCCESS;
3117 }
3118
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303119 request = hdd_request_alloc(&params);
3120 if (!request) {
3121 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3122 return VOS_STATUS_E_NOMEM;
3123 }
3124 cookie = hdd_request_cookie(request);
3125
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 /* query only for Class A statistics (which include link speed) */
3127 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3128 eCSR_HDD,
3129 SME_GLOBAL_CLASSA_STATS,
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303130 hdd_get_class_a_statistics_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 0, // not periodic
3132 FALSE, //non-cached results
3133 pHddStaCtx->conn_info.staId[0],
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303134 cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 if (eHAL_STATUS_SUCCESS != hstatus)
3136 {
3137 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003138 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003139 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 /* we'll returned a cached value below */
3141 }
3142 else
3143 {
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303144 /* request was sent -- wait for the response */
3145 ret = hdd_request_wait_for_response(request);
3146 if (ret)
3147 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303149 FL("SME timeout while retrieving Class A statistics"));
3150 }
3151 else
3152 {
3153 priv = hdd_request_priv(request);
3154 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
3155
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 }
3157 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003158
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303159 /*
3160 * either we never sent a request, we sent a request and received a
3161 * response or we sent a request and timed out. Regardless we are
3162 * done with the request.
3163 */
3164 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003165
3166 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 return VOS_STATUS_SUCCESS;
3168}
3169
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303170struct stats_ctx {
3171 tCsrSummaryStatsInfo summary_stats;
3172 tCsrGlobalClassAStatsInfo class_a_stats;
3173};
3174
3175static void hdd_get_station_statistics_cb(void *stats, void *context)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003176{
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303177 tCsrSummaryStatsInfo *summary_stats;
3178 tCsrGlobalClassAStatsInfo *class_a_stats;
3179 struct hdd_request *request;
3180 struct stats_ctx *priv;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003181
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003182
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303183 if (ioctl_debug) {
3184 pr_info("%s: stats [%pK] context [%pK]\n",
3185 __func__, stats, context);
3186 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003187
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303188 if (NULL == stats) {
3189 hddLog(VOS_TRACE_LEVEL_ERROR,
3190 "%s: Bad param, stats [%pK]",
3191 __func__, stats);
3192 return;
3193 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003194
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303195 request = hdd_request_get(context);
3196 if (!request) {
3197 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
3198 return;
3199 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003200
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303201 summary_stats = (tCsrSummaryStatsInfo *)stats;
3202 class_a_stats = (tCsrGlobalClassAStatsInfo *)(summary_stats + 1);
Jeff Johnson72a40512013-12-19 10:14:15 -08003203
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303204 priv = hdd_request_priv(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003205
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303206 /* copy over the stats. do so as a struct copy */
3207 priv->summary_stats = *summary_stats;
3208 priv->class_a_stats = *class_a_stats;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003209
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303210 hdd_request_complete(request);
3211 hdd_request_put(request);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003212}
3213
3214VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3215{
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303216 hdd_station_ctx_t *pHddStaCtx;
3217 hdd_ap_ctx_t *sap_ctx;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003218 eHalStatus hstatus;
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303219 tANI_U8 sta_id;
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303220 int ret;
3221 void *cookie;
3222 struct hdd_request *request;
3223 struct stats_ctx *priv;
3224 static const struct hdd_request_params params = {
3225 .priv_size = sizeof(*priv),
3226 .timeout_ms = WLAN_WAIT_TIME_STATS,
3227 };
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003228
3229 if (NULL == pAdapter)
3230 {
3231 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3232 return VOS_STATUS_SUCCESS;
3233 }
3234
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303235 if (pAdapter->device_mode == WLAN_HDD_SOFTAP) {
3236 sap_ctx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3237 sta_id = sap_ctx->uBCStaId;
3238 } else {
3239 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3240 sta_id = pHddStaCtx->conn_info.staId[0];
3241 }
3242
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303243 request = hdd_request_alloc(&params);
3244 if (!request) {
3245 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3246 return VOS_STATUS_E_NOMEM;
3247 }
3248 cookie = hdd_request_cookie(request);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003249
3250 /* query only for Summary & Class A statistics */
3251 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3252 eCSR_HDD,
3253 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303254 SME_GLOBAL_CLASSA_STATS |
3255 SME_PER_PKT_STATS,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303256 hdd_get_station_statistics_cb,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003257 0, // not periodic
3258 FALSE, //non-cached results
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303259 sta_id,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303260 cookie);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003261 if (eHAL_STATUS_SUCCESS != hstatus)
3262 {
3263 hddLog(VOS_TRACE_LEVEL_ERROR,
3264 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003265 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003266 /* we'll return with cached values */
3267 }
3268 else
3269 {
3270 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303271 ret = hdd_request_wait_for_response(request);
3272 if (ret)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003273 {
3274 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303275 FL("SME timeout while retrieving statistics"));
3276 }
3277 else
3278 {
3279 priv = hdd_request_priv(request);
3280 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
3281 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003282 }
3283 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003284
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303285 /*
3286 * either we never sent a request, we sent a request and received a
3287 * response or we sent a request and timed out. Regardless we are
3288 * done with the request.
3289 */
3290 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003291
3292 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003293 return VOS_STATUS_SUCCESS;
3294}
3295
Jeff Johnson295189b2012-06-20 16:38:30 -07003296/*
3297 * Support for the LINKSPEED private command
3298 * Per the WiFi framework the response must be of the form
3299 * "LinkSpeed xx"
3300 */
3301static int iw_get_linkspeed(struct net_device *dev,
3302 struct iw_request_info *info,
3303 union iwreq_data *wrqu, char *extra)
3304{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303305 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303306 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303308 int len = sizeof(v_U32_t) + 1;
3309 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303310 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303311 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303312 int rc, valid = 0;
3313
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303314 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303315 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3316 if (NULL == pAdapter)
3317 {
3318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3319 "%s: Adapter is NULL",__func__);
3320 return -EINVAL;
3321 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003322
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303323 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303324 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303325 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003326 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303327 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003328 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303329 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3330 if (NULL == pHddStaCtx)
3331 {
3332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3333 "%s: STA Context is NULL",__func__);
3334 return -EINVAL;
3335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3337 {
3338 /* we are not connected so we don't have a classAstats */
3339 link_speed = 0;
3340 }
3341 else
3342 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303343 status = wlan_hdd_get_classAstats(pAdapter);
3344
3345 if (!VOS_IS_STATUS_SUCCESS(status ))
3346 {
3347 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3348 return -EINVAL;
3349 }
3350
3351 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3352 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3353 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3354 &link_speed);
3355
3356 link_speed = link_speed / 10;
3357
3358 if (0 == link_speed)
3359 {
3360 /* The linkspeed returned by HAL is in units of 500kbps.
3361 * converting it to mbps.
3362 * This is required to support legacy firmware which does
3363 * not return link capacity.
3364 */
3365 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3366 }
3367
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 }
3369
3370 wrqu->data.length = len;
3371 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003372 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 if ((rc < 0) || (rc >= len))
3374 {
3375 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303376 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 return -EIO;
3378 }
3379
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303380 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003382 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003383}
3384
Arif Hussain695279c2014-03-24 14:06:07 -07003385/*
3386 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3387 *
3388 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303389static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003390 struct iw_request_info *info,
3391 union iwreq_data *wrqu, char *extra)
3392{
3393 int rc;
3394
3395 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3396
3397 if (rc < 0)
3398 return rc;
3399
3400 /* a value is being successfully returned */
3401 return 0;
3402}
Jeff Johnson295189b2012-06-20 16:38:30 -07003403
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303404static int iw_get_linkspeed_priv(struct net_device *dev,
3405 struct iw_request_info *info,
3406 union iwreq_data *wrqu, char *extra)
3407{
3408 int ret;
3409
3410 vos_ssr_protect(__func__);
3411 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3412 vos_ssr_unprotect(__func__);
3413
3414 return ret;
3415}
3416
Jeff Johnson295189b2012-06-20 16:38:30 -07003417/*
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303418 * Support for the RSSI & RSSI-APPROX private commands
3419 * Per the WiFi framework the response must be of the form
3420 * "<ssid> rssi <xx>"
3421 * unless we are not associated, in which case the response is
3422 * "OK"
3423 */
3424static int iw_get_rssi(struct net_device *dev,
3425 struct iw_request_info *info,
3426 union iwreq_data *wrqu, char *extra)
3427{
3428 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3429 char *cmd = extra;
3430 int len = wrqu->data.length;
3431 v_S7_t s7Rssi = 0;
3432 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3433 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3434 VOS_STATUS vosStatus;
3435 int rc;
3436
3437 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3438 (0 == ssidlen) || (ssidlen >= len))
3439 {
3440 /* we are not connected or our SSID is too long
3441 so we cannot report an rssi */
3442 rc = scnprintf(cmd, len, "OK");
3443 }
3444 else
3445 {
3446 /* we are connected with a valid SSID
3447 so we can write the SSID into the return buffer
3448 (note that it is not NUL-terminated) */
3449 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3450
Hanumanth Reddy Pothula01abc502016-08-30 15:34:43 +05303451 wlan_hdd_get_station_stats(pAdapter);
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303452 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3453
3454 if (VOS_STATUS_SUCCESS == vosStatus)
3455 {
3456 /* append the rssi to the ssid in the format required by
3457 the WiFI Framework */
3458 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3459 rc += ssidlen;
3460 }
3461 else
3462 {
3463 rc = -1;
3464 }
3465 }
3466
3467 /* verify that we wrote a valid response */
3468 if ((rc < 0) || (rc >= len))
3469 {
3470 // encoding or length error?
3471 hddLog(VOS_TRACE_LEVEL_ERROR,
3472 "%s: Unable to encode RSSI, got [%s]",
3473 __func__, cmd);
3474 return -EIO;
3475 }
3476
3477 /* a value is being successfully returned */
3478 return rc;
3479}
3480
3481/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 * Support for SoftAP channel range private command
3483 */
3484static int iw_softap_set_channel_range( struct net_device *dev,
3485 int startChannel,
3486 int endChannel,
3487 int band)
3488{
Jeff Johnson43971f52012-07-17 12:26:56 -07003489 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 int ret = 0;
3491 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3492 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003493 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3494
Jeff Johnson295189b2012-06-20 16:38:30 -07003495
3496 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3497 if (VOS_STATUS_SUCCESS != status)
3498 {
3499 ret = -EINVAL;
3500 }
Yathish9f22e662012-12-10 14:21:35 -08003501 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 return ret;
3503}
3504
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303505static uint8 chartohex(char c)
3506{
3507 uint8 val = 0;
3508 if (c >= '0' && c <= '9')
3509 val = c - '0';
3510 else if (c >= 'a' && c <= 'f')
3511 val = c - 'a' + 10;
3512 else if (c >= 'A' && c <= 'F')
3513 val = c - 'A' + 10;
3514 else
3515 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3516
3517 return val;
3518}
3519
3520uint8 getByte(char **buf)
3521{
3522 uint8 byte = 0;
3523 char *temp = *buf;
3524 byte = chartohex(*temp) * 16;
3525 temp++;
3526 byte += chartohex(*temp);
3527 temp++;
3528 *buf = temp;
3529 return byte;
3530}
3531
3532static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3533{
3534 tSir80211Header *macHeader;
3535 int i = 0, j = 0, length = 0;
3536 uint8 byte = 0;
3537 char *temp = pBuffer;
3538 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303539 char *pHeader;
3540 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303541
3542 macHeader = &pkt->macHeader;
3543
3544 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3545
3546 temp++;
3547
3548 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3549 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3550 pkt->encParams.keyParams.key[0].keyId);
3551
3552 for (i = 0; i< 16; i++) {
3553 pkt->encParams.keyParams.key[0].key[i]
3554 = getByte(&temp);
3555 }
3556
3557 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3558 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3559
3560 for (i = 0; i< 6; i++) {
3561 pkt->encParams.pn[i]
3562 = getByte(&temp);
3563 }
3564
3565 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3566 &pkt->encParams.pn[0], 6, 0);
3567
3568 for (i = 0, j= 5; i< 3; i++, j--) {
3569 byte = pkt->encParams.pn[i];
3570 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3571 pkt->encParams.pn[j] = byte;
3572 }
3573
3574 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303575 if (length > sizeof(tSir80211Header))
3576 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303577
Srinivas Dasari2382de62015-01-22 15:00:04 +05303578 pHeader = temp;
3579 vos_mem_zero(&header, sizeof(tSir80211Header));
3580 for (i = 0; i < length; i++) {
3581 *((uint8 *)&header + i) = getByte(&pHeader);
3582 }
3583
3584 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3585 (char *)&header, length, 0);
3586
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303587 byte = getByte(&temp);
3588
3589 macHeader->frameCtrl.protVer = byte & 0x3;
3590 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3591 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3592
3593 byte = getByte(&temp);
3594 macHeader->frameCtrl.toDS = (byte) & 0x1;
3595 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3596 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3597 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3598 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3599 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3600 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3601 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3602
3603 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3604 "macHeader->frameCtrl.type : %x "
3605 "macHeader->frameCtrl.subType : %x "
3606 "macHeader->frameCtrl.toDS : %x "
3607 "macHeader->frameCtrl.fromDS : %x "
3608 "macHeader->frameCtrl.moreFrag : %x "
3609 "macHeader->frameCtrl.retry : %x "
3610 "macHeader->frameCtrl.powerMgmt : %x "
3611 "macHeader->frameCtrl.MoreData : %x "
3612 "macHeader->frameCtrl.wep : %x "
3613 "macHeader->frameCtrl.order : %x "
3614 , macHeader->frameCtrl.protVer
3615 , macHeader->frameCtrl.type
3616 , macHeader->frameCtrl.subType
3617 , macHeader->frameCtrl.toDS
3618 , macHeader->frameCtrl.fromDS
3619 , macHeader->frameCtrl.moreFrag
3620 , macHeader->frameCtrl.retry
3621 , macHeader->frameCtrl.powerMgmt
3622 , macHeader->frameCtrl.moreData
3623 , macHeader->frameCtrl.wep
3624 , macHeader->frameCtrl.order);
3625
3626
3627 macHeader->usDurationId = getByte(&temp);
3628 macHeader->usDurationId += getByte(&temp) << 8;
3629
3630 macHeader->vA1[0] = getByte(&temp);
3631 macHeader->vA1[1] = getByte(&temp);
3632 macHeader->vA1[2] = getByte(&temp);
3633 macHeader->vA1[3] = getByte(&temp);
3634 macHeader->vA1[4] = getByte(&temp);
3635 macHeader->vA1[5] = getByte(&temp);
3636
3637 macHeader->vA2[0] = getByte(&temp);
3638 macHeader->vA2[1] = getByte(&temp);
3639 macHeader->vA2[2] = getByte(&temp);
3640 macHeader->vA2[3] = getByte(&temp);
3641 macHeader->vA2[4] = getByte(&temp);
3642 macHeader->vA2[5] = getByte(&temp);
3643
3644 macHeader->vA3[0] = getByte(&temp);
3645 macHeader->vA3[1] = getByte(&temp);
3646 macHeader->vA3[2] = getByte(&temp);
3647 macHeader->vA3[3] = getByte(&temp);
3648 macHeader->vA3[4] = getByte(&temp);
3649 macHeader->vA3[5] = getByte(&temp);
3650
3651 macHeader->sSeqCtrl = getByte(&temp);
3652 fragNum = macHeader->sSeqCtrl & 0xF;
3653 macHeader->sSeqCtrl >>= 4;
3654
3655 macHeader->sSeqCtrl += getByte(&temp) << 4;
3656
3657 macHeader->sSeqCtrl |= fragNum << 12;
3658
3659 if (length == 30 || length == 32) {
3660 macHeader->optvA4[0] = getByte(&temp);
3661 macHeader->optvA4[1] = getByte(&temp);
3662 macHeader->optvA4[2] = getByte(&temp);
3663 macHeader->optvA4[3] = getByte(&temp);
3664 macHeader->optvA4[4] = getByte(&temp);
3665 macHeader->optvA4[5] = getByte(&temp);
3666 }
3667
3668 if (length == 26 || length == 32) {
3669 macHeader->usQosCtrl = getByte(&temp);
3670 macHeader->usQosCtrl += getByte(&temp) << 8;
3671 }
3672
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303673 //parse payload
3674 length = getByte(&temp);
3675 length += getByte(&temp) << 8;
3676 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3677
Manjeet Singh5830f142016-11-21 18:21:17 +05303678 if (length >= WLAN_DISA_MAX_PAYLOAD_SIZE)
3679 length = WLAN_DISA_MAX_PAYLOAD_SIZE;
3680
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303681 pkt->data.length = length;
3682
3683 for (i = 0; i< length; i++) {
3684 pkt->data.data[i] = getByte(&temp);
3685 }
3686
3687 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3688 &pkt->data.data[0], pkt->data.length, 0);
3689}
3690
3691/**---------------------------------------------------------------------------
3692
3693 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3694 encrypt message request
3695 This is an asynchronous callback function from SME when the encrypted data
3696 is received
3697
3698 \pEncInfoRsp -> Encrypted data info
3699
3700 \return - 0 for success non-zero for failure
3701 --------------------------------------------------------------------------*/
3702static void
3703hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3704{
3705 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3706
3707 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3708
3709 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3710 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3711 pEncryptedDataRsp->encryptedPayload.length);
3712 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3713 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3714 pEncryptedDataRsp->encryptedPayload.data,
3715 pEncryptedDataRsp->encryptedPayload.length, 0);
3716}
3717
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05303718/**
3719 * iw_power_callback_func() - Callback function registered with PMC
3720 * @context: cookie originally registered with PMC
3721 * @status: status code indicated by PMC state machine
3722 *
3723 * Return: None
3724 */
3725static void iw_power_callback_func(void *context, eHalStatus status)
3726{
3727 struct hdd_request *request = hdd_request_get(context);
3728
3729 if (!request) {
3730 hddLog(VOS_TRACE_LEVEL_ERROR,
3731 "%s: Obsolete request", __func__);
3732 return;
3733 }
3734
3735 hdd_request_complete(request);
3736 hdd_request_put(request);
3737}
3738
Jeff Johnson295189b2012-06-20 16:38:30 -07003739VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3740{
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 eHalStatus status;
3742 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303743 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303744 int ret;
3745 void *cookie;
3746 struct hdd_request *request;
3747 static const struct hdd_request_params params = {
3748 .priv_size = 0,
3749 .timeout_ms = WLAN_WAIT_TIME_STATS,
3750 };
Jeff Johnson295189b2012-06-20 16:38:30 -07003751
3752 if (NULL == pAdapter)
3753 {
3754 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3755 return VOS_STATUS_E_FAULT;
3756 }
3757
3758 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3759 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303760 if (pHddCtx->isLogpInProgress) {
3761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3762 "%s:LOGP in Progress. Ignore!!!", __func__);
3763 return VOS_STATUS_E_FAILURE;
3764 }
3765
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303766 request = hdd_request_alloc(&params);
3767 if (!request) {
3768 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3769 return VOS_STATUS_E_NOMEM;
3770 }
3771 cookie = hdd_request_cookie(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07003772
Jeff Johnson295189b2012-06-20 16:38:30 -07003773
3774 if (DRIVER_POWER_MODE_ACTIVE == mode)
3775 {
3776 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3777 "Full Power", __func__);
3778 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303779 iw_power_callback_func, cookie,
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 eSME_FULL_PWR_NEEDED_BY_HDD);
3781 // Enter Full power command received from GUI this means we are disconnected
3782 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3783 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3784 if (eHAL_STATUS_PMC_PENDING == status)
3785 {
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303786 ret = hdd_request_wait_for_response(request);
3787 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 {
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303789 hddLog(VOS_TRACE_LEVEL_ERROR,
3790 FL("SME timeout while requesting fullpower"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 }
3792 }
3793 }
3794 else if (DRIVER_POWER_MODE_AUTO == mode)
3795 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303796 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
3797 * was already in BMPS state and thus either STA or P2P-CLI is in
3798 * associated state and authenticated, so even if STA connState is
3799 * not associated it can be assumed that P2P-CLI is associated and
3800 * authenticated. Thus driver can enter BMPS. And even if we try to enter
3801 * BMPS with no adaptor in associated state, pmcRequestBmps will check
3802 * if all condition are satisfied for entering BMPS.
3803 */
3804 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
3805 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303806 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303807 hddLog(LOGE,
3808 FL("Station is associated but, still not Authenticated ignore "
3809 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303810 return VOS_STATUS_E_AGAIN;
3811 }
3812
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3814 {
3815 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3816 __func__);
3817 // Enter BMPS command received from GUI this means DHCP is completed
3818 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3819 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3820 FALSE);
3821 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303822 iw_power_callback_func, cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 if (eHAL_STATUS_PMC_PENDING == status)
3824 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003825 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303826 ret = hdd_request_wait_for_response(request);
3827 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003829 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303830 FL("SME timeout while requesting bmps"));
3831 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 }
3833 }
3834 else
3835 {
3836 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3837 "enabled in the cfg");
3838 }
3839 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003840
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303841 /*
3842 * either we never sent a request, we sent a request and received a
3843 * response or we sent a request and timed out. Regardless we are
3844 * done with the request.
3845 */
3846 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003847
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 return VOS_STATUS_SUCCESS;
3849}
3850
3851VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3852 hdd_adapter_t *pAdapter)
3853{
3854 VOS_STATUS vos_Status;
3855
3856 if ((NULL == pAdapter) || (NULL == pHddCtx))
3857 {
3858 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3859 return VOS_STATUS_E_FAULT;
3860 }
3861
3862 /**Exit from Deep sleep or standby if we get the driver
3863 START cmd from android GUI
3864 */
3865 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3866 {
3867 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3868 "from Stand by",__func__);
3869 vos_Status = hdd_exit_standby(pHddCtx);
3870 }
3871 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3872 {
3873 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3874 "from deep sleep",__func__);
3875 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3876 }
3877 else
3878 {
3879 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3880 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3881 vos_Status = VOS_STATUS_SUCCESS;
3882 }
3883
3884 return vos_Status;
3885}
3886
3887VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3888{
3889 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3890
3891 if (NULL == pHddCtx)
3892 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303893 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 return VOS_STATUS_E_FAULT;
3895 }
3896
3897 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3898 {
3899 //Execute standby procedure.
3900 //Executing standby procedure will cause the STA to
3901 //disassociate first and then the chip will be put into standby.
3902 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3903 vos_Status = hdd_enter_standby(pHddCtx);
3904 }
3905 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3906 pHddCtx->cfg_ini->nEnableDriverStop)
3907 {
3908 //Execute deep sleep procedure
3909 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003910 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 //Deep sleep not supported
3912 vos_Status = hdd_enter_standby(pHddCtx);
3913 }
3914 else
3915 {
3916 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3917 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3918 vos_Status = VOS_STATUS_SUCCESS;
3919 }
3920
3921 return vos_Status;
3922}
3923
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003924
3925void* wlan_hdd_change_country_code_callback(void *pAdapter)
3926{
3927
3928 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003929 complete(&call_back_pAdapter->change_country_code);
3930
3931 return NULL;
3932}
3933
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303934static int __iw_set_priv(struct net_device *dev,
3935 struct iw_request_info *info,
3936 union iwreq_data *wrqu, char *extra)
3937{
3938 hdd_adapter_t *pAdapter;
3939 char *cmd = NULL;
3940 int cmd_len = wrqu->data.length;
3941 int rc = 0, ret = 0;
3942 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3943
3944 hdd_context_t *pHddCtx;
3945
3946 ENTER();
3947
3948 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3949 if (NULL == pAdapter)
3950 {
3951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3952 "mem_alloc_copy_from_user_helper fail");
3953 return -EINVAL;
3954 }
3955 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3956 rc = wlan_hdd_validate_context(pHddCtx);
3957 if (0 != rc)
3958 {
3959 return rc;
3960 }
3961
3962 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3963 wrqu->data.length);
3964 if (NULL == cmd)
3965 {
3966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3967 "mem_alloc_copy_from_user_helper fail");
3968 return -ENOMEM;
3969 }
3970
3971 if (ioctl_debug)
3972 {
3973 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
3974 }
3975
3976 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3977 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
3978
3979 if (strncmp(cmd, "CSCAN", 5) == 0 )
3980 {
3981 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3983 "%s: Error in iw_set_scan!", __func__);
3984 rc = -EINVAL;
3985 }
3986 }
3987 else if( strcasecmp(cmd, "start") == 0 ) {
3988
3989 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
3990 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
3991
3992 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3993 if (vos_status == VOS_STATUS_SUCCESS)
3994 {
3995 union iwreq_data wrqu;
3996 char buf[10];
3997
3998 memset(&wrqu, 0, sizeof(wrqu));
3999 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4000 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4001 }
4002 else
4003 {
4004 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4005 rc = -EIO;
4006 }
4007 goto done;
4008 }
4009 else if( strcasecmp(cmd, "stop") == 0 )
4010 {
4011 union iwreq_data wrqu;
4012 char buf[10];
4013
4014 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4015
4016 wlan_hdd_enter_lowpower(pHddCtx);
4017 memset(&wrqu, 0, sizeof(wrqu));
4018 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4019 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4020 goto done;
4021 }
4022 else if (strcasecmp(cmd, "macaddr") == 0)
4023 {
4024 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4025 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4026 }
4027 else if (strcasecmp(cmd, "scan-active") == 0)
4028 {
4029 hddLog(LOG1,
4030 FL("making default scan to active"));
4031 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4032 ret = snprintf(cmd, cmd_len, "OK");
4033 }
4034 else if (strcasecmp(cmd, "scan-passive") == 0)
4035 {
4036 hddLog(LOG1,
4037 FL("making default scan to passive"));
4038 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4039 ret = snprintf(cmd, cmd_len, "OK");
4040 }
4041 else if( strcasecmp(cmd, "scan-mode") == 0 )
4042 {
4043 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4044 }
4045 else if( strcasecmp(cmd, "linkspeed") == 0 )
4046 {
4047 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4048 }
4049 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4050 {
4051 ret = iw_get_rssi(dev, info, wrqu, cmd);
4052 }
4053 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4054 int mode;
4055 char *ptr;
4056
4057 if (9 < cmd_len)
4058 {
4059 ptr = (char*)(cmd + 9);
4060
4061 }else{
4062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4063 "CMD LENGTH %d is not correct",cmd_len);
4064 kfree(cmd);
4065 return -EINVAL;
4066 }
4067
4068 if (1 != sscanf(ptr,"%d",&mode))
4069 {
4070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4071 "powermode input %s is not correct",ptr);
4072 kfree(cmd);
4073 return -EIO;
4074 }
4075
4076 wlan_hdd_enter_bmps(pAdapter, mode);
4077 /*TODO:Set the power mode*/
4078 }
4079 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4080 v_U32_t pmc_state;
4081 v_U16_t value;
4082
4083 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4084 if(pmc_state == BMPS) {
4085 value = DRIVER_POWER_MODE_AUTO;
4086 }
4087 else {
4088 value = DRIVER_POWER_MODE_ACTIVE;
4089 }
4090 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4091 }
4092 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4093 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4094 /*TODO: set the btcoexmode*/
4095 }
4096 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4097
4098 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4099 /*TODO: Return the btcoex status*/
4100 }
4101 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4102
4103 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4104
4105 /*TODO: Enable Rx data Filter*/
4106 }
4107 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4108
4109 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4110
4111 /*TODO: Disable Rx data Filter*/
4112 }
4113 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4114
4115 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4116 /*TODO: rxfilter-statistics*/
4117 }
4118 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4119
4120 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4121 /*TODO: rxfilter-add*/
4122 }
4123 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4124
4125 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4126 /*TODO: rxfilter-remove*/
4127 }
4128#ifdef FEATURE_WLAN_SCAN_PNO
4129 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4130 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4131 /*TODO: support pnosetup*/
4132 }
4133 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4134 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4135 /*TODO: support pnoforce*/
4136 }
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05304137 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4138 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4139 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4140 kfree(cmd);
4141 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4142 }
4143#endif /*FEATURE_WLAN_SCAN_PNO*/
4144 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4145 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4146 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4147 kfree(cmd);
4148 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4149 }
4150 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4151 tSirTxPerTrackingParam tTxPerTrackingParam;
4152 char *ptr;
4153
4154 if (18 < cmd_len)
4155 {
4156 ptr = (char*)(cmd + 18);
4157 }else{
4158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4159 "CMD LENGTH %d is not correct",cmd_len);
4160 kfree(cmd);
4161 return -EINVAL;
4162 }
4163
4164 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4165 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4166 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4167 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4168 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4169 {
4170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4171 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4172 kfree(cmd);
4173 return -EIO;
4174 }
4175
4176 // parameters checking
4177 // period has to be larger than 0
4178 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4179 {
4180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4181 kfree(cmd);
4182 return -EIO;
4183 }
4184
4185 // use default value 5 is the input is not reasonable. in unit of 10%
4186 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4187 {
4188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4189 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4190 }
4191
4192 // default is 5
4193 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4194 {
4195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4196 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4197 }
4198
4199 if (eHAL_STATUS_SUCCESS !=
4200 sme_SetTxPerTracking(pHddCtx->hHal,
4201 hdd_tx_per_hit_cb,
4202 (void*)pAdapter, &tTxPerTrackingParam)) {
4203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4204 rc = -EIO;
4205 }
4206 }
4207 else {
4208 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4209 __func__, cmd);
4210 }
4211done:
4212 /* many of the commands write information back into the command
4213 string using snprintf(). check the return value here in one
4214 place */
4215 if ((ret < 0) || (ret >= cmd_len))
4216 {
4217 /* there was an encoding error or overflow */
4218 rc = -EINVAL;
4219 }
4220 else if (ret > 0)
4221 {
4222 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4223 {
4224 hddLog(VOS_TRACE_LEVEL_ERROR,
4225 "%s: failed to copy data to user buffer", __func__);
4226 kfree(cmd);
4227 return -EFAULT;
4228 }
4229 wrqu->data.length = ret;
4230 }
4231
4232 if (ioctl_debug)
4233 {
4234 pr_info("%s: rsp [%s] len [%d] status %d\n",
4235 __func__, cmd, wrqu->data.length, rc);
4236 }
4237 kfree(cmd);
4238 EXIT();
4239 return rc;
4240}
4241
4242static int iw_set_priv(struct net_device *dev,
4243 struct iw_request_info *info,
4244 union iwreq_data *wrqu, char *extra)
4245{
4246 int ret;
4247 vos_ssr_protect(__func__);
4248 ret = __iw_set_priv(dev, info, wrqu, extra);
4249 vos_ssr_unprotect(__func__);
4250
4251 return ret;
4252}
4253
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304254static int __iw_set_nick(struct net_device *dev,
4255 struct iw_request_info *info,
4256 union iwreq_data *wrqu, char *extra)
4257{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304258 hdd_adapter_t *pAdapter;
4259 hdd_context_t *pHddCtx;
4260 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304261
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304262 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304263
4264 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4265 if (NULL == pAdapter)
4266 {
4267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4268 "%s: Adapter is NULL",__func__);
4269 return -EINVAL;
4270 }
4271
4272 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4273 ret = wlan_hdd_validate_context(pHddCtx);
4274 if (0 != ret)
4275 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304276 return ret;
4277 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304278 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304279 return 0;
4280}
4281
Jeff Johnson295189b2012-06-20 16:38:30 -07004282static int iw_set_nick(struct net_device *dev,
4283 struct iw_request_info *info,
4284 union iwreq_data *wrqu, char *extra)
4285{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304286 int ret;
4287
4288 vos_ssr_protect(__func__);
4289 ret = __iw_set_nick(dev, info, wrqu, extra);
4290 vos_ssr_unprotect(__func__);
4291
4292 return ret;
4293}
4294
4295static int __iw_get_nick(struct net_device *dev,
4296 struct iw_request_info *info,
4297 union iwreq_data *wrqu, char *extra)
4298{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304299 hdd_adapter_t *pAdapter;
4300 hdd_context_t *pHddCtx;
4301 int ret = 0;
4302
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304304
4305 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4306 if (NULL == pAdapter)
4307 {
4308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4309 "%s: Adapter is NULL",__func__);
4310 return -EINVAL;
4311 }
4312
4313 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4314 ret = wlan_hdd_validate_context(pHddCtx);
4315 if (0 != ret)
4316 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304317 return ret;
4318 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304319 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004320 return 0;
4321}
4322
4323static int iw_get_nick(struct net_device *dev,
4324 struct iw_request_info *info,
4325 union iwreq_data *wrqu, char *extra)
4326{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304327 int ret;
4328
4329 vos_ssr_protect(__func__);
4330 ret = __iw_get_nick(dev, info, wrqu, extra);
4331 vos_ssr_unprotect(__func__);
4332
4333 return ret;
4334}
4335
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304336/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304337static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4338{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304339 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4340 hdd_context_t *pHddCtx;
4341 hdd_station_ctx_t *pHddStaCtx;
4342 v_S7_t snr = 0, rssi = 0;
4343 eHalStatus status = eHAL_STATUS_SUCCESS;
4344
4345 ENTER();
4346
4347 if (NULL == pAdapter)
4348 {
4349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4350 "%s: Adapter is NULL",__func__);
4351 return NULL;
4352 }
4353
4354 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4355 status = wlan_hdd_validate_context(pHddCtx);
4356 if (0 != status)
4357 {
4358 return NULL;
4359 }
4360
4361 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4362 if (NULL == pHddStaCtx)
4363 {
4364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4365 "%s: STA Context is NULL",__func__);
4366 return NULL;
4367 }
4368
4369 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4370 {
4371 wlan_hdd_get_station_stats(pAdapter);
4372 wlan_hdd_get_snr(pAdapter, &snr);
4373 wlan_hdd_get_rssi(pAdapter, &rssi);
4374
4375 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4376 pAdapter->iwStats.status = 0;
4377 pAdapter->iwStats.qual.qual = snr;
4378 pAdapter->iwStats.qual.level = rssi;
4379 pAdapter->iwStats.qual.noise = rssi - snr;
4380 pAdapter->iwStats.discard.code = 0;
4381 pAdapter->iwStats.discard.retries= 0;
4382 pAdapter->iwStats.miss.beacon = 0;
4383 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4384 }
4385 else
4386 {
4387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4388 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4389 return NULL;
4390 }
4391
4392 EXIT();
4393 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004394}
4395
4396static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4397{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304398
4399 struct iw_statistics *stats;
4400
4401 vos_ssr_protect(__func__);
4402 stats = __get_wireless_stats(dev);
4403 vos_ssr_unprotect(__func__);
4404
4405 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004406}
4407
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304408static int __iw_set_encode(struct net_device *dev,
4409 struct iw_request_info *info,
4410 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004411
4412{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304413 hdd_adapter_t *pAdapter;
4414 hdd_station_ctx_t *pHddStaCtx;
4415 hdd_wext_state_t *pWextState;
4416 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 struct iw_point *encoderq = &(wrqu->encoding);
4418 v_U32_t keyId;
4419 v_U8_t key_length;
4420 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4421 v_BOOL_t fKeyPresent = 0;
4422 int i;
4423 eHalStatus status = eHAL_STATUS_SUCCESS;
4424
4425
4426 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304427 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4428 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4431 "%s: Adapter is NULL",__func__);
4432 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 }
4434
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304435 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4436 status = wlan_hdd_validate_context(pHddCtx);
4437 if (0 != status)
4438 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304439 return status;
4440 }
4441 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4442 if (NULL == pWextState)
4443 {
4444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4445 "%s: pWextState is NULL ",__func__);
4446 return -EINVAL;
4447 }
4448 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4449 if (NULL == pHddStaCtx)
4450 {
4451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4452 "%s: STA Context is NULL",__func__);
4453 return -EINVAL;
4454 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004455
4456 keyId = encoderq->flags & IW_ENCODE_INDEX;
4457
4458 if(keyId)
4459 {
4460 if(keyId > MAX_WEP_KEYS)
4461 {
4462 return -EINVAL;
4463 }
4464
4465 fKeyPresent = 1;
4466 keyId--;
4467 }
4468 else
4469 {
4470 fKeyPresent = 0;
4471 }
4472
4473
4474 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4475 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 if(!fKeyPresent) {
4478
4479 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4480
4481 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4482 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4483 }
4484 }
4485 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4486 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4487 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4488 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4489
4490 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4491 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4492
4493 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4494 {
4495 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4496 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004497 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304498 {
4499 long ret;
4500 ret = wait_for_completion_interruptible_timeout(
4501 &pAdapter->disconnect_comp_var,
4502 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4503 if (ret <= 0)
4504 hddLog(VOS_TRACE_LEVEL_ERROR,
4505 FL("failed wait on disconnect_comp_var %ld"), ret);
4506 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004507 }
4508
4509 return status;
4510
4511 }
4512
4513 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4514 {
4515 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4516
4517 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4518
4519 }
4520
4521
4522 if(wrqu->data.length > 0)
4523 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004524 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004525
4526 key_length = wrqu->data.length;
4527
4528 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4529
4530 if(5 == key_length)
4531 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004532 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004533
4534 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4535 {
4536 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4537 }
4538 else
4539 {
4540 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4541 }
4542 }
4543 else if(13 == key_length)
4544 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004545 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004546
4547 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4548 {
4549 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4550 }
4551 else
4552 {
4553 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4554 }
4555 }
4556 else
4557 {
4558 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004559 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 return -EINVAL;
4561 }
4562
4563 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4564 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4565 pWextState->roamProfile.EncryptionType.numEntries = 1;
4566 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4567 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4568 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4569
4570 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4571 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4572 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4573 {
4574
4575 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4576
4577 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4578 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4579
4580 return status;
4581 }
4582 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304583 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 return 0;
4585}
4586
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304587static int iw_set_encode(struct net_device *dev,
4588 struct iw_request_info *info,
4589 union iwreq_data *wrqu,char *extra)
4590{
4591 int ret;
4592
4593 vos_ssr_protect(__func__);
4594 ret = __iw_set_encode(dev, info, wrqu, extra);
4595 vos_ssr_unprotect(__func__);
4596
4597 return ret;
4598}
4599
4600static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 struct iw_request_info *info,
4602 struct iw_point *dwrq,
4603 char *extra)
4604{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304605 hdd_adapter_t *pAdapter;
4606 hdd_wext_state_t *pWextState;
4607 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 int keyId;
4609 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4610 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304611 int i, ret = 0;
4612 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004613
4614 ENTER();
4615
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304616 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4617 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004618 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4620 "%s: Adapter is NULL",__func__);
4621 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004622 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304623 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4624 ret = wlan_hdd_validate_context(pHddCtx);
4625 if (0 != ret)
4626 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304627 return ret;
4628 }
4629 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4630 if (NULL == pWextState)
4631 {
4632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4633 "%s: pWextState is NULL",__func__);
4634 return -EINVAL;
4635 }
4636 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004637
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 keyId = pRoamProfile->Keys.defaultIndex;
4639
4640 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4641 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004642 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 return -EINVAL;
4644 }
4645
4646 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4647 {
4648 dwrq->flags |= IW_ENCODE_ENABLED;
4649 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304650 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4651 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 }
4653 else
4654 {
4655 dwrq->flags |= IW_ENCODE_DISABLED;
4656 }
4657
4658 for(i=0; i < MAX_WEP_KEYS; i++)
4659 {
4660 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4661 {
4662 continue;
4663 }
4664 else
4665 {
4666 break;
4667 }
4668 }
4669
4670 if(MAX_WEP_KEYS == i)
4671 {
4672 dwrq->flags |= IW_ENCODE_NOKEY;
4673 }
4674 else
4675 {
4676 dwrq->flags |= IW_ENCODE_ENABLED;
4677 }
4678
4679 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4680
4681 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4682 {
4683 dwrq->flags |= IW_ENCODE_DISABLED;
4684 }
4685
4686 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4687
4688 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4689 {
4690 dwrq->flags |= IW_ENCODE_OPEN;
4691 }
4692 else
4693 {
4694 dwrq->flags |= IW_ENCODE_RESTRICTED;
4695 }
4696 EXIT();
4697 return 0;
4698
4699}
4700
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304701static int iw_get_encodeext(struct net_device *dev,
4702 struct iw_request_info *info,
4703 struct iw_point *dwrq,
4704 char *extra)
4705{
4706 int ret;
4707 vos_ssr_protect(__func__);
4708 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4709 vos_ssr_unprotect(__func__);
4710
4711 return ret;
4712}
4713
4714static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 struct iw_request_info *info,
4716 union iwreq_data *wrqu, char *extra)
4717{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304718 hdd_adapter_t *pAdapter;
4719 hdd_station_ctx_t *pHddStaCtx;
4720 hdd_wext_state_t *pWextState;
4721 hdd_context_t *pHddCtx;
4722 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004723
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304724 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004725 v_U32_t status = 0;
4726
4727 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4728
4729 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4730
4731 int key_index;
4732 struct iw_point *encoding = &wrqu->encoding;
4733 tCsrRoamSetKey setKey;
4734 v_U32_t roamId= 0xFF;
4735 VOS_STATUS vos_status;
4736
4737 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304738 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4739 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4742 "%s: Adapter is NULL",__func__);
4743 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304745 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4746 status = wlan_hdd_validate_context(pHddCtx);
4747 if (0 != status)
4748 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304749 return status;
4750 }
4751 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4752 if (NULL == pHddStaCtx)
4753 {
4754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4755 "%s: STA Context is NULL",__func__);
4756 return -EINVAL;
4757 }
4758 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4759 if (NULL == pWextState)
4760 {
4761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4762 "%s: pWextState is NULL",__func__);
4763 return -EINVAL;
4764 }
4765 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 key_index = encoding->flags & IW_ENCODE_INDEX;
4767
4768 if(key_index > 0) {
4769
4770 /*Convert from 1-based to 0-based keying*/
4771 key_index--;
4772 }
4773 if(!ext->key_len) {
4774
4775 /*Set the encrytion type to NONE*/
4776 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4777 return status;
4778 }
4779
4780 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4781 (IW_ENCODE_ALG_WEP == ext->alg))
4782 {
4783 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4784
Agarwal Ashish971c2882013-10-30 20:11:12 +05304785 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4786 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 return -EINVAL;
4788 }
4789 else {
4790 /*Static wep, update the roam profile with the keys */
4791 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4792 key_index < CSR_MAX_NUM_KEY) {
4793 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4794 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4795
4796 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4797 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4798
4799 }
4800 }
4801 return status;
4802 }
4803
4804 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4805
4806 setKey.keyId = key_index;
4807 setKey.keyLength = ext->key_len;
4808
4809 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4810 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4811 }
4812
4813 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4814 /*Key direction for group is RX only*/
4815 setKey.keyDirection = eSIR_RX_ONLY;
4816 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4817 }
4818 else {
4819
4820 setKey.keyDirection = eSIR_TX_RX;
4821 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4822 }
4823
4824 /*For supplicant pae role is zero*/
4825 setKey.paeRole = 0;
4826
4827 switch(ext->alg)
4828 {
4829 case IW_ENCODE_ALG_NONE:
4830 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4831 break;
4832
4833 case IW_ENCODE_ALG_WEP:
4834 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4835 break;
4836
4837 case IW_ENCODE_ALG_TKIP:
4838 {
4839 v_U8_t *pKey = &setKey.Key[0];
4840
4841 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4842
4843 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4844
4845 /*Supplicant sends the 32bytes key in this order
4846
4847 |--------------|----------|----------|
4848 | Tk1 |TX-MIC | RX Mic |
4849 |--------------|----------|----------|
4850 <---16bytes---><--8bytes--><--8bytes-->
4851
4852 */
4853 /*Sme expects the 32 bytes key to be in the below order
4854
4855 |--------------|----------|----------|
4856 | Tk1 |RX-MIC | TX Mic |
4857 |--------------|----------|----------|
4858 <---16bytes---><--8bytes--><--8bytes-->
4859 */
4860 /* Copy the Temporal Key 1 (TK1) */
4861 vos_mem_copy(pKey,ext->key,16);
4862
4863 /*Copy the rx mic first*/
4864 vos_mem_copy(&pKey[16],&ext->key[24],8);
4865
4866 /*Copy the tx mic */
4867 vos_mem_copy(&pKey[24],&ext->key[16],8);
4868
4869 }
4870 break;
4871
4872 case IW_ENCODE_ALG_CCMP:
4873 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4874 break;
4875
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004876#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004877#define IW_ENCODE_ALG_KRK 6
4878 case IW_ENCODE_ALG_KRK:
4879 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4880 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004881#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004882
4883 default:
4884 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4885 break;
4886 }
4887
4888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004889 ("%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 -07004890
4891#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304892 /* The supplicant may attempt to set the PTK once pre-authentication
4893 is done. Save the key in the UMAC and include it in the ADD
4894 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304896 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304898 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4899 "%s: Update PreAuth Key success", __func__);
4900 return 0;
4901 }
4902 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
4903 {
4904 hddLog(VOS_TRACE_LEVEL_ERROR,
4905 "%s: Update PreAuth Key failed", __func__);
4906 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 }
4908#endif /* WLAN_FEATURE_VOWIFI_11R */
4909
4910 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4911
4912 vos_status = wlan_hdd_check_ula_done(pAdapter);
4913 if ( vos_status != VOS_STATUS_SUCCESS )
4914 {
4915 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4916 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
4917 __LINE__, vos_status );
4918
4919 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4920 }
4921
4922 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
4923
4924 if ( halStatus != eHAL_STATUS_SUCCESS )
4925 {
4926 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4927 "[%4d] sme_RoamSetKey returned ERROR status= %d",
4928 __LINE__, halStatus );
4929
4930 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4931 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304932 EXIT();
4933 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004934}
4935
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304936static int iw_set_encodeext(struct net_device *dev,
4937 struct iw_request_info *info,
4938 union iwreq_data *wrqu, char *extra)
4939{
4940 int ret;
4941
4942 vos_ssr_protect(__func__);
4943 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4944 vos_ssr_unprotect(__func__);
4945
4946 return ret;
4947}
4948
4949static int __iw_set_retry(struct net_device *dev,
4950 struct iw_request_info *info,
4951 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004952{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304953 hdd_adapter_t *pAdapter;
4954 tHalHandle hHal;
4955 hdd_context_t *pHddCtx;
4956 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004957
4958 ENTER();
4959
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304960 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4961 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004962 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4964 "%s: Adapter is NULL",__func__);
4965 return -EINVAL;
4966 }
4967
4968 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4969 ret = wlan_hdd_validate_context(pHddCtx);
4970 if (0 != ret)
4971 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304972 return ret;
4973 }
4974
4975 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4976 if (NULL == hHal)
4977 {
4978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4979 "%s: Hal Context is NULL",__func__);
4980 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004981 }
4982
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4984 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4985
Arif Hussain6d2a3322013-11-17 19:50:10 -08004986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004987
4988 return -EINVAL;
4989 }
4990
4991 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
4992
4993 if((wrqu->retry.flags & IW_RETRY_LONG))
4994 {
4995 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
4996 {
c_hpothub8245442013-11-20 23:41:09 +05304997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4998 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 return -EIO;
5000 }
5001 }
5002 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5003 {
5004 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5005 {
c_hpothub8245442013-11-20 23:41:09 +05305006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5007 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 return -EIO;
5009 }
5010 }
5011 }
5012 else
5013 {
5014 return -EOPNOTSUPP;
5015 }
5016
Arif Hussain6d2a3322013-11-17 19:50:10 -08005017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005018
5019 EXIT();
5020
5021 return 0;
5022
5023}
5024
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305025static int iw_set_retry(struct net_device *dev,
5026 struct iw_request_info *info,
5027 union iwreq_data *wrqu, char *extra)
5028{
5029 int ret;
5030
5031 vos_ssr_protect(__func__);
5032 ret = __iw_set_retry(dev, info, wrqu, extra);
5033 vos_ssr_unprotect(__func__);
5034
5035 return ret;
5036}
5037
5038static int __iw_get_retry(struct net_device *dev,
5039 struct iw_request_info *info,
5040 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005041{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305042 hdd_adapter_t *pAdapter;
5043 hdd_context_t *pHddCtx;
5044 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305046 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005047
5048 ENTER();
5049
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305050 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5051 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005052 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5054 "%s: Adapter is NULL",__func__);
5055 return -EINVAL;
5056 }
5057
5058 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5059 ret = wlan_hdd_validate_context(pHddCtx);
5060 if (0 != ret)
5061 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305062 return ret;
5063 }
5064
5065 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5066 if (NULL == hHal)
5067 {
5068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5069 "%s: Hal Context is NULL",__func__);
5070 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005071 }
5072
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 if((wrqu->retry.flags & IW_RETRY_LONG))
5074 {
5075 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5076
5077 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5078 {
c_hpothub8245442013-11-20 23:41:09 +05305079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5080 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005081 return -EIO;
5082 }
5083
5084 wrqu->retry.value = retry;
5085 }
5086 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5087 {
5088 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5089
5090 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5091 {
c_hpothub8245442013-11-20 23:41:09 +05305092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5093 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 return -EIO;
5095 }
5096
5097 wrqu->retry.value = retry;
5098 }
5099 else {
5100 return -EOPNOTSUPP;
5101 }
5102
Arif Hussain6d2a3322013-11-17 19:50:10 -08005103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005104
5105 EXIT();
5106
5107 return 0;
5108}
5109
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305110static int iw_get_retry(struct net_device *dev,
5111 struct iw_request_info *info,
5112 union iwreq_data *wrqu, char *extra)
5113{
5114 int ret;
5115
5116 vos_ssr_protect(__func__);
5117 ret = __iw_get_retry(dev, info, wrqu, extra);
5118 vos_ssr_unprotect(__func__);
5119
5120 return ret;
5121}
5122
5123static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 struct iw_request_info *info,
5125 union iwreq_data *wrqu,
5126 char *extra)
5127{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305128 hdd_adapter_t *pAdapter;
5129 hdd_context_t *pHddCtx;
5130 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5132 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305133 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005134
5135 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305136 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5137 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5140 "%s:Adapter is NULL",__func__);
5141 return -EINVAL;
5142 }
5143 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5144 ret = wlan_hdd_validate_context(pHddCtx);
5145 if (0 != ret)
5146 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305147 return ret;
5148 }
5149 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5150 if (NULL == pHddStaCtx)
5151 {
5152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5153 "%s:STA context is NULL",__func__);
5154 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005155 }
5156
5157 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5158 switch (mlme->cmd) {
5159 case IW_MLME_DISASSOC:
5160 case IW_MLME_DEAUTH:
5161
5162 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5163 {
5164 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5165
5166 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5167 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5168
5169 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5170 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5171
Jeff Johnson43971f52012-07-17 12:26:56 -07005172 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305173 {
5174 long ret;
5175 ret = wait_for_completion_interruptible_timeout(
5176 &pAdapter->disconnect_comp_var,
5177 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5178 if (ret <= 0)
5179 hddLog(VOS_TRACE_LEVEL_ERROR,
5180 FL("failed wait on disconnect_comp_var %ld"), ret);
5181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005183 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005184 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005185
5186 /* Resetting authKeyMgmt */
5187 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5188
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305189 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 netif_tx_disable(dev);
5191 netif_carrier_off(dev);
5192
5193 }
5194 else
5195 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005196 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 -07005197 }
5198 break;
5199 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005200 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005201 return -EINVAL;
5202 }//end of switch
5203
5204 EXIT();
5205
5206 return status;
5207
5208}
5209
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305210static int iw_set_mlme(struct net_device *dev,
5211 struct iw_request_info *info,
5212 union iwreq_data *wrqu,
5213 char *extra)
5214{
5215 int ret;
5216
5217 vos_ssr_protect(__func__);
5218 ret = __iw_set_mlme(dev, info, wrqu, extra);
5219 vos_ssr_unprotect(__func__);
5220
5221 return ret;
5222}
5223
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305224int wlan_hdd_set_proximity(int set_value, tHalHandle hal)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305225{
5226 sHwCalValues hwCalValues;
5227 uint16 hwCalTxPower;
5228 uint8 txPwr = TX_PWR_DEF;
5229
5230 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5231
5232 if (TRUE == set_value) {
5233 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5234 NULL, sizeof(sHwCalValues) )
5235 != VOS_STATUS_SUCCESS) {
5236 return -EINVAL;
5237 }
5238 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5239
5240 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5241 hwCalTxPower, hwCalValues.calData.hwParam7);
5242
5243 txPwr = (int8)(hwCalTxPower & 0x00FF);
5244 txPwr = txPwr/10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305245 if (txPwr == 0)
5246 txPwr = TX_PWR_DEF;
5247 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305248 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305249 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305250 txPwr = TX_PWR_MAX;
5251
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305252 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305253 eHAL_STATUS_SUCCESS) {
5254 hddLog(VOS_TRACE_LEVEL_ERROR,
5255 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5256 return -EIO;
5257 }
5258
5259 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5260 txPwr /= 10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305261 if (txPwr == 0)
5262 txPwr = TX_PWR_DEF;
5263 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305264 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305265 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305266 txPwr = TX_PWR_MAX;
5267
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305268 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305269 eHAL_STATUS_SUCCESS) {
5270 hddLog(VOS_TRACE_LEVEL_ERROR,
5271 FL("setting tx power failed for 5GHz band %d"), txPwr);
5272 return -EIO;
5273 }
5274 }
5275 else if(FALSE == set_value) {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305276 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305277 eHAL_STATUS_SUCCESS) {
5278 hddLog(VOS_TRACE_LEVEL_ERROR,
5279 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5280 return -EIO;
5281 }
5282
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305283 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305284 eHAL_STATUS_SUCCESS) {
5285 hddLog(VOS_TRACE_LEVEL_ERROR,
5286 FL("setting tx power failed for 5GHz band %d"), txPwr);
5287 return -EIO;
5288 }
5289 }
5290 else {
5291 return -EINVAL;
5292 }
5293
5294 return eHAL_STATUS_SUCCESS;
5295}
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05305296
5297static int hdd_set_dynamic_aggregation(int value, hdd_adapter_t *adapter)
5298{
5299 int ret = 0;
5300 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5301 tDelBaParams del_session;
5302
5303 del_session.session_id = adapter->sessionId;
5304 hddLog(LOG1, FL("WLAN_SET_DYNNAMIC_AGGREGATION: %d"), value);
5305
5306 if ((value == DISABLE_AGGREGATION) || (value == ENABLE_AGGREGATION))
5307 {
5308 ret = ccmCfgSetInt(hal, WNI_CFG_ENABLE_TX_RX_AGGREGATION,
5309 value,NULL, eANI_BOOLEAN_FALSE);
5310 if (ret != eHAL_STATUS_SUCCESS)
5311 {
5312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5313 FL("failed to set ini parameter, WNI_CFG_ENABLE_TX_RX_AGGREGATION"));
5314 return -EIO;
5315 }
5316
5317 } else {
5318 hddLog(VOS_TRACE_LEVEL_ERROR,
5319 FL("Invalid command input"));
5320 return -EINVAL;
5321 }
5322 ret = sme_del_sta_ba_session_req(hal, del_session);
5323 if (ret != VOS_STATUS_SUCCESS) {
5324 hddLog(VOS_TRACE_LEVEL_ERROR, FL("send ba session req fail"));
5325 return -EINVAL;
5326 }
5327
5328 EXIT();
5329 return ret;
5330}
5331
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305332static int
5333wlan_hdd_sta_mon_op(hdd_context_t *hdd_ctx, uint32_t set_value,
5334 hdd_adapter_t *mon_adapter, hdd_mon_ctx_t *mon_ctx)
5335{
5336 hdd_station_ctx_t *sta_ctx;
5337 VOS_STATUS disable_bmps_status;
5338 hdd_adapter_t *sta_adapter;
5339 v_CONTEXT_t vos_ctx = (WLAN_HDD_GET_CTX(mon_adapter))->pvosContext;
5340
5341 if (!test_bit(DEVICE_IFACE_OPENED, &mon_adapter->event_flags)) {
5342 hddLog(LOGE, FL("Monitor Interface is not OPENED"));
5343 return -EINVAL;
5344 }
5345
5346 if (set_value == MON_MODE_STOP) {
5347 if (wlan_hdd_check_monitor_state(hdd_ctx))
5348 return 0;
5349 return -EINVAL;
5350 }
5351
5352 sta_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION);
5353 if (!sta_adapter) {
5354 hddLog(LOGE, FL("No Station adapter"));
5355 return -EINVAL;
5356 }
5357
5358 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
5359 if (!sta_ctx || !hdd_connIsConnected(sta_ctx)) {
5360 hddLog(LOGE, FL("STA is not connected"));
5361 return -EINVAL;
5362 }
5363
5364 if (hdd_isConnectionInProgress(hdd_ctx, NULL, NULL)) {
5365 hddLog(LOGE, FL("Roaming or set-key is in progress"));
5366 return -EBUSY;
5367 }
5368
5369 hdd_disable_roaming(hdd_ctx);
5370
5371 hddLog(LOG1, FL("Disable BMPS"));
5372 disable_bmps_status = hdd_disable_bmps_imps(hdd_ctx,
5373 WLAN_HDD_INFRA_STATION);
5374 if (disable_bmps_status != VOS_STATUS_SUCCESS) {
5375 hddLog(LOGE, FL("Cannot start monitor mode"));
5376 hdd_restore_roaming(hdd_ctx);
5377 return -EINVAL;
5378 }
5379
5380 mon_ctx->ChannelNo = sta_ctx->conn_info.operationChannel;
5381
5382 /*
5383 * In STA + Mon mode, firmware should not consider ChannelBW
5384 */
5385 mon_ctx->ChannelBW = 0;
5386 mon_ctx->crcCheckEnabled = 0;
5387 wlan_hdd_mon_set_typesubtype(mon_ctx, 100);
5388 mon_ctx->is80211to803ConReq = 0;
5389 WLANTL_SetIsConversionReq(vos_ctx, 0);
5390 mon_adapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
5391
5392 mon_ctx->state = MON_MODE_START;
5393 return 0;
5394}
5395
5396/* set param sub-ioctls */
5397static int __iw_mon_setint_getnone(struct net_device *dev,
5398 struct iw_request_info *info,
5399 union iwreq_data *wrqu, char *extra)
5400{
5401 hdd_adapter_t *adapter;
5402 hdd_context_t *hdd_ctx;
5403 hdd_mon_ctx_t *mon_ctx;
5404 int *value = (int *)extra;
5405 int sub_cmd = value[0];
5406 int set_value = value[1];
5407 int ret = 0; /* success */
5408 tVOS_CONCURRENCY_MODE concurrency_mode;
5409
5410 ENTER();
5411 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5412 if (!adapter || adapter->device_mode != WLAN_HDD_MONITOR)
5413 return -EINVAL;
5414
5415 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5416 ret = wlan_hdd_validate_context(hdd_ctx);
5417 if (ret)
5418 return ret;
5419
5420 concurrency_mode = hdd_ctx->concurrency_mode;
5421 if (concurrency_mode != VOS_STA_MON) {
5422 hddLog(LOGE, "invalid concurrency mode %d", concurrency_mode);
5423 return -EINVAL;
5424 }
5425
5426 switch(sub_cmd) {
5427
5428 case WE_SET_MONITOR_STATE:
5429 {
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05305430 void *cookie;
5431 struct hdd_request *request;
5432 static const struct hdd_request_params params = {
5433 .priv_size = 0,
5434 .timeout_ms = MON_MODE_MSG_TIMEOUT,
5435 };
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305436
5437 mon_ctx = WLAN_HDD_GET_MONITOR_CTX_PTR(adapter);
5438 if(!mon_ctx) {
5439 hddLog(LOGE, "Monitor Context NULL");
5440 ret = -EIO;
5441 break;
5442 }
5443
5444 if (mon_ctx->state == set_value) {
5445 hddLog(LOGE, FL("already in same mode curr_mode:%d req_mode: %d"),
5446 mon_ctx->state, set_value);
5447 break;
5448 }
5449
5450 ret = wlan_hdd_sta_mon_op(hdd_ctx, set_value,
5451 adapter,mon_ctx);
5452 if (ret)
5453 break;
5454
5455 mon_ctx->state = set_value;
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05305456 request = hdd_request_alloc(&params);
5457 if (!request) {
5458 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
5459 ret = -ENOMEM;
5460 break;
5461 }
5462 cookie = hdd_request_cookie(request);
5463 if (wlan_hdd_mon_postMsg(cookie, mon_ctx,
5464 hdd_mon_post_msg_cb)
5465 != VOS_STATUS_SUCCESS) {
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305466 hddLog(LOGE, FL("failed to post MON MODE REQ"));
5467 mon_ctx->state =
5468 (mon_ctx->state==MON_MODE_START) ?
5469 MON_MODE_STOP : MON_MODE_START;
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305470 ret = -EIO;
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05305471 } else {
5472 ret = hdd_request_wait_for_response(request);
5473 if (ret){
5474 hddLog(LOGE, FL("failed to wait on monitor mode completion %d"),
5475 ret);
5476 } else if (mon_ctx->state == MON_MODE_STOP) {
5477 hddLog(LOG1, FL("Enable BMPS"));
5478 hdd_enable_bmps_imps(hdd_ctx);
5479 hdd_restore_roaming(hdd_ctx);
5480 }
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305481 }
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05305482 hdd_request_put(request);
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305483 }
5484 break;
5485
5486 default:
5487 {
5488 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
5489 sub_cmd, set_value);
5490 }
5491 break;
5492 }
5493
5494 EXIT();
5495 return ret;
5496}
5497
Jeff Johnson295189b2012-06-20 16:38:30 -07005498/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305499static int __iw_setint_getnone(struct net_device *dev,
5500 struct iw_request_info *info,
5501 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005502{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305503 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305504 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305505 hdd_wext_state_t *pWextState;
5506 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305507 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005508 int *value = (int *)extra;
5509 int sub_cmd = value[0];
5510 int set_value = value[1];
5511 int ret = 0; /* success */
5512 int enable_pbm, enable_mp;
5513#ifdef CONFIG_HAS_EARLYSUSPEND
5514 v_U8_t nEnableSuspendOld;
5515#endif
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305516 void *cookie;
5517 struct hdd_request *request;
Jeff Johnson295189b2012-06-20 16:38:30 -07005518
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305519 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305520 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5521 if (NULL == pAdapter)
5522 {
5523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5524 "%s: Adapter is NULL",__func__);
5525 return -EINVAL;
5526 }
5527 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5528 ret = wlan_hdd_validate_context(pHddCtx);
5529 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005530 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305531 return ret;
5532 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305533
Katya Nigameae74b62015-05-28 17:19:16 +05305534 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305535 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305536 /* In monitor mode hHal is NULL */
5537 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5538 if (NULL == hHal)
5539 {
5540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5541 "%s: Hal Context is NULL",__func__);
5542 return -EINVAL;
5543 }
Katya Nigameae74b62015-05-28 17:19:16 +05305544 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5545 if (NULL == pWextState)
5546 {
5547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5548 "%s: pWextState is NULL",__func__);
5549 return -EINVAL;
5550 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005551
Katya Nigameae74b62015-05-28 17:19:16 +05305552 INIT_COMPLETION(pWextState->completion_var);
5553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 switch(sub_cmd)
5555 {
5556 case WE_SET_11D_STATE:
5557 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005558 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005559 memset(&smeConfig, 0x00, sizeof(smeConfig));
5560
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305561 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5562 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 sme_GetConfigParam(hHal,&smeConfig);
5564 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5565
Arif Hussain6d2a3322013-11-17 19:50:10 -08005566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005567
5568 sme_UpdateConfig(hHal,&smeConfig);
5569 }
5570 else {
5571 return -EINVAL;
5572 }
5573 break;
5574 }
5575
5576 case WE_WOWL:
5577 {
5578 switch (set_value)
5579 {
5580 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305581 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005582 break;
5583 case 0x01:
5584 case 0x02:
5585 case 0x03:
5586 enable_mp = (set_value & 0x01) ? 1 : 0;
5587 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005588 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5590 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5591 break;
5592 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005593 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 ret = -EINVAL;
5595 break;
5596 }
5597
5598 break;
5599 }
5600 case WE_SET_POWER:
5601 {
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305602 if (wlan_hdd_check_monitor_state(pHddCtx)) {
5603 hddLog(LOGE, FL("setPower not allowed in STA + MON"));
5604 ret = -EOPNOTSUPP;
5605 break;
5606 }
5607
Jeff Johnson295189b2012-06-20 16:38:30 -07005608 switch (set_value)
5609 {
5610 case 0: //Full Power
5611 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305612 eHalStatus status = eHAL_STATUS_FAILURE;
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305613 static const struct hdd_request_params params = {
5614 .priv_size = 0,
5615 .timeout_ms = WLAN_WAIT_TIME_POWER,
5616 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005617
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305618 if (NULL == hHal)
5619 return -EINVAL;
5620
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305621 request = hdd_request_alloc(&params);
5622 if (!request) {
5623 hddLog(VOS_TRACE_LEVEL_ERROR,
5624 FL("Request allocation failure"));
5625 return VOS_STATUS_E_NOMEM;
5626 }
5627 cookie = hdd_request_cookie(request);
5628
Jeff Johnson295189b2012-06-20 16:38:30 -07005629 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305630 iw_power_callback_func, cookie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305632
Jeff Johnson72a40512013-12-19 10:14:15 -08005633 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 {
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305635 ret = hdd_request_wait_for_response(request);
5636 if (ret) {
Jeff Johnson72a40512013-12-19 10:14:15 -08005637 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305638 FL("SME timeout while requesting bmps"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 }
5640 }
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305641
5642 /*
5643 * either we never sent a request, we sent a request and
5644 * received a response or we sent a request and timed out.
5645 * Regardless we are done with the request.
5646 */
5647 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08005648
Arif Hussain6d2a3322013-11-17 19:50:10 -08005649 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 break;
5651 }
5652 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305653 if (hHal)
5654 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5655 else
5656 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 break;
5658 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305659 if (hHal)
5660 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5661 else
5662 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005663 break;
5664 case 3: //Request Bmps
5665 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305666 eHalStatus status = eHAL_STATUS_FAILURE;
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305667 static const struct hdd_request_params params = {
5668 .priv_size = 0,
5669 .timeout_ms = WLAN_WAIT_TIME_POWER,
5670 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005671
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305672 if (NULL == hHal)
5673 return -EINVAL;
5674
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305675 request = hdd_request_alloc(&params);
5676 if (!request) {
5677 hddLog(VOS_TRACE_LEVEL_ERROR,
5678 FL("Request allocation failure"));
5679 return VOS_STATUS_E_NOMEM;
5680 }
5681 cookie = hdd_request_cookie(request);
5682
Jeff Johnson295189b2012-06-20 16:38:30 -07005683 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305684 iw_power_callback_func, cookie);
Jeff Johnson72a40512013-12-19 10:14:15 -08005685 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 {
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305687 ret = hdd_request_wait_for_response(request);
5688 if (ret) {
Jeff Johnson72a40512013-12-19 10:14:15 -08005689 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305690 FL("SME timeout while requesting fullpower"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 }
5692 }
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305693
5694 /*
5695 * either we never sent a request, we sent a request and
5696 * received a response or we sent a request and timed out.
5697 * Regardless we are done with the request.
5698 */
5699 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08005700
Arif Hussain6d2a3322013-11-17 19:50:10 -08005701 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 break;
5703 }
5704 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305705 if (hHal)
5706 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5707 else
5708 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 break;
5710 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305711 if (hHal)
5712 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5713 else
5714 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 break;
5716 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305717 if (hHal)
5718 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5719 else
5720 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005721 break;
5722 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305723 if (hHal)
5724 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5725 else
5726 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005727 break;
5728 case 8: //Request Standby
5729#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005730#endif
5731 break;
5732 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305733 if (hHal)
5734 sme_StartAutoBmpsTimer(hHal);
5735 else
5736 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005737 break;
5738 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305739 if (hHal)
5740 sme_StopAutoBmpsTimer(hHal);
5741 else
5742 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005743 break;
5744#ifdef CONFIG_HAS_EARLYSUSPEND
5745 case 11://suspend to standby
5746#ifdef CONFIG_HAS_EARLYSUSPEND
5747 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5748 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5750#endif
5751 break;
5752 case 12://suspend to deep sleep
5753#ifdef CONFIG_HAS_EARLYSUSPEND
5754 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5755 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5757#endif
5758 break;
5759 case 13://resume from suspend
5760#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005761#endif
5762 break;
5763#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005765 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 ret = -EINVAL;
5767 break;
5768 }
5769 break;
5770 }
5771
5772 case WE_SET_MAX_ASSOC:
5773 {
5774 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305775 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
5776 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07005777 {
5778 ret = -EINVAL;
5779 }
5780 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5781 set_value, NULL, eANI_BOOLEAN_FALSE)
5782 != eHAL_STATUS_SUCCESS )
5783 {
c_hpothub8245442013-11-20 23:41:09 +05305784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5785 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 ret = -EIO;
5787 }
5788 break;
5789 }
5790
5791 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5792 {
5793 if( 0 == set_value )
5794 {
5795 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5796 }
5797 else if ( 1 == set_value )
5798 {
5799 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5800 }
5801 else
5802 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005803 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 ret = -EINVAL;
5805 }
5806 break;
5807 }
5808
5809 case WE_SET_DATA_INACTIVITY_TO:
5810 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305811 if (NULL == hHal)
5812 return -EINVAL;
5813
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5815 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5816 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5817 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5818 set_value,
5819 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5820 {
5821 hddLog(LOGE,"Failure: Could not pass on "
5822 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005823 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 ret = -EINVAL;
5825 }
5826 break;
5827 }
5828 case WE_SET_MAX_TX_POWER:
5829 {
5830 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5831 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5832
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305833 if (NULL == hHal)
5834 return -EINVAL;
5835
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5837 __func__, set_value);
5838 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5839 eHAL_STATUS_SUCCESS )
5840 {
5841 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5842 __func__);
5843 return -EIO;
5844 }
5845
5846 break;
5847 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005848 case WE_SET_MAX_TX_POWER_2_4:
5849 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305850 if (NULL == hHal)
5851 return -EINVAL;
5852
Arif Hussaina5ebce02013-08-09 15:09:58 -07005853 hddLog(VOS_TRACE_LEVEL_INFO,
5854 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5855 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305856 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07005857 eHAL_STATUS_SUCCESS)
5858 {
5859 hddLog(VOS_TRACE_LEVEL_ERROR,
5860 "%s: Setting maximum tx power failed for 2.4 GHz band",
5861 __func__);
5862 return -EIO;
5863 }
5864
5865 break;
5866 }
5867 case WE_SET_MAX_TX_POWER_5_0:
5868 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305869 if (NULL == hHal)
5870 return -EINVAL;
5871
Arif Hussaina5ebce02013-08-09 15:09:58 -07005872 hddLog(VOS_TRACE_LEVEL_INFO,
5873 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5874 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305875 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07005876 eHAL_STATUS_SUCCESS)
5877 {
5878 hddLog(VOS_TRACE_LEVEL_ERROR,
5879 "%s: Setting maximum tx power failed for 5.0 GHz band",
5880 __func__);
5881 return -EIO;
5882 }
5883
5884 break;
5885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 case WE_SET_HIGHER_DTIM_TRANSITION:
5887 {
5888 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5889 (set_value == eANI_BOOLEAN_TRUE)))
5890 {
5891 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5892 ret = -EINVAL;
5893 }
5894 else
5895 {
5896 if(pAdapter->higherDtimTransition != set_value)
5897 {
5898 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005899 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 }
5901 }
5902
5903 break;
5904 }
5905
5906 case WE_SET_TM_LEVEL:
5907 {
5908 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005909 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5911
5912 break;
5913 }
5914
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305915 case WE_ENABLE_STRICT_FCC_REG:
5916 {
5917 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5918 struct wiphy *wiphy = NULL;
5919 long lrc;
5920 int status;
5921
5922 wiphy = hddCtxt->wiphy;
5923 if(wiphy == NULL)
5924 {
5925 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5926 break;
5927 }
5928 init_completion(&hddCtxt->wiphy_channel_update_event);
5929
5930 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5931
5932 status = regulatory_hint(wiphy, "00");
5933 if(status < 0)
5934 {
5935 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5936 break;
5937 }
5938
5939 /* Wait for completion */
5940 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5941 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5942 if (lrc <= 0)
5943 {
5944 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5945 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5946 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5947 }
5948 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5949
5950 break;
5951 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005952 case WE_SET_DEBUG_LOG:
5953 {
5954 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5955 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305956 if (hHal)
5957 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5958 else
5959 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005960 break;
5961 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305962#ifdef FEATURE_WLAN_TDLS
5963 case WE_SET_TDLS_OFF_CHAN:
5964 {
5965 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5967 __func__, set_value);
5968 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5969 break;
5970 }
5971 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5972 {
5973 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5975 __func__, set_value);
5976 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5977 break;
5978 }
5979 case WE_SET_TDLS_OFF_CHAN_MODE:
5980 {
5981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5982 __func__, set_value);
5983 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5984 break;
5985 }
5986#endif
Peng Xu2446a892014-09-05 17:21:18 +05305987 case WE_SET_SCAN_BAND_PREFERENCE:
5988 {
5989 tSmeConfigParams smeConfig;
5990 memset(&smeConfig, 0x00, sizeof(smeConfig));
5991 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5992 ret = -EINVAL;
5993 break;
5994 }
5995 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5996
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305997 if ((eCSR_BAND_ALL == set_value ||
5998 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
5999 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306000 sme_GetConfigParam(hHal, &smeConfig);
6001 smeConfig.csrConfig.scanBandPreference = set_value;
6002
6003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6004 "set band scan preference = %d\n",
6005 smeConfig.csrConfig.scanBandPreference);
6006
6007 sme_UpdateConfig(hHal, &smeConfig);
6008 }
6009 else {
6010 ret = -EINVAL;
6011 }
6012 break;
6013 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306014 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6015 * connection happens so that the params can take effect during
6016 * association. Also this should not be used in STA+p2p concurrency
6017 * as the param will also effect the STA mode.
6018 */
6019 case WE_SET_MIRACAST_VENDOR_CONFIG:
6020 {
6021 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306022
Abhishek Singh01c73d12015-03-12 15:13:44 +05306023 hddLog(LOG1, FL(
6024 "Set Miracast vendor tuning %d"), set_value);
6025
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306026 if (NULL == hHal)
6027 return -EINVAL;
6028
Abhishek Singh01c73d12015-03-12 15:13:44 +05306029 if (1 == set_value || 0 == set_value)
6030 {
6031 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6032 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6033 {
6034 hddLog( LOGE, FL("set vendor miracast config failed"));
6035 ret = -EIO;
6036 }
6037 }
6038 else
6039 {
6040 hddLog(LOGE,
6041 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6042 ret = -EINVAL;
6043 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306044 break;
6045 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306046
6047 case WE_GET_FRAME_LOG:
6048 {
6049 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6050 != VOS_STATUS_SUCCESS)
6051 {
6052 ret = -EINVAL;
6053 }
6054 break;
6055 }
6056
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306057 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6058 {
6059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6060 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306061 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306062 {
6063 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6064 set_value);
6065 }
6066 else
6067 ret = -EINVAL;
6068
6069 break;
6070 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306071 /* Bit mask value to enable RTS/CTS for different modes
6072 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6073 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6074 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6075 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6076 * for 5 GHz, VHT80 - 0x1000
6077 */
6078 case WE_SET_RTS_CTS_HTVHT:
6079 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306080
Abhishek Singh41988ba2015-05-25 19:42:29 +05306081 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6082
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306083 if (NULL == hHal)
6084 return -EINVAL;
6085
Abhishek Singh41988ba2015-05-25 19:42:29 +05306086 if (eHAL_STATUS_SUCCESS !=
6087 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6088 {
6089 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6090 ret = -EINVAL;
6091 }
6092 break;
6093 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306094 case WE_SET_MONITOR_STATE:
6095 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306096 tVOS_CON_MODE mode = hdd_get_conparam();
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306097 int ret;
6098 void *cookie;
6099 struct hdd_request *request;
6100 static const struct hdd_request_params params = {
6101 .priv_size = 0,
6102 .timeout_ms = MON_MODE_MSG_TIMEOUT,
6103 };
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306104
6105 if( VOS_MONITOR_MODE != mode)
6106 {
6107 hddLog(LOGE, "invalid mode %d", mode);
6108 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306109 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306110 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306111
6112 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6113 if( pMonCtx == NULL )
6114 {
6115 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306116 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306117 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306118 }
6119 if (pMonCtx->state == set_value)
6120 {
6121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6122 FL("already in same mode curr_mode:%d req_mode: %d"),
6123 pMonCtx->state, set_value);
6124 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306125 }
6126 pMonCtx->state = set_value;
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306127 request = hdd_request_alloc(&params);
6128 if (!request) {
6129 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
6130 ret = -ENOMEM;
6131 break;
6132 }
6133 cookie = hdd_request_cookie(request);
6134
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306135 if (VOS_STATUS_SUCCESS !=
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306136 wlan_hdd_mon_postMsg(cookie, pMonCtx,
6137 hdd_mon_post_msg_cb)) {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6139 FL("failed to post MON MODE REQ"));
6140 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6141 MON_MODE_STOP : MON_MODE_START;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306142 ret = -EIO;
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306143 } else {
6144 ret = hdd_request_wait_for_response(request);
6145 if (ret) {
6146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6147 FL("failed to wait on monitor mode completion %d"),
6148 ret);
6149 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306150 }
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306151 hdd_request_put(request);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306152 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306153 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306154 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6155 {
6156 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6157 tAniWifiStartLog start_log;
6158 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6159 !vos_isPktStatsEnabled())
6160 {
6161 hddLog(LOGE, FL("per pkt stats not enabled"));
6162 return -EINVAL;
6163 }
6164 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6165
6166 if (1 == set_value || 0 == set_value)
6167 {
6168 start_log.ringId = RING_ID_PER_PACKET_STATS;
6169 start_log.flag = 0;
6170 if (set_value)
6171 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6172 else
6173 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6174
6175 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6176 }
6177 else
6178 {
6179 hddLog(LOGE,
6180 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6181 set_value);
6182 ret = -EINVAL;
6183 }
6184 break;
6185 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306186 case WE_SET_PROXIMITY_ENABLE:
6187 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306188 if (NULL == hHal)
6189 return -EINVAL;
6190
6191 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306192 break;
6193 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05306194 case WE_CAP_TSF:
6195 {
6196 if (NULL == hHal)
6197 return -EINVAL;
6198
6199 ret = hdd_capture_tsf(pAdapter, (uint32_t *)&set_value, 1);
6200 break;
6201 }
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306202 case WE_SET_MODULATED_DTIM:
6203 {
6204 if ((set_value < CFG_ENABLE_MODULATED_DTIM_MIN) ||
6205 (set_value > CFG_ENABLE_MODULATED_DTIM_MAX)) {
6206 hddLog(LOGE, FL("Invalid value %d in gEnableModuleDTIM"),
6207 set_value);
6208 return -EINVAL;
6209 } else {
6210 ret = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->
6211 enableModulatedDTIM = set_value;
6212 }
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05306213 }
6214 case WLAN_SET_DYNNAMIC_AGGREGATION:
6215 {
6216 if (NULL == hHal)
6217 return -EINVAL;
6218
6219 ret = hdd_set_dynamic_aggregation(set_value, pAdapter);
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306220 break;
6221 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006222 default:
6223 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006224 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 sub_cmd, set_value);
6226 break;
6227 }
6228 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306229 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 return ret;
6231}
6232
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306233static int iw_setint_getnone(struct net_device *dev,
6234 struct iw_request_info *info,
6235 union iwreq_data *wrqu, char *extra)
6236{
6237 int ret;
6238
6239 vos_ssr_protect(__func__);
6240 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6241 vos_ssr_unprotect(__func__);
6242
6243 return 0;
6244}
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306245
6246static
6247int iw_mon_setint_getnone(struct net_device *dev,
6248 struct iw_request_info *info,
6249 union iwreq_data *wrqu, char *extra)
6250{
6251 int ret;
6252
6253 vos_ssr_protect(__func__);
6254 ret = __iw_mon_setint_getnone(dev, info, wrqu, extra);
6255 vos_ssr_unprotect(__func__);
6256
6257 return 0;
6258}
6259
Jeff Johnson295189b2012-06-20 16:38:30 -07006260/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306261static int __iw_setchar_getnone(struct net_device *dev,
6262 struct iw_request_info *info,
6263 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006264{
6265 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306266 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006268 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306269 hdd_adapter_t *pAdapter;
6270 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006271#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306272 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006273#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306274 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306275 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006276
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306277 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306278
6279 if (!capable(CAP_NET_ADMIN))
6280 {
6281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6282 FL("permission check failed"));
6283 return -EPERM;
6284 }
6285
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306286 pAdapter = (netdev_priv(dev));
6287 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006288 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6290 "%s: Adapter is NULL",__func__);
6291 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006292 }
6293
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306294 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6295 ret = wlan_hdd_validate_context(pHddCtx);
6296 if (0 != ret)
6297 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306298 return ret;
6299 }
6300#ifdef WLAN_FEATURE_VOWIFI
6301 pConfig = pHddCtx->cfg_ini;
6302#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306303 /* helper function to get iwreq_data with compat handling. */
6304 if (hdd_priv_get_data(&s_priv_data, wrqu))
6305 {
6306 return -EINVAL;
6307 }
6308
6309 /* make sure all params are correctly passed to function */
6310 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6311 {
6312 return -EINVAL;
6313 }
6314
6315 sub_cmd = s_priv_data.flags;
6316
Arif Hussain0273cba2014-01-07 20:58:29 -08006317 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306318 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6319 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006320 if (NULL == pBuffer)
6321 {
6322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6323 "mem_alloc_copy_from_user_helper fail");
6324 return -ENOMEM;
6325 }
6326
6327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306328 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006329 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6330 "%s: Received data %s", __func__, pBuffer);
6331
Jeff Johnson295189b2012-06-20 16:38:30 -07006332 switch(sub_cmd)
6333 {
6334 case WE_WOWL_ADD_PTRN:
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306335 if (wlan_hdd_check_monitor_state(pHddCtx)) {
6336 hddLog(LOGE, FL("wowlAddPtrn not allowed in STA + MON"));
6337 ret = -EOPNOTSUPP;
6338 break;
6339 }
6340
Arif Hussain6d2a3322013-11-17 19:50:10 -08006341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006342 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 break;
6344 case WE_WOWL_DEL_PTRN:
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306345 if (wlan_hdd_check_monitor_state(pHddCtx)) {
6346 hddLog(LOGE, FL("wowlDelPtrn 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, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006352 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 break;
6354#if defined WLAN_FEATURE_VOWIFI
6355 case WE_NEIGHBOR_REPORT_REQUEST:
6356 {
6357 tRrmNeighborReq neighborReq;
6358 tRrmNeighborRspCallbackInfo callbackInfo;
6359
6360 if (pConfig->fRrmEnable)
6361 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306363 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 if( !neighborReq.no_ssid )
6365 {
Girish Gowli552fc072014-06-14 18:26:16 +05306366 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006367 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 }
6369
6370 callbackInfo.neighborRspCallback = NULL;
6371 callbackInfo.neighborRspCallbackContext = NULL;
6372 callbackInfo.timeout = 5000; //5 seconds
6373 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6374 }
6375 else
6376 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006377 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 ret = -EINVAL;
6379 }
6380 }
6381 break;
6382#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 case WE_SET_AP_WPS_IE:
6384 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306385 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006388 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 if (VOS_STATUS_SUCCESS != vstatus)
6390 {
6391 ret = -EINVAL;
6392 }
6393 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306394 case WE_SET_ENCRYPT_MSG:
6395 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6396 if (NULL == pkt)
6397 {
6398 hddLog(VOS_TRACE_LEVEL_ERROR,
6399 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306400 ret = -ENOMEM;
6401 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306402 }
6403
6404 memset(pkt, 0, sizeof(tSirpkt80211));
6405
6406 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6407 hddLog(VOS_TRACE_LEVEL_ERROR,
6408 FL("Firmware is not DISA capable"));
6409 ret = -EINVAL;
6410 vos_mem_free(pkt);
6411 break;
6412 }
6413
6414 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6415
6416 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6417 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6418 if (eHAL_STATUS_SUCCESS != ret) {
6419 hddLog(VOS_TRACE_LEVEL_ERROR,
6420 FL("SENDEncryptMSG: fail to post WDA cmd"));
6421 ret = -EINVAL;
6422 }
6423 vos_mem_free(pkt);
6424
6425 break;
6426
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 default:
6428 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006429 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 ret = -EINVAL;
6431 break;
6432 }
6433 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006434 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306435
6436 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 return ret;
6438}
6439
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306440static int iw_setchar_getnone(struct net_device *dev,
6441 struct iw_request_info *info,
6442 union iwreq_data *wrqu, char *extra)
6443{
6444 int ret;
6445
6446 vos_ssr_protect(__func__);
6447 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6448 vos_ssr_unprotect(__func__);
6449
6450 return ret;
6451}
6452
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306453struct get_antenna_idx_priv {
6454 int antenna_id;
6455};
6456
6457static void hdd_get_current_antenna_index_cb(int antenna_id, void *context)
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306458{
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306459 struct hdd_request *request;
6460 struct get_antenna_idx_priv *priv;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306461
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306462 request = hdd_request_get(context);
6463 if (!request) {
6464 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
6465 return;
6466 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306467
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306468 priv = hdd_request_priv(request);
6469 priv->antenna_id = antenna_id;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306470
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306471 hdd_request_complete(request);
6472 hdd_request_put(request);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306473
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306474}
6475
6476static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6477 int *antennaIndex)
6478{
6479 hdd_context_t *pHddCtx;
6480 eHalStatus halStatus;
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306481 int ret;
6482 void *cookie;
6483 struct hdd_request *request;
6484 struct get_antenna_idx_priv *priv;
6485 static const struct hdd_request_params params = {
6486 .priv_size = sizeof(*priv),
6487 .timeout_ms = WLAN_WAIT_TIME_STATS,
6488 };
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306489
6490 ENTER();
6491 if (NULL == pAdapter)
6492 {
6493 hddLog(VOS_TRACE_LEVEL_WARN,
6494 "%s: Invalid context, pAdapter", __func__);
6495 return VOS_STATUS_E_FAULT;
6496 }
6497 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6498 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6499 {
6500 return VOS_STATUS_E_FAULT;
6501 }
6502 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6503 {
6504 hddLog(VOS_TRACE_LEVEL_ERROR,
6505 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6506 __func__);
6507 return VOS_STATUS_E_NOSUPPORT;
6508 }
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306509
6510 request = hdd_request_alloc(&params);
6511 if (!request) {
6512 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
6513 return VOS_STATUS_E_NOMEM;
6514 }
6515 cookie = hdd_request_cookie(request);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306516
6517 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306518 hdd_get_current_antenna_index_cb,
6519 cookie, pAdapter->sessionId);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306520 if (eHAL_STATUS_SUCCESS != halStatus)
6521 {
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306522 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6523 __func__);
6524 /* we'll returned a cached value below */
6525 *antennaIndex = -1;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306526 }
6527 else
6528 {
6529 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula543559a2018-05-02 13:06:40 +05306530 ret = hdd_request_wait_for_response(request);
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306531 if (ret)
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306532 {
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306533 hddLog(VOS_TRACE_LEVEL_ERROR,
6534 FL("SME timeout while retrieving Antenna Index"));
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306535 *antennaIndex = -1;
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306536 }
6537 else
6538 {
6539 priv = hdd_request_priv(request);
6540 pAdapter->antennaIndex = priv->antenna_id;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306541 }
6542 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306543
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306544 if (*antennaIndex != -1)
6545 *antennaIndex = pAdapter->antennaIndex;
6546
6547 /*
6548 * either we never sent a request, we sent a request and received a
6549 * response or we sent a request and timed out. Regardless we are
6550 * done with the request.
6551 */
6552 hdd_request_put(request);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306553
6554 EXIT();
6555 return VOS_STATUS_SUCCESS;
6556}
6557
Jeff Johnson295189b2012-06-20 16:38:30 -07006558/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306559static int __iw_setnone_getint(struct net_device *dev,
6560 struct iw_request_info *info,
6561 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006562{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306563 hdd_adapter_t *pAdapter;
6564 tHalHandle hHal;
6565 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006566 int *value = (int *)extra;
6567 int ret = 0; /* success */
6568
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306569 ENTER();
6570
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306571 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6572 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006573 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6575 "%s: Adapter is NULL",__func__);
6576 return -EINVAL;
6577 }
6578 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6579 ret = wlan_hdd_validate_context(pHddCtx);
6580 if (0 != ret)
6581 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306582 return ret;
6583 }
6584 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6585 if (NULL == hHal)
6586 {
6587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6588 "%s: Hal Context is NULL",__func__);
6589 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006591
6592 switch (value[0])
6593 {
6594 case WE_GET_11D_STATE:
6595 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006596 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306598
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6600
Arif Hussain6d2a3322013-11-17 19:50:10 -08006601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006602
6603 break;
6604 }
6605
6606 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 break;
6609
6610 case WE_PMC_STATE:
6611 {
6612 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006614 break;
6615 }
6616 case WE_GET_WLAN_DBG:
6617 {
6618 vos_trace_display();
6619 *value = 0;
6620 break;
6621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006622 case WE_GET_MAX_ASSOC:
6623 {
6624 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6625 {
c_hpothub8245442013-11-20 23:41:09 +05306626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6627 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 ret = -EIO;
6629 }
Girish Gowli385be612014-09-18 11:17:20 +05306630#ifdef WLAN_SOFTAP_VSTA_FEATURE
6631 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6632 {
6633 if (*value > VSTA_NUM_ASSOC_STA)
6634 {
6635 *value = VSTA_NUM_ASSOC_STA;
6636 }
6637 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6638 (*value > (VSTA_NUM_ASSOC_STA -
6639 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6640 {
6641 *value = (VSTA_NUM_ASSOC_STA -
6642 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6643 }
6644 }
6645 else
6646#endif
6647 {
6648 if (*value > NUM_ASSOC_STA)
6649 {
6650 *value = NUM_ASSOC_STA;
6651 }
6652 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6653 (*value > (NUM_ASSOC_STA -
6654 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6655 {
6656 *value = (NUM_ASSOC_STA -
6657 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6658 }
6659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 break;
6661 }
6662
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 case WE_GET_WDI_DBG:
6664 {
6665 wpalTraceDisplay();
6666 *value = 0;
6667 break;
6668 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006669
6670 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6671 {
6672 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6673 break;
6674 }
6675 case WE_GET_CONCURRENCY_MODE:
6676 {
6677 *value = hdd_get_concurrency_mode ( );
6678
Arif Hussain6d2a3322013-11-17 19:50:10 -08006679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 break;
6681 }
6682
Peng Xu2446a892014-09-05 17:21:18 +05306683 case WE_GET_SCAN_BAND_PREFERENCE:
6684 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306685 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306686 sme_GetConfigParam(hHal, &smeConfig);
6687 *value = smeConfig.csrConfig.scanBandPreference;
6688
6689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6690 "scanBandPreference = %d\n", *value);
6691 break;
6692 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306693 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6694 {
6695 wlan_hdd_get_current_antenna_index(pAdapter, value);
6696 break;
6697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006698 default:
6699 {
6700 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6701 break;
6702 }
6703 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306704 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 return ret;
6706}
6707
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306708static int iw_setnone_getint(struct net_device *dev,
6709 struct iw_request_info *info,
6710 union iwreq_data *wrqu, char *extra)
6711{
6712 int ret;
6713
6714 vos_ssr_protect(__func__);
6715 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6716 vos_ssr_unprotect(__func__);
6717
6718 return ret;
6719
6720}
Jeff Johnson295189b2012-06-20 16:38:30 -07006721/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306722int __iw_set_three_ints_getnone(struct net_device *dev,
6723 struct iw_request_info *info,
6724 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006725{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306726 hdd_adapter_t *pAdapter;
6727 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006728 int *value = (int *)extra;
6729 int sub_cmd = value[0];
6730 int ret = 0;
6731
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306732 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306733
6734 if (!capable(CAP_NET_ADMIN))
6735 {
6736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6737 FL("permission check failed"));
6738 return -EPERM;
6739 }
6740
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306741 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6742 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006743 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6745 "%s: Adapter is NULL",__func__);
6746 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006747 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306748 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6749 ret = wlan_hdd_validate_context(pHddCtx);
6750 if (0 != ret)
6751 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306752 return ret;
6753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 switch(sub_cmd)
6755 {
6756 case WE_SET_WLAN_DBG:
6757 {
6758 vos_trace_setValue( value[1], value[2], value[3]);
6759 break;
6760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 case WE_SET_WDI_DBG:
6762 {
6763 wpalTraceSetLevel( value[1], value[2], value[3]);
6764 break;
6765 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006766 case WE_SET_SAP_CHANNELS:
6767 {
6768 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6769 break;
6770 }
6771
6772 default:
6773 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006774 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006775 break;
6776 }
6777 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306778 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 return ret;
6780}
6781
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306782int iw_set_three_ints_getnone(struct net_device *dev,
6783 struct iw_request_info *info,
6784 union iwreq_data *wrqu, char *extra)
6785{
6786 int ret;
6787
6788 vos_ssr_protect(__func__);
6789 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6790 vos_ssr_unprotect(__func__);
6791
6792 return ret;
6793}
6794
6795static int __iw_get_char_setnone(struct net_device *dev,
6796 struct iw_request_info *info,
6797 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006798{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306799 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006800 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306801 hdd_context_t *pHddCtx;
6802 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006803#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006804 hdd_wext_state_t *pWextState;
6805#endif
6806
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306807 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306808 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006809 if (pAdapter == NULL)
6810 {
6811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6812 "%s: pAdapter is NULL!", __func__);
6813 return -EINVAL;
6814 }
Alok Kumar69a8b752017-11-08 15:24:32 +05306815
6816 if (WLAN_HDD_MONITOR == pAdapter->device_mode ||
6817 WLAN_HDD_FTM == pAdapter->device_mode)
6818 return ret;
6819
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306820 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6821 ret = wlan_hdd_validate_context(pHddCtx);
6822 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006823 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306824 return ret;
6825 }
6826#ifdef WLAN_FEATURE_11W
6827 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6828 if (NULL == pWextState)
6829 {
6830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6831 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006832 return -EINVAL;
6833 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306834#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006835
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 switch(sub_cmd)
6837 {
6838 case WE_WLAN_VERSION:
6839 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006840 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006841 break;
6842 }
6843
6844 case WE_GET_STATS:
6845 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306846 tHalHandle hHal = NULL;
6847 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006848 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6849 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6850 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05306851 hdd_arp_stats_t *parpStats = &pAdapter->hdd_stats.hddArpStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07006852
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306853
Jeff Johnson295189b2012-06-20 16:38:30 -07006854 snprintf(extra, WE_MAX_STR_LEN,
6855 "\nTransmit"
6856 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6857 "\n dropped BK %u, BE %u, VI %u, VO %u"
6858 "\n classified BK %u, BE %u, VI %u, VO %u"
6859 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6860 "\n queued BK %u, BE %u, VI %u, VO %u"
6861 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006862 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 "\n fetched BK %u, BE %u, VI %u, VO %u"
6864 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6865 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006866 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006867 "\n flushed BK %u, BE %u, VI %u, VO %u"
6868 "\n\nReceive"
6869 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6870 "\n\nResetsStats"
6871 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05306872 "\n"
6873 "\n\nARP Transmit"
6874 "\nTransmit Count %u, dropped %u"
6875 "\n\nARP Receive"
6876 "\nReceive Count %u, dropped %u, Delivered %u, Refused %u, Drop Reason %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 "\n",
6878 pStats->txXmitCalled,
6879 pStats->txXmitDropped,
6880 pStats->txXmitBackPressured,
6881 pStats->txXmitQueued,
6882
6883 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6884 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6885 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6886 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6887
6888 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6889 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6890 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6891 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6892
6893 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6894 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6895 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6896 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6897
6898 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6899 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6900 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6901 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6902
6903 pStats->txFetched,
6904 pStats->txFetchEmpty,
6905 pStats->txFetchLowResources,
6906 pStats->txFetchDequeueError,
6907
6908 pStats->txFetchDequeued,
6909 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006910 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006911 pStats->txCompleted,
6912 pStats->txFlushed,
6913
6914 pStats->txFetchedAC[WLANTL_AC_BK],
6915 pStats->txFetchedAC[WLANTL_AC_BE],
6916 pStats->txFetchedAC[WLANTL_AC_VI],
6917 pStats->txFetchedAC[WLANTL_AC_VO],
6918
6919 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6920 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6921 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6922 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6923
6924 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6925 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6926 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6927 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6928
Ravi Joshi41914632013-10-21 23:02:21 -07006929 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6930 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6931 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6932 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6933
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 pStats->txFlushedAC[WLANTL_AC_BK],
6935 pStats->txFlushedAC[WLANTL_AC_BE],
6936 pStats->txFlushedAC[WLANTL_AC_VI],
6937 pStats->txFlushedAC[WLANTL_AC_VO],
6938
6939 pStats->rxChains,
6940 pStats->rxPackets,
6941 pStats->rxDropped,
6942 pStats->rxDelivered,
6943 pStats->rxRefused,
6944
6945 pResetStats->totalLogpResets,
6946 pResetStats->totalCMD53Failures,
6947 pResetStats->totalMutexReadFailures,
6948 pResetStats->totalMIFErrorFailures,
6949 pResetStats->totalFWHearbeatFailures,
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05306950 pResetStats->totalUnknownExceptions,
6951
6952 parpStats->txCount,
6953 parpStats->txDropped,
6954
6955 parpStats->rxCount,
6956 parpStats->rxDropped,
6957 parpStats->rxDelivered,
6958 parpStats->rxRefused,
6959 parpStats->reason
Jeff Johnson295189b2012-06-20 16:38:30 -07006960 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306961 wrqu->data.length = strlen(extra);
6962
6963 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6964
6965 if (hHal)
6966 pMac = PMAC_STRUCT( hHal );
6967
6968 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6969 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6970 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306971 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6972 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6973 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6974 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306975 "\n",
6976 pMac->pmm.BmpscntSleep,
6977 pMac->pmm.BmpscntAwake,
6978 pMac->pmm.BmpsSleeReqFailCnt,
6979 pMac->pmm.BmpsWakeupReqFailCnt,
6980 pMac->pmm.ImpsCntSleep,
6981 pMac->pmm.ImpsCntAwake,
6982 pMac->pmm.ImpsSleepErrCnt,
6983 pMac->pmm.ImpsWakeupErrCnt,
6984 pMac->pmm.ImpsLastErr
6985 );
6986 }
6987
Jeff Johnson295189b2012-06-20 16:38:30 -07006988 wrqu->data.length = strlen(extra)+1;
6989 break;
6990 }
6991
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306992/* The case prints the current state of the HDD, SME, CSR, PE, TL
6993 *it can be extended for WDI Global State as well.
6994 *And currently it only checks P2P_CLIENT adapter.
6995 *P2P_DEVICE and P2P_GO have not been added as of now.
6996*/
6997 case WE_GET_STATES:
6998 {
6999 int buf = 0, len = 0;
7000 int adapter_num = 0;
7001 int count = 0, check = 1;
7002
7003 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007004 tHalHandle hHal = NULL;
7005 tpAniSirGlobal pMac = NULL;
7006 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307007
7008 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7009 hdd_adapter_t *useAdapter = NULL;
7010
7011 /* Print wlan0 or p2p0 states based on the adapter_num
7012 *by using the correct adapter
7013 */
7014 while ( adapter_num < 2 )
7015 {
7016 if ( WLAN_ADAPTER == adapter_num )
7017 {
7018 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007019 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307020 "\n\n wlan0 States:-");
7021 len += buf;
7022 }
7023 else if ( P2P_ADAPTER == adapter_num )
7024 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007025 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307026 "\n\n p2p0 States:-");
7027 len += buf;
7028
7029 if( !pHddCtx )
7030 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007031 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307032 "\n pHddCtx is NULL");
7033 len += buf;
7034 break;
7035 }
7036
7037 /*Printing p2p0 states only in the case when the device is
7038 configured as a p2p_client*/
7039 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7040 if ( !useAdapter )
7041 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007042 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307043 "\n Device not configured as P2P_CLIENT.");
7044 len += buf;
7045 break;
7046 }
7047 }
7048
7049 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007050 if (!hHal) {
7051 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7052 "\n pMac is NULL");
7053 len += buf;
7054 break;
7055 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307056 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007057 if (!pMac) {
7058 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7059 "\n pMac is NULL");
7060 len += buf;
7061 break;
7062 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307063 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7064 if( !pHddStaCtx )
7065 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007066 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307067 "\n pHddStaCtx is NULL");
7068 len += buf;
7069 break;
7070 }
7071
7072 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7073
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007074 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307075 "\n HDD Conn State - %s "
7076 "\n \n SME State:"
7077 "\n Neighbour Roam State - %s"
7078 "\n CSR State - %s"
7079 "\n CSR Substate - %s"
7080 "\n \n TL STA %d State: %s",
7081 macTraceGetHDDWlanConnState(
7082 pHddStaCtx->conn_info.connState),
7083 macTraceGetNeighbourRoamState(
7084 pMac->roam.neighborRoamInfo.neighborRoamState),
7085 macTraceGetcsrRoamState(
7086 pMac->roam.curState[useAdapter->sessionId]),
7087 macTraceGetcsrRoamSubState(
7088 pMac->roam.curSubState[useAdapter->sessionId]),
7089 pHddStaCtx->conn_info.staId[0],
7090 macTraceGetTLState(tlState)
7091 );
7092 len += buf;
7093 adapter_num++;
7094 }
7095
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007096 if (pMac) {
7097 /* Printing Lim State starting with global lim states */
7098 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7099 "\n \n LIM STATES:-"
7100 "\n Global Sme State - %s "\
7101 "\n Global mlm State - %s "\
7102 "\n",
7103 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7104 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7105 );
7106 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307107
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007108 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307109 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307110 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007111 if ( pMac->lim.gpSession[count].valid )
7112 {
7113 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7114 "\n Lim Valid Session %d:-"
7115 "\n PE Sme State - %s "
7116 "\n PE Mlm State - %s "
7117 "\n",
7118 check,
7119 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7120 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7121 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307122
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007123 len += buf;
7124 check++;
7125 }
7126 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307127 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307128 }
7129
7130 wrqu->data.length = strlen(extra)+1;
7131 break;
7132 }
7133
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 case WE_GET_CFG:
7135 {
7136 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7137 wrqu->data.length = strlen(extra)+1;
7138 break;
7139 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007140#ifdef WLAN_FEATURE_11AC
7141 case WE_GET_RSSI:
7142 {
7143 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307144 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007145 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7146 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7147 wrqu->data.length = strlen(extra)+1;
7148 break;
7149 }
7150#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307151
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007152#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007153 case WE_GET_ROAM_RSSI:
7154 {
7155 v_S7_t s7Rssi = 0;
7156 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7157 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7158 wrqu->data.length = strlen(extra)+1;
7159 break;
7160 }
7161#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 case WE_GET_WMM_STATUS:
7163 {
7164 snprintf(extra, WE_MAX_STR_LEN,
7165 "\nDir: 0=up, 1=down, 3=both\n"
7166 "|------------------------|\n"
7167 "|AC | ACM |Admitted| Dir |\n"
7168 "|------------------------|\n"
7169 "|VO | %d | %3s | %d |\n"
7170 "|VI | %d | %3s | %d |\n"
7171 "|BE | %d | %3s | %d |\n"
7172 "|BK | %d | %3s | %d |\n"
7173 "|------------------------|\n",
7174 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7175 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7176 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7177 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7178 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7179 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7180 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7181 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7182 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7183 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7184 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7185 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7186
Jeff Johnsone7245742012-09-05 17:12:55 -07007187
Jeff Johnson295189b2012-06-20 16:38:30 -07007188 wrqu->data.length = strlen(extra)+1;
7189 break;
7190 }
7191 case WE_GET_CHANNEL_LIST:
7192 {
7193 VOS_STATUS status;
7194 v_U8_t i, len;
7195 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307196 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7197 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7198 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007199 tChannelListInfo channel_list;
7200
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007201 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007202 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007203 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007204 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007205 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 return -EINVAL;
7207 }
7208 buf = extra;
7209
7210 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007211 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7212 * needed = 5 * number of channels. Check ifsufficient
7213 * buffer is available and then proceed to fill the buffer.
7214 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7216 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007217 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007218 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007219 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007220 return -EINVAL;
7221 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007222 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7223 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307224 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7225 {
7226 //Printing Country code in getChannelList
7227 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7228 {
7229 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7230 "%c ", pBuf[i]);
7231 }
7232 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007233 for(i = 0 ; i < channel_list.num_channels; i++)
7234 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007235 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 }
7238 wrqu->data.length = strlen(extra)+1;
7239
7240 break;
7241 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007242#ifdef FEATURE_WLAN_TDLS
7243 case WE_GET_TDLS_PEERS:
7244 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007245 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007246 break;
7247 }
7248#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007249#ifdef WLAN_FEATURE_11W
7250 case WE_GET_11W_INFO:
7251 {
7252 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7253
7254 snprintf(extra, WE_MAX_STR_LEN,
7255 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7256 "\n Number of Unprotected Disassocs %d"
7257 "\n Number of Unprotected Deauths %d",
7258 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7259 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7260 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7261 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7262 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7263
7264 wrqu->data.length = strlen(extra)+1;
7265 break;
7266 }
7267#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307268#ifdef WLAN_FEATURE_RMC
7269 case WE_GET_IBSS_STA_INFO:
7270 {
7271 hdd_station_ctx_t *pHddStaCtx =
7272 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7273 int idx = 0;
7274 int length = 0, buf = 0;
7275
7276 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7277 {
7278 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7279 {
7280 buf = snprintf
7281 (
7282 (extra + length), WE_MAX_STR_LEN - length,
7283 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7284 pHddStaCtx->conn_info.staId[ idx ],
7285 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7286 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7287 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7288 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7289 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7290 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7291 );
7292 length += buf;
7293 }
7294 }
7295 wrqu->data.length = strlen(extra)+1;
7296 break;
7297 }
7298#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307299 case WE_GET_SNR:
7300 {
7301 v_S7_t s7snr = 0;
7302 int status = 0;
7303 hdd_context_t *pHddCtx;
7304 hdd_station_ctx_t *pHddStaCtx;
7305
7306 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7307 status = wlan_hdd_validate_context(pHddCtx);
7308 if (0 != status)
7309 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307310 return status;
7311 }
7312
7313 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7314
7315 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7316 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7317 {
7318 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7319 " ConnectionState-%d", __func__,
7320 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7321 pHddStaCtx->conn_info.connState);
7322 return -ENONET;
7323 }
7324
7325 /*update the stats in TL*/
7326 wlan_hdd_get_station_stats(pAdapter);
7327 wlan_hdd_get_snr(pAdapter, &s7snr);
7328 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7329 wrqu->data.length = strlen(extra) + 1;
7330 break;
7331 }
7332
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307333#ifdef FEATURE_OEM_DATA_SUPPORT
7334 case WE_GET_OEM_DATA_CAP:
7335 {
7336 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7337 }
7338#endif /* FEATURE_OEM_DATA_SUPPORT */
7339
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307340 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007341 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007342 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007343 break;
7344 }
7345 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307346 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007347 return 0;
7348}
7349
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307350static int iw_get_char_setnone(struct net_device *dev,
7351 struct iw_request_info *info,
7352 union iwreq_data *wrqu, char *extra)
7353{
7354 int ret;
7355
7356 vos_ssr_protect(__func__);
7357 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7358 vos_ssr_unprotect(__func__);
7359
7360 return ret;
7361}
7362
Jeff Johnson295189b2012-06-20 16:38:30 -07007363/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307364static int __iw_setnone_getnone(struct net_device *dev,
7365 struct iw_request_info *info,
7366 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007367{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307368 hdd_adapter_t *pAdapter;
7369 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307370 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007371 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307372 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007373
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307374 ENTER();
7375
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307376 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7377 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007378 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7380 "%s: Adapter is NULL",__func__);
7381 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007382 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307383 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7384 ret = wlan_hdd_validate_context(pHddCtx);
7385 if (0 != ret)
7386 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307387 return ret;
7388 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307389 /* helper function to get iwreq_data with compat handling. */
7390 if (hdd_priv_get_data(&s_priv_data, wrqu))
7391 {
7392 return -EINVAL;
7393 }
7394
7395 sub_cmd = s_priv_data.flags;
7396
Jeff Johnson295189b2012-06-20 16:38:30 -07007397 switch (sub_cmd)
7398 {
7399 case WE_CLEAR_STATS:
7400 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007402 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7403 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7404 break;
7405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 case WE_INIT_AP:
7407 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307408 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7409
7410 /* As Soft AP mode might been changed to STA already with
7411 * killing of Hostapd, need to find the adpater by name
7412 * rather than mode */
7413 hdd_adapter_t* pAdapter_to_stop =
7414 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7415 if( pAdapter_to_stop )
7416 {
7417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7418 "Adapter with name softap.0 already "
7419 "exist, ignoring the request.\nRemove the "
7420 "adapter and try again\n");
7421 break;
7422 }
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05307423
7424 if (wlan_hdd_check_monitor_state(pHddCtx)) {
7425 hddLog(LOGE, FL("initAP not allowed in STA + MON"));
7426 ret = -EOPNOTSUPP;
7427 break;
7428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007429 pr_info("Init AP trigger\n");
7430 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7431 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7432 break;
7433 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307434#ifdef WLAN_FEATURE_RMC
7435 case WE_IBSS_GET_PEER_INFO_ALL:
7436 {
7437 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7438 break;
7439 }
7440#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007441 case WE_STOP_AP:
7442 {
7443 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7444 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7445 * this is a dead code and need to find the adpater by name rather than mode */
7446 hdd_adapter_t* pAdapter_to_stop =
7447 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7448 if( pAdapter_to_stop )
7449 {
7450 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7451
7452 pr_info("Stopping AP mode\n");
7453
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307454 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7455 {
7456 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7457 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7458 }
7459
Jeff Johnson295189b2012-06-20 16:38:30 -07007460 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307461 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307462 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7464
7465 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7466 pAdapter_to_stop->macAddressCurrent.bytes);
7467 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7468 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307469
7470 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7471 {
7472 /* put the device back into BMPS */
7473 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007475 }
7476 else
7477 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007478 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007479 }
7480
7481 break;
7482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007483#ifdef WLAN_BTAMP_FEATURE
7484 case WE_ENABLE_AMP:
7485 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007487 WLANBAP_RegisterWithHCI(pAdapter);
7488 break;
7489 }
7490 case WE_DISABLE_AMP:
7491 {
7492 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7493 VOS_STATUS status;
7494
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007495 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007496
7497 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7498 status = WLANBAP_StopAmp();
7499 if(VOS_STATUS_SUCCESS != status )
7500 {
7501 pHddCtx->isAmpAllowed = VOS_TRUE;
7502 hddLog(VOS_TRACE_LEVEL_FATAL,
7503 "%s: Failed to stop AMP", __func__);
7504 }
7505 else
7506 {
7507 //a state m/c implementation in PAL is TBD to avoid this delay
7508 msleep(500);
7509 pHddCtx->isAmpAllowed = VOS_FALSE;
7510 WLANBAP_DeregisterFromHCI();
7511 }
7512
7513 break;
7514 }
7515#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007516 case WE_ENABLE_DXE_STALL_DETECT:
7517 {
schang6295e542013-03-12 15:31:23 -07007518 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7519 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007520 break;
7521 }
7522 case WE_DISPLAY_DXE_SNAP_SHOT:
7523 {
schang6295e542013-03-12 15:31:23 -07007524 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7525 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007526 break;
7527 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307528 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7529 {
7530 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7531 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307532 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307533 break;
7534 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307535
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307536 case WE_SET_REASSOC_TRIGGER:
7537 {
7538 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7539 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7540 v_U32_t roamId = 0;
7541 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307542 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7543 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307544 return 0;
7545 }
7546
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307547 case WE_STOP_OBSS_SCAN:
7548 {
7549 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7550 2.OBSS scan is stopped by Firmware during the disassociation
7551 3.OBSS stop comamnd is added for debugging purpose*/
7552 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7553 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007554
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307555 if (pAdapter == NULL)
7556 {
7557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7558 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307559 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307560 }
7561 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7562 if (pMac == NULL)
7563 {
7564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7565 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307566 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307567 }
7568 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7569 }
7570 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307571 case WE_DUMP_ROAM_TIMER_LOG:
7572 {
7573 vos_dump_roam_time_log_service();
7574 break;
7575 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307576
Mukul Sharma84f27252014-07-14 18:11:42 +05307577 case WE_RESET_ROAM_TIMER_LOG:
7578 {
7579 vos_reset_roam_timer_log();
7580 break;
7581 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307582 case WE_GET_FW_LOGS:
7583 {
7584 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7585 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307586 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307587 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307588 break;
7589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007590 default:
7591 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007592 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007593 break;
7594 }
7595 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307596 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007597 return ret;
7598}
7599
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307600static int iw_setnone_getnone(struct net_device *dev,
7601 struct iw_request_info *info,
7602 union iwreq_data *wrqu, char *extra)
7603{
7604 int ret;
7605
7606 vos_ssr_protect(__func__);
7607 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7608 vos_ssr_unprotect(__func__);
7609
7610 return ret;
7611}
7612
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307613void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7614{
7615 /*
7616 * Function to display HDD WMM information
7617 * for Tx Queues.
7618 * Prints globala as well as per client depending
7619 * whether the clients are registered or not.
7620 */
7621 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307622 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7623 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307624 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7625 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307626 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307627
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307628 for ( i=0; i< NUM_TX_QUEUES; i++)
7629 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307630 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307631 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307632 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307633 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307634
7635 for ( i=0; i< NUM_TX_QUEUES; i++) {
7636 if (tx_queue_count[i]) {
7637 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7638 i, tx_queue_count[i]);
7639 }
7640 }
7641
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307642 if(pSapCtx == NULL){
7643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7644 FL("psapCtx is NULL"));
7645 return;
7646 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307647
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307648 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307649 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7650 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307651 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307652 {
7653 hddLog(LOGE, "******STAIndex: %d*********", i);
7654 for ( j=0; j< NUM_TX_QUEUES; j++)
7655 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307656 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7657 {
7658 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307659 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7660 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307661 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7662 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307663 }
7664 }
7665 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307666 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307667
Katya Nigam1fd24402015-02-16 14:52:19 +05307668 if(pHddStaCtx == NULL){
7669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7670 FL("pHddStaCtx is NULL"));
7671 return;
7672 }
7673
7674 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7675 if(pPeerInfo == NULL){
7676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7677 FL("ppeerinfo is NULL"));
7678 return;
7679 }
7680
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307681 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7682 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7683 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7684 for (j = 0; j < NUM_TX_QUEUES; j++) {
7685 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7686 spin_lock_bh(
7687 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7688 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07007689 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%pK, NextAddress:%pK",
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307690 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7691 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7692 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7693 spin_unlock_bh(
7694 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7695 }
7696 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307697 }
7698 }
7699
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307700}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307701
Girish Gowlifb9758e2014-11-19 15:19:17 +05307702static int __iw_set_var_ints_getnone(struct net_device *dev,
7703 struct iw_request_info *info,
7704 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007705{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307706 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307707 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307708 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307709 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007710 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307711 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307712 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007713 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307714 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007715 int cmd = 0;
7716 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307717 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007718
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307719 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307720 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307721 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7723 "%s: NULL extra buffer pointer", __func__);
7724 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307725 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307726 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7727 if (NULL == pAdapter)
7728 {
7729 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7730 "%s: Adapter is NULL",__func__);
7731 return -EINVAL;
7732 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307733 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307734 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7735 ret = wlan_hdd_validate_context(pHddCtx);
7736 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007737 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307738 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007739 }
Katya Nigameae74b62015-05-28 17:19:16 +05307740 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307741 {
Katya Nigameae74b62015-05-28 17:19:16 +05307742 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7743 if (NULL == hHal)
7744 {
7745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7746 "%s: Hal Context is NULL",__func__);
7747 return -EINVAL;
7748 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307749 }
7750 sub_cmd = wrqu->data.flags;
7751
7752 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7753
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007754
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007755 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7756 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7757 {
7758 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7759 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7760 {
7761 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7762 staId = pStaCtx->conn_info.staId[0];
7763 }
7764 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7765 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7766 {
7767 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7768 staId = pAPCtx->uBCStaId;
7769 }
7770 else
7771 {
7772 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7773 return 0;
7774 }
7775 }
7776
Jeff Johnson295189b2012-06-20 16:38:30 -07007777 switch (sub_cmd)
7778 {
7779 case WE_LOG_DUMP_CMD:
7780 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307781 if(apps_args[0] == 26) {
7782 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7783 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7784 return 0;
7785 }
7786 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007787 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007788 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007789 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307790 if (hHal)
7791 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7792 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007793
7794 }
7795 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307796#ifdef WLAN_FEATURE_RMC
7797 case WE_IBSS_GET_PEER_INFO:
7798 {
7799 pr_info ( "Station ID = %d\n",apps_args[0]);
7800 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7801 }
7802 break;
7803#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007804
Jeff Johnson295189b2012-06-20 16:38:30 -07007805 case WE_P2P_NOA_CMD:
7806 {
7807 p2p_app_setP2pPs_t p2pNoA;
7808
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307809 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7810 hddLog(LOGE,
7811 FL("Setting NoA is not allowed in Device mode:%d"),
7812 pAdapter->device_mode);
7813 return -EINVAL;
7814 }
7815
Jeff Johnson295189b2012-06-20 16:38:30 -07007816 p2pNoA.opp_ps = apps_args[0];
7817 p2pNoA.ctWindow = apps_args[1];
7818 p2pNoA.duration = apps_args[2];
7819 p2pNoA.interval = apps_args[3];
7820 p2pNoA.count = apps_args[4];
7821 p2pNoA.single_noa_duration = apps_args[5];
7822 p2pNoA.psSelection = apps_args[6];
7823
7824 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7825 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007826 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7828
7829 hdd_setP2pPs(dev, &p2pNoA);
7830
7831 }
7832 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007833
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307834 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7835 {
7836 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7837 __func__, apps_args[0], apps_args[1]);
7838 vosTraceEnable(apps_args[0], apps_args[1]);
7839 }
7840 break;
7841
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007842 case WE_MTRACE_DUMP_CMD:
7843 {
7844 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7845 "bitmask_of_module %d ",
7846 __func__, apps_args[0], apps_args[1], apps_args[2],
7847 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307848 if (hHal)
7849 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7850 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007851
7852 }
7853 break;
7854
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007855 case WE_MCC_CONFIG_CREDENTIAL :
7856 {
7857 cmd = 287; //Command should be updated if there is any change
7858 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007859 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007860 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307861 if (hHal)
7862 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
7863 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007864 }
7865 else
7866 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007867 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007868 return 0;
7869 }
7870 }
7871 break;
7872
7873 case WE_MCC_CONFIG_PARAMS :
7874 {
7875 cmd = 288; //command Should be updated if there is any change
7876 // in the Riva dump command
7877 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7878 }
7879 break;
7880
Chilam NG571c65a2013-01-19 12:27:36 +05307881#ifdef FEATURE_WLAN_TDLS
7882 case WE_TDLS_CONFIG_PARAMS :
7883 {
7884 tdls_config_params_t tdlsParams;
7885
Chilam Ng01120412013-02-19 18:32:21 -08007886 tdlsParams.tdls = apps_args[0];
7887 tdlsParams.tx_period_t = apps_args[1];
7888 tdlsParams.tx_packet_n = apps_args[2];
7889 tdlsParams.discovery_period_t = apps_args[3];
7890 tdlsParams.discovery_tries_n = apps_args[4];
7891 tdlsParams.idle_timeout_t = apps_args[5];
7892 tdlsParams.idle_packet_n = apps_args[6];
7893 tdlsParams.rssi_hysteresis = apps_args[7];
7894 tdlsParams.rssi_trigger_threshold = apps_args[8];
7895 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307896
Chilam Ng01120412013-02-19 18:32:21 -08007897 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307898 }
7899 break;
7900#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307901 case WE_CONFIGURE_MONITOR_MODE:
7902 {
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307903 tVOS_CON_MODE mode = hdd_get_conparam();
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307904 int ret;
7905 void *cookie;
7906 struct hdd_request *request;
7907 static const struct hdd_request_params params = {
7908 .priv_size = 0,
7909 .timeout_ms = MON_MODE_MSG_TIMEOUT,
7910 };
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307911
7912 if (VOS_MONITOR_MODE != mode) {
7913 hddLog(LOGE, FL("invalid mode %d"), mode);
7914 return -EIO;
7915 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307916
Katya Nigamf0511f62015-05-05 16:40:57 +05307917 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7918 if( pMonCtx == NULL )
7919 {
7920 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307921 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05307922 }
7923 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7924 __func__, apps_args[0], apps_args[1], apps_args[2],
7925 apps_args[3], apps_args[4]);
7926 /* Input Validation part of FW */
7927 pMonCtx->ChannelNo = apps_args[0];
7928 pMonCtx->ChannelBW = apps_args[1];
7929 pMonCtx->crcCheckEnabled = apps_args[2];
7930 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7931 pMonCtx->is80211to803ConReq = apps_args[4];
7932 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7933 if( pMonCtx->is80211to803ConReq )
7934 pAdapter->dev->type = ARPHRD_ETHER;
7935 else
7936 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7937 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7938 {
7939 hddLog(LOGE, "%s: Filtering data packets as management and control"
7940 " cannot be converted to 802.3 ",__func__);
7941 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7942 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307943 if (MON_MODE_START == pMonCtx->state) {
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307944 request = hdd_request_alloc(&params);
7945 if (!request) {
7946 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
7947 return -ENOMEM;
7948 }
7949 cookie = hdd_request_cookie(request);
7950
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307951 if (VOS_STATUS_SUCCESS !=
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307952 wlan_hdd_mon_postMsg(cookie, pMonCtx,
7953 hdd_mon_post_msg_cb)) {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7955 FL("failed to post MON MODE REQ"));
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307956 ret = -EIO;
7957 } else {
7958 ret = hdd_request_wait_for_response(request);
7959 if (ret)
7960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7961 FL("failed to wait on monitor mode completion %d"),
7962 ret);
7963 }
7964 hdd_request_put(request);
7965 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307966 }
7967 break;
7968
7969 case WE_SET_MONITOR_MODE_FILTER:
7970 {
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307971 tVOS_CON_MODE mode = hdd_get_conparam();
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307972 int ret;
7973 void *cookie;
7974 struct hdd_request *request;
7975 static const struct hdd_request_params params = {
7976 .priv_size = 0,
7977 .timeout_ms = MON_MODE_MSG_TIMEOUT,
7978 };
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307979
7980 if (VOS_MONITOR_MODE != mode) {
7981 hddLog(LOGE, FL("invalid mode %d"), mode);
7982 return -EIO;
7983 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307984
Katya Nigamf0511f62015-05-05 16:40:57 +05307985 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7986 if( pMonCtx == NULL )
7987 {
7988 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307989 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05307990 }
7991 /* Input Validation Part of FW */
7992 pMonCtx->numOfMacFilters=1;
7993 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
7994 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
7995 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
7996 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
7997 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
7998 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
7999 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8000 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8001 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8002 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8003 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8004 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308005 if (MON_MODE_START == pMonCtx->state) {
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05308006 request = hdd_request_alloc(&params);
8007 if (!request) {
8008 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
8009 return -ENOMEM;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308010 }
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05308011 cookie = hdd_request_cookie(request);
8012
8013 if (VOS_STATUS_SUCCESS ==
8014 wlan_hdd_mon_postMsg(cookie, pMonCtx,
8015 hdd_mon_post_msg_cb)) {
8016 ret = hdd_request_wait_for_response(request);
8017 if (ret)
8018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8019 FL("failed to wait on monitor mode completion %d"),
8020 ret);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308021 }
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05308022 hdd_request_put(request);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308023 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308024 }
8025 break;
8026
Jeff Johnson295189b2012-06-20 16:38:30 -07008027 default:
8028 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008029 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8030 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008031 }
8032 break;
8033 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308034 EXIT();
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05308035 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008036}
8037
Girish Gowlifb9758e2014-11-19 15:19:17 +05308038static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8039 struct iw_request_info *info,
8040 union iwreq_data *wrqu, char *extra)
8041{
8042 int ret;
8043 union iwreq_data u_priv_wrqu;
8044 int apps_args[MAX_VAR_ARGS] = {0};
8045 int num_args;
8046
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308047 if (!capable(CAP_NET_ADMIN))
8048 {
8049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8050 FL("permission check failed"));
8051 return -EPERM;
8052 }
8053
Girish Gowlifb9758e2014-11-19 15:19:17 +05308054 /* helper function to get iwreq_data with compat handling. */
8055 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8056 {
8057 return -EINVAL;
8058 }
8059
8060 if (NULL == u_priv_wrqu.data.pointer)
8061 {
8062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8063 "%s: NULL data pointer", __func__);
8064 return -EINVAL;
8065 }
8066
8067 num_args = u_priv_wrqu.data.length;
8068 if (num_args > MAX_VAR_ARGS)
8069 {
8070 num_args = MAX_VAR_ARGS;
8071 }
8072
8073 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8074 (sizeof(int)) * num_args))
8075 {
8076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8077 "%s: failed to copy data from user buffer", __func__);
8078 return -EFAULT;
8079 }
8080
8081 vos_ssr_protect(__func__);
8082 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8083 (char *)&apps_args);
8084 vos_ssr_unprotect(__func__);
8085
8086 return ret;
8087}
8088
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308089int iw_set_var_ints_getnone(struct net_device *dev,
8090 struct iw_request_info *info,
8091 union iwreq_data *wrqu, char *extra)
8092{
8093 int ret;
8094 vos_ssr_protect(__func__);
8095 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8096 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008097
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308098 return ret;
8099}
8100
8101static int __iw_add_tspec(struct net_device *dev,
8102 struct iw_request_info *info,
8103 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008104{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308105 hdd_adapter_t *pAdapter;
8106 hdd_station_ctx_t *pHddStaCtx;
8107 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008108 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8109 int params[HDD_WLAN_WMM_PARAM_COUNT];
8110 sme_QosWmmTspecInfo tSpec;
8111 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308112 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308113 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008114
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308115 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308116 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8117 if (NULL == pAdapter)
8118 {
8119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8120 "%s: Adapter is NULL",__func__);
8121 return -EINVAL;
8122 }
8123 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8124 ret = wlan_hdd_validate_context(pHddCtx);
8125 if (0 != ret)
8126 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308127 return ret;
8128 }
8129 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8130 if (NULL == pHddStaCtx)
8131 {
8132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8133 "%s: STA Context is NULL",__func__);
8134 return -EINVAL;
8135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008136 // make sure the application is sufficiently priviledged
8137 // note that the kernel will do this for "set" ioctls, but since
8138 // this ioctl wants to return status to user space it must be
8139 // defined as a "get" ioctl
8140 if (!capable(CAP_NET_ADMIN))
8141 {
8142 return -EPERM;
8143 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 // we must be associated in order to add a tspec
8145 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8146 {
8147 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8148 return 0;
8149 }
8150
8151 // since we are defined to be a "get" ioctl, and since the number
8152 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308153 // will pass down in the iwreq_data, we must copy the "set" params.
8154 // We must handle the compat for iwreq_data in 32U/64K environment.
8155
8156 // helper fucntion to get iwreq_data with compat handling.
8157 if (hdd_priv_get_data(&s_priv_data, wrqu))
8158 {
8159 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8160 return 0;
8161 }
8162
8163 // make sure all params are correctly passed to function
8164 if ((NULL == s_priv_data.pointer) ||
8165 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8166 {
8167 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8168 return 0;
8169 }
8170
Jeff Johnson295189b2012-06-20 16:38:30 -07008171 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308172 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 {
8174 // hmmm, can't get them
8175 return -EIO;
8176 }
8177
8178 // clear the tspec
8179 memset(&tSpec, 0, sizeof(tSpec));
8180
8181 // validate the handle
8182 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8183 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8184 {
8185 // that one is reserved
8186 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8187 return 0;
8188 }
8189
8190 // validate the TID
8191 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8192 {
8193 // out of range
8194 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8195 return 0;
8196 }
8197 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8198
8199 // validate the direction
8200 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8201 {
8202 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8203 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8204 break;
8205
8206 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8207 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8208 break;
8209
8210 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8211 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8212 break;
8213
8214 default:
8215 // unknown
8216 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8217 return 0;
8218 }
8219
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308220 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8221
Jeff Johnson295189b2012-06-20 16:38:30 -07008222 // validate the user priority
8223 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8224 {
8225 // out of range
8226 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8227 return 0;
8228 }
8229 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308230 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8231 {
8232 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8233 return 0;
8234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008235
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8237 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8238 tSpec.ts_info.psb, tSpec.ts_info.up);
8239
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8241 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8242 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8243 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8244 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8245 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8246 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8247 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8248 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8249 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8250 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8251 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8252
8253 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8254
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308255 // Save the expected UAPSD settings by application, this will be needed
8256 // when re-negotiating UAPSD settings during BT Coex cases.
8257 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8258
Jeff Johnson295189b2012-06-20 16:38:30 -07008259 // validate the ts info ack policy
8260 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8261 {
8262 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8263 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8264 break;
8265
8266 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8267 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8268 break;
8269
8270 default:
8271 // unknown
8272 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8273 return 0;
8274 }
8275
8276 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308277
8278 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008279 return 0;
8280}
8281
8282
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308283static int iw_add_tspec(struct net_device *dev,
8284 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008285 union iwreq_data *wrqu, char *extra)
8286{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308287 int ret;
8288
8289 vos_ssr_protect(__func__);
8290 ret = __iw_add_tspec(dev, info, wrqu, extra);
8291 vos_ssr_unprotect(__func__);
8292
8293 return ret;
8294}
8295
8296static int __iw_del_tspec(struct net_device *dev,
8297 struct iw_request_info *info,
8298 union iwreq_data *wrqu, char *extra)
8299{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308300 hdd_adapter_t *pAdapter;
8301 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008302 int *params = (int *)extra;
8303 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8304 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308305 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008306
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308307 ENTER();
8308
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308309 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8310 if (NULL == pAdapter)
8311 {
8312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8313 "%s: Adapter is NULL",__func__);
8314 return -EINVAL;
8315 }
8316
8317 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8318 ret = wlan_hdd_validate_context(pHddCtx);
8319 if (0 != ret)
8320 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308321 return ret;
8322 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008323 // make sure the application is sufficiently priviledged
8324 // note that the kernel will do this for "set" ioctls, but since
8325 // this ioctl wants to return status to user space it must be
8326 // defined as a "get" ioctl
8327 if (!capable(CAP_NET_ADMIN))
8328 {
8329 return -EPERM;
8330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008331 // although we are defined to be a "get" ioctl, the params we require
8332 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8333 // is no need to copy the params from user space
8334
8335 // validate the handle
8336 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8337 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8338 {
8339 // that one is reserved
8340 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8341 return 0;
8342 }
8343
8344 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308345
8346 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008347 return 0;
8348}
8349
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308350static int iw_del_tspec(struct net_device *dev,
8351 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008352 union iwreq_data *wrqu, char *extra)
8353{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308354 int ret;
8355
8356 vos_ssr_protect(__func__);
8357 ret = __iw_del_tspec(dev, info, wrqu, extra);
8358 vos_ssr_unprotect(__func__);
8359
8360 return ret;
8361}
8362
8363
8364static int __iw_get_tspec(struct net_device *dev,
8365 struct iw_request_info *info,
8366 union iwreq_data *wrqu, char *extra)
8367{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308368 hdd_adapter_t *pAdapter;
8369 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008370 int *params = (int *)extra;
8371 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8372 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308373 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008374
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308375 ENTER();
8376
Jeff Johnson295189b2012-06-20 16:38:30 -07008377 // although we are defined to be a "get" ioctl, the params we require
8378 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8379 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308380 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8381 if (NULL == pAdapter)
8382 {
8383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8384 "%s: Adapter is NULL",__func__);
8385 return -EINVAL;
8386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008387
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308388 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8389 ret = wlan_hdd_validate_context(pHddCtx);
8390 if (0 != ret)
8391 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308392 return ret;
8393 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008394 // validate the handle
8395 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8396 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8397 {
8398 // that one is reserved
8399 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8400 return 0;
8401 }
8402
8403 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308404 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 return 0;
8406}
8407
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308408static int iw_get_tspec(struct net_device *dev,
8409 struct iw_request_info *info,
8410 union iwreq_data *wrqu, char *extra)
8411{
8412 int ret;
8413
8414 vos_ssr_protect(__func__);
8415 ret = __iw_get_tspec(dev, info, wrqu, extra);
8416 vos_ssr_unprotect(__func__);
8417
8418 return ret;
8419}
8420
Manjeet Singh3ed79242017-01-11 19:04:32 +05308421/**
8422 * __iw_setnone_get_threeint() - return three value to up layer.
8423 *
8424 * @dev: pointer of net_device of this wireless card
8425 * @info: meta data about Request sent
8426 * @wrqu: include request info
8427 * @extra: buf used for in/Output
8428 *
8429 * Return: execute result
8430 */
8431static int __iw_setnone_get_threeint(struct net_device *dev,
8432 struct iw_request_info *info,
8433 union iwreq_data *wrqu, char *extra)
8434{
8435 int ret = 0; /* success */
8436 uint32_t *value = (int *)extra;
8437 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8438
8439 hddLog(VOS_TRACE_LEVEL_INFO, FL("param = %d"), value[0]);
8440
8441 switch (value[0]) {
8442 case WE_GET_TSF:
8443 ret = hdd_indicate_tsf(adapter, value, 3);
8444 break;
8445 default:
8446 hddLog(VOS_TRACE_LEVEL_ERROR,
8447 FL("Invalid IOCTL get_value command %d"),
8448 value[0]);
8449 break;
8450 }
8451 return ret;
8452}
8453
8454/**
8455 * iw_setnone_get_threeint() - return three value to up layer.
8456 *
8457 * @dev: pointer of net_device of this wireless card
8458 * @info: meta data about Request sent
8459 * @wrqu: include request info
8460 * @extra: buf used for in/Output
8461 *
8462 * Return: execute result
8463 */
8464static int iw_setnone_get_threeint(struct net_device *dev,
8465 struct iw_request_info *info,
8466 union iwreq_data *wrqu, char *extra)
8467{
8468 int ret;
8469
8470 vos_ssr_protect(__func__);
8471 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8472 vos_ssr_unprotect(__func__);
8473
8474 return ret;
8475}
8476
Jeff Johnson295189b2012-06-20 16:38:30 -07008477#ifdef WLAN_FEATURE_VOWIFI_11R
8478//
8479//
8480// Each time the supplicant has the auth_request or reassoc request
8481// IEs ready. This is pushed to the driver. The driver will inturn use
8482// it to send out the auth req and reassoc req for 11r FT Assoc.
8483//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308484static int __iw_set_fties(struct net_device *dev,
8485 struct iw_request_info *info,
8486 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008487{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308488 hdd_adapter_t *pAdapter;
8489 hdd_station_ctx_t *pHddStaCtx;
8490 hdd_context_t *pHddCtx;
8491 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008492 //v_CONTEXT_t pVosContext;
8493
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308494 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308495 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8496 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008497 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8499 "%s: Adapter is NULL",__func__);
8500 return -EINVAL;
8501 }
8502 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8503 ret = wlan_hdd_validate_context(pHddCtx);
8504 if (0 != ret)
8505 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308506 return ret;
8507 }
8508 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8509 if (NULL == pHddStaCtx)
8510 {
8511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8512 "%s: STA Context is NULL",__func__);
8513 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008515 if (!wrqu->data.length)
8516 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008517 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008518 return -EINVAL;
8519 }
8520 if (wrqu->data.pointer == NULL)
8521 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008522 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 return -EINVAL;
8524 }
8525
8526 // Added for debug on reception of Re-assoc Req.
8527 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8528 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008529 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008530 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008531 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008532 }
8533
8534#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008535 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008536#endif
8537
8538 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008539 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 wrqu->data.length);
8541
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308542 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 return 0;
8544}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308545
8546static int iw_set_fties(struct net_device *dev,
8547 struct iw_request_info *info,
8548 union iwreq_data *wrqu, char *extra)
8549{
8550 int ret;
8551
8552 vos_ssr_protect(__func__);
8553 ret = __iw_set_fties(dev, info, wrqu, extra);
8554 vos_ssr_unprotect(__func__);
8555
8556 return ret;
8557}
Jeff Johnson295189b2012-06-20 16:38:30 -07008558#endif
8559
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308560static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008561 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008562 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008563{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308564 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008565 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308566 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008567 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308568 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008569 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8570 int idx;
8571 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008572
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308573 ENTER();
8574
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308575 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8576 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008577 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8579 "%s: Adapter is NULL",__func__);
8580 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008581 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308582 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8583 ret_val = wlan_hdd_validate_context(pHddCtx);
8584 if (0 != ret_val)
8585 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308586 return ret_val;
8587 }
8588 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8589 if (NULL == hHal)
8590 {
8591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8592 "%s: Hal Context is NULL",__func__);
8593 return -EINVAL;
8594 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308595 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8596 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308597#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008598
Amar Singhalf3a6e762013-02-19 15:06:50 -08008599 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8600 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008601 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008602 hddLog(VOS_TRACE_LEVEL_ERROR,
8603 "%s: vos_mem_alloc failed", __func__);
8604 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008605 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008606
8607 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8608
8609 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8610 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8611
8612 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8613 mc_addr_list_ptr->ulMulticastAddrCnt);
8614
8615 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008616 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008617 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8618 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8619
8620 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8621 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008622 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008623
Amar Singhalf3a6e762013-02-19 15:06:50 -08008624 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8625 vos_mem_free(mc_addr_list_ptr);
8626 if (eHAL_STATUS_SUCCESS != ret_val)
8627 {
8628 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8629 __func__);
8630 return -EINVAL;
8631 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308632#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308633 }
8634 else
8635 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008636
Amar Singhalf3a6e762013-02-19 15:06:50 -08008637 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8638 "%s: Set MC BC Filter Config request: %d suspend %d",
8639 __func__, pRequest->mcastBcastFilterSetting,
8640 pHddCtx->hdd_wlan_suspended);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308641 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308642 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308643 spin_unlock(&pHddCtx->filter_lock);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008644
8645 if (pHddCtx->hdd_wlan_suspended)
8646 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008647 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8648 if (NULL == wlanRxpFilterParam)
8649 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308650 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008651 "%s: vos_mem_alloc failed", __func__);
8652 return -EINVAL;
8653 }
8654
Amar Singhalf3a6e762013-02-19 15:06:50 -08008655 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8656 pRequest->mcastBcastFilterSetting;
8657 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308658 /* Fwr expect offload needs to clear before set */
8659 hdd_conf_hostoffload(pAdapter, FALSE);
8660 spin_lock(&pHddCtx->filter_lock);
8661 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
8662 spin_unlock(&pHddCtx->filter_lock);
8663 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8664 {
8665 hddLog(VOS_TRACE_LEVEL_INFO, "%s: pRequest->mcastBcastFilterSetting ", __func__);
8666 pHddCtx->sus_res_mcastbcast_filter =
8667 pRequest->mcastBcastFilterSetting;
8668 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008669
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308670 hdd_conf_hostoffload(pAdapter, TRUE);
8671 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8672 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008673
8674 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8675 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308676 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008677 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8678 wlanRxpFilterParam->setMcstBcstFilter);
8679
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308680 if (eHAL_STATUS_SUCCESS !=
8681 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8682 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008683 {
8684 hddLog(VOS_TRACE_LEVEL_ERROR,
8685 "%s: Failure to execute set HW MC/BC Filter request",
8686 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008687 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008688 return -EINVAL;
8689 }
8690
mukul sharmae4abd892016-11-24 22:03:31 +05308691 /* mc add list cfg item configuration in fwr */
8692 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008693 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008695
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308696 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008697 return 0;
8698}
8699
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308700static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8701 struct iw_request_info *info,
8702 union iwreq_data *wrqu, char *extra)
8703{
8704 int ret;
8705
8706 vos_ssr_protect(__func__);
8707 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8708 vos_ssr_unprotect(__func__);
8709
8710 return ret;
8711}
8712
8713static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8714 struct iw_request_info *info,
8715 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008716{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308717 hdd_adapter_t *pAdapter;
8718 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308719 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308720 int ret = 0;
8721
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308722 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008723
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308724 if (!capable(CAP_NET_ADMIN))
8725 {
8726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8727 FL("permission check failed"));
8728 return -EPERM;
8729 }
8730
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308731 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8732 if (NULL == pAdapter)
8733 {
8734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8735 "%s: Adapter is NULL",__func__);
8736 return -EINVAL;
8737 }
8738
8739 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8740 ret = wlan_hdd_validate_context(pHddCtx);
8741 if (0 != ret)
8742 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308743 return ret;
8744 }
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308745 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308746 //Reset the filter to INI value as we have to clear the dynamic filter
8747 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308748 spin_unlock(&pHddCtx->filter_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008749
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308750 //Configure FW with new setting
8751 if (pHddCtx->hdd_wlan_suspended)
8752 {
8753 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8754 if (NULL == wlanRxpFilterParam)
8755 {
8756 hddLog(VOS_TRACE_LEVEL_ERROR,
8757 "%s: vos_mem_alloc failed", __func__);
8758 return -EINVAL;
8759 }
8760
8761 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8762 pHddCtx->configuredMcastBcastFilter;
8763 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308764 /* Fwr expect offload needs to clear before set */
8765 hdd_conf_hostoffload(pAdapter, FALSE);
8766 spin_lock(&pHddCtx->filter_lock);
8767 pHddCtx->configuredMcastBcastFilter =
8768 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8769 spin_unlock(&pHddCtx->filter_lock);
8770
8771 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8772 {
8773 pHddCtx->sus_res_mcastbcast_filter =
8774 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8775 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308776
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308777 hdd_conf_hostoffload(pAdapter, TRUE);
8778 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8779 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308780 if (eHAL_STATUS_SUCCESS !=
8781 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8782 wlanRxpFilterParam))
8783 {
8784 hddLog(VOS_TRACE_LEVEL_ERROR,
8785 "%s: Failure to execute set HW MC/BC Filter request",
8786 __func__);
8787 vos_mem_free(wlanRxpFilterParam);
8788 return -EINVAL;
8789 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308790
mukul sharmae4abd892016-11-24 22:03:31 +05308791 /* mc add list cfg item configuration in fwr */
8792 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308793 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308794 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 return 0;
8796}
8797
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308798
8799static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8800 struct iw_request_info *info,
8801 union iwreq_data *wrqu, char *extra)
8802{
8803 int ret;
8804
8805 vos_ssr_protect(__func__);
8806 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8807 vos_ssr_unprotect(__func__);
8808
8809 return ret;
8810}
8811
8812static int __iw_set_host_offload(struct net_device *dev,
8813 struct iw_request_info *info,
8814 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008815{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308816 hdd_adapter_t *pAdapter;
8817 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008818 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008819 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308820 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008821
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308822 ENTER();
8823
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308824 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8825 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008826 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8828 "%s: Adapter is NULL",__func__);
8829 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008830 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308831 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8832 ret = wlan_hdd_validate_context(pHddCtx);
8833 if (0 != ret)
8834 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308835 return ret;
8836 }
8837
Jeff Johnson295189b2012-06-20 16:38:30 -07008838 /* Debug display of request components. */
8839 switch (pRequest->offloadType)
8840 {
8841 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008842 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008843 switch (pRequest->enableOrDisable)
8844 {
8845 case WLAN_OFFLOAD_DISABLE:
8846 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8847 break;
8848 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8849 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8850 case WLAN_OFFLOAD_ENABLE:
8851 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8852 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8853 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8854 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8855 }
8856 break;
8857
8858 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008859 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008860 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008861 switch (pRequest->enableOrDisable)
8862 {
8863 case WLAN_OFFLOAD_DISABLE:
8864 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8865 break;
8866 case WLAN_OFFLOAD_ENABLE:
8867 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8868 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8869 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8870 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8871 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8872 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8873 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8874 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8875 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8876 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8877 }
8878 }
8879
Hanumanth Reddy Pothula94bd51a2017-12-01 13:34:48 +05308880 vos_mem_zero(&offloadRequest, sizeof(offloadRequest));
8881 offloadRequest.offloadType = pRequest->offloadType;
8882 offloadRequest.enableOrDisable = pRequest->enableOrDisable;
8883 vos_mem_copy(&offloadRequest.params, &pRequest->params,
8884 sizeof(pRequest->params));
8885 vos_mem_copy(&offloadRequest.bssId, &pRequest->bssId.bytes,
8886 VOS_MAC_ADDRESS_LEN);
8887
Jeff Johnsone7245742012-09-05 17:12:55 -07008888 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8889 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008891 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008892 __func__);
8893 return -EINVAL;
8894 }
8895
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308896 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008897 return 0;
8898}
8899
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308900static int iw_set_host_offload(struct net_device *dev,
8901 struct iw_request_info *info,
8902 union iwreq_data *wrqu, char *extra)
8903{
8904 int ret;
8905
8906 vos_ssr_protect(__func__);
8907 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8908 vos_ssr_unprotect(__func__);
8909
8910 return ret;
8911}
8912
8913static int __iw_set_keepalive_params(struct net_device *dev,
8914 struct iw_request_info *info,
8915 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008916{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308917 hdd_adapter_t *pAdapter;
8918 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008919 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008920 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308921 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008922
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308923 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308924 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8925 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008926 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8928 "%s: Adapter is NULL",__func__);
8929 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308931 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8932 ret = wlan_hdd_validate_context(pHddCtx);
8933 if (0 != ret)
8934 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308935 return ret;
8936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008937 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008938 hddLog(VOS_TRACE_LEVEL_INFO,
8939 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8940 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008941
8942 switch (pRequest->packetType)
8943 {
8944 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008945 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008946 break;
8947
8948 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8949
Arif Hussain6d2a3322013-11-17 19:50:10 -08008950 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008951 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008952
8953 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8954 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8955 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8956
8957 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8958 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8959 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8960
8961 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8962 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8963 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8964 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8965 break;
8966
8967 }
8968
8969 /* Execute keep alive request. The reason that we can copy the request information
8970 from the ioctl structure to the SME structure is that they are laid out
8971 exactly the same. Otherwise, each piece of information would have to be
8972 copied individually. */
8973 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8974
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05308975 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
8976 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008977
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008978 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008979 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008980 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008981 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008982 __func__);
8983 return -EINVAL;
8984 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308985 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 return 0;
8987}
8988
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308989static int iw_set_keepalive_params(struct net_device *dev,
8990 struct iw_request_info *info,
8991 union iwreq_data *wrqu, char *extra)
8992{
8993 int ret;
8994 vos_ssr_protect(__func__);
8995 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8996 vos_ssr_unprotect(__func__);
8997
8998 return ret;
8999}
9000
Jeff Johnson295189b2012-06-20 16:38:30 -07009001#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309002/**-----------------------------------------------------------------
9003
9004 \brief hdd_pkt_filter_done - callback to be executed on completion
9005 successful/failure) for clear filter request.
9006
9007 \return - None
9008
9009 --------------------------------------------------------------------------*/
9010static void hdd_pkt_filter_done(void *data, v_U32_t status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009011{
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309012 struct hdd_request *request;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309013
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309014 hddLog(VOS_TRACE_LEVEL_INFO,
9015 FL("Pkt Filter Clear Status : %d"), status);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309016
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309017 request = hdd_request_get(data);
9018 if (!request) {
9019 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
9020 if (ioctl_debug)
9021 pr_info("%s: Obsolete request", __func__);
9022 return;
9023 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309024
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309025 hdd_request_complete(request);
9026 hdd_request_put(request);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309027}
9028
9029int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest)
9030{
9031 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309032 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009033 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9034 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309035 int i=0, status;
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309036 void *cookie;
9037 struct hdd_request *request;
9038 static const struct hdd_request_params params = {
9039 .priv_size = 0,
9040 .timeout_ms = PKT_FILTER_TIMEOUT,
9041 };
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309042
9043 status = wlan_hdd_validate_context(pHddCtx);
9044 if (0 != status)
9045 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009046
9047 if (pHddCtx->cfg_ini->disablePacketFilter)
9048 {
9049 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009050 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 return 0;
9052 }
Agrawal Ashisha2662d22016-10-26 12:41:13 +05309053 if (pHddCtx->isLogpInProgress)
9054 {
9055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9056 "%s:LOGP in Progress. Ignore!!!", __func__);
9057 return -EBUSY;
9058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009059 /* Debug display of request components. */
9060 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009061 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07009062
9063 switch (pRequest->filterAction)
9064 {
9065 case HDD_RCV_FILTER_SET:
9066 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009067 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009068
9069 packetFilterSetReq.filterId = pRequest->filterId;
9070 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
9071 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009072 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009073 __func__, pRequest->numParams);
9074 return -EINVAL;
9075 }
9076 packetFilterSetReq.numFieldParams = pRequest->numParams;
9077 packetFilterSetReq.coalesceTime = 0;
9078 packetFilterSetReq.filterType = 1;
9079 for (i=0; i < pRequest->numParams; i++)
9080 {
9081 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9082 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9083 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9084 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9085 packetFilterSetReq.paramsData[i].reserved = 0;
9086
Arif Hussain6d2a3322013-11-17 19:50:10 -08009087 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009088 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9089 packetFilterSetReq.filterType);
9090
Arif Hussain6d2a3322013-11-17 19:50:10 -08009091 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009092 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309093 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9094 (pRequest->paramsData[i].dataLength))
9095 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009096
9097 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9098 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9099 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9100 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9101
Arif Hussain6d2a3322013-11-17 19:50:10 -08009102 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009103 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9104 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9105 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9106
Arif Hussain6d2a3322013-11-17 19:50:10 -08009107 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009108 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9109 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9110 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9111 }
9112
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309113 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009114 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009115 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009116 __func__);
9117 return -EINVAL;
9118 }
9119
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309120 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9121 pHddStaCtx->conn_info.staId[0], true);
Jeff Johnson295189b2012-06-20 16:38:30 -07009122 break;
9123
9124 case HDD_RCV_FILTER_CLEAR:
9125
Arif Hussain6d2a3322013-11-17 19:50:10 -08009126 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009127 __func__, pRequest->filterId);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309128
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309129 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9130 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) {
9131 WLANTL_ResetRxSSN((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9132 pHddStaCtx->conn_info.staId[0]);
9133 }
9134
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309135 request = hdd_request_alloc(&params);
9136 if (!request) {
9137 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
9138 return VOS_STATUS_E_NOMEM;
9139 }
9140 cookie = hdd_request_cookie(request);
9141
9142 packetFilterClrReq.cbCtx = cookie;
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 packetFilterClrReq.filterId = pRequest->filterId;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309144 packetFilterClrReq.pktFilterCallback = hdd_pkt_filter_done;
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309145 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(
9146 pHddCtx->hHal,
9147 &packetFilterClrReq,
9148 pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009149 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009150 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009151 __func__);
Hanumanth Reddy Pothula249a2b02018-05-30 17:04:25 +05309152 hdd_request_put(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07009153 return -EINVAL;
9154 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309155
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309156 status = hdd_request_wait_for_response(request);
9157 hdd_request_put(request);
9158 if (status)
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309159 {
9160 hddLog(LOGE, FL("failure waiting for pkt_filter_comp_var %d"),
9161 status);
9162 return -EINVAL;
9163 }
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309164
9165 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9166 pHddStaCtx->conn_info.staId[0], false);
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 break;
9168
9169 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009170 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009171 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009172 return -EINVAL;
9173 }
9174 return 0;
9175}
9176
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309177int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9178 tANI_U8 sessionId)
9179{
9180 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9181 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9182
9183 if (NULL == pHddCtx)
9184 {
9185 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9186 return -EINVAL;
9187 }
9188
9189 if (pHddCtx->isLogpInProgress)
9190 {
9191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9192 "%s:LOGP in Progress. Ignore!!!", __func__);
9193 return -EBUSY;
9194 }
9195
9196 if (pHddCtx->cfg_ini->disablePacketFilter)
9197 {
9198 hddLog(VOS_TRACE_LEVEL_ERROR,
9199 "%s: Packet Filtering Disabled. Returning ",
9200 __func__ );
9201 return -EINVAL;
9202 }
9203
9204 switch (filterType)
9205 {
9206 /* For setting IPV6 MC and UC Filter we need to configure
9207 * 2 filters, one for MC and one for UC.
9208 * The Filter ID shouldn't be swapped, which results in making
9209 * UC Filter ineffective.
9210 * We have Hardcode all the values
9211 *
9212 * Reason for a seperate UC filter is because, driver need to
9213 * specify the FW that the specific filter is for unicast
9214 * otherwise FW will not pass the unicast frames by default
9215 * through the filter. This is required to avoid any performance
9216 * hits when no unicast filter is set and only MC/BC are set.
9217 * The way driver informs host is by using the MAC protocol
9218 * layer, CMP flag set to MAX, CMP Data set to 1.
9219 */
9220
9221 case HDD_FILTER_IPV6_MC_UC:
9222 /* Setting IPV6 MC Filter below
9223 */
9224 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9225 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9226 packetFilterSetReq.numFieldParams = 2;
9227 packetFilterSetReq.paramsData[0].protocolLayer =
9228 HDD_FILTER_PROTO_TYPE_MAC;
9229 packetFilterSetReq.paramsData[0].cmpFlag =
9230 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9231 packetFilterSetReq.paramsData[0].dataOffset =
9232 WLAN_HDD_80211_FRM_DA_OFFSET;
9233 packetFilterSetReq.paramsData[0].dataLength = 1;
9234 packetFilterSetReq.paramsData[0].compareData[0] =
9235 HDD_IPV6_MC_CMP_DATA;
9236
9237 packetFilterSetReq.paramsData[1].protocolLayer =
9238 HDD_FILTER_PROTO_TYPE_ARP;
9239 packetFilterSetReq.paramsData[1].cmpFlag =
9240 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9241 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9242 packetFilterSetReq.paramsData[1].dataLength = 2;
9243 packetFilterSetReq.paramsData[1].compareData[0] =
9244 HDD_IPV6_CMP_DATA_0;
9245 packetFilterSetReq.paramsData[1].compareData[1] =
9246 HDD_IPV6_CMP_DATA_1;
9247
9248
9249 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9250 &packetFilterSetReq, sessionId))
9251 {
9252 hddLog(VOS_TRACE_LEVEL_ERROR,
9253 "%s: Failure to execute Set IPv6 Mulicast Filter",
9254 __func__);
9255 return -EINVAL;
9256 }
9257
9258 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9259
9260 /*
9261 * Setting IPV6 UC Filter below
9262 */
9263 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9264 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9265 packetFilterSetReq.numFieldParams = 2;
9266 packetFilterSetReq.paramsData[0].protocolLayer =
9267 HDD_FILTER_PROTO_TYPE_MAC;
9268 packetFilterSetReq.paramsData[0].cmpFlag =
9269 HDD_FILTER_CMP_TYPE_MAX;
9270 packetFilterSetReq.paramsData[0].dataOffset = 0;
9271 packetFilterSetReq.paramsData[0].dataLength = 1;
9272 packetFilterSetReq.paramsData[0].compareData[0] =
9273 HDD_IPV6_UC_CMP_DATA;
9274
9275 packetFilterSetReq.paramsData[1].protocolLayer =
9276 HDD_FILTER_PROTO_TYPE_ARP;
9277 packetFilterSetReq.paramsData[1].cmpFlag =
9278 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9279 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9280 packetFilterSetReq.paramsData[1].dataLength = 2;
9281 packetFilterSetReq.paramsData[1].compareData[0] =
9282 HDD_IPV6_CMP_DATA_0;
9283 packetFilterSetReq.paramsData[1].compareData[1] =
9284 HDD_IPV6_CMP_DATA_1;
9285
9286 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9287 &packetFilterSetReq, sessionId))
9288 {
9289 hddLog(VOS_TRACE_LEVEL_ERROR,
9290 "%s: Failure to execute Set IPv6 Unicast Filter",
9291 __func__);
9292 return -EINVAL;
9293 }
9294
9295 break;
9296
9297 case HDD_FILTER_IPV6_MC:
9298 /*
9299 * IPV6 UC Filter might be already set,
9300 * clear the UC Filter. As the Filter
9301 * IDs are static, we can directly clear it.
9302 */
9303 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9304 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9305 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9306 &packetFilterClrReq, sessionId))
9307 {
9308 hddLog(VOS_TRACE_LEVEL_ERROR,
9309 "%s: Failure to execute Clear IPv6 Unicast Filter",
9310 __func__);
9311 return -EINVAL;
9312 }
9313
9314 /*
9315 * Setting IPV6 MC Filter below
9316 */
9317 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9318 packetFilterSetReq.numFieldParams = 2;
9319 packetFilterSetReq.paramsData[0].protocolLayer =
9320 HDD_FILTER_PROTO_TYPE_MAC;
9321 packetFilterSetReq.paramsData[0].cmpFlag =
9322 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9323 packetFilterSetReq.paramsData[0].dataOffset =
9324 WLAN_HDD_80211_FRM_DA_OFFSET;
9325 packetFilterSetReq.paramsData[0].dataLength = 1;
9326 packetFilterSetReq.paramsData[0].compareData[0] =
9327 HDD_IPV6_MC_CMP_DATA;
9328
9329 packetFilterSetReq.paramsData[1].protocolLayer =
9330 HDD_FILTER_PROTO_TYPE_ARP;
9331 packetFilterSetReq.paramsData[1].cmpFlag =
9332 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9333 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9334 packetFilterSetReq.paramsData[1].dataLength = 2;
9335 packetFilterSetReq.paramsData[1].compareData[0] =
9336 HDD_IPV6_CMP_DATA_0;
9337 packetFilterSetReq.paramsData[1].compareData[1] =
9338 HDD_IPV6_CMP_DATA_1;
9339
9340
9341 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9342 &packetFilterSetReq, sessionId))
9343 {
9344 hddLog(VOS_TRACE_LEVEL_ERROR,
9345 "%s: Failure to execute Set IPv6 Multicast Filter",
9346 __func__);
9347 return -EINVAL;
9348 }
9349 break;
9350
9351 default :
9352 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9353 "%s: Packet Filter Request: Invalid",
9354 __func__);
9355 return -EINVAL;
9356 }
9357 return 0;
9358}
9359
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309360void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009361{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309362 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309363 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009364 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309365 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009366
Yue Ma3ede6052013-08-29 00:33:26 -07009367 if (NULL == pHddCtx)
9368 {
9369 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9370 return;
9371 }
9372
9373 hHal = pHddCtx->hHal;
9374
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309375 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009376 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9378 return;
9379 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309380
9381 /* Check if INI is enabled or not, other wise just return
9382 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309383 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309384 {
9385 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9386 if (NULL == pMulticastAddrs)
9387 {
9388 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9389 return;
9390 }
9391
Jeff Johnson295189b2012-06-20 16:38:30 -07009392 if (set)
9393 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309394 /* Following pre-conditions should be satisfied before wei
9395 * configure the MC address list.
9396 */
9397 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9398 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9399 && pAdapter->mc_addr_list.mc_cnt
9400 && (eConnectionState_Associated ==
9401 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9402 {
9403 pMulticastAddrs->ulMulticastAddrCnt =
9404 pAdapter->mc_addr_list.mc_cnt;
9405 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9406 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009407 memcpy(pMulticastAddrs->multicastAddr[i],
9408 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309409 sizeof(pAdapter->mc_addr_list.addr[i]));
9410 hddLog(VOS_TRACE_LEVEL_INFO,
9411 "%s: %s multicast filter: addr ="
9412 MAC_ADDRESS_STR,
9413 __func__, set ? "setting" : "clearing",
9414 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9415 }
9416 /* Set multicast filter */
9417 sme_8023MulticastList(hHal, pAdapter->sessionId,
9418 pMulticastAddrs);
9419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309421 else
9422 {
9423 /* Need to clear only if it was previously configured
9424 */
9425 if (pAdapter->mc_addr_list.isFilterApplied)
9426 {
9427 pMulticastAddrs->ulMulticastAddrCnt = 0;
9428 sme_8023MulticastList(hHal, pAdapter->sessionId,
9429 pMulticastAddrs);
9430 }
9431
9432 }
9433 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009434 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009435 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309436 else
9437 {
9438 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309439 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309440 }
9441 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009442}
9443
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309444static int __iw_set_packet_filter_params(struct net_device *dev,
9445 struct iw_request_info *info,
9446 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309447{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309448 hdd_adapter_t *pAdapter;
9449 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009450 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309451 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309452 struct iw_point s_priv_data;
9453
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309454 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309455
9456 if (!capable(CAP_NET_ADMIN))
9457 {
9458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9459 FL("permission check failed"));
9460 return -EPERM;
9461 }
9462
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309463 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9464 if (NULL == pAdapter)
9465 {
9466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9467 "%s: Adapter is NULL",__func__);
9468 return -EINVAL;
9469 }
9470 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9471 ret = wlan_hdd_validate_context(pHddCtx);
9472 if (0 != ret)
9473 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309474 return ret;
9475 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309476 if (hdd_priv_get_data(&s_priv_data, wrqu))
9477 {
9478 return -EINVAL;
9479 }
9480
9481 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9482 {
9483 return -EINVAL;
9484 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009485
Arif Hussain0273cba2014-01-07 20:58:29 -08009486 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309487 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9488 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009489 if (NULL == pRequest)
9490 {
9491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9492 "mem_alloc_copy_from_user_helper fail");
9493 return -ENOMEM;
9494 }
9495
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309496 ret = wlan_hdd_set_filter(pAdapter, pRequest);
Arif Hussain0273cba2014-01-07 20:58:29 -08009497 kfree(pRequest);
9498
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309499 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009500 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009501}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309502
9503static int iw_set_packet_filter_params(struct net_device *dev,
9504 struct iw_request_info *info,
9505 union iwreq_data *wrqu, char *extra)
9506{
9507 int ret;
9508
9509 vos_ssr_protect(__func__);
9510 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9511 vos_ssr_unprotect(__func__);
9512
9513 return ret;
9514}
Jeff Johnson295189b2012-06-20 16:38:30 -07009515#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309516static int __iw_get_statistics(struct net_device *dev,
9517 struct iw_request_info *info,
9518 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009519{
9520
9521 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9522 eHalStatus status = eHAL_STATUS_SUCCESS;
9523 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309524 hdd_adapter_t *pAdapter;
9525 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009526 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309527 int tlen = 0, ret = 0;
9528 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009529
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309530 tCsrGlobalClassAStatsInfo *aStats;
9531 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009532
9533 ENTER();
9534
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309535 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9536 if (NULL == pAdapter)
9537 {
9538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9539 "%s: Adapter is NULL",__func__);
9540 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309542 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9543 ret = wlan_hdd_validate_context(pHddCtx);
9544 if (0 != ret)
9545 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309546 return ret;
9547 }
9548 pStats = &(pAdapter->hdd_stats.summary_stat);
9549 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9550 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9552
9553 wrqu->txpower.value = 0;
9554 }
9555 else {
9556 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9557 SME_SUMMARY_STATS |
9558 SME_GLOBAL_CLASSA_STATS |
9559 SME_GLOBAL_CLASSB_STATS |
9560 SME_GLOBAL_CLASSC_STATS |
9561 SME_GLOBAL_CLASSD_STATS |
9562 SME_PER_STA_STATS,
9563 hdd_StatisticsCB, 0, FALSE,
9564 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9565
9566 if (eHAL_STATUS_SUCCESS != status)
9567 {
9568 hddLog(VOS_TRACE_LEVEL_ERROR,
9569 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009570 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009571 return -EINVAL;
9572 }
9573
9574 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309575 if (NULL == pWextState)
9576 {
9577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9578 "%s: pWextState is NULL",__func__);
9579 return -EINVAL;
9580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009581
9582 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9583 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9584 {
9585 hddLog(VOS_TRACE_LEVEL_ERROR,
9586 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009587 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009588 /*Remove the SME statistics list by passing NULL in callback argument*/
9589 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9590 SME_SUMMARY_STATS |
9591 SME_GLOBAL_CLASSA_STATS |
9592 SME_GLOBAL_CLASSB_STATS |
9593 SME_GLOBAL_CLASSC_STATS |
9594 SME_GLOBAL_CLASSD_STATS |
9595 SME_PER_STA_STATS,
9596 NULL, 0, FALSE,
9597 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9598
9599 return -EINVAL;
9600 }
9601 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9602 (tANI_U8) sizeof (pStats->retry_cnt),
9603 (char*) &(pStats->retry_cnt[0]),
9604 tlen);
9605
9606 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9607 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9608 (char*) &(pStats->multiple_retry_cnt[0]),
9609 tlen);
9610
9611 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9612 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9613 (char*) &(pStats->tx_frm_cnt[0]),
9614 tlen);
9615
9616 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9617 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9618 (char*) &(pStats->rx_frm_cnt),
9619 tlen);
9620
9621 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9622 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9623 (char*) &(pStats->frm_dup_cnt),
9624 tlen);
9625
9626 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9627 (tANI_U8) sizeof (pStats->fail_cnt),
9628 (char*) &(pStats->fail_cnt[0]),
9629 tlen);
9630
9631 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9632 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9633 (char*) &(pStats->rts_fail_cnt),
9634 tlen);
9635
9636 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9637 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9638 (char*) &(pStats->ack_fail_cnt),
9639 tlen);
9640
9641 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9642 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9643 (char*) &(pStats->rts_succ_cnt),
9644 tlen);
9645
9646 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9647 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9648 (char*) &(pStats->rx_discard_cnt),
9649 tlen);
9650
9651 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9652 (tANI_U8) sizeof (pStats->rx_error_cnt),
9653 (char*) &(pStats->rx_error_cnt),
9654 tlen);
9655
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009656 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009657 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009658 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009659 tlen);
9660
9661 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9662 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9663 (char*) &(dStats->rx_byte_cnt),
9664 tlen);
9665
9666 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9667 (tANI_U8) sizeof (dStats->rx_rate),
9668 (char*) &(dStats->rx_rate),
9669 tlen);
9670
9671 /* Transmit rate, in units of 500 kbit/sec */
9672 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9673 (tANI_U8) sizeof (aStats->tx_rate),
9674 (char*) &(aStats->tx_rate),
9675 tlen);
9676
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009677 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9678 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9679 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009680 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009681 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9682 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9683 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009684 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009685 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9686 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9687 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009688 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009689 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9690 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9691 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009692 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009693 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9694 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9695 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009696 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009697 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9698 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9699 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009700 tlen);
9701
Jeff Johnson295189b2012-06-20 16:38:30 -07009702 wrqu->data.length = tlen;
9703
9704 }
9705
9706 EXIT();
9707
9708 return 0;
9709}
9710
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309711static int iw_get_statistics(struct net_device *dev,
9712 struct iw_request_info *info,
9713 union iwreq_data *wrqu, char *extra)
9714{
9715 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009716
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309717 vos_ssr_protect(__func__);
9718 ret = __iw_get_statistics(dev, info, wrqu, extra);
9719 vos_ssr_unprotect(__func__);
9720
9721 return ret;
9722}
Jeff Johnson295189b2012-06-20 16:38:30 -07009723#ifdef FEATURE_WLAN_SCAN_PNO
Jeff Johnson295189b2012-06-20 16:38:30 -07009724VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9725 union iwreq_data *wrqu, char *extra, int nOffset)
9726{
9727 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9728 v_U8_t rssiThreshold = 0;
9729 v_U8_t nRead;
9730
Arif Hussain7adce1b2013-11-11 22:59:34 -08009731 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009732 &rssiThreshold);
9733
9734 if ( 1 != nRead )
9735 {
9736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9737 "Incorrect format");
9738 return VOS_STATUS_E_FAILURE;
9739 }
9740
9741 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9742 return VOS_STATUS_SUCCESS;
9743}
Jeff Johnson295189b2012-06-20 16:38:30 -07009744#endif /*FEATURE_WLAN_SCAN_PNO*/
9745
9746//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309747int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009748{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309749 hdd_adapter_t *pAdapter;
9750 tHalHandle hHal;
9751 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309752 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309753 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309754 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009755 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309756 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309757 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309758 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309759
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309760 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309761 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9762 if (NULL == pAdapter)
9763 {
9764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9765 "%s: Adapter is NULL",__func__);
9766 return -EINVAL;
9767 }
9768 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9769 retval = wlan_hdd_validate_context(pHddCtx);
9770 if (0 != retval)
9771 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309772 return retval;
9773 }
9774 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9775 if (NULL == hHal)
9776 {
9777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9778 "%s: Hal Context is NULL",__func__);
9779 return -EINVAL;
9780 }
9781 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009782
Atul Mittal54378cb2014-04-02 16:51:50 +05309783 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009784 {
9785 case WLAN_HDD_UI_BAND_AUTO:
9786 band = eCSR_BAND_ALL;
9787 break;
9788 case WLAN_HDD_UI_BAND_5_GHZ:
9789 band = eCSR_BAND_5G;
9790 break;
9791 case WLAN_HDD_UI_BAND_2_4_GHZ:
9792 band = eCSR_BAND_24;
9793 break;
9794 default:
9795 band = eCSR_BAND_MAX;
9796 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309797 connectedBand =
9798 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009799
Atul Mittal54378cb2014-04-02 16:51:50 +05309800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009801 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009802
9803 if (band == eCSR_BAND_MAX)
9804 {
9805 /* Received change band request with invalid band value */
9806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309807 "%s: Invalid band value %u", __func__, ui_band);
9808 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009809 }
9810
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309811 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309812 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309813 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009815 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009816 band, pHddCtx->cfg_ini->nBandCapability);
9817 return -EIO;
9818 }
9819
Sushant Kaushik1165f872015-03-30 20:25:27 +05309820 if (band == eCSR_BAND_ALL)
9821 {
9822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9823 "received. Setting band same as ini value %d"),
9824 pHddCtx->cfg_ini->nBandCapability);
9825 band = pHddCtx->cfg_ini->nBandCapability;
9826 }
9827
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9829 {
9830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9831 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009832 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 return -EIO;
9834 }
9835
9836 if (currBand != band)
9837 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309838 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309839 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309840 /* Return failure if current country code is world regulatory domain*/
9841 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9842 pMac->scan.countryCodeCurrent[1] == '0') )
9843 {
9844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9845 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309846 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309847 return -EAGAIN;
9848 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309849 }
9850
Jeff Johnson295189b2012-06-20 16:38:30 -07009851 /* Change band request received.
9852 * Abort pending scan requests, flush the existing scan results,
9853 * and change the band capability
9854 */
9855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9856 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009857 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009858
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309859 /* We need to change the band and flush the scan results here itself
9860 * as we may get timeout for disconnection in which we will return
9861 * with out doing any of these
9862 */
9863 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9864 {
9865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9866 "%s: failed to set the band value to %u ",
9867 __func__, band);
9868 return -EINVAL;
9869 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309870 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9871 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309872 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309873 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9874 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309875 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309876 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9877 * information available in NV so to get the channel information from kernel
9878 * we need to send regulatory hint for the currunt country
9879 * And to set the same country again we need to set the dummy country
9880 * first and then the actual country.
9881 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309882#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Ashish Kumar Dhanotiyaaebbe052017-11-16 14:41:09 +05309883 if(curr_country[0] == '0' && curr_country[1] == '0')
9884 regulatory_hint_user("IN", NL80211_USER_REG_HINT_USER);
9885 else
Yeshwanth Sriram Guntuka88566212019-04-17 15:02:33 +05309886 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309887#else
Ashish Kumar Dhanotiyaaebbe052017-11-16 14:41:09 +05309888 if(curr_country[0] == '0' && curr_country[1] == '0')
9889 regulatory_hint_user("IN");
9890 else
9891 regulatory_hint_user("00");
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309892#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309893 wait_result = wait_for_completion_interruptible_timeout(
9894 &pHddCtx->linux_reg_req,
9895 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9896
9897 /* if the country information does not exist with the kernel,
9898 then the driver callback would not be called */
9899
9900 if (wait_result >= 0)
9901 {
9902 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9903 "runtime country code is found in kernel db");
9904 }
9905 else
9906 {
9907 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9908 "runtime country code is not found"
9909 " in kernel db");
9910 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309911
9912 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309913
9914 /*
9915 * Update 11dcountry and current country here as the hint
9916 * with 00 results in 11d and current country with 00
9917 */
9918 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9919 WNI_CFG_COUNTRY_CODE_LEN);
9920 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9921 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309922#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9923 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9924#else
9925 regulatory_hint_user(curr_country);
9926#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309927 wait_result = wait_for_completion_interruptible_timeout(
9928 &pHddCtx->linux_reg_req,
9929 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9930
9931 /* if the country information does not exist with the kernel,
9932 then the driver callback would not be called */
9933 if (wait_result >= 0)
9934 {
9935 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9936 "runtime country code is found in kernel db");
9937 }
9938 else
9939 {
9940 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9941 "runtime country code is not found"
9942 " in kernel db");
9943 }
9944
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309945 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309946 }
9947 else
9948 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309949#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309950 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9951 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309952#else
9953 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9954#endif
9955
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309956 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309957 pScanInfo = &pHddCtx->scan_info;
9958 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9959 {
9960 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9961 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9962 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309963 sme_FilterScanResults(hHal, pAdapter->sessionId);
9964
9965 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309966 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9967 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009968 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009969 eHalStatus status = eHAL_STATUS_SUCCESS;
9970 long lrc;
9971
9972 /* STA already connected on current band, So issue disconnect first,
9973 * then change the band*/
9974
9975 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309976 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309977 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009978
Jeff Johnson295189b2012-06-20 16:38:30 -07009979 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9980
9981 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9982 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9983
Jeff Johnson43971f52012-07-17 12:26:56 -07009984 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009985 {
9986 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009987 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009988 __func__, (int)status );
9989 return -EINVAL;
9990 }
9991
9992 lrc = wait_for_completion_interruptible_timeout(
9993 &pAdapter->disconnect_comp_var,
9994 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9995
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309996 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009997
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009998 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009999 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010000
10001 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10002 }
10003 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010004 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010005 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010006 if (TRUE == pHddCtx->isSetBandByNL)
10007 return 0;
10008 else
10009 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010010}
10011
Atul Mittal54378cb2014-04-02 16:51:50 +053010012int hdd_setBand_helper(struct net_device *dev, const char *command)
10013{
10014 u8 band;
10015
10016 /*convert the band value from ascii to integer*/
10017 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10018
10019 return hdd_setBand(dev, band);
10020
10021}
10022
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010023static int __iw_set_band_config(struct net_device *dev,
10024 struct iw_request_info *info,
10025 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010026{
Atul Mittal54378cb2014-04-02 16:51:50 +053010027 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010028
Arif Hussain0273cba2014-01-07 20:58:29 -080010029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010030
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010031 if (!capable(CAP_NET_ADMIN))
10032 {
10033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10034 FL("permission check failed"));
10035 return -EPERM;
10036 }
10037
Atul Mittal54378cb2014-04-02 16:51:50 +053010038 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010039}
10040
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010041static int iw_set_band_config(struct net_device *dev,
10042 struct iw_request_info *info,
10043 union iwreq_data *wrqu, char *extra)
10044{
10045 int ret;
10046
10047 vos_ssr_protect(__func__);
10048 ret = __iw_set_band_config(dev, info, wrqu, extra);
10049 vos_ssr_unprotect(__func__);
10050
10051 return ret;
10052}
10053
10054static int __iw_set_power_params_priv(struct net_device *dev,
10055 struct iw_request_info *info,
10056 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010057{
Arif Hussain0273cba2014-01-07 20:58:29 -080010058 int ret;
10059 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010060
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10062 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010063
10064 if (!capable(CAP_NET_ADMIN))
10065 {
10066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10067 FL("permission check failed"));
10068 return -EPERM;
10069 }
10070
Arif Hussain0273cba2014-01-07 20:58:29 -080010071 /* ODD number is used for set, copy data using copy_from_user */
10072 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10073 wrqu->data.length);
10074 if (NULL == ptr)
10075 {
10076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10077 "mem_alloc_copy_from_user_helper fail");
10078 return -ENOMEM;
10079 }
10080
10081 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10082 kfree(ptr);
10083 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010084}
10085
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010086static int iw_set_power_params_priv(struct net_device *dev,
10087 struct iw_request_info *info,
10088 union iwreq_data *wrqu, char *extra)
10089{
10090 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010091
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010092 vos_ssr_protect(__func__);
10093 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10094 vos_ssr_unprotect(__func__);
10095
10096 return ret;
10097}
Jeff Johnson295189b2012-06-20 16:38:30 -070010098
10099/*string based input*/
10100VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10101 union iwreq_data *wrqu, char *extra, int nOffset)
10102{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010103 hdd_adapter_t *pAdapter;
10104 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010105 tSirSetPowerParamsReq powerRequest;
10106 char *ptr;
10107 v_U8_t ucType;
10108 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010109 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010110
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010111 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010112 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10113 if (NULL == pAdapter)
10114 {
10115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10116 "%s: Adapter is NULL",__func__);
10117 return -EINVAL;
10118 }
10119
10120 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10121 ret = wlan_hdd_validate_context(pHddCtx);
10122 if (0 != ret)
10123 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010124 return ret;
10125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10127 "Power Params data len %d data %s",
10128 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010129 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010130
10131 if (wrqu->data.length <= nOffset )
10132 {
10133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10134 return VOS_STATUS_E_FAILURE;
10135 }
10136
10137 uTotalSize = wrqu->data.length - nOffset;
10138
10139 /*-----------------------------------------------------------------------
10140 Input is string based and expected to be like this:
10141
10142 <param_type> <param_value> <param_type> <param_value> ...
10143
10144 e.g:
10145 1 2 2 3 3 0 4 1 5 1
10146
10147 e.g. setting just a few:
10148 1 2 4 1
10149
10150 parameter types:
10151 -----------------------------
10152 1 - Ignore DTIM
10153 2 - Listen Interval
10154 3 - Broadcast Multicas Filter
10155 4 - Beacon Early Termination
10156 5 - Beacon Early Termination Interval
10157 -----------------------------------------------------------------------*/
10158 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10159 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10160 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10161 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10162 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10163
Arif Hussain7adce1b2013-11-11 22:59:34 -080010164 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010165
10166 while ( uTotalSize )
10167 {
Wilson Yang6f971452013-10-08 15:00:00 -070010168 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10169 {
10170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10171 "Invalid input parameter type %s",ptr);
10172 return VOS_STATUS_E_FAILURE;
10173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010174
10175 uTotalSize -= nOffset;
10176
10177 if (!uTotalSize)
10178 {
10179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010180 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010181 ucType, nOffset);
10182 return VOS_STATUS_E_FAILURE;
10183 }
10184
10185 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010186
Jeff Johnson02797792013-10-26 19:17:13 -070010187 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010188 {
10189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10190 "Invalid input parameter value %s",ptr);
10191 return VOS_STATUS_E_FAILURE;
10192 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010193
10194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10195 "Power request parameter %d value %d offset %d",
10196 ucType, uValue, nOffset);
10197
10198 switch (ucType)
10199 {
10200 case eSIR_IGNORE_DTIM:
10201 powerRequest.uIgnoreDTIM = uValue;
10202 break;
10203 case eSIR_LISTEN_INTERVAL:
10204 powerRequest.uListenInterval = uValue;
10205 break;
10206 case eSIR_MCAST_BCAST_FILTER:
10207 powerRequest.uBcastMcastFilter = uValue;
10208 break;
10209 case eSIR_ENABLE_BET:
10210 powerRequest.uEnableBET = uValue;
10211 break;
10212 case eSIR_BET_INTERVAL:
10213 powerRequest.uBETInterval = uValue;
10214 break;
10215 default:
10216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010217 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010218 ucType, uValue, nOffset);
10219 return VOS_STATUS_E_FAILURE;
10220 }
10221
10222 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10224 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010225 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010226 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010227 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010228 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010229 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10230 {
10231 uTotalSize = 0;
10232 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010233
10234 }/*Go for as long as we have a valid string*/
10235
10236 /* put the device into full power*/
10237 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10238
10239 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010240 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010241
10242 /* put the device back to power save*/
10243 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10244
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010245 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010246 return VOS_STATUS_SUCCESS;
10247}/*iw_set_power_params*/
10248
Atul Mittalc0f739f2014-07-31 13:47:47 +053010249// tdlsoffchan
10250#ifdef FEATURE_WLAN_TDLS
10251
Atul Mittal87ec2422014-09-24 13:12:50 +053010252int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010253{
10254 if (offchannel < 0 || offchannel > 165)
10255 {
10256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10257 __func__, offchannel);
10258 return -1;
10259
10260 }
10261
10262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10263 __func__, tdlsOffCh, offchannel);
10264
10265 tdlsOffCh = offchannel;
10266 return 0;
10267}
10268
Atul Mittal87ec2422014-09-24 13:12:50 +053010269int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010270{
10271 if (offchanoffset == 0)
10272 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010273 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10275 __func__, tdlsOffChBwOffset);
10276
10277 return 0;
10278
10279 }
10280
10281 if ( offchanoffset == 40 )
10282 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010283 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10285 __func__, tdlsOffChBwOffset);
10286
10287 return 0;
10288
10289 }
10290 if (offchanoffset == -40)
10291 {
10292 tdlsOffChBwOffset = 3;
10293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10294 __func__, tdlsOffChBwOffset);
10295
10296 return 0;
10297
10298 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010299
10300 if ((offchanoffset == 80) &&
10301 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10302 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10303 {
10304 tdlsOffChBwOffset = 4;
10305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10306 "%s: change tdls secondary off channel offset to %u",
10307 __func__, tdlsOffChBwOffset);
10308
10309 return 0;
10310 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10312 __func__, offchanoffset);
10313 return -1;
10314}
10315
Atul Mittal87ec2422014-09-24 13:12:50 +053010316int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010317{
10318 hddTdlsPeer_t *connPeer = NULL;
10319 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10320 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010321 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010322 if (offchanmode < 0 || offchanmode > 4)
10323 {
10324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10325 "%s: Invalid tdls off channel mode %d",
10326 __func__, offchanmode);
10327 return -1;
10328 }
10329
10330 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10331 {
10332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10333 "%s: tdls off channel mode req in not associated state %d",
10334 __func__, offchanmode);
10335 return -1;
10336 }
10337
10338 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10339 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10340 {
10341 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010342 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010343 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010344 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010345 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10347 "%s: No TDLS Connected Peer", __func__);
10348 return -1;
10349 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010350 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010351 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010352 }
10353 else
10354 {
10355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10356 "%s: TDLS Connection not supported", __func__);
10357 return -1;
10358 }
10359
10360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10361 ("%s: TDLS Channel Switch in swmode=%d"),
10362 __func__, offchanmode);
10363
10364 switch (offchanmode)
10365 {
10366 case 1:/*Enable*/
10367 case 2:/*Disable*/
10368 {
10369 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10370 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10371 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10372 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10373 {
10374
10375 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010376 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053010377 tdlsOffCh, tdlsOffChBwOffset,
10378 offchanmode);
10379 }
10380 else
10381 {
10382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10383 "%s: TDLS Off Channel not supported", __func__);
10384 return -1;
10385 }
10386 break;
10387 }
10388 case 3:
10389 {
10390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10391 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10392 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10393
10394 break;
10395 }
10396 case 4:
10397 {
10398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10399 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10400 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10401 break;
10402 }
10403 default:
10404 {
10405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10406 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10407 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10408 break;
10409 }
10410
10411 }
10412
10413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10414 __func__, offchanmode);
10415 return 0;
10416}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010417#endif
10418
Jeff Johnson295189b2012-06-20 16:38:30 -070010419// Define the Wireless Extensions to the Linux Network Device structure
10420// A number of these routines are NULL (meaning they are not implemented.)
10421
10422static const iw_handler we_handler[] =
10423{
10424 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10425 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10426 (iw_handler) NULL, /* SIOCSIWNWID */
10427 (iw_handler) NULL, /* SIOCGIWNWID */
10428 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10429 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
Ashish Kumar Dhanotiya6b484a82018-04-24 15:11:55 +053010430 (iw_handler) NULL, /* SIOCSIWMODE */
10431 (iw_handler) NULL, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -070010432 (iw_handler) NULL, /* SIOCSIWSENS */
10433 (iw_handler) NULL, /* SIOCGIWSENS */
10434 (iw_handler) NULL, /* SIOCSIWRANGE */
10435 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053010436 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 (iw_handler) NULL, /* SIOCGIWPRIV */
10438 (iw_handler) NULL, /* SIOCSIWSTATS */
10439 (iw_handler) NULL, /* SIOCGIWSTATS */
10440 iw_handler_set_spy, /* SIOCSIWSPY */
10441 iw_handler_get_spy, /* SIOCGIWSPY */
10442 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10443 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10444 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10445 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10446 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10447 (iw_handler) NULL, /* SIOCGIWAPLIST */
10448 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10449 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10450 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10451 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10452 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10453 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10454 (iw_handler) NULL, /* -- hole -- */
10455 (iw_handler) NULL, /* -- hole -- */
10456 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10457 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10458 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10459 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10460 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10461 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10462 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10463 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10464 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10465 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10466 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10467 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10468 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10469 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10470 (iw_handler) NULL, /* -- hole -- */
10471 (iw_handler) NULL, /* -- hole -- */
10472 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10473 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10474 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10475 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10476 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10477 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10478 (iw_handler) NULL, /* SIOCSIWPMKSA */
10479};
10480
10481static const iw_handler we_private[] = {
10482
10483 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10484 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10485 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10486 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10487 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10488 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010489 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010490 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10491 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10492 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Manjeet Singh3ed79242017-01-11 19:04:32 +053010493 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
10494 iw_setnone_get_threeint,
Jeff Johnsone7245742012-09-05 17:12:55 -070010495#ifdef FEATURE_OEM_DATA_SUPPORT
10496 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10497 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10498#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010499
Jeff Johnson295189b2012-06-20 16:38:30 -070010500#ifdef WLAN_FEATURE_VOWIFI_11R
10501 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10502#endif
10503 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10504 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10505 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10506#ifdef WLAN_FEATURE_PACKET_FILTERING
10507 ,
10508 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10509#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010510 ,
10511 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10512 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10513 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10514 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010515 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010516};
10517
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053010518static const iw_handler we_mon_private[] = {
10519 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10520 iw_mon_setint_getnone,
10521};
10522
10523static const struct iw_priv_args we_mon_private_args[] = {
10524 {WE_SET_MONITOR_STATE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10525 0, "monitor"},
10526
10527 /* handlers for main ioctl */
10528 {WLAN_PRIV_SET_INT_GET_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10529 0, "" },
10530};
10531
Jeff Johnson295189b2012-06-20 16:38:30 -070010532/*Maximum command length can be only 15 */
10533static const struct iw_priv_args we_private_args[] = {
10534
Katya Nigamf0511f62015-05-05 16:40:57 +053010535 { WE_SET_MONITOR_STATE,
10536 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10537 0, "monitor" },
10538
Jeff Johnson295189b2012-06-20 16:38:30 -070010539 /* handlers for main ioctl */
10540 { WLAN_PRIV_SET_INT_GET_NONE,
10541 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10542 0,
10543 "" },
10544
10545 /* handlers for sub-ioctl */
10546 { WE_SET_11D_STATE,
10547 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10548 0,
10549 "set11Dstate" },
10550
10551 { WE_WOWL,
10552 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10553 0,
10554 "wowl" },
10555
10556 { WE_SET_POWER,
10557 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10558 0,
10559 "setPower" },
10560
10561 { WE_SET_MAX_ASSOC,
10562 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10563 0,
10564 "setMaxAssoc" },
10565
10566 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10567 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10568 0,
10569 "setAutoChannel" },
10570
10571 { WE_SET_DATA_INACTIVITY_TO,
10572 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10573 0,
10574 "inactivityTO" },
10575
10576 { WE_SET_MAX_TX_POWER,
10577 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10578 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010579 "setMaxTxPower" },
10580
10581 { WE_SET_MAX_TX_POWER_2_4,
10582 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10583 0,
10584 "setTxMaxPower2G" },
10585
10586 { WE_SET_MAX_TX_POWER_5_0,
10587 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10588 0,
10589 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010590
10591 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10592 * as well to keep same syntax as in SAP. Now onwards, STA
10593 * will support both */
10594 { WE_SET_MAX_TX_POWER,
10595 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10596 0,
10597 "setTxMaxPower" },
10598
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10600 * 1 = enable and 0 = disable */
10601 {
10602 WE_SET_HIGHER_DTIM_TRANSITION,
10603 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10604 0,
10605 "setHDtimTransn" },
10606
10607 { WE_SET_TM_LEVEL,
10608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010609 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010610 "setTmLevel" },
10611
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010612 { WE_ENABLE_STRICT_FCC_REG,
10613 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10614 0,
10615 "setStrictFCCreg" },
10616
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010617 { WE_SET_DEBUG_LOG,
10618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10619 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010620#ifdef FEATURE_WLAN_TDLS
10621 {
10622 WE_SET_TDLS_OFF_CHAN,
10623 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10624 0,
10625 "tdlsoffchan" },
10626 {
10627 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10628 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10629 0,
10630 "tdlsecchnoffst" },
10631 {
10632 WE_SET_TDLS_OFF_CHAN_MODE,
10633 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10634 0,
10635 "tdlsoffchnmode" },
10636#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010637
Peng Xu2446a892014-09-05 17:21:18 +053010638 { WE_SET_SCAN_BAND_PREFERENCE,
10639 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10640 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010641 {
10642 WE_GET_FRAME_LOG,
10643 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10644 0,
10645 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010646
Abhishek Singh01c73d12015-03-12 15:13:44 +053010647 { WE_SET_MIRACAST_VENDOR_CONFIG,
10648 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10649 0, "setMiracstConf" },
10650
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010651#ifdef FEATURE_WLAN_TDLS
10652 {
10653 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10654 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10655 0,
10656 "tdls_2040bsscox" },
10657#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010658 { WE_SET_RTS_CTS_HTVHT,
10659 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10660 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053010661 { WE_SET_PKT_STATS_ENABLE_DISABLE,
10662 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10663 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053010664 { WE_SET_PROXIMITY_ENABLE,
10665 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10666 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053010667
10668#ifdef WLAN_FEATURE_TSF
10669 { WE_CAP_TSF,
10670 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10671 0, "cap_tsf" },
10672#endif
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +053010673 { WE_SET_MODULATED_DTIM,
10674 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10675 0, "setModDTIM" },
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +053010676 {
10677 WLAN_SET_DYNNAMIC_AGGREGATION,
10678 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10679 0, "setAggregation" },
10680
Jeff Johnson295189b2012-06-20 16:38:30 -070010681 /* handlers for main ioctl */
10682 { WLAN_PRIV_SET_NONE_GET_INT,
10683 0,
10684 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10685 "" },
10686
10687 /* handlers for sub-ioctl */
10688 { WE_GET_11D_STATE,
10689 0,
10690 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10691 "get11Dstate" },
10692
10693 { WE_IBSS_STATUS,
10694 0,
10695 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10696 "getAdhocStatus" },
10697
10698 { WE_PMC_STATE,
10699 0,
10700 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10701 "pmcState" },
10702
10703 { WE_GET_WLAN_DBG,
10704 0,
10705 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10706 "getwlandbg" },
10707
Jeff Johnson295189b2012-06-20 16:38:30 -070010708 { WE_GET_MAX_ASSOC,
10709 0,
10710 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10711 "getMaxAssoc" },
10712
Jeff Johnson295189b2012-06-20 16:38:30 -070010713 { WE_GET_WDI_DBG,
10714 0,
10715 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10716 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010717
10718 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10719 0,
10720 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10721 "getAutoChannel" },
10722
10723 { WE_GET_CONCURRENCY_MODE,
10724 0,
10725 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10726 "getconcurrency" },
10727
Peng Xu2446a892014-09-05 17:21:18 +053010728 { WE_GET_SCAN_BAND_PREFERENCE,
10729 0,
10730 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10731 "get_scan_pref"},
10732
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053010733 { WE_GET_ANTENA_DIVERSITY_SELECTION,
10734 0,
10735 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10736 "getCurAnt"},
10737
Jeff Johnson295189b2012-06-20 16:38:30 -070010738 /* handlers for main ioctl */
10739 { WLAN_PRIV_SET_CHAR_GET_NONE,
10740 IW_PRIV_TYPE_CHAR| 512,
10741 0,
10742 "" },
10743
10744 /* handlers for sub-ioctl */
10745 { WE_WOWL_ADD_PTRN,
10746 IW_PRIV_TYPE_CHAR| 512,
10747 0,
10748 "wowlAddPtrn" },
10749
10750 { WE_WOWL_DEL_PTRN,
10751 IW_PRIV_TYPE_CHAR| 512,
10752 0,
10753 "wowlDelPtrn" },
10754
10755#if defined WLAN_FEATURE_VOWIFI
10756 /* handlers for sub-ioctl */
10757 { WE_NEIGHBOR_REPORT_REQUEST,
10758 IW_PRIV_TYPE_CHAR | 512,
10759 0,
10760 "neighbor" },
10761#endif
10762 { WE_SET_AP_WPS_IE,
10763 IW_PRIV_TYPE_CHAR| 512,
10764 0,
10765 "set_ap_wps_ie" },
10766
10767 { WE_SET_CONFIG,
10768 IW_PRIV_TYPE_CHAR| 512,
10769 0,
10770 "setConfig" },
10771
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010772 { WE_SET_ENCRYPT_MSG,
10773 IW_PRIV_TYPE_CHAR| 512,
10774 0,
10775 "encryptMsg" },
10776
10777
Jeff Johnson295189b2012-06-20 16:38:30 -070010778 /* handlers for main ioctl */
10779 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10781 0,
10782 "" },
10783
10784 /* handlers for sub-ioctl */
10785 { WE_SET_WLAN_DBG,
10786 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10787 0,
10788 "setwlandbg" },
10789
Jeff Johnson295189b2012-06-20 16:38:30 -070010790 { WE_SET_WDI_DBG,
10791 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10792 0,
10793 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010794
10795 { WE_SET_SAP_CHANNELS,
10796 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10797 0,
10798 "setsapchannels" },
10799
10800 /* handlers for main ioctl */
10801 { WLAN_PRIV_GET_CHAR_SET_NONE,
10802 0,
10803 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10804 "" },
10805
10806 /* handlers for sub-ioctl */
10807 { WE_WLAN_VERSION,
10808 0,
10809 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10810 "version" },
10811 { WE_GET_STATS,
10812 0,
10813 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10814 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010815 { WE_GET_STATES,
10816 0,
10817 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10818 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010819 { WE_GET_CFG,
10820 0,
10821 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10822 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010823#ifdef WLAN_FEATURE_11AC
10824 { WE_GET_RSSI,
10825 0,
10826 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10827 "getRSSI" },
10828#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010829#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010830 { WE_GET_ROAM_RSSI,
10831 0,
10832 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10833 "getRoamRSSI" },
10834#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010835 { WE_GET_WMM_STATUS,
10836 0,
10837 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10838 "getWmmStatus" },
10839 {
10840 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010841 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010842 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10843 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010844#ifdef FEATURE_WLAN_TDLS
10845 {
10846 WE_GET_TDLS_PEERS,
10847 0,
10848 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10849 "getTdlsPeers" },
10850#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010851#ifdef WLAN_FEATURE_11W
10852 {
10853 WE_GET_11W_INFO,
10854 0,
10855 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10856 "getPMFInfo" },
10857#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053010858#ifdef WLAN_FEATURE_RMC
10859 {
10860 WE_GET_IBSS_STA_INFO,
10861 0,
10862 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10863 "getIbssSTAs" },
10864#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010865 { WE_GET_SNR,
10866 0,
10867 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10868 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053010869#ifdef FEATURE_OEM_DATA_SUPPORT
10870 {
10871 WE_GET_OEM_DATA_CAP,
10872 0,
10873 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10874 "getOemDataCap" },
10875#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070010876 /* handlers for main ioctl */
10877 { WLAN_PRIV_SET_NONE_GET_NONE,
10878 0,
10879 0,
10880 "" },
10881
10882 /* handlers for sub-ioctl */
10883 { WE_CLEAR_STATS,
10884 0,
10885 0,
10886 "clearStats" },
10887 { WE_INIT_AP,
10888 0,
10889 0,
10890 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053010891#ifdef WLAN_FEATURE_RMC
10892 {
10893 WE_IBSS_GET_PEER_INFO_ALL,
10894 0,
10895 0,
10896 "ibssPeerInfoAll" },
10897#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010898 { WE_STOP_AP,
10899 0,
10900 0,
10901 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010902#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010903 { WE_ENABLE_AMP,
10904 0,
10905 0,
10906 "enableAMP" },
10907 { WE_DISABLE_AMP,
10908 0,
10909 0,
10910 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010911#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010912 { WE_ENABLE_DXE_STALL_DETECT,
10913 0,
10914 0,
10915 "dxeStallDetect" },
10916 { WE_DISPLAY_DXE_SNAP_SHOT,
10917 0,
10918 0,
10919 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010920 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10921 0,
10922 0,
10923 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010924 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010925 WE_SET_REASSOC_TRIGGER,
10926 0,
10927 0,
10928 "reassoc" },
10929 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010930 WE_STOP_OBSS_SCAN,
10931 0,
10932 0,
10933 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010934 {
10935 WE_DUMP_ROAM_TIMER_LOG,
10936 0,
10937 0,
10938 "dumpRoamDelay" },
10939 {
10940 WE_RESET_ROAM_TIMER_LOG,
10941 0,
10942 0,
10943 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010944 {
10945 WE_GET_FW_LOGS,
10946 0,
10947 0,
10948 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053010949 {
10950 WE_GET_FW_MEMDUMP,
10951 0,
10952 0,
10953 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010954 /* handlers for main ioctl */
10955 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10956 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10957 0,
10958 "" },
10959
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010960
10961
Jeff Johnson295189b2012-06-20 16:38:30 -070010962 /* handlers for sub-ioctl */
10963 { WE_LOG_DUMP_CMD,
10964 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10965 0,
10966 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053010967#ifdef WLAN_FEATURE_RMC
10968 { WE_IBSS_GET_PEER_INFO,
10969 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10970 0,
10971 "ibssPeerInfo" },
10972#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010973
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010974 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010975 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10976 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10977 0,
10978 "setdumplog" },
10979
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010980 { WE_MTRACE_DUMP_CMD,
10981 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10982 0,
10983 "dumplog" },
10984
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010985 /* handlers for sub ioctl */
10986 {
10987 WE_MCC_CONFIG_CREDENTIAL,
10988 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10989 0,
10990 "setMccCrdnl" },
10991
10992 /* handlers for sub ioctl */
10993 {
10994 WE_MCC_CONFIG_PARAMS,
10995 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10996 0,
10997 "setMccConfig" },
10998
Chilam NG571c65a2013-01-19 12:27:36 +053010999#ifdef FEATURE_WLAN_TDLS
11000 /* handlers for sub ioctl */
11001 {
11002 WE_TDLS_CONFIG_PARAMS,
11003 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11004 0,
11005 "setTdlsConfig" },
11006#endif
11007
Katya Nigamf0511f62015-05-05 16:40:57 +053011008 {
11009 WE_CONFIGURE_MONITOR_MODE,
11010 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11011 0,
11012 "MonitorModeConf" },
11013
11014 {
11015 WE_SET_MONITOR_MODE_FILTER,
11016 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11017 0,
11018 "MonitorFilter" },
11019
Jeff Johnson295189b2012-06-20 16:38:30 -070011020 /* handlers for main ioctl */
11021 { WLAN_PRIV_ADD_TSPEC,
11022 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11023 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11024 "addTspec" },
11025
11026 /* handlers for main ioctl */
11027 { WLAN_PRIV_DEL_TSPEC,
11028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11029 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11030 "delTspec" },
11031
11032 /* handlers for main ioctl */
11033 { WLAN_PRIV_GET_TSPEC,
11034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11035 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11036 "getTspec" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011037 /* handlers for main ioctl */
11038 { WLAN_PRIV_SET_NONE_GET_THREE_INT,
11039 0,
11040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11041 "" },
11042#ifdef WLAN_FEATURE_TSF
11043 { WE_GET_TSF,
11044 0,
11045 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11046 "get_tsf" },
11047#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011048#ifdef FEATURE_OEM_DATA_SUPPORT
11049 /* handlers for main ioctl - OEM DATA */
11050 {
11051 WLAN_PRIV_SET_OEM_DATA_REQ,
11052 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11053 0,
11054 "set_oem_data_req" },
11055
11056 /* handlers for main ioctl - OEM DATA */
11057 {
11058 WLAN_PRIV_GET_OEM_DATA_RSP,
11059 0,
11060 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11061 "get_oem_data_rsp" },
11062#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011063
Jeff Johnson295189b2012-06-20 16:38:30 -070011064 /* handlers for main ioctl - host offload */
11065 {
11066 WLAN_PRIV_SET_HOST_OFFLOAD,
11067 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11068 0,
11069 "setHostOffload" },
11070
11071 {
11072 WLAN_GET_WLAN_STATISTICS,
11073 0,
11074 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11075 "getWlanStats" },
11076
11077 {
11078 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011079 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11080 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011081 0,
11082 "setKeepAlive" },
11083#ifdef WLAN_FEATURE_PACKET_FILTERING
11084 {
11085 WLAN_SET_PACKET_FILTER_PARAMS,
11086 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11087 0,
11088 "setPktFilter" },
11089#endif
11090#ifdef FEATURE_WLAN_SCAN_PNO
11091 {
11092 WLAN_SET_PNO,
11093 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11094 0,
11095 "setpno" },
11096#endif
11097 {
11098 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011099 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011100 0,
11101 "SETBAND" },
11102 /* handlers for dynamic MC BC ioctl */
11103 {
11104 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011105 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011106 0,
11107 "setMCBCFilter" },
11108 {
11109 WLAN_PRIV_CLEAR_MCBC_FILTER,
11110 0,
11111 0,
11112 "clearMCBCFilter" },
11113 {
11114 WLAN_SET_POWER_PARAMS,
11115 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11116 0,
11117 "setpowerparams" },
11118 {
11119 WLAN_GET_LINK_SPEED,
11120 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011121 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Nishank Aggarwal87a36882017-07-11 15:28:27 +053011122 {
11123 WLAN_PRIV_SET_FTIES,
11124 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
11125 0, "set_ft_ies"},
Jeff Johnson295189b2012-06-20 16:38:30 -070011126};
11127
11128
11129
11130const struct iw_handler_def we_handler_def = {
11131 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11132 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11133 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11134
11135 .standard = (iw_handler *)we_handler,
11136 .private = (iw_handler *)we_private,
11137 .private_args = we_private_args,
11138 .get_wireless_stats = get_wireless_stats,
11139};
11140
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053011141const struct iw_handler_def we_mon_handler_def = {
11142 .num_standard = 0,
11143 .num_private = sizeof(we_mon_private) / sizeof(we_mon_private[0]),
11144 .num_private_args =
11145 sizeof(we_mon_private_args) / sizeof(we_mon_private_args[0]),
11146 .standard = NULL,
11147 .private = (iw_handler *)we_mon_private,
11148 .private_args = we_mon_private_args,
11149 .get_wireless_stats = NULL,
11150};
11151
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011152int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11153{
11154 v_U32_t cmd = 288; //Command to RIVA
11155 hdd_context_t *pHddCtx = NULL;
11156 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11157 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11158 /*
11159 *configMccParam : specify the bit which needs to be modified
11160 *allowed to update based on wlan_qcom_cfg.ini
11161 * configuration
11162 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11163 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11164 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11165 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11166 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11167 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11168 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11169 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11170 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11171 * Bit 9 : Reserved
11172 */
11173 switch (arg1)
11174 {
11175 //Update MCC SCHEDULE_TIME_SLICE parameter
11176 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11177 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11178 {
11179 if((arg2 >= 5) && (arg2 <= 20))
11180 {
11181 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11182 }
11183 else
11184 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011185 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011186 return 0;
11187 }
11188 }
11189 break;
11190
11191 //Update MCC MAX_NULL_SEND_TIME parameter
11192 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11193 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11194 {
11195 if((arg2 >= 1) && (arg2 <= 10))
11196 {
11197 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11198 }
11199 else
11200 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011201 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011202 return 0;
11203 }
11204 }
11205 break;
11206
11207 //Update MCC TX_EARLY_STOP_TIME parameter
11208 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11209 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11210 {
11211 if((arg2 >= 1) && (arg2 <= 10))
11212 {
11213 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11214 }
11215 else
11216 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011217 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011218 return 0;
11219 }
11220 }
11221 break;
11222
11223 //Update MCC RX_DRAIN_TIME parameter
11224 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11225 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11226 {
11227 if((arg2 >= 1) && (arg2 <= 10))
11228 {
11229 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11230 }
11231 else
11232 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011233 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011234 return 0;
11235 }
11236 }
11237 break;
11238
11239 //Update MCC CHANNEL_SWITCH_TIME parameter
11240 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11241 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11242 {
11243 if((arg2 >= 1) && (arg2 <= 20))
11244 {
11245 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11246 }
11247 else
11248 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011249 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011250 return 0;
11251 }
11252 }
11253 break;
11254
11255 //Update MCC MIN_CHANNEL_TIME parameter
11256 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11257 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11258 {
11259 if((arg2 >= 5) && (arg2 <= 20))
11260 {
11261 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11262 }
11263 else
11264 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011265 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011266 return 0;
11267 }
11268 }
11269 break;
11270
11271 //Update MCC PARK_BEFORE_TBTT parameter
11272 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11273 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11274 {
11275 if((arg2 >= 1) && (arg2 <= 5))
11276 {
11277 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11278 }
11279 else
11280 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011281 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011282 return 0;
11283 }
11284 }
11285 break;
11286
11287 //Update MCC MIN_AFTER_DTIM parameter
11288 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11289 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11290 {
11291 if((arg2 >= 5) && (arg2 <= 15))
11292 {
11293 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11294 }
11295 else
11296 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011297 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011298 return 0;
11299 }
11300 }
11301 break;
11302
11303 //Update MCC TOO_CLOSE_MARGIN parameter
11304 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11305 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11306 {
11307 if((arg2 >= 1) && (arg2 <= 3))
11308 {
11309 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11310 }
11311 else
11312 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011313 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011314 return 0;
11315 }
11316 }
11317 break;
11318
11319 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011320 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011321 __FUNCTION__,arg1);
11322 break;
11323 }
11324 return 0;
11325}
11326
Jeff Johnson295189b2012-06-20 16:38:30 -070011327int hdd_set_wext(hdd_adapter_t *pAdapter)
11328{
11329 hdd_wext_state_t *pwextBuf;
11330 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011331 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011332
11333 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11334
11335 // Now configure the roaming profile links. To SSID and bssid.
11336 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11337 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11338
11339 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11340 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11341
11342 /*Set the numOfChannels to zero to scan all the channels*/
11343 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11344 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11345
11346 /* Default is no encryption */
11347 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11348 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11349
11350 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11351 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11352
11353 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11354
11355 /* Default is no authentication */
11356 pwextBuf->roamProfile.AuthType.numEntries = 1;
11357 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11358
11359 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11360 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11361
11362 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011363 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011364
11365 hdd_clearRoamProfileIe(pAdapter);
11366
11367 return VOS_STATUS_SUCCESS;
11368
11369 }
11370
11371int hdd_register_wext(struct net_device *dev)
11372 {
11373 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11374 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11375 VOS_STATUS status;
11376
11377 ENTER();
11378
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053011379 if (pAdapter->device_mode == WLAN_HDD_MONITOR &&
11380 hdd_get_conparam() != VOS_MONITOR_MODE) {
11381 // Register as a wireless device
11382 dev->wireless_handlers = (struct iw_handler_def *)&we_mon_handler_def;
11383 return 0;
11384 }
11385
Jeff Johnson295189b2012-06-20 16:38:30 -070011386 // Zero the memory. This zeros the profile structure.
11387 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11388
11389 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11390
11391
11392 status = hdd_set_wext(pAdapter);
11393
11394 if(!VOS_IS_STATUS_SUCCESS(status)) {
11395
Arif Hussain6d2a3322013-11-17 19:50:10 -080011396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011397 return eHAL_STATUS_FAILURE;
11398 }
11399
11400 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11401 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011403 return eHAL_STATUS_FAILURE;
11404 }
11405
11406 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11407 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011409 return eHAL_STATUS_FAILURE;
11410 }
11411
11412 // Register as a wireless device
11413 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11414
11415 EXIT();
11416 return 0;
11417}
11418
11419int hdd_UnregisterWext(struct net_device *dev)
11420{
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070011421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %pK", __func__, dev);
c_hpothu2a13bc32015-01-21 12:48:54 +053011422 if (dev != NULL)
11423 {
11424 rtnl_lock();
11425 dev->wireless_handlers = NULL;
11426 rtnl_unlock();
11427 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011428
Jeff Johnson295189b2012-06-20 16:38:30 -070011429 return 0;
11430}
11431
11432