blob: b6930ed806d3aa50a48bd9c2c2043757cdaa5e24 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -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/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_wext.c
30 *
31 * Linux Wireless Extensions Implementation
32 */
33
Jeff Johnson99bac312016-06-28 10:38:18 -070034/* denote that this file does not allow legacy hddLog */
35#define HDD_DISALLOW_LEGACY_HDDLOG 1
36
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037#include <linux/version.h>
38#include <linux/module.h>
39#include <linux/kernel.h>
40#include <linux/init.h>
41#include <linux/wireless.h>
42#include <mac_trace.h>
43#include <wlan_hdd_includes.h>
44#include <cds_api.h>
45#include <net/arp.h>
Manjunathappa Prakash3454fd62016-04-01 08:52:06 -070046#include <cdp_txrx_stats.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "sir_params.h"
48#include "csr_api.h"
49#include "csr_inside_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "sme_rrm_internal.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051#include <ani_global.h>
52#include "dot11f.h"
53#include <wlan_hdd_wowl.h>
54#include <wlan_hdd_cfg.h>
55#include <wlan_hdd_wmm.h>
56#include "utils_api.h"
57#include "wlan_hdd_p2p.h"
58#ifdef FEATURE_WLAN_TDLS
59#include "wlan_hdd_tdls.h"
60#endif
61
62#include "cds_ieee80211_common.h"
63#include "ol_if_athvar.h"
64#include "dbglog_host.h"
65#include "wma.h"
66
67#include "wlan_hdd_power.h"
68#include "qwlan_version.h"
69#include "wlan_hdd_host_offload.h"
70
71#include <linux/wireless.h>
72#include <net/cfg80211.h>
73
74#include "wlan_hdd_misc.h"
75
76#include "qc_sap_ioctl.h"
77#include "sme_api.h"
78#include "wma_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053079#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080#include "wlan_hdd_assoc.h"
81#include "wlan_hdd_ioctl.h"
82#include "wlan_hdd_scan.h"
83#include "sme_power_save_api.h"
84#include "cds_concurrency.h"
85#include "wlan_hdd_conc_ut.h"
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070086#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087#include "wlan_hdd_ocb.h"
88#include "wlan_hdd_napi.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080089#include "cdp_txrx_flow_ctrl_legacy.h"
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070090#include "wlan_hdd_nan_datapath.h"
Nirav Shahbf1b0332016-05-25 14:27:39 +053091#include "wlan_hdd_stats.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070092#ifdef WLAN_SUSPEND_RESUME_TEST
93#include "wlan_hdd_driver_ops.h"
94#include "hif.h"
Rajeev Kumar9bb2e852016-09-24 12:29:25 -070095#include "pld_common.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070096#endif
Dhanashri Atree7d442a2016-07-14 18:20:29 -070097#include "wlan_hdd_lro.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099#define HDD_FINISH_ULA_TIME_OUT 800
100#define HDD_SET_MCBC_FILTERS_TO_FW 1
101#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103static int ioctl_debug;
104module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
105
106/* To Validate Channel against the Frequency and Vice-Versa */
107static const hdd_freq_chan_map_t freq_chan_map[] = {
108 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
109 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
110 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
111 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
112 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
113 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
114 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
115 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
116 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
117 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
118 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
119 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
120
121#define FREQ_CHAN_MAP_TABLE_SIZE \
122 (sizeof(freq_chan_map) / sizeof(freq_chan_map[0]))
123
124/* Private ioctls and their sub-ioctls */
125#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
126#define WE_SET_11D_STATE 1
127#define WE_WOWL 2
128#define WE_SET_POWER 3
129#define WE_SET_MAX_ASSOC 4
130#define WE_SET_SCAN_DISABLE 5
131#define WE_SET_DATA_INACTIVITY_TO 6
132#define WE_SET_MAX_TX_POWER 7
133#define WE_SET_HIGHER_DTIM_TRANSITION 8
134#define WE_SET_TM_LEVEL 9
135#define WE_SET_PHYMODE 10
136#define WE_SET_NSS 11
137#define WE_SET_LDPC 12
138#define WE_SET_TX_STBC 13
139#define WE_SET_RX_STBC 14
140#define WE_SET_SHORT_GI 15
141#define WE_SET_RTSCTS 16
142#define WE_SET_CHWIDTH 17
143#define WE_SET_ANI_EN_DIS 18
144#define WE_SET_ANI_POLL_PERIOD 19
145#define WE_SET_ANI_LISTEN_PERIOD 20
146#define WE_SET_ANI_OFDM_LEVEL 21
147#define WE_SET_ANI_CCK_LEVEL 22
148#define WE_SET_DYNAMIC_BW 23
149#define WE_SET_TX_CHAINMASK 24
150#define WE_SET_RX_CHAINMASK 25
151#define WE_SET_11N_RATE 26
152#define WE_SET_AMPDU 27
153#define WE_SET_AMSDU 28
154#define WE_SET_TXPOW_2G 29
155#define WE_SET_TXPOW_5G 30
156/* Private ioctl for firmware debug log */
157#define WE_DBGLOG_LOG_LEVEL 31
158#define WE_DBGLOG_VAP_ENABLE 32
159#define WE_DBGLOG_VAP_DISABLE 33
160#define WE_DBGLOG_MODULE_ENABLE 34
161#define WE_DBGLOG_MODULE_DISABLE 35
162#define WE_DBGLOG_MOD_LOG_LEVEL 36
163#define WE_DBGLOG_TYPE 37
164#define WE_SET_TXRX_FWSTATS 38
165#define WE_SET_VHT_RATE 39
166#define WE_DBGLOG_REPORT_ENABLE 40
167#define WE_TXRX_FWSTATS_RESET 41
168#define WE_SET_MAX_TX_POWER_2_4 42
169#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800170#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171/* Private ioctl for packet powe save */
172#define WE_PPS_PAID_MATCH 45
173#define WE_PPS_GID_MATCH 46
174#define WE_PPS_EARLY_TIM_CLEAR 47
175#define WE_PPS_EARLY_DTIM_CLEAR 48
176#define WE_PPS_EOF_PAD_DELIM 49
177#define WE_PPS_MACADDR_MISMATCH 50
178#define WE_PPS_DELIM_CRC_FAIL 51
179#define WE_PPS_GID_NSTS_ZERO 52
180#define WE_PPS_RSSI_CHECK 53
181#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
182#define WE_SET_HTSMPS 55
183/* Private ioctl for QPower */
184#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
185#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
186#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
187#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
188
189#define WE_SET_BURST_ENABLE 60
190#define WE_SET_BURST_DUR 61
191/* GTX Commands */
192#define WE_SET_GTX_HT_MCS 62
193#define WE_SET_GTX_VHT_MCS 63
194#define WE_SET_GTX_USRCFG 64
195#define WE_SET_GTX_THRE 65
196#define WE_SET_GTX_MARGIN 66
197#define WE_SET_GTX_STEP 67
198#define WE_SET_GTX_MINTPC 68
199#define WE_SET_GTX_BWMASK 69
200/* Private ioctl to configure MCC home channels time quota and latency */
201#define WE_MCC_CONFIG_LATENCY 70
202#define WE_MCC_CONFIG_QUOTA 71
203/* Private IOCTL for debug connection issues */
204#define WE_SET_DEBUG_LOG 72
205#ifdef WE_SET_TX_POWER
206#undef WE_SET_TX_POWER
207#endif
208#define WE_SET_TX_POWER 74
209/* Private ioctl for earlyrx power save feature */
210#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
211#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
212#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
213#define WE_SET_EARLY_RX_SLOP_STEP 78
214#define WE_SET_EARLY_RX_INIT_SLOP 79
215#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
216#define WE_SET_MC_RATE 81
217#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
218/* Private ioctl for packet power save */
219#define WE_PPS_5G_EBT 83
220#define WE_SET_CTS_CBW 84
221#define WE_DUMP_STATS 85
222#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +0530223/* Private sub ioctl for starting/stopping the profiling */
224#define WE_START_FW_PROFILE 87
Abhishek Singh1bdb1572015-10-16 16:24:19 +0530225#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +0530226#define WE_SET_CONC_SYSTEM_PREF 89
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227
228/* Private ioctls and their sub-ioctls */
229#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
230#define WE_GET_11D_STATE 1
231#define WE_IBSS_STATUS 2
232#define WE_SET_SAP_CHANNELS 3
233#define WE_GET_WLAN_DBG 4
234#define WE_GET_MAX_ASSOC 6
235/* 7 is unused */
236#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
237#define WE_GET_CONCURRENCY_MODE 9
238#define WE_GET_NSS 11
239#define WE_GET_LDPC 12
240#define WE_GET_TX_STBC 13
241#define WE_GET_RX_STBC 14
242#define WE_GET_SHORT_GI 15
243#define WE_GET_RTSCTS 16
244#define WE_GET_CHWIDTH 17
245#define WE_GET_ANI_EN_DIS 18
246#define WE_GET_ANI_POLL_PERIOD 19
247#define WE_GET_ANI_LISTEN_PERIOD 20
248#define WE_GET_ANI_OFDM_LEVEL 21
249#define WE_GET_ANI_CCK_LEVEL 22
250#define WE_GET_DYNAMIC_BW 23
251#define WE_GET_TX_CHAINMASK 24
252#define WE_GET_RX_CHAINMASK 25
253#define WE_GET_11N_RATE 26
254#define WE_GET_AMPDU 27
255#define WE_GET_AMSDU 28
256#define WE_GET_TXPOW_2G 29
257#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -0800258/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259#define WE_GET_PPS_PAID_MATCH 32
260#define WE_GET_PPS_GID_MATCH 33
261#define WE_GET_PPS_EARLY_TIM_CLEAR 34
262#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
263#define WE_GET_PPS_EOF_PAD_DELIM 36
264#define WE_GET_PPS_MACADDR_MISMATCH 37
265#define WE_GET_PPS_DELIM_CRC_FAIL 38
266#define WE_GET_PPS_GID_NSTS_ZERO 39
267#define WE_GET_PPS_RSSI_CHECK 40
268/* Private ioctl for QPower */
269#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
270#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
271#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
272#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
273#define WE_GET_BURST_ENABLE 45
274#define WE_GET_BURST_DUR 46
275/* GTX Commands */
276#define WE_GET_GTX_HT_MCS 47
277#define WE_GET_GTX_VHT_MCS 48
278#define WE_GET_GTX_USRCFG 49
279#define WE_GET_GTX_THRE 50
280#define WE_GET_GTX_MARGIN 51
281#define WE_GET_GTX_STEP 52
282#define WE_GET_GTX_MINTPC 53
283#define WE_GET_GTX_BWMASK 54
284#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700285#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700286#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287
288/* Private ioctls and their sub-ioctls */
289#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
290
291/* Private ioctls and their sub-ioctls */
292#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
293#define WE_WOWL_ADD_PTRN 1
294#define WE_WOWL_DEL_PTRN 2
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295#define WE_NEIGHBOR_REPORT_REQUEST 3
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296#define WE_SET_AP_WPS_IE 4 /* This is called in station mode to set probe rsp ie. */
297#define WE_SET_CONFIG 5
298
299/* Private ioctls and their sub-ioctls */
300#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
301#define WE_SET_WLAN_DBG 1
302#define WE_SET_DP_TRACE 2
303#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +0530304#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305
306/* Private ioctls and their sub-ioctls */
307#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
308#define WE_WLAN_VERSION 1
309#define WE_GET_STATS 2
310#define WE_GET_CFG 3
311#define WE_GET_WMM_STATUS 4
312#define WE_GET_CHANNEL_LIST 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313#define WE_GET_RSSI 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314#ifdef FEATURE_WLAN_TDLS
315#define WE_GET_TDLS_PEERS 8
316#endif
317#ifdef WLAN_FEATURE_11W
318#define WE_GET_11W_INFO 9
319#endif
320#define WE_GET_STATES 10
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800321#define WE_GET_IBSS_STA_INFO 11
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322#define WE_GET_PHYMODE 12
323#ifdef FEATURE_OEM_DATA_SUPPORT
324#define WE_GET_OEM_DATA_CAP 13
325#endif
326#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +0530327#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800328
329/* Private ioctls and their sub-ioctls */
330#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
331#define WE_SET_REASSOC_TRIGGER 8
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800332#define WE_IBSS_GET_PEER_INFO_ALL 10
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333#define WE_DUMP_AGC_START 11
334#define WE_DUMP_AGC 12
335#define WE_DUMP_CHANINFO_START 13
336#define WE_DUMP_CHANINFO 14
337#define WE_DUMP_WATCHDOG 15
338#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
339#define WE_DUMP_PCIE_LOG 16
340#endif
341#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -0800342#define WE_GET_FW_PROFILE_DATA 18
343#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344
345/* Private ioctls and their sub-ioctls */
346#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
347
348#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +0530349/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350
Manjeet Singhf82ed072016-07-08 11:40:00 +0530351#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352
353#ifdef FEATURE_WLAN_TDLS
354#define WE_TDLS_CONFIG_PARAMS 5
355#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800356#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357#define WE_UNIT_TEST_CMD 7
358
359#define WE_MTRACE_DUMP_CMD 8
360#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
361
362
363#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
364#define WE_LED_FLASHING_PARAM 10
365#endif
366
367#define WE_POLICY_MANAGER_CLIST_CMD 11
368#define WE_POLICY_MANAGER_DLIST_CMD 12
369#define WE_POLICY_MANAGER_DBS_CMD 13
370#define WE_POLICY_MANAGER_PCL_CMD 14
371#define WE_POLICY_MANAGER_CINFO_CMD 15
372#define WE_POLICY_MANAGER_ULIST_CMD 16
373#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
374#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
375#define WE_POLICY_MANAGER_SCENARIO_CMD 19
376#define WE_POLICY_SET_HW_MODE_CMD 20
377
378#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
379#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -0700380#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381
382#ifdef FEATURE_WLAN_TDLS
383#undef MAX_VAR_ARGS
384#define MAX_VAR_ARGS 11
385#else
386#undef MAX_VAR_ARGS
387#define MAX_VAR_ARGS 9
388#endif
389
390/* Private ioctls (with no sub-ioctls) */
391/* note that they must be odd so that they have "get" semantics */
392#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
393#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
394#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
395
396/* (SIOCIWFIRSTPRIV + 8) is currently unused */
397/* (SIOCIWFIRSTPRIV + 10) is currently unused */
398/* (SIOCIWFIRSTPRIV + 12) is currently unused */
399/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700400#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
401#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402/* (SIOCIWFIRSTPRIV + 16) is currently unused */
403/* (SIOCIWFIRSTPRIV + 17) is currently unused */
404/* (SIOCIWFIRSTPRIV + 19) is currently unused */
405
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800407
408/* Private ioctl for setting the host offload feature */
409#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
410
411/* Private ioctl to get the statistics */
412#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
413
414/* Private ioctl to set the Keep Alive Params */
415#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
416
417#ifdef WLAN_FEATURE_PACKET_FILTERING
418/* Private ioctl to set the packet filtering params */
419#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
420#endif
421
422
423#ifdef FEATURE_WLAN_SCAN_PNO
424/* Private ioctl to get the statistics */
425#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
426#endif
427
428#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
429
430/* (SIOCIWFIRSTPRIV + 26) is currently unused */
431/* (SIOCIWFIRSTPRIV + 27) is currently unused */
432
433/* Private ioctls and their sub-ioctls */
434#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
435#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -0700436#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437#define WE_SET_FW_CRASH_INJECT 2
438#endif
439#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +0530440/* Private sub ioctl for enabling and setting histogram interval of profiling */
441#define WE_ENABLE_FW_PROFILE 4
442#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443
Rajeev Kumar9bb2e852016-09-24 12:29:25 -0700444/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -0700445#define WE_SET_WLAN_SUSPEND 6
446#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -0700447
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448/* (SIOCIWFIRSTPRIV + 29) is currently unused */
449
450/* 802.11p IOCTL */
451#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
452
453#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
454
455#define WLAN_STATS_INVALID 0
456#define WLAN_STATS_RETRY_CNT 1
457#define WLAN_STATS_MUL_RETRY_CNT 2
458#define WLAN_STATS_TX_FRM_CNT 3
459#define WLAN_STATS_RX_FRM_CNT 4
460#define WLAN_STATS_FRM_DUP_CNT 5
461#define WLAN_STATS_FAIL_CNT 6
462#define WLAN_STATS_RTS_FAIL_CNT 7
463#define WLAN_STATS_ACK_FAIL_CNT 8
464#define WLAN_STATS_RTS_SUC_CNT 9
465#define WLAN_STATS_RX_DISCARD_CNT 10
466#define WLAN_STATS_RX_ERROR_CNT 11
467#define WLAN_STATS_TX_BYTE_CNT 12
468
469#define WLAN_STATS_RX_BYTE_CNT 13
470#define WLAN_STATS_RX_RATE 14
471#define WLAN_STATS_TX_RATE 15
472
473#define WLAN_STATS_RX_UC_BYTE_CNT 16
474#define WLAN_STATS_RX_MC_BYTE_CNT 17
475#define WLAN_STATS_RX_BC_BYTE_CNT 18
476#define WLAN_STATS_TX_UC_BYTE_CNT 19
477#define WLAN_STATS_TX_MC_BYTE_CNT 20
478#define WLAN_STATS_TX_BC_BYTE_CNT 21
479
480#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
481 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
482 *__p++ = __type; \
483 *__p++ = __size; \
484 memcpy(__p, __val, __size); \
485 __p += __size; \
486 __tlen += __size + 2; \
487 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -0700488 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800489 } \
490 } while (0)
491
492#define VERSION_VALUE_MAX_LEN 32
493
494#define TX_PER_TRACKING_DEFAULT_RATIO 5
495#define TX_PER_TRACKING_MAX_RATIO 10
496#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
497
498#define WLAN_ADAPTER 0
499#define P2P_ADAPTER 1
500
501/**
502 * mem_alloc_copy_from_user_helper - copy from user helper
503 * @wrqu_data: wireless extensions request data
504 * @len: length of @wrqu_data
505 *
506 * Helper function to allocate buffer and copy user data.
507 *
508 * Return: On success return a pointer to a kernel buffer containing a
509 * copy of the userspace data (with an additional NUL character
510 * appended for safety). On failure return %NULL.
511 */
512void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
513{
514 u8 *ptr = NULL;
515
516 /* in order to protect the code, an extra byte is post
517 * appended to the buffer and the null termination is added.
518 * However, when allocating (len+1) byte of memory, we need to
519 * make sure that there is no uint overflow when doing
520 * addition. In theory check len < UINT_MAX protects the uint
521 * overflow. For wlan private ioctl, the buffer size is much
522 * less than UINT_MAX, as a good guess, now, it is assumed
523 * that the private command buffer size is no greater than 4K
524 * (4096 bytes). So we use 4096 as the upper boundary for now.
525 */
526 if (len > MAX_USER_COMMAND_SIZE) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700527 hdd_err("Invalid length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800528 return NULL;
529 }
530
531 ptr = kmalloc(len + 1, GFP_KERNEL);
532 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700533 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800534 return NULL;
535 }
536
537 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700538 hdd_err("failed to copy data to user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800539 kfree(ptr);
540 return NULL;
541 }
542 ptr[len] = '\0';
543 return ptr;
544}
545
546/**
547 * hdd_priv_get_data() - Get pointer to ioctl private data
548 * @p_priv_data: pointer to iw_point struct to be filled
549 * @wrqu: Pointer to IOCTL Data received from userspace
550 *
551 * Helper function to get compatible struct iw_point passed to ioctl
552 *
553 * Return - 0 if p_priv_data successfully filled, error otherwise
554 */
555int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
556{
557 if ((NULL == p_priv_data) || (NULL == wrqu)) {
558 return -EINVAL;
559 }
560#ifdef CONFIG_COMPAT
561 if (is_compat_task()) {
562 struct compat_iw_point *p_compat_priv_data;
563
564 /* Compat task:
565 * typecast to compat structure and copy the members.
566 */
567 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
568
569 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
570 p_priv_data->length = p_compat_priv_data->length;
571 p_priv_data->flags = p_compat_priv_data->flags;
572 } else {
573#endif /* #ifdef CONFIG_COMPAT */
574
575 /* Non compat task: directly copy the structure. */
576 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
577
578#ifdef CONFIG_COMPAT
579 }
580#endif /* #ifdef CONFIG_COMPAT */
581
582 return 0;
583}
584
585
586/**
587 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
588 * @pAdapter: Pointer to the hdd adapter.
589 * @length: Size of the data copied
590 * @buffer: Pointer to char buffer.
591 * @buf_len: Length of the char buffer.
592 *
593 * This function called when the "iwpriv wlan0 get_stats" command is given.
594 * It used to collect the txrx stats when the device is configured in SAP mode.
595 *
596 * Return - none
597 */
598void hdd_wlan_get_stats(hdd_adapter_t *pAdapter, uint16_t *length,
599 char *buffer, uint16_t buf_len)
600{
601 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
602 uint32_t len = 0;
603 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
604 uint32_t total_rx_delv = 0, total_rx_refused = 0;
605 int i = 0;
606
607 for (; i < NUM_CPUS; i++) {
608 total_rx_pkt += pStats->rxPackets[i];
609 total_rx_dropped += pStats->rxDropped[i];
610 total_rx_delv += pStats->rxDelivered[i];
611 total_rx_refused += pStats->rxRefused[i];
612 }
613
614 len = scnprintf(buffer, buf_len,
615 "\nTransmit"
616 "\ncalled %u, dropped %u,"
617 "\n dropped BK %u, BE %u, VI %u, VO %u"
618 "\n classified BK %u, BE %u, VI %u, VO %u"
619 "\ncompleted %u,"
620 "\n\nReceive Total"
621 "\n packets %u, dropped %u, delivered %u, refused %u"
622 "\n",
623 pStats->txXmitCalled,
624 pStats->txXmitDropped,
625
626 pStats->txXmitDroppedAC[SME_AC_BK],
627 pStats->txXmitDroppedAC[SME_AC_BE],
628 pStats->txXmitDroppedAC[SME_AC_VI],
629 pStats->txXmitDroppedAC[SME_AC_VO],
630
631 pStats->txXmitClassifiedAC[SME_AC_BK],
632 pStats->txXmitClassifiedAC[SME_AC_BE],
633 pStats->txXmitClassifiedAC[SME_AC_VI],
634 pStats->txXmitClassifiedAC[SME_AC_VO],
635
636 pStats->txCompleted,
637 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
638 );
639
640 for (i = 0; i < NUM_CPUS; i++) {
641 len += scnprintf(buffer + len, buf_len - len,
642 "\nReceive CPU: %d"
643 "\n packets %u, dropped %u, delivered %u, refused %u",
644 i, pStats->rxPackets[i], pStats->rxDropped[i],
645 pStats->rxDelivered[i], pStats->rxRefused[i]);
646 }
647
648 len += scnprintf(buffer + len, buf_len - len,
649 "\n\nTX_FLOW"
650 "\nCurrent status: %s"
651 "\ntx-flow timer start count %u"
652 "\npause count %u, unpause count %u",
653 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
654 pStats->txflow_timer_cnt,
655 pStats->txflow_pause_cnt,
656 pStats->txflow_unpause_cnt);
657
Leo Changfdb45c32016-10-28 11:09:23 -0700658 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
659 pAdapter->sessionId, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660
661 len += hdd_napi_stats(buffer + len, buf_len - len,
662 NULL, hdd_napi_get_all());
663
664 *length = len + 1;
665}
666
667/**
Govind Singha471e5e2015-10-12 17:11:14 +0530668 * hdd_wlan_list_fw_profile() - Get fw profiling points
669 * @length: Size of the data copied
670 * @buffer: Pointer to char buffer.
671 * @buf_len: Length of the char buffer.
672 *
673 * This function called when the "iwpriv wlan0 listProfile" command is given.
674 * It is used to get the supported profiling points in FW.
675 *
676 * Return - none
677 */
678void hdd_wlan_list_fw_profile(uint16_t *length,
679 char *buffer, uint16_t buf_len)
680{
681 uint32_t len = 0;
682
683 len = scnprintf(buffer, buf_len,
684 "PROF_CPU_IDLE: %u\n"
685 "PROF_PPDU_PROC: %u\n"
686 "PROF_PPDU_POST: %u\n"
687 "PROF_HTT_TX_INPUT: %u\n"
688 "PROF_MSDU_ENQ: %u\n"
689 "PROF_PPDU_POST_HAL: %u\n"
690 "PROF_COMPUTE_TX_TIME: %u\n",
691 PROF_CPU_IDLE,
692 PROF_PPDU_PROC,
693 PROF_PPDU_POST,
694 PROF_HTT_TX_INPUT,
695 PROF_MSDU_ENQ,
696 PROF_PPDU_POST_HAL,
697 PROF_COMPUTE_TX_TIME);
698
699 *length = len + 1;
700}
701
702/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800703 * hdd_wlan_dump_stats() - display dump Stats
704 * @adapter: adapter handle
705 * @value: value from user
706 *
707 * Return: none
708 */
709void hdd_wlan_dump_stats(hdd_adapter_t *adapter, int value)
710{
711 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
712
713 switch (value) {
714
715 case WLAN_TXRX_HIST_STATS:
716 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
717 break;
718 case WLAN_HDD_NETIF_OPER_HISTORY:
719 wlan_hdd_display_netif_queue_history(hdd_ctx);
720 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +0530721 case WLAN_HIF_STATS:
722 hdd_display_hif_stats();
723 break;
Dhanashri Atree7d442a2016-07-14 18:20:29 -0700724 case WLAN_LRO_STATS:
725 hdd_lro_display_stats(hdd_ctx);
726 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800727 default:
Leo Changfdb45c32016-10-28 11:09:23 -0700728 cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 break;
730 }
731}
732
733/**
734 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530735 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 * @wrqu: Pointer to IOCTL REQUEST Data.
737 * @extra: Pointer to destination buffer
738 *
739 * This function is used to get Wlan Driver, Firmware, & Hardware
740 * Version information. If @wrqu and @extra are specified, then the
741 * version string is returned. Otherwise it is simply printed to the
742 * kernel log.
743 *
744 * Return: none
745 */
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530746void hdd_wlan_get_version(hdd_context_t *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747 char *extra)
748{
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530749 tSirVersionString wcnss_sw_version;
750 const char *swversion;
751 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -0700752 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530754 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700755 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756 goto error;
757 }
758
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530759 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
760 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800761
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530762 swversion = wcnss_sw_version;
763 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
764 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
765 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
766 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -0700767 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530769 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770
771 if (wrqu && extra) {
772 wrqu->data.length =
773 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -0700774 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800775 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -0700776 msp_id, mspid, siid, crmid,
777 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -0700779 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800780 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -0700781 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782 }
783error:
784 return;
785}
786
787/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800788 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
789 * @pAdapter: Adapter upon which the IBSS client is active
790 * @staIdx: Station index of the IBSS peer
791 *
792 * Return: a pointer to the MAC address of the IBSS peer if the peer is
793 * found, otherwise %NULL.
794 */
795struct qdf_mac_addr *
796hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter,
797 uint8_t staIdx)
798{
799 uint8_t idx;
800 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
801
Naveen Rawatc45d1622016-07-05 12:20:09 -0700802 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800803 if (0 != pHddStaCtx->conn_info.staId[idx] &&
804 staIdx == pHddStaCtx->conn_info.staId[idx]) {
805 return &pHddStaCtx->conn_info.peerMacAddress[idx];
806 }
807 }
808 return NULL;
809}
810
811/**
812 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
813 * @pAdapter: Adapter upon which the IBSS client is active
814 * @staIdx: Station index of the IBSS peer
815 *
816 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
817 * otherwise an appropriate QDF_STATUS_E_* failure code.
818 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -0700819static QDF_STATUS hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter,
820 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800821{
822 QDF_STATUS status = QDF_STATUS_E_FAILURE;
823 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
824 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700825 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800826
827 status =
828 sme_request_ibss_peer_info(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
829 false, staIdx);
830
831 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
832
833 if (QDF_STATUS_SUCCESS == status) {
834 unsigned long rc;
835 rc = wait_for_completion_timeout
836 (&pAdapter->ibss_peer_info_comp,
837 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
838 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700839 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800840 return QDF_STATUS_E_FAILURE;
841 }
842
843 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700844 hdd_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800845 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700846 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
847 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800848
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700849 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
850 mac_addr, sizeof(mac_addr));
851 hdd_info("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
852 mac_addr, (int)tx_rate,
853 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800854 }
855 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -0700856 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800857 }
858
859 return status;
860}
861
862/**
863 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
864 * @pAdapter: Adapter upon which the IBSS clients are active
865 *
866 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
867 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
868 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -0700869static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800870{
871 QDF_STATUS status = QDF_STATUS_E_FAILURE;
872 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
873 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700874 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800875 int i;
876
877 status =
878 sme_request_ibss_peer_info(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
879 true, 0xFF);
880 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
881
882 if (QDF_STATUS_SUCCESS == status) {
883 unsigned long rc;
884 rc = wait_for_completion_timeout
885 (&pAdapter->ibss_peer_info_comp,
886 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
887 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700888 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800889 return QDF_STATUS_E_FAILURE;
890 }
891
892 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700893 hdd_info("pPeerInfo->numIBSSPeers = %d ",
894 (int)pPeerInfo->numPeers);
895 for (i = 0; i < pPeerInfo->numPeers; i++) {
896 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
897 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800898
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700899 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
900 qdf_mem_copy(mac_addr,
901 pPeerInfo->peerInfoParams[i].mac_addr,
902 sizeof(mac_addr));
903
904 hdd_info(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
905 mac_addr, (int)tx_rate,
906 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800907 }
908 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -0700909 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800910 }
911
912 return status;
913}
914
915/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 * hdd_wlan_get_rts_threshold() - Get RTS threshold
917 * @pAdapter: adapter upon which the request was received
918 * @wrqu: pointer to the ioctl request
919 *
920 * This function retrieves the current RTS threshold value and stores
921 * it in the ioctl request structure
922 *
923 * Return: 0 if valid data was returned, non-zero on error
924 */
925int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
926{
927 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
928 uint32_t threshold = 0;
929 hdd_context_t *hdd_ctx;
930 int ret = 0;
931
932 ENTER();
933
934 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700935 hdd_err("Adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 return -EINVAL;
937 }
938
939 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
940 ret = wlan_hdd_validate_context(hdd_ctx);
941 if (0 != ret)
942 return ret;
943
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530944 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945 sme_cfg_get_int(hHal, WNI_CFG_RTS_THRESHOLD, &threshold)) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700946 hdd_warn("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947 return -EIO;
948 }
949 wrqu->rts.value = threshold;
950
Jeff Johnson99bac312016-06-28 10:38:18 -0700951 hdd_notice("Rts-Threshold=%d!!", wrqu->rts.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952
953 EXIT();
954
955 return 0;
956}
957
958/**
959 * hdd_wlan_get_frag_threshold() - Get fragmentation threshold
960 * @pAdapter: adapter upon which the request was received
961 * @wrqu: pointer to the ioctl request
962 *
963 * This function retrieves the current fragmentation threshold value
964 * and stores it in the ioctl request structure
965 *
966 * Return: 0 if valid data was returned, non-zero on error
967 */
968int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter,
969 union iwreq_data *wrqu)
970{
971 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
972 uint32_t threshold = 0, status = 0;
973 hdd_context_t *hdd_ctx;
974
975 ENTER();
976
977 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700978 hdd_err("Adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 return -EINVAL;
980 }
981
982 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
983 status = wlan_hdd_validate_context(hdd_ctx);
984 if (0 != status)
985 return status;
986
987 if (sme_cfg_get_int(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530988 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700989 hdd_warn("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 return -EIO;
991 }
992 wrqu->frag.value = threshold;
993
Jeff Johnson99bac312016-06-28 10:38:18 -0700994 hdd_notice("Frag-Threshold=%d!!", wrqu->frag.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995
996 EXIT();
997
998 return 0;
999}
1000
1001/**
1002 * hdd_wlan_get_freq() - Convert channel to frequency
1003 * @channel: channel to be converted
1004 * @pfreq: where to store the frequency
1005 *
1006 * Return: 1 on success, otherwise a negative errno
1007 */
1008int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
1009{
1010 int i;
1011 if (channel > 0) {
1012 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
1013 if (channel == freq_chan_map[i].chan) {
1014 *pfreq = freq_chan_map[i].freq;
1015 return 1;
1016 }
1017 }
1018 }
Jeff Johnson99bac312016-06-28 10:38:18 -07001019 hdd_notice("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020 return -EINVAL;
1021}
1022
1023/**
1024 * hdd_is_auth_type_rsn() - RSN authentication type check
1025 * @authType: authentication type to be checked
1026 *
1027 * Return: true if @authType is an RSN authentication type,
1028 * false if it is not
1029 */
1030static bool hdd_is_auth_type_rsn(eCsrAuthType authType)
1031{
1032 bool rsnType = false;
1033 /* is the authType supported? */
1034 switch (authType) {
1035 case eCSR_AUTH_TYPE_NONE: /* never used */
1036 rsnType = false;
1037 break;
1038 /* MAC layer authentication types */
1039 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
1040 rsnType = false;
1041 break;
1042 case eCSR_AUTH_TYPE_SHARED_KEY:
1043 rsnType = false;
1044 break;
1045 case eCSR_AUTH_TYPE_AUTOSWITCH:
1046 rsnType = false;
1047 break;
1048
1049 /* Upper layer authentication types */
1050 case eCSR_AUTH_TYPE_WPA:
1051 rsnType = true;
1052 break;
1053 case eCSR_AUTH_TYPE_WPA_PSK:
1054 rsnType = true;
1055 break;
1056 case eCSR_AUTH_TYPE_WPA_NONE:
1057 rsnType = true;
1058 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 case eCSR_AUTH_TYPE_RSN:
1061 rsnType = true;
1062 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 case eCSR_AUTH_TYPE_RSN_PSK:
1065#ifdef WLAN_FEATURE_11W
1066 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
1067 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
1068#endif
1069 rsnType = true;
1070 break;
1071 /* case eCSR_AUTH_TYPE_FAILED: */
1072 case eCSR_AUTH_TYPE_UNKNOWN:
1073 rsnType = false;
1074 break;
1075 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07001076 hdd_err("unknown authType %d, treat as open",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077 authType);
1078 rsnType = false;
1079 break;
1080 }
Jeff Johnson99bac312016-06-28 10:38:18 -07001081 hdd_notice("called with authType: %d, returned: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082 authType, rsnType);
1083 return rsnType;
1084}
1085
1086/**
1087 * hdd_get_rssi_cb() - "Get RSSI" callback function
1088 * @rssi: Current RSSI of the station
1089 * @staId: ID of the station
1090 * @pContext: opaque context originally passed to SME. HDD always passes
1091 * a &struct statsContext
1092 *
1093 * Return: None
1094 */
1095static void hdd_get_rssi_cb(int8_t rssi, uint32_t staId, void *pContext)
1096{
1097 struct statsContext *pStatsContext;
1098 hdd_adapter_t *pAdapter;
1099
1100 if (ioctl_debug) {
1101 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1102 __func__, (int)rssi, (int)staId, pContext);
1103 }
1104
1105 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001106 hdd_err("Bad param");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107 return;
1108 }
1109
1110 pStatsContext = pContext;
1111 pAdapter = pStatsContext->pAdapter;
1112
1113 /* there is a race condition that exists between this callback
1114 * function and the caller since the caller could time out
1115 * either before or while this code is executing. we use a
1116 * spinlock to serialize these actions
1117 */
1118 spin_lock(&hdd_context_lock);
1119
1120 if ((NULL == pAdapter) ||
1121 (RSSI_CONTEXT_MAGIC != pStatsContext->magic)) {
1122 /* the caller presumably timed out so there is nothing
1123 * we can do
1124 */
1125 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07001126 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
1127 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 if (ioctl_debug) {
1129 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1130 __func__, pAdapter, pStatsContext->magic);
1131 }
1132 return;
1133 }
1134
1135 /* context is valid so caller is still waiting */
1136
1137 /* paranoia: invalidate the magic */
1138 pStatsContext->magic = 0;
1139
1140 /* copy over the rssi */
1141 pAdapter->rssi = rssi;
1142
Sachin Ahujabef8c102015-11-16 15:15:49 +05301143 if (pAdapter->rssi > 0)
1144 pAdapter->rssi = 0;
1145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146 /* notify the caller */
1147 complete(&pStatsContext->completion);
1148
1149 /* serialization is complete */
1150 spin_unlock(&hdd_context_lock);
1151}
1152
1153/**
1154 * hdd_get_snr_cb() - "Get SNR" callback function
1155 * @snr: Current SNR of the station
1156 * @staId: ID of the station
1157 * @pContext: opaque context originally passed to SME. HDD always passes
1158 * a &struct statsContext
1159 *
1160 * Return: None
1161 */
1162static void hdd_get_snr_cb(int8_t snr, uint32_t staId, void *pContext)
1163{
1164 struct statsContext *pStatsContext;
1165 hdd_adapter_t *pAdapter;
1166
1167 if (ioctl_debug) {
1168 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
1169 __func__, (int)snr, (int)staId, pContext);
1170 }
1171
1172 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001173 hdd_err("Bad param");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174 return;
1175 }
1176
1177 pStatsContext = pContext;
1178 pAdapter = pStatsContext->pAdapter;
1179
1180 /* there is a race condition that exists between this callback
1181 * function and the caller since the caller could time out
1182 * either before or while this code is executing. we use a
1183 * spinlock to serialize these actions
1184 */
1185 spin_lock(&hdd_context_lock);
1186
1187 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic)) {
1188 /* the caller presumably timed out so there is nothing
1189 * we can do
1190 */
1191 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07001192 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
1193 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001194 if (ioctl_debug) {
1195 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1196 __func__, pAdapter, pStatsContext->magic);
1197 }
1198 return;
1199 }
1200
1201 /* context is valid so caller is still waiting */
1202
1203 /* paranoia: invalidate the magic */
1204 pStatsContext->magic = 0;
1205
1206 /* copy over the snr */
1207 pAdapter->snr = snr;
1208
1209 /* notify the caller */
1210 complete(&pStatsContext->completion);
1211
1212 /* serialization is complete */
1213 spin_unlock(&hdd_context_lock);
1214}
1215
1216/**
1217 * wlan_hdd_get_rssi() - Get the current RSSI
1218 * @pAdapter: adapter upon which the measurement is requested
1219 * @rssi_value: pointer to where the RSSI should be returned
1220 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301221 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301223QDF_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001224{
Houston Hoffman59c097f2016-11-09 15:50:25 -08001225 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226 hdd_context_t *pHddCtx;
1227 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301228 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 unsigned long rc;
1230
1231 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001232 hdd_warn("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301233 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08001235 if (cds_is_driver_recovering()) {
1236 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
1237 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 /* return a cached value */
1239 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301240 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 }
1242
1243 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1244 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1245
1246 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301247 hdd_err("Not associated!, rssi on disconnect %d",
1248 pAdapter->rssi_on_disconnect);
1249 *rssi_value = pAdapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301250 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251 }
1252
1253 if (pHddStaCtx->hdd_ReassocScenario) {
1254 hdd_info("Roaming in progress, return cached RSSI");
1255 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301256 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001257 }
1258
1259 init_completion(&context.completion);
1260 context.pAdapter = pAdapter;
1261 context.magic = RSSI_CONTEXT_MAGIC;
1262
1263 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
1264 pHddStaCtx->conn_info.staId[0],
1265 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
1266 &context, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301267 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001268 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269 /* we'll returned a cached value below */
1270 } else {
1271 /* request was sent -- wait for the response */
1272 rc = wait_for_completion_timeout(&context.completion,
1273 msecs_to_jiffies
1274 (WLAN_WAIT_TIME_STATS));
1275 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001276 hdd_err("SME timed out while retrieving RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 /* we'll now returned a cached value below */
1278 }
1279 }
1280
1281 /* either we never sent a request, we sent a request and
1282 * received a response or we sent a request and timed out. if
1283 * we never sent a request or if we sent a request and got a
1284 * response, we want to clear the magic out of paranoia. if
1285 * we timed out there is a race condition such that the
1286 * callback function could be executing at the same time we
1287 * are. of primary concern is if the callback function had
1288 * already verified the "magic" but had not yet set the
1289 * completion variable when a timeout occurred. we serialize
1290 * these activities by invalidating the magic while holding a
1291 * shared spinlock which will cause us to block if the
1292 * callback is currently executing
1293 */
1294 spin_lock(&hdd_context_lock);
1295 context.magic = 0;
1296 spin_unlock(&hdd_context_lock);
1297
1298 *rssi_value = pAdapter->rssi;
1299
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301300 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301}
1302
1303/**
1304 * wlan_hdd_get_snr() - Get the current SNR
1305 * @pAdapter: adapter upon which the measurement is requested
1306 * @snr: pointer to where the SNR should be returned
1307 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301308 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301310QDF_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311{
Houston Hoffman59c097f2016-11-09 15:50:25 -08001312 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001313 hdd_context_t *pHddCtx;
1314 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301315 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001316 unsigned long rc;
1317 int valid;
1318
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301319 ENTER();
1320
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001322 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301323 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 }
1325
1326 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1327
1328 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301329 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301330 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331
1332 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1333
1334 init_completion(&context.completion);
1335 context.pAdapter = pAdapter;
1336 context.magic = SNR_CONTEXT_MAGIC;
1337
1338 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
1339 pHddStaCtx->conn_info.staId[0],
1340 pHddStaCtx->conn_info.bssId, &context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301341 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001342 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 /* we'll returned a cached value below */
1344 } else {
1345 /* request was sent -- wait for the response */
1346 rc = wait_for_completion_timeout(&context.completion,
1347 msecs_to_jiffies
1348 (WLAN_WAIT_TIME_STATS));
1349 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001350 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 /* we'll now returned a cached value below */
1352 }
1353 }
1354
1355 /* either we never sent a request, we sent a request and
1356 * received a response or we sent a request and timed out. if
1357 * we never sent a request or if we sent a request and got a
1358 * response, we want to clear the magic out of paranoia. if
1359 * we timed out there is a race condition such that the
1360 * callback function could be executing at the same time we
1361 * are. of primary concern is if the callback function had
1362 * already verified the "magic" but had not yet set the
1363 * completion variable when a timeout occurred. we serialize
1364 * these activities by invalidating the magic while holding a
1365 * shared spinlock which will cause us to block if the
1366 * callback is currently executing
1367 */
1368 spin_lock(&hdd_context_lock);
1369 context.magic = 0;
1370 spin_unlock(&hdd_context_lock);
1371
1372 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301373 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301374 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375}
1376
1377/**
1378 * hdd_get_link_speed_cb() - Get link speed callback function
1379 * @pLinkSpeed: pointer to the link speed record
1380 * @pContext: pointer to the user context passed to SME
1381 *
1382 * This function is passed as the callback function to
1383 * sme_get_link_speed() by wlan_hdd_get_linkspeed_for_peermac(). By
1384 * agreement a &struct linkspeedContext is passed as @pContext. If
1385 * the context is valid, then the contents of @pLinkSpeed are copied
1386 * into the adapter record referenced by @pContext where they can be
1387 * subsequently retrieved. If the context is invalid, then this
1388 * function does nothing since it is assumed the caller has already
1389 * timed-out and destroyed the context.
1390 *
1391 * Return: None.
1392 */
1393static void
1394hdd_get_link_speed_cb(tSirLinkSpeedInfo *pLinkSpeed, void *pContext)
1395{
1396 struct linkspeedContext *pLinkSpeedContext;
1397 hdd_adapter_t *pAdapter;
1398
1399 if ((NULL == pLinkSpeed) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001400 hdd_err("Bad param, pLinkSpeed [%p] pContext [%p]",
1401 pLinkSpeed, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 return;
1403 }
1404 spin_lock(&hdd_context_lock);
1405 pLinkSpeedContext = pContext;
1406 pAdapter = pLinkSpeedContext->pAdapter;
1407
1408 /* there is a race condition that exists between this callback
1409 * function and the caller since the caller could time out either
1410 * before or while this code is executing. we use a spinlock to
1411 * serialize these actions
1412 */
1413
1414 if ((NULL == pAdapter) ||
1415 (LINK_CONTEXT_MAGIC != pLinkSpeedContext->magic)) {
1416 /* the caller presumably timed out so there is nothing
1417 * we can do
1418 */
1419 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07001420 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
1421 pAdapter, pLinkSpeedContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 if (ioctl_debug) {
1423 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1424 __func__, pAdapter, pLinkSpeedContext->magic);
1425 }
1426 return;
1427 }
1428
1429 /* context is valid so caller is still waiting */
1430
1431 /* paranoia: invalidate the magic */
1432 pLinkSpeedContext->magic = 0;
1433
1434 /* copy over the stats. do so as a struct copy */
1435 pAdapter->ls_stats = *pLinkSpeed;
1436
1437 /* notify the caller */
1438 complete(&pLinkSpeedContext->completion);
1439
1440 /* serialization is complete */
1441 spin_unlock(&hdd_context_lock);
1442}
1443
1444/**
1445 * wlan_hdd_get_linkspeed_for_peermac() - Get link speed for a peer
1446 * @pAdapter: adapter upon which the peer is active
1447 * @macAddress: MAC address of the peer
1448 *
1449 * This function will send a query to SME for the linkspeed of the
1450 * given peer, and then wait for the callback to be invoked.
1451 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301452 * Return: QDF_STATUS_SUCCESS if linkspeed data is available,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301453 * otherwise a QDF_STATUS_E_** error.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301455QDF_STATUS wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *pAdapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301456 struct qdf_mac_addr macAddress) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301457 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 unsigned long rc;
Houston Hoffman59c097f2016-11-09 15:50:25 -08001459 static struct linkspeedContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460 tSirLinkSpeedInfo *linkspeed_req;
1461
1462 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001463 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301464 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301466 linkspeed_req = qdf_mem_malloc(sizeof(*linkspeed_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467 if (NULL == linkspeed_req) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001468 hdd_err("Request Buffer Alloc Fail");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301469 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 }
1471 init_completion(&context.completion);
1472 context.pAdapter = pAdapter;
1473 context.magic = LINK_CONTEXT_MAGIC;
1474
Anurag Chouhanc5548422016-02-24 18:33:27 +05301475 qdf_copy_macaddr(&linkspeed_req->peer_macaddr, &macAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(pAdapter),
1477 linkspeed_req,
1478 &context, hdd_get_link_speed_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301479 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001480 hdd_err("Unable to retrieve statistics for link speed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301481 qdf_mem_free(linkspeed_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482 } else {
1483 rc = wait_for_completion_timeout
1484 (&context.completion,
1485 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
1486 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001487 hdd_err("SME timed out while retrieving link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 }
1489 }
1490
1491 /* either we never sent a request, we sent a request and
1492 * received a response or we sent a request and timed out. if
1493 * we never sent a request or if we sent a request and got a
1494 * response, we want to clear the magic out of paranoia. if
1495 * we timed out there is a race condition such that the
1496 * callback function could be executing at the same time we
1497 * are. of primary concern is if the callback function had
1498 * already verified the "magic" but had not yet set the
1499 * completion variable when a timeout occurred. we serialize
1500 * these activities by invalidating the magic while holding a
1501 * shared spinlock which will cause us to block if the
1502 * callback is currently executing
1503 */
1504 spin_lock(&hdd_context_lock);
1505 context.magic = 0;
1506 spin_unlock(&hdd_context_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301507 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508}
1509
1510/**
1511 * wlan_hdd_get_link_speed() - get link speed
1512 * @pAdapter: pointer to the adapter
1513 * @link_speed: pointer to link speed
1514 *
1515 * This function fetches per bssid link speed.
1516 *
1517 * Return: if associated, link speed shall be returned.
1518 * if not associated, link speed of 0 is returned.
1519 * On error, error number will be returned.
1520 */
1521int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
1522{
1523 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
1524 hdd_station_ctx_t *hdd_stactx =
1525 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
1526 int ret;
1527
1528 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301529 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05301532 /* Linkspeed is allowed only for P2P mode */
1533 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
1534 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
1535 hdd_device_mode_to_string(sta_adapter->device_mode),
1536 sta_adapter->device_mode);
1537 return -ENOTSUPP;
1538 }
1539
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
1541 /* we are not connected so we don't have a classAstats */
1542 *link_speed = 0;
1543 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301544 QDF_STATUS status;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301545 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546
Anurag Chouhanc5548422016-02-24 18:33:27 +05301547 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548
1549 status = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301550 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001551 hdd_err("Unable to retrieve SME linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 return -EINVAL;
1553 }
1554 *link_speed = sta_adapter->ls_stats.estLinkSpeed;
1555 /* linkspeed in units of 500 kbps */
1556 *link_speed = (*link_speed) / 500;
1557 }
1558 return 0;
1559}
1560
1561/**
1562 * hdd_statistics_cb() - "Get statistics" callback function
1563 * @pStats: statistics payload
1564 * @pContext: opaque context originally passed to SME. HDD always passes
1565 * a pointer to an adapter
1566 *
1567 * Return: None
1568 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07001569static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570{
1571 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
1572 hdd_stats_t *pStatsCache = NULL;
1573 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05301574 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575
1576 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1577 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1578 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1579 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1580 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1581 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1582
1583 if (pAdapter != NULL)
1584 pStatsCache = &pAdapter->hdd_stats;
1585
1586 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
1587 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
1588 pClassBStats = (tCsrGlobalClassBStatsInfo *) (pClassAStats + 1);
1589 pClassCStats = (tCsrGlobalClassCStatsInfo *) (pClassBStats + 1);
1590 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassCStats + 1);
1591 pPerStaStats = (tCsrPerStaStatsInfo *) (pClassDStats + 1);
1592
1593 if (pStatsCache != NULL) {
1594 /* copy the stats into the cache we keep in the
1595 * adapter instance structure
1596 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301597 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301599 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301601 qdf_mem_copy(&pStatsCache->ClassB_stat, pClassBStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001602 sizeof(pStatsCache->ClassB_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301603 qdf_mem_copy(&pStatsCache->ClassC_stat, pClassCStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 sizeof(pStatsCache->ClassC_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301605 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 sizeof(pStatsCache->ClassD_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301607 qdf_mem_copy(&pStatsCache->perStaStats, pPerStaStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608 sizeof(pStatsCache->perStaStats));
1609 }
1610
1611 if (pAdapter) {
1612 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301613 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05301614 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001615 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 return;
1617 }
1618 }
1619}
1620
1621/**
1622 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
1623 * @pAdapter: adapter who's IEs are to be cleared
1624 *
1625 * Return: None
1626 */
1627void hdd_clear_roam_profile_ie(hdd_adapter_t *pAdapter)
1628{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001629 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07001630
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001631 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632
1633 /* clear WPA/RSN/WSC IE information in the profile */
1634 pWextState->roamProfile.nWPAReqIELength = 0;
1635 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
1636 pWextState->roamProfile.nRSNReqIELength = 0;
1637 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
1638
1639#ifdef FEATURE_WLAN_WAPI
1640 pWextState->roamProfile.nWAPIReqIELength = 0;
1641 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
1642#endif
1643
1644 pWextState->roamProfile.bWPSAssociation = false;
1645 pWextState->roamProfile.bOSENAssociation = false;
1646 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
1647 pWextState->roamProfile.nAddIEScanLength = 0;
1648 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
1649 pWextState->roamProfile.nAddIEAssocLength = 0;
1650
1651 pWextState->roamProfile.EncryptionType.numEntries = 1;
1652 pWextState->roamProfile.EncryptionType.encryptionType[0]
1653 = eCSR_ENCRYPT_TYPE_NONE;
1654
1655 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1656 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1657 = eCSR_ENCRYPT_TYPE_NONE;
1658
1659 pWextState->roamProfile.AuthType.numEntries = 1;
1660 pWextState->roamProfile.AuthType.authType[0] =
1661 eCSR_AUTH_TYPE_OPEN_SYSTEM;
1662
1663#ifdef WLAN_FEATURE_11W
1664 pWextState->roamProfile.MFPEnabled = false;
1665 pWextState->roamProfile.MFPRequired = 0;
1666 pWextState->roamProfile.MFPCapable = 0;
1667#endif
1668
1669 pWextState->authKeyMgmt = 0;
1670
Yingying Tang3cc6b792016-10-20 17:00:37 +08001671 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
1672
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673#ifdef FEATURE_WLAN_WAPI
1674 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1675 pAdapter->wapi_info.nWapiMode = 0;
1676#endif
1677
Anurag Chouhanc5548422016-02-24 18:33:27 +05301678 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001679 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680}
1681
1682/**
1683 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
1684 * @oui: The OUI that is being searched for
1685 * @oui_size: The length of @oui
1686 * @ie: The set of IEs within which we're trying to find @oui
1687 * @ie_len: The length of @ie
1688 *
1689 * This function will scan the IEs contained within @ie looking for @oui.
1690 *
1691 * Return: Pointer to @oui embedded within @ie if it is present, NULL
1692 * if @oui is not present within @ie.
1693 */
1694uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
1695 uint8_t *ie, int ie_len)
1696{
1697 int left = ie_len;
1698 uint8_t *ptr = ie;
1699 uint8_t elem_id, elem_len;
1700 uint8_t eid = 0xDD;
1701
1702 if (NULL == ie || 0 == ie_len)
1703 return NULL;
1704
1705 while (left >= 2) {
1706 elem_id = ptr[0];
1707 elem_len = ptr[1];
1708 left -= 2;
1709 if (elem_len > left) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001710 hdd_alert("****Invalid IEs eid = %d elem_len=%d left=%d*****",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 eid, elem_len, left);
1712 return NULL;
1713 }
1714 if (elem_id == eid) {
1715 if (memcmp(&ptr[2], oui, oui_size) == 0)
1716 return ptr;
1717 }
1718
1719 left -= elem_len;
1720 ptr += (elem_len + 2);
1721 }
1722 return NULL;
1723}
1724
1725/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05301726 * hdd_get_ldpc() - Get adapter LDPC
1727 * @adapter: adapter being queried
1728 * @value: where to store the value
1729 *
1730 * Return: 0 on success, negative errno on failure
1731 */
1732int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
1733{
1734 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1735 int ret;
1736
1737 ENTER();
1738 ret = sme_get_ht_config(hal, adapter->sessionId,
1739 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
1740 if (ret < 0) {
1741 hdd_alert("Failed to get LDPC value");
1742 } else {
1743 *value = ret;
1744 ret = 0;
1745 }
1746 return ret;
1747}
1748
1749/**
1750 * hdd_set_ldpc() - Set adapter LDPC
1751 * @adapter: adapter being modified
1752 * @value: new LDPC value
1753 *
1754 * Return: 0 on success, negative errno on failure
1755 */
1756int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
1757{
1758 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1759 int ret;
1760
1761 hdd_alert("%d", value);
1762 if (value) {
1763 /* make sure HT capabilities allow this */
1764 QDF_STATUS status;
1765 uint32_t cfg_value;
1766 union {
1767 uint16_t cfg_value16;
1768 tSirMacHTCapabilityInfo ht_cap_info;
1769 } u;
1770
1771 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1772 if (QDF_STATUS_SUCCESS != status) {
1773 hdd_alert("Failed to get HT capability info");
1774 return -EIO;
1775 }
1776 u.cfg_value16 = cfg_value & 0xFFFF;
1777 if (!u.ht_cap_info.advCodingCap) {
1778 hdd_alert("LDCP not supported");
1779 return -EINVAL;
1780 }
1781 }
1782
1783 ret = sme_update_ht_config(hal, adapter->sessionId,
1784 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
1785 value);
1786 if (ret)
1787 hdd_alert("Failed to set LDPC value");
1788
1789 return ret;
1790}
1791
1792/**
1793 * hdd_get_tx_stbc() - Get adapter TX STBC
1794 * @adapter: adapter being queried
1795 * @value: where to store the value
1796 *
1797 * Return: 0 on success, negative errno on failure
1798 */
1799int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
1800{
1801 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1802 int ret;
1803
1804 ENTER();
1805 ret = sme_get_ht_config(hal, adapter->sessionId,
1806 WNI_CFG_HT_CAP_INFO_TX_STBC);
1807 if (ret < 0) {
1808 hdd_alert("Failed to get TX STBC value");
1809 } else {
1810 *value = ret;
1811 ret = 0;
1812 }
1813
1814 return ret;
1815}
1816
1817/**
1818 * hdd_set_tx_stbc() - Set adapter TX STBC
1819 * @adapter: adapter being modified
1820 * @value: new TX STBC value
1821 *
1822 * Return: 0 on success, negative errno on failure
1823 */
1824int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
1825{
1826 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1827 int ret;
1828
1829 hdd_alert("%d", value);
1830 if (value) {
1831 /* make sure HT capabilities allow this */
1832 QDF_STATUS status;
1833 uint32_t cfg_value;
1834 union {
1835 uint16_t cfg_value16;
1836 tSirMacHTCapabilityInfo ht_cap_info;
1837 } u;
1838
1839 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1840 if (QDF_STATUS_SUCCESS != status) {
1841 hdd_alert("Failed to get HT capability info");
1842 return -EIO;
1843 }
1844 u.cfg_value16 = cfg_value & 0xFFFF;
1845 if (!u.ht_cap_info.txSTBC) {
1846 hdd_alert("TX STBC not supported");
1847 return -EINVAL;
1848 }
1849 }
1850 ret = sme_update_ht_config(hal, adapter->sessionId,
1851 WNI_CFG_HT_CAP_INFO_TX_STBC,
1852 value);
1853 if (ret)
1854 hdd_alert("Failed to set TX STBC value");
1855
1856 return ret;
1857}
1858
1859/**
1860 * hdd_get_rx_stbc() - Get adapter RX STBC
1861 * @adapter: adapter being queried
1862 * @value: where to store the value
1863 *
1864 * Return: 0 on success, negative errno on failure
1865 */
1866int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
1867{
1868 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1869 int ret;
1870
1871 ENTER();
1872 ret = sme_get_ht_config(hal, adapter->sessionId,
1873 WNI_CFG_HT_CAP_INFO_RX_STBC);
1874 if (ret < 0) {
1875 hdd_alert("Failed to get RX STBC value");
1876 } else {
1877 *value = ret;
1878 ret = 0;
1879 }
1880
1881 return ret;
1882}
1883
1884/**
1885 * hdd_set_rx_stbc() - Set adapter RX STBC
1886 * @adapter: adapter being modified
1887 * @value: new RX STBC value
1888 *
1889 * Return: 0 on success, negative errno on failure
1890 */
1891int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
1892{
1893 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1894 int ret;
1895
1896 hdd_alert("%d", value);
1897 if (value) {
1898 /* make sure HT capabilities allow this */
1899 QDF_STATUS status;
1900 uint32_t cfg_value;
1901 union {
1902 uint16_t cfg_value16;
1903 tSirMacHTCapabilityInfo ht_cap_info;
1904 } u;
1905
1906 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1907 if (QDF_STATUS_SUCCESS != status) {
1908 hdd_alert("Failed to get HT capability info");
1909 return -EIO;
1910 }
1911 u.cfg_value16 = cfg_value & 0xFFFF;
1912 if (!u.ht_cap_info.rxSTBC) {
1913 hdd_alert("RX STBC not supported");
1914 return -EINVAL;
1915 }
1916 }
1917 ret = sme_update_ht_config(hal, adapter->sessionId,
1918 WNI_CFG_HT_CAP_INFO_RX_STBC,
1919 value);
1920 if (ret)
1921 hdd_alert("Failed to set RX STBC value");
1922
1923 return ret;
1924}
1925
1926/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
1928 * @dev: device upon which the ioctl was received
1929 * @info: ioctl request information
1930 * @wrqu: ioctl request data
1931 * @extra: ioctl extra data
1932 *
1933 * Return: 0 on success, non-zero on error
1934 */
1935static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1936 union iwreq_data *wrqu, char *extra)
1937{
1938 hdd_adapter_t *adapter;
1939 hdd_context_t *hdd_ctx;
1940 int ret;
1941
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08001942 ENTER_DEV(dev);
1943
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1945 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
1946 ret = wlan_hdd_validate_context(hdd_ctx);
1947 if (0 != ret)
1948 return ret;
1949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 /* Do nothing for now */
1951 return 0;
1952}
1953
1954/**
1955 * iw_set_commit() - SSR wrapper function for __iw_set_commit
1956 * @dev: pointer to net_device
1957 * @info: pointer to iw_request_info
1958 * @wrqu: pointer to iwreq_data
1959 * @extra: extra
1960 *
1961 * Return: 0 on success, error number otherwise
1962 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07001963static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964 union iwreq_data *wrqu, char *extra)
1965{
1966 int ret;
1967
1968 cds_ssr_protect(__func__);
1969 ret = __iw_set_commit(dev, info, wrqu, extra);
1970 cds_ssr_unprotect(__func__);
1971
1972 return ret;
1973}
1974
1975/**
1976 * __iw_get_name() - SIOCGIWNAME ioctl handler
1977 * @dev: device upon which the ioctl was received
1978 * @info: ioctl request information
1979 * @wrqu: ioctl request data
1980 * @extra: ioctl extra data
1981 *
1982 * Return: 0 on success, non-zero on error
1983 */
1984static int __iw_get_name(struct net_device *dev,
1985 struct iw_request_info *info, char *wrqu, char *extra)
1986{
1987 hdd_adapter_t *adapter;
1988 hdd_context_t *hdd_ctx;
1989 int ret;
1990
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08001991 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992
1993 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1994 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
1995 ret = wlan_hdd_validate_context(hdd_ctx);
1996 if (0 != ret)
1997 return ret;
1998
1999 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
2000 EXIT();
2001 return 0;
2002}
2003
2004/**
2005 * __iw_get_name() - SSR wrapper for __iw_get_name
2006 * @dev: pointer to net_device
2007 * @info: pointer to iw_request_info
2008 * @wrqu: pointer to iwreq_data
2009 * @extra: extra
2010 *
2011 * Return: 0 on success, error number otherwise
2012 */
2013static int iw_get_name(struct net_device *dev,
2014 struct iw_request_info *info,
2015 char *wrqu, char *extra)
2016{
2017 int ret;
2018
2019 cds_ssr_protect(__func__);
2020 ret = __iw_get_name(dev, info, wrqu, extra);
2021 cds_ssr_unprotect(__func__);
2022
2023 return ret;
2024}
2025
2026/**
2027 * __iw_set_mode() - ioctl handler
2028 * @dev: device upon which the ioctl was received
2029 * @info: ioctl request information
2030 * @wrqu: ioctl request data
2031 * @extra: ioctl extra data
2032 *
2033 * Return: 0 on success, non-zero on error
2034 */
2035static int __iw_set_mode(struct net_device *dev,
2036 struct iw_request_info *info,
2037 union iwreq_data *wrqu, char *extra)
2038{
2039 hdd_wext_state_t *pWextState;
2040 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2041 hdd_context_t *hdd_ctx;
2042 tCsrRoamProfile *pRoamProfile;
2043 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002044 struct hdd_config *pConfig;
2045 struct wireless_dev *wdev;
2046 int ret;
2047
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002048 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049
2050 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2051 ret = wlan_hdd_validate_context(hdd_ctx);
2052 if (0 != ret)
2053 return ret;
2054
2055 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2056 wdev = dev->ieee80211_ptr;
2057 pRoamProfile = &pWextState->roamProfile;
2058 LastBSSType = pRoamProfile->BSSType;
2059
Jeff Johnson99bac312016-06-28 10:38:18 -07002060 hdd_notice("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061
2062 switch (wrqu->mode) {
2063 case IW_MODE_ADHOC:
Jeff Johnson99bac312016-06-28 10:38:18 -07002064 hdd_notice("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2066 /* Set the phymode correctly for IBSS. */
2067 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
2068 pWextState->roamProfile.phyMode =
2069 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08002070 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071 wdev->iftype = NL80211_IFTYPE_ADHOC;
2072 break;
2073 case IW_MODE_INFRA:
Jeff Johnson99bac312016-06-28 10:38:18 -07002074 hdd_notice("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
2076 wdev->iftype = NL80211_IFTYPE_STATION;
2077 break;
2078 case IW_MODE_AUTO:
Jeff Johnson99bac312016-06-28 10:38:18 -07002079 hdd_notice("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
2081 break;
2082 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002083 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 return -EOPNOTSUPP;
2085 }
2086
2087 if (LastBSSType != pRoamProfile->BSSType) {
2088 /* the BSS mode changed. We need to issue disconnect
2089 * if connected or in IBSS disconnect state
2090 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07002091 if (hdd_conn_is_connected
2092 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302094 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095 /* need to issue a disconnect to CSR. */
2096 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302097 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
2099 pAdapter->sessionId,
2100 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302101 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 unsigned long rc;
2103 rc = wait_for_completion_timeout(&pAdapter->
2104 disconnect_comp_var,
2105 msecs_to_jiffies
2106 (WLAN_WAIT_TIME_DISCONNECT));
2107 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07002108 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109 }
2110 }
2111 }
2112
2113 EXIT();
2114 return 0;
2115}
2116
2117/**
2118 * iw_set_mode() - SSR wrapper for __iw_set_mode()
2119 * @dev: pointer to net_device
2120 * @info: pointer to iw_request_info
2121 * @wrqu: pointer to iwreq_data
2122 * @extra: pointer to extra ioctl payload
2123 *
2124 * Return: 0 on success, error number otherwise
2125 */
2126static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
2127 union iwreq_data *wrqu, char *extra)
2128{
2129 int ret;
2130
2131 cds_ssr_protect(__func__);
2132 ret = __iw_set_mode(dev, info, wrqu, extra);
2133 cds_ssr_unprotect(__func__);
2134
2135 return ret;
2136}
2137
2138/**
2139 * __iw_get_mode() - SIOCGIWMODE ioctl handler
2140 * @dev: device upon which the ioctl was received
2141 * @info: ioctl request information
2142 * @wrqu: ioctl request data
2143 * @extra: ioctl extra data
2144 *
2145 * Return: 0 on success, non-zero on error
2146 */
2147static int
2148__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2149 union iwreq_data *wrqu, char *extra)
2150{
2151 hdd_wext_state_t *pWextState;
2152 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2153 hdd_context_t *hdd_ctx;
2154 int ret;
2155
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002156 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157
2158 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2159 ret = wlan_hdd_validate_context(hdd_ctx);
2160 if (0 != ret)
2161 return ret;
2162
2163 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2164
2165 switch (pWextState->roamProfile.BSSType) {
2166 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Jeff Johnson99bac312016-06-28 10:38:18 -07002167 hdd_notice("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 wrqu->mode = IW_MODE_INFRA;
2169 break;
2170 case eCSR_BSS_TYPE_IBSS:
2171 case eCSR_BSS_TYPE_START_IBSS:
Jeff Johnson99bac312016-06-28 10:38:18 -07002172 hdd_notice("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002173 wrqu->mode = IW_MODE_ADHOC;
2174 break;
2175 case eCSR_BSS_TYPE_ANY:
2176 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002177 hdd_notice("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002178 wrqu->mode = IW_MODE_AUTO;
2179 break;
2180 }
2181
2182 EXIT();
2183 return 0;
2184}
2185
2186/**
2187 * iw_get_mode() - SSR wrapper for __iw_get_mode()
2188 * @dev: pointer to net_device
2189 * @info: pointer to iw_request_info
2190 * @wrqu: pointer to iwreq_data
2191 * @extra: pointer to extra ioctl payload
2192 *
2193 * Return: 0 on success, error number otherwise
2194 */
2195static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2196 union iwreq_data *wrqu, char *extra)
2197{
2198 int ret;
2199
2200 cds_ssr_protect(__func__);
2201 ret = __iw_get_mode(dev, info, wrqu, extra);
2202 cds_ssr_unprotect(__func__);
2203
2204 return ret;
2205}
2206
2207/**
2208 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
2209 * @dev: device upon which the ioctl was received
2210 * @info: ioctl request information
2211 * @wrqu: ioctl request data
2212 * @extra: ioctl extra data
2213 *
2214 * Return: 0 on success, non-zero on error
2215 */
2216static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2217 union iwreq_data *wrqu, char *extra)
2218{
2219 uint32_t numChans = 0;
2220 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2221 uint32_t indx = 0;
2222 int ret;
2223 hdd_wext_state_t *pWextState;
2224 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2225 hdd_context_t *hdd_ctx;
2226 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2227 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2228 tCsrRoamProfile *pRoamProfile;
2229
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002230 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231
2232 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2233 ret = wlan_hdd_validate_context(hdd_ctx);
2234 if (0 != ret)
2235 return ret;
2236
2237 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2238
2239 pRoamProfile = &pWextState->roamProfile;
2240
Jeff Johnson99bac312016-06-28 10:38:18 -07002241 hdd_notice("setCHANNEL ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242
2243 /* Link is up then return cant set channel */
2244 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
2245 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002246 hdd_err("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 return -EOPNOTSUPP;
2248 }
2249
2250 /* Settings by Frequency as input */
2251 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
2252 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
2253 uint32_t freq = wrqu->freq.m / 100000;
2254
2255 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
2256 && (freq != freq_chan_map[indx].freq))
2257 indx++;
2258 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) {
2259 return -EINVAL;
2260 }
2261 wrqu->freq.e = 0;
2262 wrqu->freq.m = freq_chan_map[indx].chan;
2263
2264 }
2265
2266 if (wrqu->freq.e == 0) {
2267 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
2268 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002269 hdd_notice("Channel %d is outside valid range from %d to %d",
2270 wrqu->freq.m,
2271 WNI_CFG_CURRENT_CHANNEL_STAMIN,
2272 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 return -EINVAL;
2274 }
2275
2276 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2277
2278 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2279 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302280 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002281 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 return -EIO;
2283 }
2284
2285 for (indx = 0; indx < numChans; indx++) {
2286 if (wrqu->freq.m == validChan[indx]) {
2287 break;
2288 }
2289 }
2290 } else {
2291
2292 return -EINVAL;
2293 }
2294
2295 if (indx >= numChans) {
2296 return -EINVAL;
2297 }
2298
2299 /* Set the Operational Channel */
2300 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2301 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2302 pRoamProfile->ChannelInfo.ChannelList =
2303 &pHddStaCtx->conn_info.operationChannel;
2304
Jeff Johnson99bac312016-06-28 10:38:18 -07002305 hdd_notice("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306
2307 EXIT();
2308
2309 return ret;
2310}
2311
2312/**
2313 * iw_set_freq() - SSR wrapper for __iw_set_freq()
2314 * @dev: pointer to net_device
2315 * @info: pointer to iw_request_info
2316 * @wrqu: pointer to iwreq_data
2317 * @extra: pointer to extra ioctl payload
2318 *
2319 * Return: 0 on success, error number otherwise
2320 */
2321static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2322 union iwreq_data *wrqu, char *extra)
2323{
2324 int ret;
2325
2326 cds_ssr_protect(__func__);
2327 ret = __iw_set_freq(dev, info, wrqu, extra);
2328 cds_ssr_unprotect(__func__);
2329
2330 return ret;
2331}
2332
2333/**
2334 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
2335 * @dev: device upon which the ioctl was received
2336 * @info: ioctl request information
2337 * @wrqu: ioctl request data
2338 * @extra: ioctl extra data
2339 *
2340 * Return: 0 on success, non-zero on error
2341 */
2342static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2343 struct iw_freq *fwrq, char *extra)
2344{
2345 uint32_t status = false, channel = 0, freq = 0;
2346 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2347 tHalHandle hHal;
2348 hdd_wext_state_t *pWextState;
2349 tCsrRoamProfile *pRoamProfile;
2350 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2351 hdd_context_t *hdd_ctx;
2352 int ret;
2353
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002354 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355
2356 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2357 ret = wlan_hdd_validate_context(hdd_ctx);
2358 if (0 != ret)
2359 return ret;
2360
2361 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2362 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2363
2364 pRoamProfile = &pWextState->roamProfile;
2365
2366 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
2367 if (sme_get_operation_channel(hHal, &channel, pAdapter->sessionId)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302368 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002369 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002370 pAdapter->sessionId);
2371 return -EIO;
2372 } else {
2373 status = hdd_wlan_get_freq(channel, &freq);
2374 if (true == status) {
2375 /* Set Exponent parameter as 6 (MHZ)
2376 * in struct iw_freq iwlist & iwconfig
2377 * command shows frequency into proper
2378 * format (2.412 GHz instead of 246.2
2379 * MHz)
2380 */
2381 fwrq->m = freq;
2382 fwrq->e = MHZ;
2383 }
2384 }
2385 } else {
2386 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2387 * iwlist & iwconfig command shows frequency into proper
2388 * format (2.412 GHz instead of 246.2 MHz)
2389 */
2390 fwrq->m = 0;
2391 fwrq->e = MHZ;
2392 }
2393 return 0;
2394}
2395
2396/**
2397 * iw_get_freq() - SSR wrapper for __iw_get_freq()
2398 * @dev: pointer to net_device
2399 * @info: pointer to iw_request_info
2400 * @fwrq: pointer to frequency data
2401 * @extra: pointer to extra ioctl payload
2402 *
2403 * Return: 0 on success, error number otherwise
2404 */
2405static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2406 struct iw_freq *fwrq, char *extra)
2407{
2408 int ret;
2409
2410 cds_ssr_protect(__func__);
2411 ret = __iw_get_freq(dev, info, fwrq, extra);
2412 cds_ssr_unprotect(__func__);
2413
2414 return ret;
2415}
2416
2417/**
2418 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
2419 * @dev: device upon which the ioctl was received
2420 * @info: ioctl request information
2421 * @wrqu: ioctl request data
2422 * @extra: ioctl extra data
2423 *
2424 * Return: 0 on success, non-zero on error
2425 */
2426static int __iw_get_tx_power(struct net_device *dev,
2427 struct iw_request_info *info,
2428 union iwreq_data *wrqu, char *extra)
2429{
2430
2431 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2432 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2433 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2434 int ret;
2435
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002436 ENTER_DEV(dev);
2437
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 ret = wlan_hdd_validate_context(hdd_ctx);
2439 if (0 != ret)
2440 return ret;
2441
2442 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2443 wrqu->txpower.value = 0;
2444 return 0;
2445 }
2446 wlan_hdd_get_class_astats(pAdapter);
2447 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2448
2449 return 0;
2450}
2451
2452/**
2453 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
2454 * @dev: pointer to net_device
2455 * @info: pointer to iw_request_info
2456 * @wrqu: pointer to iwreq_data
2457 * @extra: pointer to extra ioctl payload
2458 *
2459 * Return: 0 on success, error number otherwise
2460 */
2461static int iw_get_tx_power(struct net_device *dev,
2462 struct iw_request_info *info,
2463 union iwreq_data *wrqu, char *extra)
2464{
2465 int ret;
2466
2467 cds_ssr_protect(__func__);
2468 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2469 cds_ssr_unprotect(__func__);
2470
2471 return ret;
2472}
2473
2474/**
2475 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
2476 * @dev: device upon which the ioctl was received
2477 * @info: ioctl request information
2478 * @wrqu: ioctl request data
2479 * @extra: ioctl extra data
2480 *
2481 * Return: 0 on success, non-zero on error
2482 */
2483static int __iw_set_tx_power(struct net_device *dev,
2484 struct iw_request_info *info,
2485 union iwreq_data *wrqu, char *extra)
2486{
2487 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2488 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2489 hdd_context_t *hdd_ctx;
2490 int ret;
2491
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002492 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493
2494 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2495 ret = wlan_hdd_validate_context(hdd_ctx);
2496 if (0 != ret)
2497 return ret;
2498
2499 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302500 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002501 hdd_err("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502 return -EIO;
2503 }
2504
2505 EXIT();
2506
2507 return 0;
2508}
2509
2510/**
2511 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
2512 * @dev: pointer to net_device
2513 * @info: pointer to iw_request_info
2514 * @wrqu: pointer to iwreq_data
2515 * @extra: pointer to extra ioctl payload
2516 *
2517 * Return: 0 on success, error number otherwise
2518 */
2519static int iw_set_tx_power(struct net_device *dev,
2520 struct iw_request_info *info,
2521 union iwreq_data *wrqu, char *extra)
2522{
2523 int ret;
2524
2525 cds_ssr_protect(__func__);
2526 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2527 cds_ssr_unprotect(__func__);
2528
2529 return ret;
2530}
2531
2532/**
2533 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
2534 * @dev: device upon which the ioctl was received
2535 * @info: ioctl request information
2536 * @wrqu: ioctl request data
2537 * @extra: ioctl extra data
2538 *
2539 * Return: 0 on success, non-zero on error
2540 */
2541static int __iw_get_bitrate(struct net_device *dev,
2542 struct iw_request_info *info,
2543 union iwreq_data *wrqu, char *extra)
2544{
Anurag Chouhance0dc992016-02-16 18:18:03 +05302545 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302546 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547 hdd_wext_state_t *pWextState;
2548 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2549 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2550 hdd_context_t *hdd_ctx;
2551 int ret;
2552
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002553 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554
2555 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2556 ret = wlan_hdd_validate_context(hdd_ctx);
2557 if (0 != ret)
2558 return ret;
2559
Prashanth Bhatta9e143052015-12-04 11:56:47 -08002560 if (cds_is_driver_recovering()) {
2561 hdd_alert("Recovery in Progress. State: 0x%x Ignore!!!",
2562 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 return status;
2564 }
2565
2566 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2567 wrqu->bitrate.value = 0;
2568 } else {
2569 status =
2570 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2571 eCSR_HDD,
2572 SME_SUMMARY_STATS |
2573 SME_GLOBAL_CLASSA_STATS |
2574 SME_GLOBAL_CLASSB_STATS |
2575 SME_GLOBAL_CLASSC_STATS |
2576 SME_GLOBAL_CLASSD_STATS |
2577 SME_PER_STA_STATS,
2578 hdd_statistics_cb, 0,
2579 false,
2580 pHddStaCtx->conn_info.staId[0],
2581 pAdapter, pAdapter->sessionId);
2582
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302583 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002584 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585 return status;
2586 }
2587
2588 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2589
Anurag Chouhance0dc992016-02-16 18:18:03 +05302590 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302591 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592 WLAN_WAIT_TIME_STATS);
2593
Anurag Chouhance0dc992016-02-16 18:18:03 +05302594 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002595 hdd_err("SME timeout while retrieving statistics");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302596 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 }
2598
2599 wrqu->bitrate.value =
2600 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
2601 }
2602
2603 EXIT();
2604
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302605 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606}
2607
2608/**
2609 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
2610 * @dev: pointer to net_device
2611 * @info: pointer to iw_request_info
2612 * @wrqu: pointer to iwreq_data
2613 * @extra: pointer to extra ioctl payload
2614 *
2615 * Return: 0 on success, error number otherwise
2616 */
2617static int iw_get_bitrate(struct net_device *dev,
2618 struct iw_request_info *info,
2619 union iwreq_data *wrqu, char *extra)
2620{
2621 int ret;
2622
2623 cds_ssr_protect(__func__);
2624 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2625 cds_ssr_unprotect(__func__);
2626
2627 return ret;
2628}
2629
2630/**
2631 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
2632 * @dev: device upon which the ioctl was received
2633 * @info: ioctl request information
2634 * @wrqu: ioctl request data
2635 * @extra: ioctl extra data
2636 *
2637 * Return: 0 on success, non-zero on error
2638 */
2639static int __iw_set_bitrate(struct net_device *dev,
2640 struct iw_request_info *info,
2641 union iwreq_data *wrqu, char *extra)
2642{
2643 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2644 hdd_wext_state_t *pWextState;
2645 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2646 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2647 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2648 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2649 uint32_t i, rate;
2650 uint32_t valid_rate = false, active_phy_mode = 0;
2651 hdd_context_t *hdd_ctx;
2652 int ret;
2653
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002654 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655
2656 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2657 ret = wlan_hdd_validate_context(hdd_ctx);
2658 if (0 != ret)
2659 return ret;
2660
2661 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2662
2663 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2664 return -ENXIO;
2665 }
2666
2667 rate = wrqu->bitrate.value;
2668
2669 if (rate == -1) {
2670 rate = WNI_CFG_FIXED_RATE_AUTO;
2671 valid_rate = true;
2672 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
2673 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302674 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
2676 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2677 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
2678 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
2679 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302680 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681 &&
2682 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
2683 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302684 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 for (i = 0; i < (b_len + a_len); ++i) {
2686 /* supported rates returned is double
2687 * the actual rate so we divide it by 2
2688 */
2689 if ((supp_rates[i] & 0x7F) / 2 ==
2690 rate) {
2691 valid_rate = true;
2692 rate = i +
2693 WNI_CFG_FIXED_RATE_1MBPS;
2694 break;
2695 }
2696 }
2697 }
2698 }
2699 }
2700 if (valid_rate != true) {
2701 return -EINVAL;
2702 }
2703 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302704 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002705 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 return -EIO;
2707 }
2708 return 0;
2709}
2710
2711/**
2712 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
2713 * @dev: pointer to net_device
2714 * @info: pointer to iw_request_info
2715 * @wrqu: pointer to iwreq_data
2716 * @extra: pointer to extra ioctl payload
2717 *
2718 * Return: 0 on success, error number otherwise
2719 */
2720static int iw_set_bitrate(struct net_device *dev,
2721 struct iw_request_info *info,
2722 union iwreq_data *wrqu, char *extra)
2723{
2724 int ret;
2725
2726 cds_ssr_protect(__func__);
2727 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2728 cds_ssr_unprotect(__func__);
2729
2730 return ret;
2731}
2732
2733/**
2734 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
2735 * @dev: device upon which the ioctl was received
2736 * @info: ioctl request information
2737 * @wrqu: ioctl request data
2738 * @extra: ioctl extra data
2739 *
2740 * Return: 0 on success, non-zero on error
2741 */
2742static int __iw_set_genie(struct net_device *dev,
2743 struct iw_request_info *info,
2744 union iwreq_data *wrqu, char *extra)
2745{
2746 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2747 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2748 uint8_t *genie = NULL;
2749 uint8_t *base_genie = NULL;
2750 uint16_t remLen;
2751 hdd_context_t *hdd_ctx;
2752 int ret;
2753
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002754 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755
2756 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2757 ret = wlan_hdd_validate_context(hdd_ctx);
2758 if (0 != ret)
2759 return ret;
2760
2761 if (!wrqu->data.length) {
2762 hdd_clear_roam_profile_ie(pAdapter);
2763 EXIT();
2764 return 0;
2765 }
2766
2767 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2768 wrqu->data.length);
2769 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002770 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771 return -ENOMEM;
2772 }
2773
2774 genie = base_genie;
2775
2776 remLen = wrqu->data.length;
2777
Jeff Johnson99bac312016-06-28 10:38:18 -07002778 hdd_notice("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779 genie[1]);
2780
2781 /* clear any previous genIE before this call */
2782 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
2783
2784 while (remLen >= 2) {
2785 uint16_t eLen = 0;
2786 uint8_t elementId;
2787 elementId = *genie++;
2788 eLen = *genie++;
2789 remLen -= 2;
2790
Jeff Johnson99bac312016-06-28 10:38:18 -07002791 hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002792
2793 switch (elementId) {
2794 case IE_EID_VENDOR:
2795 if ((IE_LEN_SIZE + IE_EID_SIZE + IE_VENDOR_OUI_SIZE) > eLen) { /* should have at least OUI */
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302796 ret = -EINVAL;
2797 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 }
2799
2800 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
2801 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07002802 hdd_notice("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2803 genie[0], genie[1], genie[2],
2804 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002805
2806 if (SIR_MAC_MAX_IE_LENGTH <
2807 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002808 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302809 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302810 ret = -ENOMEM;
2811 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 }
2813 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
2814 memcpy(pWextState->genIE.addIEdata +
2815 curGenIELen, genie - 2, eLen + 2);
2816 pWextState->genIE.length += eLen + 2;
2817 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002818 hdd_notice("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302819 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
2820 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
2821 ret = -EINVAL;
2822 QDF_ASSERT(0);
2823 goto exit;
2824 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825 memset(pWextState->WPARSNIE, 0,
2826 MAX_WPA_RSN_IE_LEN);
2827 memcpy(pWextState->WPARSNIE, genie - 2,
2828 (eLen + 2));
2829 pWextState->roamProfile.pWPAReqIE =
2830 pWextState->WPARSNIE;
2831 pWextState->roamProfile.nWPAReqIELength =
2832 eLen + 2;
2833 } else { /* any vendorId except WPA IE should be accumulated to genIE */
2834
2835 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07002836 hdd_notice("Set OUI(%02x %02x %02x %02x) IE(len %d)",
2837 genie[0], genie[1], genie[2],
2838 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839
2840 if (SIR_MAC_MAX_IE_LENGTH <
2841 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002842 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302843 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302844 ret = -ENOMEM;
2845 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846 }
2847 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
2848 memcpy(pWextState->genIE.addIEdata +
2849 curGenIELen, genie - 2, eLen + 2);
2850 pWextState->genIE.length += eLen + 2;
2851 }
2852 break;
2853 case DOT11F_EID_RSN:
Jeff Johnson99bac312016-06-28 10:38:18 -07002854 hdd_notice("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302855 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
2856 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
2857 ret = -EINVAL;
2858 QDF_ASSERT(0);
2859 goto exit;
2860 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
2862 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
2863 pWextState->roamProfile.pRSNReqIE =
2864 pWextState->WPARSNIE;
2865 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2866 break;
2867
2868 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002869 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302870 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871 }
2872 genie += eLen;
2873 remLen -= eLen;
2874 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302875exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876 EXIT();
2877 kfree(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302878 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879}
2880
2881/**
2882 * iw_set_genie() - SSR wrapper for __iw_set_genie()
2883 * @dev: pointer to net_device
2884 * @info: pointer to iw_request_info
2885 * @wrqu: pointer to iwreq_data
2886 * @extra: pointer to extra ioctl payload
2887 *
2888 * Return: 0 on success, error number otherwise
2889 */
2890static int iw_set_genie(struct net_device *dev,
2891 struct iw_request_info *info,
2892 union iwreq_data *wrqu, char *extra)
2893{
2894 int ret;
2895
2896 cds_ssr_protect(__func__);
2897 ret = __iw_set_genie(dev, info, wrqu, extra);
2898 cds_ssr_unprotect(__func__);
2899
2900 return ret;
2901}
2902
2903/**
2904 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
2905 * @dev: device upon which the ioctl was received
2906 * @info: ioctl request information
2907 * @wrqu: ioctl request data
2908 * @extra: ioctl extra data
2909 *
2910 * Return: 0 on success, non-zero on error
2911 */
2912static int __iw_get_genie(struct net_device *dev,
2913 struct iw_request_info *info,
2914 union iwreq_data *wrqu, char *extra)
2915{
2916 hdd_wext_state_t *pWextState;
2917 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2918 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302919 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
2921 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2922 hdd_context_t *hdd_ctx;
2923 int ret;
2924
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002925 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926
2927 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2928 ret = wlan_hdd_validate_context(hdd_ctx);
2929 if (0 != ret)
2930 return ret;
2931
Jeff Johnson99bac312016-06-28 10:38:18 -07002932 hdd_notice("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933
2934 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2935
2936 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
2937 return -ENXIO;
2938 }
2939
2940 /* Return something ONLY if we are associated with an RSN or
2941 * WPA network
2942 */
2943 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
2944 return -ENXIO;
2945 }
2946
2947 /* Actually retrieve the RSN IE from CSR. (We previously sent
2948 * it down in the CSR Roam Profile.)
2949 */
2950 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
2951 pAdapter->sessionId,
2952 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05302953 if (QDF_STATUS_SUCCESS != status) {
2954 hdd_notice("failed to get WPA-RSN IE data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 return -EFAULT;
2956 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002957 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05302958 if (length > DOT11F_IE_RSN_MAX_LEN) {
2959 hdd_notice("invalid buffer length length:%d", length);
2960 return -E2BIG;
2961 }
2962 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963
Jeff Johnson99bac312016-06-28 10:38:18 -07002964 hdd_notice("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 wrqu->data.length);
2966
2967 EXIT();
2968
2969 return 0;
2970}
2971
2972/**
2973 * iw_get_genie() - SSR wrapper for __iw_get_genie()
2974 * @dev: pointer to net_device
2975 * @info: pointer to iw_request_info
2976 * @wrqu: pointer to iwreq_data
2977 * @extra: pointer to extra ioctl payload
2978 *
2979 * Return: 0 on success, error number otherwise
2980 */
2981static int iw_get_genie(struct net_device *dev,
2982 struct iw_request_info *info,
2983 union iwreq_data *wrqu, char *extra)
2984{
2985 int ret;
2986
2987 cds_ssr_protect(__func__);
2988 ret = __iw_get_genie(dev, info, wrqu, extra);
2989 cds_ssr_unprotect(__func__);
2990
2991 return ret;
2992}
2993
2994/**
2995 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
2996 * @dev: device upon which the ioctl was received
2997 * @info: ioctl request information
2998 * @wrqu: ioctl request data
2999 * @extra: ioctl extra data
3000 *
3001 * Return: 0 on success, non-zero on error
3002 */
3003static int __iw_get_encode(struct net_device *dev,
3004 struct iw_request_info *info,
3005 struct iw_point *dwrq, char *extra)
3006{
3007 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3008 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3009 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3010 int keyId;
3011 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3012 int i;
3013 hdd_context_t *hdd_ctx;
3014 int ret;
3015
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003016 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017
3018 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3019 ret = wlan_hdd_validate_context(hdd_ctx);
3020 if (0 != ret)
3021 return ret;
3022
3023 keyId = pRoamProfile->Keys.defaultIndex;
3024
3025 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003026 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 return -EINVAL;
3028 }
3029
3030 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
3031 dwrq->flags |= IW_ENCODE_ENABLED;
3032 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303033 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 pRoamProfile->Keys.KeyLength[keyId]);
3035
3036 dwrq->flags |= (keyId + 1);
3037
3038 } else {
3039 dwrq->flags |= IW_ENCODE_DISABLED;
3040 }
3041
3042 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08003043 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 continue;
3045 } else {
3046 break;
3047 }
3048 }
3049
3050 if (MAX_WEP_KEYS == i) {
3051 dwrq->flags |= IW_ENCODE_NOKEY;
3052 }
3053
3054 authType =
3055 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
3056 conn_info.authType;
3057
3058 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
3059 dwrq->flags |= IW_ENCODE_OPEN;
3060 } else {
3061 dwrq->flags |= IW_ENCODE_RESTRICTED;
3062 }
3063 EXIT();
3064 return 0;
3065}
3066
3067/**
3068 * iw_get_encode() - SSR wrapper for __iw_get_encode()
3069 * @dev: pointer to net_device
3070 * @info: pointer to iw_request_info
3071 * @dwrq: pointer to encoding information
3072 * @extra: pointer to extra ioctl payload
3073 *
3074 * Return: 0 on success, error number otherwise
3075 */
3076static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
3077 struct iw_point *dwrq, char *extra)
3078{
3079 int ret;
3080
3081 cds_ssr_protect(__func__);
3082 ret = __iw_get_encode(dev, info, dwrq, extra);
3083 cds_ssr_unprotect(__func__);
3084
3085 return ret;
3086}
3087
3088/**
3089 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
3090 * @dev: device upon which the ioctl was received
3091 * @info: ioctl request information
3092 * @wrqu: ioctl request data
3093 * @extra: ioctl extra data
3094 *
3095 * Return: 0 on success, non-zero on error
3096 */
3097static int __iw_get_rts_threshold(struct net_device *dev,
3098 struct iw_request_info *info,
3099 union iwreq_data *wrqu, char *extra)
3100{
3101 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3102 uint32_t status = 0;
3103
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003104 ENTER_DEV(dev);
3105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 status = hdd_wlan_get_rts_threshold(pAdapter, wrqu);
3107
3108 return status;
3109}
3110
3111/**
3112 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
3113 * @dev: device upon which the ioctl was received
3114 * @info: ioctl request information
3115 * @wrqu: ioctl request data
3116 * @extra: ioctl extra data
3117 *
3118 * Return: 0 on success, non-zero on error
3119 */
3120static int __iw_set_rts_threshold(struct net_device *dev,
3121 struct iw_request_info *info,
3122 union iwreq_data *wrqu, char *extra)
3123{
3124 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3125 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3126 hdd_context_t *hdd_ctx;
3127 int ret;
3128
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003129 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130
3131 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3132 ret = wlan_hdd_validate_context(hdd_ctx);
3133 if (0 != ret)
3134 return ret;
3135
3136 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
3137 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
3138 return -EINVAL;
3139 }
3140
3141 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303142 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003143 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 return -EIO;
3145 }
3146
3147 EXIT();
3148
3149 return 0;
3150}
3151
3152/**
3153 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
3154 * @dev: pointer to net_device
3155 * @info: pointer to iw_request_info
3156 * @wrqu: pointer to iwreq_data
3157 * @extra: pointer to extra ioctl payload
3158 *
3159 * Return: 0 on success, error number otherwise
3160 */
3161static int iw_get_rts_threshold(struct net_device *dev,
3162 struct iw_request_info *info,
3163 union iwreq_data *wrqu, char *extra)
3164{
3165 int ret;
3166
3167 cds_ssr_protect(__func__);
3168 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
3169 cds_ssr_unprotect(__func__);
3170
3171 return ret;
3172}
3173
3174/**
3175 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
3176 * @dev: pointer to net_device
3177 * @info: pointer to iw_request_info
3178 * @wrqu: pointer to iwreq_data
3179 * @extra: pointer to extra ioctl payload
3180 *
3181 * Return: 0 on success, error number otherwise
3182 */
3183static int iw_set_rts_threshold(struct net_device *dev,
3184 struct iw_request_info *info,
3185 union iwreq_data *wrqu, char *extra)
3186{
3187 int ret;
3188
3189 cds_ssr_protect(__func__);
3190 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
3191 cds_ssr_unprotect(__func__);
3192
3193 return ret;
3194}
3195
3196/**
3197 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
3198 * @dev: device upon which the ioctl was received
3199 * @info: ioctl request information
3200 * @wrqu: ioctl request data
3201 * @extra: ioctl extra data
3202 *
3203 * Return: 0 on success, non-zero on error
3204 */
3205static int __iw_get_frag_threshold(struct net_device *dev,
3206 struct iw_request_info *info,
3207 union iwreq_data *wrqu, char *extra)
3208{
3209 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3210 uint32_t status = 0;
3211
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003212 ENTER_DEV(dev);
3213
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214 status = hdd_wlan_get_frag_threshold(pAdapter, wrqu);
3215
3216 return status;
3217}
3218
3219/**
3220 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
3221 * @dev: pointer to net_device
3222 * @info: pointer to iw_request_info
3223 * @wrqu: pointer to iwreq_data
3224 * @extra: pointer to extra ioctl payload
3225 *
3226 * Return: 0 on success, error number otherwise
3227 */
3228static int iw_get_frag_threshold(struct net_device *dev,
3229 struct iw_request_info *info,
3230 union iwreq_data *wrqu, char *extra)
3231{
3232 int ret;
3233
3234 cds_ssr_protect(__func__);
3235 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
3236 cds_ssr_unprotect(__func__);
3237
3238 return ret;
3239}
3240
3241/**
3242 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
3243 * @dev: device upon which the ioctl was received
3244 * @info: ioctl request information
3245 * @wrqu: ioctl request data
3246 * @extra: ioctl extra data
3247 *
3248 * Return: 0 on success, non-zero on error
3249 */
3250static int __iw_set_frag_threshold(struct net_device *dev,
3251 struct iw_request_info *info,
3252 union iwreq_data *wrqu, char *extra)
3253{
3254 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3255 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3256 hdd_context_t *hdd_ctx;
3257 int ret;
3258
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003259 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260
3261 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3262 ret = wlan_hdd_validate_context(hdd_ctx);
3263 if (0 != ret)
3264 return ret;
3265
3266 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
3267 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
3268 return -EINVAL;
3269 }
3270
3271 if (sme_cfg_set_int
3272 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303273 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003274 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275 return -EIO;
3276 }
3277
3278 EXIT();
3279
3280 return 0;
3281}
3282
3283/**
3284 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
3285 * @dev: pointer to net_device
3286 * @info: pointer to iw_request_info
3287 * @wrqu: pointer to iwreq_data
3288 * @extra: pointer to extra ioctl payload
3289 *
3290 * Return: 0 on success, error number otherwise
3291 */
3292static int iw_set_frag_threshold(struct net_device *dev,
3293 struct iw_request_info *info,
3294 union iwreq_data *wrqu, char *extra)
3295{
3296 int ret;
3297
3298 cds_ssr_protect(__func__);
3299 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3300 cds_ssr_unprotect(__func__);
3301
3302 return ret;
3303}
3304
3305/**
3306 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
3307 * @dev: device upon which the ioctl was received
3308 * @info: ioctl request information
3309 * @wrqu: ioctl request data
3310 * @extra: ioctl extra data
3311 *
3312 * Return: 0 on success, non-zero on error
3313 */
3314static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003315 struct iw_request_info *info,
3316 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317{
3318 hdd_adapter_t *adapter;
3319 hdd_context_t *hdd_ctx;
3320 int ret;
3321
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003322 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323
3324 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3325 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3326 ret = wlan_hdd_validate_context(hdd_ctx);
3327 if (0 != ret)
3328 return ret;
3329
3330 return -EOPNOTSUPP;
3331}
3332
3333/**
3334 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
3335 * @dev: pointer to net_device
3336 * @info: pointer to iw_request_info
3337 * @wrqu: pointer to iwreq_data
3338 * @extra: extra
3339 *
3340 * Return: 0 on success, error number otherwise
3341 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003342static int iw_get_power_mode(struct net_device *dev,
3343 struct iw_request_info *info,
3344 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345{
3346 int ret;
3347
3348 cds_ssr_protect(__func__);
3349 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3350 cds_ssr_unprotect(__func__);
3351
3352 return ret;
3353}
3354
3355/**
3356 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
3357 * @dev: device upon which the ioctl was received
3358 * @info: ioctl request information
3359 * @wrqu: ioctl request data
3360 * @extra: ioctl extra data
3361 *
3362 * Return: 0 on success, non-zero on error
3363 */
3364static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003365 struct iw_request_info *info,
3366 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367{
3368 hdd_adapter_t *adapter;
3369 hdd_context_t *hdd_ctx;
3370 int ret;
3371
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003372 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003373
3374 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3375 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3376 ret = wlan_hdd_validate_context(hdd_ctx);
3377 if (0 != ret)
3378 return ret;
3379
3380 return -EOPNOTSUPP;
3381}
3382
3383/**
3384 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
3385 * @dev: pointer to net_device
3386 * @info: pointer to iw_request_info
3387 * @wrqu: pointer to iwreq_data
3388 * @extra: extra
3389 *
3390 * Return: 0 on success, error number otherwise
3391 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003392static int iw_set_power_mode(struct net_device *dev,
3393 struct iw_request_info *info,
3394 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395{
3396 int ret;
3397
3398 cds_ssr_protect(__func__);
3399 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3400 cds_ssr_unprotect(__func__);
3401
3402 return ret;
3403}
3404
3405/**
3406 * __iw_get_range() - SIOCGIWRANGE ioctl handler
3407 * @dev: device upon which the ioctl was received
3408 * @info: ioctl request information
3409 * @wrqu: ioctl request data
3410 * @extra: ioctl extra data
3411 *
3412 * Return: 0 on success, non-zero on error
3413 */
3414static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
3415 union iwreq_data *wrqu, char *extra)
3416{
3417 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3418 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3419 struct iw_range *range = (struct iw_range *)extra;
3420
3421 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3422
3423 uint32_t num_channels = sizeof(channels);
3424 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3425 uint32_t a_len;
3426 uint32_t b_len;
3427 uint32_t active_phy_mode = 0;
3428 uint8_t index = 0, i;
3429 hdd_context_t *hdd_ctx;
3430 int ret;
3431
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003432 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433
3434 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3435 ret = wlan_hdd_validate_context(hdd_ctx);
3436 if (0 != ret)
3437 return ret;
3438
3439 wrqu->data.length = sizeof(struct iw_range);
3440 memset(range, 0, sizeof(struct iw_range));
3441
3442
3443 /*Get the phy mode */
3444 if (sme_cfg_get_int(hHal,
3445 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303446 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003447 hdd_notice("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448
3449 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
3450 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
3451 /*Get the supported rates for 11G band */
3452 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3453 if (sme_cfg_get_str(hHal,
3454 WNI_CFG_SUPPORTED_RATES_11A,
3455 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303456 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
3458 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3459 }
3460 for (i = 0; i < a_len; i++) {
3461 range->bitrate[i] =
3462 ((supp_rates[i] & 0x7F) / 2) *
3463 1000000;
3464 }
3465 range->num_bitrates = a_len;
3466 } else {
3467 return -EIO;
3468 }
3469 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
3470 /*Get the supported rates for 11B band */
3471 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3472 if (sme_cfg_get_str(hHal,
3473 WNI_CFG_SUPPORTED_RATES_11B,
3474 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303475 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
3477 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3478 }
3479 for (i = 0; i < b_len; i++) {
3480 range->bitrate[i] =
3481 ((supp_rates[i] & 0x7F) / 2) *
3482 1000000;
3483 }
3484 range->num_bitrates = b_len;
3485 } else {
3486 return -EIO;
3487 }
3488 }
3489 }
3490
3491 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3492 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3493 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3494
3495 range->encoding_size[0] = 5;
3496 range->encoding_size[1] = 13;
3497 range->num_encoding_sizes = 2;
3498 range->max_encoding_tokens = MAX_WEP_KEYS;
3499
3500 /* we support through Wireless Extensions 22 */
3501 range->we_version_compiled = WIRELESS_EXT;
3502 range->we_version_source = 22;
3503
3504 /*Supported Channels and Frequencies */
3505 if (sme_cfg_get_str
3506 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303507 &num_channels) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003508 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509 return -EIO;
3510 }
3511 if (num_channels > IW_MAX_FREQUENCIES) {
3512 num_channels = IW_MAX_FREQUENCIES;
3513 }
3514
3515 range->num_channels = num_channels;
3516 range->num_frequency = num_channels;
3517
3518 for (index = 0; index < num_channels; index++) {
3519 uint32_t frq_indx = 0;
3520
3521 range->freq[index].i = channels[index];
3522 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
3523 if (channels[index] == freq_chan_map[frq_indx].chan) {
3524 range->freq[index].m =
3525 freq_chan_map[frq_indx].freq * 100000;
3526 range->freq[index].e = 1;
3527 break;
3528 }
3529 frq_indx++;
3530 }
3531 }
3532
3533 /* Event capability (kernel + driver) */
3534 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3535 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3536 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3537 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3538
3539 /*Encryption capability */
3540 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3541 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3542
3543 /* Txpower capability */
3544 range->txpower_capa = IW_TXPOW_MWATT;
3545
3546 /*Scanning capability */
3547#if WIRELESS_EXT >= 22
3548 range->scan_capa =
3549 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3550#endif
3551
3552 EXIT();
3553 return 0;
3554}
3555
3556/**
3557 * iw_get_range() - SSR wrapper for __iw_get_range()
3558 * @dev: pointer to net_device
3559 * @info: pointer to iw_request_info
3560 * @wrqu: pointer to iwreq_data
3561 * @extra: pointer to extra ioctl payload
3562 *
3563 * Return: 0 on success, error number otherwise
3564 */
3565static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
3566 union iwreq_data *wrqu, char *extra)
3567{
3568 int ret;
3569
3570 cds_ssr_protect(__func__);
3571 ret = __iw_get_range(dev, info, wrqu, extra);
3572 cds_ssr_unprotect(__func__);
3573
3574 return ret;
3575}
3576
3577/**
3578 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
3579 * @pStats: pointer to Class A stats
3580 * @pContext: user context originally registered with SME
3581 *
3582 * Return: None
3583 */
3584static void hdd_get_class_a_statistics_cb(void *pStats, void *pContext)
3585{
3586 struct statsContext *pStatsContext;
3587 tCsrGlobalClassAStatsInfo *pClassAStats;
3588 hdd_adapter_t *pAdapter;
3589
3590 if (ioctl_debug) {
3591 pr_info("%s: pStats [%p] pContext [%p]\n",
3592 __func__, pStats, pContext);
3593 }
3594
3595 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003596 hdd_err("Bad param, pStats [%p] pContext [%p]",
3597 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 return;
3599 }
3600
3601 pClassAStats = pStats;
3602 pStatsContext = pContext;
3603 pAdapter = pStatsContext->pAdapter;
3604
3605 /* there is a race condition that exists between this callback
3606 * function and the caller since the caller could time out
3607 * either before or while this code is executing. we use a
3608 * spinlock to serialize these actions
3609 */
3610 spin_lock(&hdd_context_lock);
3611
3612 if ((NULL == pAdapter) ||
3613 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
3614 /* the caller presumably timed out so there is nothing
3615 * we can do
3616 */
3617 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07003618 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
3619 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620 if (ioctl_debug) {
3621 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
3622 __func__, pAdapter, pStatsContext->magic);
3623 }
3624 return;
3625 }
3626
3627 /* context is valid so caller is still waiting */
3628
3629 /* paranoia: invalidate the magic */
3630 pStatsContext->magic = 0;
3631
3632 /* copy over the stats. do so as a struct copy */
3633 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3634
3635 /* notify the caller */
3636 complete(&pStatsContext->completion);
3637
3638 /* serialization is complete */
3639 spin_unlock(&hdd_context_lock);
3640}
3641
3642/**
3643 * wlan_hdd_get_class_astats() - Get Class A statistics
3644 * @pAdapter: adapter for which statistics are desired
3645 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303646 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303648QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649{
3650 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303651 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652 unsigned long rc;
Houston Hoffman59c097f2016-11-09 15:50:25 -08003653 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654
3655 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003656 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303657 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003659 if (cds_is_driver_recovering()) {
3660 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3661 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303662 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 }
3664
3665 /* we are connected so prepare our callback context */
3666 init_completion(&context.completion);
3667 context.pAdapter = pAdapter;
3668 context.magic = STATS_CONTEXT_MAGIC;
3669 /* query only for Class A statistics (which include link speed) */
3670 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3671 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
3672 hdd_get_class_a_statistics_cb,
3673 0, /* not periodic */
3674 false, /* non-cached results */
3675 pHddStaCtx->conn_info.staId[0],
3676 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303677 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07003678 hdd_warn("Unable to retrieve Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003679 /* we'll returned a cached value below */
3680 } else {
3681 /* request was sent -- wait for the response */
3682 rc = wait_for_completion_timeout
3683 (&context.completion,
3684 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3685 if (!rc) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07003686 hdd_warn("SME timed out while retrieving Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687 }
3688 }
3689
3690 /* either we never sent a request, we sent a request and
3691 * received a response or we sent a request and timed out. if
3692 * we never sent a request or if we sent a request and got a
3693 * response, we want to clear the magic out of paranoia. if
3694 * we timed out there is a race condition such that the
3695 * callback function could be executing at the same time we
3696 * are. of primary concern is if the callback function had
3697 * already verified the "magic" but had not yet set the
3698 * completion variable when a timeout occurred. we serialize
3699 * these activities by invalidating the magic while holding a
3700 * shared spinlock which will cause us to block if the
3701 * callback is currently executing
3702 */
3703 spin_lock(&hdd_context_lock);
3704 context.magic = 0;
3705 spin_unlock(&hdd_context_lock);
3706
3707 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303708 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709}
3710
3711/**
3712 * hdd_get_station_statistics_cb() - Get stats callback function
3713 * @pStats: pointer to Class A stats
3714 * @pContext: user context originally registered with SME
3715 *
3716 * Return: None
3717 */
3718static void hdd_get_station_statistics_cb(void *pStats, void *pContext)
3719{
3720 struct statsContext *pStatsContext;
3721 tCsrSummaryStatsInfo *pSummaryStats;
3722 tCsrGlobalClassAStatsInfo *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303723 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724 hdd_adapter_t *pAdapter;
3725
3726 if (ioctl_debug) {
3727 pr_info("%s: pStats [%p] pContext [%p]\n",
3728 __func__, pStats, pContext);
3729 }
3730
3731 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003732 hdd_err("Bad param, pStats [%p] pContext [%p]",
3733 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734 return;
3735 }
3736
3737 /* there is a race condition that exists between this callback
3738 * function and the caller since the caller could time out
3739 * either before or while this code is executing. we use a
3740 * spinlock to serialize these actions
3741 */
3742 spin_lock(&hdd_context_lock);
3743
3744 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
3745 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303746 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
3747 (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003748 pStatsContext = pContext;
3749 pAdapter = pStatsContext->pAdapter;
3750 if ((NULL == pAdapter) ||
3751 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
3752 /* the caller presumably timed out so there is nothing
3753 * we can do
3754 */
3755 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07003756 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
3757 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003758 if (ioctl_debug) {
3759 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
3760 __func__, pAdapter, pStatsContext->magic);
3761 }
3762 return;
3763 }
3764
3765 /* context is valid so caller is still waiting */
3766
3767 /* paranoia: invalidate the magic */
3768 pStatsContext->magic = 0;
3769
3770 /* copy over the stats. do so as a struct copy */
3771 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3772 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303773 pAdapter->hdd_stats.per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774
3775 /* notify the caller */
3776 complete(&pStatsContext->completion);
3777
3778 /* serialization is complete */
3779 spin_unlock(&hdd_context_lock);
3780}
3781
3782/**
3783 * wlan_hdd_get_station_stats() - Get station statistics
3784 * @pAdapter: adapter for which statistics are desired
3785 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303786 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303788QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789{
3790 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303791 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792 unsigned long rc;
Jeff Johnson5aacdf92016-11-04 18:08:11 -07003793 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003794
3795 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003796 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303797 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798 }
3799
3800 /* we are connected so prepare our callback context */
3801 init_completion(&context.completion);
3802 context.pAdapter = pAdapter;
3803 context.magic = STATS_CONTEXT_MAGIC;
3804
3805 /* query only for Summary & Class A statistics */
3806 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3807 eCSR_HDD,
3808 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303809 SME_GLOBAL_CLASSA_STATS |
3810 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003811 hdd_get_station_statistics_cb,
3812 0, /* not periodic */
3813 false, /* non-cached results */
3814 pHddStaCtx->conn_info.staId[0],
3815 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303816 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003817 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003818 /* we'll return with cached values */
3819 } else {
3820 /* request was sent -- wait for the response */
3821 rc = wait_for_completion_timeout
3822 (&context.completion,
3823 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3824
3825 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003826 hdd_err("SME timed out while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827 }
3828 }
3829
3830 /* either we never sent a request, we sent a request and
3831 * received a response or we sent a request and timed out. if
3832 * we never sent a request or if we sent a request and got a
3833 * response, we want to clear the magic out of paranoia. if
3834 * we timed out there is a race condition such that the
3835 * callback function could be executing at the same time we
3836 * are. of primary concern is if the callback function had
3837 * already verified the "magic" but had not yet set the
3838 * completion variable when a timeout occurred. we serialize
3839 * these activities by invalidating the magic while holding a
3840 * shared spinlock which will cause us to block if the
3841 * callback is currently executing
3842 */
3843 spin_lock(&hdd_context_lock);
3844 context.magic = 0;
3845 spin_unlock(&hdd_context_lock);
3846
3847 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303848 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849}
3850
3851/**
3852 * iw_get_linkspeed() - Get current link speed ioctl
3853 * @dev: device upon which the ioctl was received
3854 * @info: ioctl request information
3855 * @wrqu: ioctl request data
3856 * @extra: extra ioctl buffer
3857 *
3858 * Return: 0 on success, non-zero on error
3859 */
3860static int __iw_get_linkspeed(struct net_device *dev,
3861 struct iw_request_info *info,
3862 union iwreq_data *wrqu, char *extra)
3863{
3864 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3865 char *pLinkSpeed = (char *)extra;
3866 int len = sizeof(uint32_t) + 1;
3867 uint32_t link_speed = 0;
3868 hdd_context_t *hdd_ctx;
3869 int rc, valid;
3870
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08003871 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303872
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3874 valid = wlan_hdd_validate_context(hdd_ctx);
3875 if (0 != valid)
3876 return valid;
3877
3878 rc = wlan_hdd_get_link_speed(pAdapter, &link_speed);
3879 if (0 != rc) {
3880 return rc;
3881 }
3882
3883 wrqu->data.length = len;
3884 /* return the linkspeed as a string */
3885 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
3886 if ((rc < 0) || (rc >= len)) {
3887 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07003888 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889 return -EIO;
3890 }
3891
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303892 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003893 /* a value is being successfully returned */
3894 return 0;
3895}
3896
3897static int iw_get_linkspeed(struct net_device *dev,
3898 struct iw_request_info *info,
3899 union iwreq_data *wrqu, char *extra)
3900{
3901 int ret;
3902
3903 cds_ssr_protect(__func__);
3904 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
3905 cds_ssr_unprotect(__func__);
3906
3907 return ret;
3908}
3909
3910/**
3911 * wlan_hdd_change_country_code_callback() - Change country code callback
3912 * @context: opaque context originally passed to SME. All functions
3913 * which use this callback pass the adapter upon which the country
3914 * code change is active
3915 *
3916 * This function is registered as the callback function when
3917 * sme_change_country_code() is invoked. Callers of
3918 * sme_change_country_code() subsequently wait for the adapter's
3919 * @change_country_code completion variable, so all this function
3920 * needs to do is set that completion variable so that execution can
3921 * continue.
3922 *
3923 * Return: none
3924 */
3925void wlan_hdd_change_country_code_callback(void *context)
3926{
3927
3928 hdd_adapter_t *adapter = context;
3929
3930 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
3931 complete(&adapter->change_country_code);
3932
3933 return;
3934}
3935
3936/**
3937 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
3938 * @dev: device upon which the ioctl was received
3939 * @info: ioctl request information
3940 * @wrqu: ioctl request data
3941 * @extra: ioctl extra data
3942 *
3943 * Return: 0 on success, non-zero on error
3944 */
3945static int __iw_set_nick(struct net_device *dev,
3946 struct iw_request_info *info,
3947 union iwreq_data *wrqu, char *extra)
3948{
3949 hdd_adapter_t *adapter;
3950 hdd_context_t *hdd_ctx;
3951 int ret;
3952
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003953 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954
3955 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3956 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3957 ret = wlan_hdd_validate_context(hdd_ctx);
3958 if (0 != ret)
3959 return ret;
3960
3961 return 0;
3962}
3963
3964/**
3965 * iw_set_nick() - SSR wrapper for __iw_set_nick
3966 * @dev: pointer to net_device
3967 * @info: pointer to iw_request_info
3968 * @wrqu: pointer to iwreq_data
3969 * @extra: extra
3970 *
3971 * Return: 0 on success, error number otherwise
3972 */
3973static int iw_set_nick(struct net_device *dev,
3974 struct iw_request_info *info,
3975 union iwreq_data *wrqu, char *extra)
3976{
3977 int ret;
3978
3979 cds_ssr_protect(__func__);
3980 ret = __iw_set_nick(dev, info, wrqu, extra);
3981 cds_ssr_unprotect(__func__);
3982
3983 return ret;
3984}
3985
3986/**
3987 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
3988 * @dev: device upon which the ioctl was received
3989 * @info: ioctl request information
3990 * @wrqu: ioctl request data
3991 * @extra: ioctl extra data
3992 *
3993 * Return: 0 on success, non-zero on error
3994 */
3995static int __iw_get_nick(struct net_device *dev,
3996 struct iw_request_info *info,
3997 union iwreq_data *wrqu, char *extra)
3998{
3999 hdd_adapter_t *adapter;
4000 hdd_context_t *hdd_ctx;
4001 int ret;
4002
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004003 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004004
4005 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4006 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4007 ret = wlan_hdd_validate_context(hdd_ctx);
4008 if (0 != ret)
4009 return ret;
4010
4011 return 0;
4012}
4013
4014/**
4015 * iw_get_nick() - SSR wrapper for __iw_get_nick
4016 * @dev: pointer to net_device
4017 * @info: pointer to iw_request_info
4018 * @wrqu: pointer to iwreq_data
4019 * @extra: extra
4020 *
4021 * Return: 0 on success, error number otherwise
4022 */
4023static int iw_get_nick(struct net_device *dev,
4024 struct iw_request_info *info,
4025 union iwreq_data *wrqu, char *extra)
4026{
4027 int ret;
4028
4029 cds_ssr_protect(__func__);
4030 ret = __iw_get_nick(dev, info, wrqu, extra);
4031 cds_ssr_unprotect(__func__);
4032
4033 return ret;
4034}
4035
4036/**
4037 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
4038 * @dev: device upon which the ioctl was received
4039 * @info: ioctl request information
4040 * @wrqu: ioctl request data
4041 * @extra: ioctl extra data
4042 *
4043 * Return: 0 on success, non-zero on error
4044 */
4045static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4046 union iwreq_data *wrqu, char *extra)
4047{
4048 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4049 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4050 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4051 hdd_context_t *hdd_ctx;
4052 struct iw_point *encoderq = &(wrqu->encoding);
4053 uint32_t keyId;
4054 uint8_t key_length;
4055 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4056 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304057 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004058 int ret;
4059
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004060 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061
4062 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4063 ret = wlan_hdd_validate_context(hdd_ctx);
4064 if (0 != ret)
4065 return ret;
4066
4067 keyId = encoderq->flags & IW_ENCODE_INDEX;
4068
4069 if (keyId) {
4070 if (keyId > MAX_WEP_KEYS) {
4071 return -EINVAL;
4072 }
4073
4074 fKeyPresent = 1;
4075 keyId--;
4076 } else {
4077 fKeyPresent = 0;
4078 }
4079
4080 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004081 hdd_notice("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08004083 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
4084 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085 }
4086 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4087 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4088 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4089 eCSR_ENCRYPT_TYPE_NONE;
4090 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4091 eCSR_ENCRYPT_TYPE_NONE;
4092
4093 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4094 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4095
4096 if (eConnectionState_Associated ==
4097 pHddStaCtx->conn_info.connState) {
4098 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4099 status =
4100 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4101 pAdapter->sessionId,
4102 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304103 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 unsigned long rc;
4105 rc = wait_for_completion_timeout(&pAdapter->
4106 disconnect_comp_var,
4107 msecs_to_jiffies
4108 (WLAN_WAIT_TIME_DISCONNECT));
4109 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004110 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 }
4112 }
4113
4114 return status;
4115
4116 }
4117
4118 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004119 hdd_notice("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120
4121 pHddStaCtx->conn_info.authType =
4122 (encoderq->
4123 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
4124 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4125
4126 }
4127
4128 if (wrqu->data.length > 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004129 hdd_notice("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004130
4131 key_length = wrqu->data.length;
4132
4133 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
4134
4135 if (5 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004136 hdd_notice("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004137 key_length);
4138
4139 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4140 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4141 pHddStaCtx->conn_info.authType)) {
4142 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4143 } else {
4144 encryptionType =
4145 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4146 }
4147 } else if (13 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004148 hdd_notice("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 key_length);
4150
4151 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4152 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4153 pHddStaCtx->conn_info.authType)) {
4154 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4155 } else {
4156 encryptionType =
4157 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4158 }
4159 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004160 hdd_warn("Invalid WEP key length :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161 key_length);
4162 return -EINVAL;
4163 }
4164
4165 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4166 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4167 pWextState->roamProfile.EncryptionType.numEntries = 1;
4168 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4169 encryptionType;
4170 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4171 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4172 encryptionType;
4173
4174 if ((eConnectionState_NotConnected ==
4175 pHddStaCtx->conn_info.connState)
4176 &&
4177 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4178 pHddStaCtx->conn_info.authType)
4179 || (eCSR_AUTH_TYPE_SHARED_KEY ==
4180 pHddStaCtx->conn_info.authType))) {
4181
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304182 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 KeyMaterial[keyId][0], extra, key_length);
4184
4185 pWextState->roamProfile.Keys.KeyLength[keyId] =
4186 (uint8_t) key_length;
4187 pWextState->roamProfile.Keys.defaultIndex =
4188 (uint8_t) keyId;
4189
4190 return status;
4191 }
4192 }
4193
4194 return 0;
4195}
4196
4197/**
4198 * iw_set_encode() - SSR wrapper for __iw_set_encode()
4199 * @dev: pointer to net_device
4200 * @info: pointer to iw_request_info
4201 * @wrqu: pointer to iwreq_data
4202 * @extra: pointer to extra ioctl payload
4203 *
4204 * Return: 0 on success, error number otherwise
4205 */
4206static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4207 union iwreq_data *wrqu, char *extra)
4208{
4209 int ret;
4210
4211 cds_ssr_protect(__func__);
4212 ret = __iw_set_encode(dev, info, wrqu, extra);
4213 cds_ssr_unprotect(__func__);
4214
4215 return ret;
4216}
4217
4218/**
4219 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
4220 * @dev: device upon which the ioctl was received
4221 * @info: ioctl request information
4222 * @wrqu: ioctl request data
4223 * @extra: ioctl extra data
4224 *
4225 * Return: 0 on success, non-zero on error
4226 */
4227static int __iw_get_encodeext(struct net_device *dev,
4228 struct iw_request_info *info,
4229 struct iw_point *dwrq, char *extra)
4230{
4231 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4232 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4233 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4234 int keyId;
4235 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4236 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
4237 int i, ret;
4238 hdd_context_t *hdd_ctx;
4239
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004240 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241
4242 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4243 ret = wlan_hdd_validate_context(hdd_ctx);
4244 if (0 != ret)
4245 return ret;
4246
4247 keyId = pRoamProfile->Keys.defaultIndex;
4248
4249 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004250 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 return -EINVAL;
4252 }
4253
4254 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
4255 dwrq->flags |= IW_ENCODE_ENABLED;
4256 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304257 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 pRoamProfile->Keys.KeyLength[keyId]);
4259 } else {
4260 dwrq->flags |= IW_ENCODE_DISABLED;
4261 }
4262
4263 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08004264 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 continue;
4266 } else {
4267 break;
4268 }
4269 }
4270
4271 if (MAX_WEP_KEYS == i) {
4272 dwrq->flags |= IW_ENCODE_NOKEY;
4273 } else {
4274 dwrq->flags |= IW_ENCODE_ENABLED;
4275 }
4276
4277 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4278
4279 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
4280 dwrq->flags |= IW_ENCODE_DISABLED;
4281 }
4282
4283 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4284
4285 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
4286 dwrq->flags |= IW_ENCODE_OPEN;
4287 } else {
4288 dwrq->flags |= IW_ENCODE_RESTRICTED;
4289 }
4290 EXIT();
4291 return 0;
4292
4293}
4294
4295/**
4296 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
4297 * @dev: pointer to net_device
4298 * @info: pointer to iw_request_info
4299 * @dwrq: pointer to encoding information
4300 * @extra: pointer to extra ioctl payload
4301 *
4302 * Return: 0 on success, error number otherwise
4303 */
4304static int iw_get_encodeext(struct net_device *dev,
4305 struct iw_request_info *info,
4306 struct iw_point *dwrq, char *extra)
4307{
4308 int ret;
4309
4310 cds_ssr_protect(__func__);
4311 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4312 cds_ssr_unprotect(__func__);
4313
4314 return ret;
4315}
4316
4317/**
4318 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
4319 * @dev: device upon which the ioctl was received
4320 * @info: ioctl request information
4321 * @wrqu: ioctl request data
4322 * @extra: ioctl extra data
4323 *
4324 * Return: 0 on success, non-zero on error
4325 */
4326static int __iw_set_encodeext(struct net_device *dev,
4327 struct iw_request_info *info,
4328 union iwreq_data *wrqu, char *extra)
4329{
4330 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4331 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4332 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4333 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304334 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4336 int ret;
4337 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
4338 int key_index;
4339 struct iw_point *encoding = &wrqu->encoding;
4340 tCsrRoamSetKey setKey;
4341 uint32_t roamId = 0xFF;
4342
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004343 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344
4345 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4346 ret = wlan_hdd_validate_context(hdd_ctx);
4347 if (0 != ret)
4348 return ret;
4349
4350 key_index = encoding->flags & IW_ENCODE_INDEX;
4351
4352 if (key_index > 0) {
4353
4354 /*Convert from 1-based to 0-based keying */
4355 key_index--;
4356 }
4357 if (!ext->key_len) {
4358
4359 /*Set the encrytion type to NONE */
4360 pRoamProfile->EncryptionType.encryptionType[0] =
4361 eCSR_ENCRYPT_TYPE_NONE;
4362 return ret;
4363 }
4364
4365 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4366 (IW_ENCODE_ALG_WEP == ext->alg)) {
4367 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4368
Jeff Johnson99bac312016-06-28 10:38:18 -07004369 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370 return -EINVAL;
4371 } else {
4372 /*Static wep, update the roam profile with the keys */
Yingying Tang3cc6b792016-10-20 17:00:37 +08004373 if (ext->key_len
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374 && (ext->key_len <=
4375 eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES)
4376 && key_index < CSR_MAX_NUM_KEY) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304377 qdf_mem_copy(&pRoamProfile->Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378 KeyMaterial[key_index][0],
4379 ext->key, ext->key_len);
4380 pRoamProfile->Keys.KeyLength[key_index] =
4381 (uint8_t) ext->key_len;
4382
4383 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4384 pRoamProfile->Keys.defaultIndex =
4385 (uint8_t) key_index;
4386
4387 }
4388 }
4389 return ret;
4390 }
4391
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304392 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393
4394 setKey.keyId = key_index;
4395 setKey.keyLength = ext->key_len;
4396
4397 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304398 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399 }
4400
4401 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4402 /*Key direction for group is RX only */
4403 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05304404 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004405 } else {
4406
4407 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304408 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304409 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410 }
4411
4412 /*For supplicant pae role is zero */
4413 setKey.paeRole = 0;
4414
4415 switch (ext->alg) {
4416 case IW_ENCODE_ALG_NONE:
4417 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4418 break;
4419
4420 case IW_ENCODE_ALG_WEP:
4421 setKey.encType =
4422 (ext->key_len ==
4423 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
4424 break;
4425
4426 case IW_ENCODE_ALG_TKIP:
4427 {
4428 uint8_t *pKey = &setKey.Key[0];
4429
4430 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4431
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304432 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004433
4434 /* Supplicant sends the 32bytes key in this order
4435 * |--------------|----------|----------|
4436 * | Tk1 | TX MIC | RX MIC |
4437 * |--------------|----------|----------|
4438 * <---16bytes---><--8bytes--><--8bytes-->
4439 *
4440 *
4441 * Sme expects the 32 bytes key to be in the below order
4442 * |--------------|----------|----------|
4443 * | Tk1 | RX MIC | TX MIC |
4444 * |--------------|----------|----------|
4445 * <---16bytes---><--8bytes--><--8bytes-->
4446 */
4447
4448 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304449 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450
4451 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304452 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453
4454 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304455 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456
4457 }
4458 break;
4459
4460 case IW_ENCODE_ALG_CCMP:
4461 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4462 break;
4463
4464#ifdef FEATURE_WLAN_ESE
4465#define IW_ENCODE_ALG_KRK 6
4466 case IW_ENCODE_ALG_KRK:
4467 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4468 break;
4469#endif /* FEATURE_WLAN_ESE */
4470
4471 default:
4472 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4473 break;
4474 }
4475
Jeff Johnson99bac312016-06-28 10:38:18 -07004476 hdd_notice("cipher_alg:%d key_len:%d EncryptionType:%d",
4477 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004479 /* The supplicant may attempt to set the PTK once
4480 * pre-authentication is done. Save the key in the UMAC and
4481 * include it in the ADD BSS request
4482 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304483 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004484 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304485 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004486 hdd_info("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304488 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004489 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 return -EINVAL;
4491 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492
4493 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4494
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304495 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 pAdapter->sessionId,
4497 &setKey, &roamId);
4498
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304499 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004500 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304501 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502
4503 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4504 }
4505
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304506 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004507}
4508
4509/**
4510 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
4511 * @dev: pointer to net_device
4512 * @info: pointer to iw_request_info
4513 * @wrqu: pointer to iwreq_data
4514 * @extra: pointer to extra ioctl payload
4515 *
4516 * Return: 0 on success, error number otherwise
4517 */
4518static int iw_set_encodeext(struct net_device *dev,
4519 struct iw_request_info *info,
4520 union iwreq_data *wrqu, char *extra)
4521{
4522 int ret;
4523
4524 cds_ssr_protect(__func__);
4525 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4526 cds_ssr_unprotect(__func__);
4527
4528 return ret;
4529}
4530
4531/**
4532 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
4533 * @dev: device upon which the ioctl was received
4534 * @info: ioctl request information
4535 * @wrqu: ioctl request data
4536 * @extra: ioctl extra data
4537 *
4538 * Return: 0 on success, non-zero on error
4539 */
4540static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
4541 union iwreq_data *wrqu, char *extra)
4542{
4543 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4544 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4545 hdd_context_t *hdd_ctx;
4546 int ret;
4547
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004548 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549
4550 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4551 ret = wlan_hdd_validate_context(hdd_ctx);
4552 if (0 != ret)
4553 return ret;
4554
4555 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4556 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4557
Jeff Johnson99bac312016-06-28 10:38:18 -07004558 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004559
4560 return -EINVAL;
4561 }
4562
4563 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
4564
4565 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
4566 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
4567 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304568 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004569 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004570 return -EIO;
4571 }
4572 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
4573 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
4574 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304575 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05304576 hdd_err("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577 return -EIO;
4578 }
4579 }
4580 } else {
4581 return -EOPNOTSUPP;
4582 }
4583
Jeff Johnson99bac312016-06-28 10:38:18 -07004584 hdd_notice("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004585
4586 EXIT();
4587
4588 return 0;
4589
4590}
4591
4592/**
4593 * iw_set_retry() - SSR wrapper for __iw_set_retry()
4594 * @dev: pointer to net_device
4595 * @info: pointer to iw_request_info
4596 * @wrqu: pointer to iwreq_data
4597 * @extra: pointer to extra ioctl payload
4598 *
4599 * Return: 0 on success, error number otherwise
4600 */
4601static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
4602 union iwreq_data *wrqu, char *extra)
4603{
4604 int ret;
4605
4606 cds_ssr_protect(__func__);
4607 ret = __iw_set_retry(dev, info, wrqu, extra);
4608 cds_ssr_unprotect(__func__);
4609
4610 return ret;
4611}
4612
4613/**
4614 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
4615 * @dev: device upon which the ioctl was received
4616 * @info: ioctl request information
4617 * @wrqu: ioctl request data
4618 * @extra: ioctl extra data
4619 *
4620 * Return: 0 on success, non-zero on error
4621 */
4622static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
4623 union iwreq_data *wrqu, char *extra)
4624{
4625 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4626 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4627 uint32_t retry = 0;
4628 hdd_context_t *hdd_ctx;
4629 int ret;
4630
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004631 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632
4633 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4634 ret = wlan_hdd_validate_context(hdd_ctx);
4635 if (0 != ret)
4636 return ret;
4637
4638 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
4639 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
4640
4641 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304642 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004643 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 return -EIO;
4645 }
4646
4647 wrqu->retry.value = retry;
4648 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
4649 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
4650
4651 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304652 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05304653 hdd_warn("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 return -EIO;
4655 }
4656
4657 wrqu->retry.value = retry;
4658 } else {
4659 return -EOPNOTSUPP;
4660 }
4661
Jeff Johnson99bac312016-06-28 10:38:18 -07004662 hdd_notice("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663
4664 EXIT();
4665
4666 return 0;
4667}
4668
4669/**
4670 * iw_get_retry() - SSR wrapper for __iw_get_retry()
4671 * @dev: pointer to net_device
4672 * @info: pointer to iw_request_info
4673 * @wrqu: pointer to iwreq_data
4674 * @extra: pointer to extra ioctl payload
4675 *
4676 * Return: 0 on success, error number otherwise
4677 */
4678static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
4679 union iwreq_data *wrqu, char *extra)
4680{
4681 int ret;
4682
4683 cds_ssr_protect(__func__);
4684 ret = __iw_get_retry(dev, info, wrqu, extra);
4685 cds_ssr_unprotect(__func__);
4686
4687 return ret;
4688}
4689
4690/**
4691 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
4692 * @dev: device upon which the ioctl was received
4693 * @info: ioctl request information
4694 * @wrqu: ioctl request data
4695 * @extra: ioctl extra data
4696 *
4697 * Return: 0 on success, non-zero on error
4698 */
4699static int __iw_set_mlme(struct net_device *dev,
4700 struct iw_request_info *info,
4701 union iwreq_data *wrqu, char *extra)
4702{
4703 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4704 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4705 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304706 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707 hdd_context_t *hdd_ctx;
4708 int ret;
4709
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004710 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004711
4712 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4713 ret = wlan_hdd_validate_context(hdd_ctx);
4714 if (0 != ret)
4715 return ret;
4716
4717 /* reason_code is unused. By default it is set to
4718 * eCSR_DISCONNECT_REASON_UNSPECIFIED
4719 */
4720 switch (mlme->cmd) {
4721 case IW_MLME_DISASSOC:
4722 case IW_MLME_DEAUTH:
4723
4724 if (pHddStaCtx->conn_info.connState ==
4725 eConnectionState_Associated) {
4726 eCsrRoamDisconnectReason reason =
4727 eCSR_DISCONNECT_REASON_UNSPECIFIED;
4728
4729 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
4730 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4731
4732 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4733 status =
4734 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4735 pAdapter->sessionId, reason);
4736
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304737 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004738 unsigned long rc;
4739 rc = wait_for_completion_timeout(&pAdapter->
4740 disconnect_comp_var,
4741 msecs_to_jiffies
4742 (WLAN_WAIT_TIME_DISCONNECT));
4743 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004744 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07004746 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
4747 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748
4749 /* Resetting authKeyMgmt */
4750 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
4751 0;
4752
Jeff Johnson99bac312016-06-28 10:38:18 -07004753 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 wlan_hdd_netif_queue_control(pAdapter,
4755 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4756 WLAN_CONTROL_PATH);
4757
4758 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004759 hdd_err("%d Command Disassociate/Deauthenticate called but station is not in associated state",
4760 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004761 }
4762 break;
4763 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004764 hdd_err("%d Command should be Disassociate/Deauthenticate",
4765 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 return -EINVAL;
4767 } /* end of switch */
4768
4769 EXIT();
4770
4771 return status;
4772
4773}
4774
4775/**
4776 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
4777 * @dev: pointer to net_device
4778 * @info: pointer to iw_request_info
4779 * @wrqu: pointer to iwreq_data
4780 * @extra: pointer to extra ioctl payload
4781 *
4782 * Return: 0 on success, error number otherwise
4783 */
4784static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
4785 union iwreq_data *wrqu, char *extra)
4786{
4787 int ret;
4788
4789 cds_ssr_protect(__func__);
4790 ret = __iw_set_mlme(dev, info, wrqu, extra);
4791 cds_ssr_unprotect(__func__);
4792
4793 return ret;
4794}
4795
4796/**
4797 * wlan_hdd_update_phymode() - handle change in PHY mode
4798 * @net: device upon which PHY mode change was received
4799 * @hal: umac handle for the driver
4800 * @new_phymode: new PHY mode for the device
4801 * @phddctx: pointer to the HDD context
4802 *
4803 * This function is called when the device is set to a new PHY mode.
4804 * It takes a holistic look at the desired PHY mode along with the
4805 * configured capabilities of the driver and the reported capabilities
4806 * of the hardware in order to correctly configure all PHY-related
4807 * parameters.
4808 *
4809 * Return: 0 on success, negative errno value on error
4810 */
4811int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
4812 int new_phymode, hdd_context_t *phddctx)
4813{
4814#ifdef QCA_HT_2040_COEX
4815 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304816 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004817#endif
4818 bool band_24 = false, band_5g = false;
4819 bool ch_bond24 = false, ch_bond5g = false;
4820 tSmeConfigParams smeconfig;
4821 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004823 eCsrPhyMode phymode = -EIO, old_phymode;
4824 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
4825 eCsrBand curr_band = eCSR_BAND_ALL;
4826
4827 old_phymode = sme_get_phy_mode(hal);
4828
4829 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
4830 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
4831 nChannelBondingMode24GHz))
4832 ch_bond24 = true;
4833
4834 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
4835 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
4836 nChannelBondingMode5GHz))
4837 ch_bond5g = true;
4838
4839 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
4840 band_24 = band_5g = true;
4841 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
4842 band_24 = true;
4843 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
4844 band_5g = true;
4845 }
4846
4847 vhtchanwidth = phddctx->config->vhtChannelWidth;
Jeff Johnson99bac312016-06-28 10:38:18 -07004848 hdd_warn("ch_bond24=%d ch_bond5g=%d band_24=%d band_5g=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004849 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
4850
4851 switch (new_phymode) {
4852 case IEEE80211_MODE_AUTO:
4853 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4854 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
4855 phymode = eCSR_DOT11_MODE_AUTO;
4856 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4857 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4858 curr_band = eCSR_BAND_ALL;
4859 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
4860 } else {
4861 sme_set_phy_mode(hal, old_phymode);
4862 return -EIO;
4863 }
4864 break;
4865 case IEEE80211_MODE_11A:
4866 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
4867 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4868 phymode = eCSR_DOT11_MODE_11a;
4869 hdd_dot11mode = eHDD_DOT11_MODE_11a;
4870 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4871 curr_band = eCSR_BAND_5G;
4872 } else {
4873 sme_set_phy_mode(hal, old_phymode);
4874 return -EIO;
4875 }
4876 break;
4877 case IEEE80211_MODE_11B:
4878 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
4879 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4880 phymode = eCSR_DOT11_MODE_11b;
4881 hdd_dot11mode = eHDD_DOT11_MODE_11b;
4882 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4883 curr_band = eCSR_BAND_24;
4884 } else {
4885 sme_set_phy_mode(hal, old_phymode);
4886 return -EIO;
4887 }
4888 break;
4889 case IEEE80211_MODE_11G:
4890 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
4891 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4892 phymode = eCSR_DOT11_MODE_11g;
4893 hdd_dot11mode = eHDD_DOT11_MODE_11g;
4894 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4895 curr_band = eCSR_BAND_24;
4896 } else {
4897 sme_set_phy_mode(hal, old_phymode);
4898 return -EIO;
4899 }
4900 break;
4901 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
4902 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
4903 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
4904 */
4905 case IEEE80211_MODE_11NA_HT20:
4906 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4907 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4908 phymode = eCSR_DOT11_MODE_11n;
4909 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4910 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4911 curr_band = eCSR_BAND_5G;
4912 } else {
4913 sme_set_phy_mode(hal, old_phymode);
4914 return -EIO;
4915 }
4916 break;
4917 case IEEE80211_MODE_11NA_HT40:
4918 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4919 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4920 phymode = eCSR_DOT11_MODE_11n;
4921 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4922 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4923 curr_band = eCSR_BAND_5G;
4924 } else {
4925 sme_set_phy_mode(hal, old_phymode);
4926 return -EIO;
4927 }
4928 break;
4929 case IEEE80211_MODE_11NG_HT20:
4930 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4931 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4932 phymode = eCSR_DOT11_MODE_11n;
4933 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4934 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4935 curr_band = eCSR_BAND_24;
4936 } else {
4937 sme_set_phy_mode(hal, old_phymode);
4938 return -EIO;
4939 }
4940 break;
4941 case IEEE80211_MODE_11NG_HT40:
4942 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4943 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4944 phymode = eCSR_DOT11_MODE_11n;
4945 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4946 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4947 curr_band = eCSR_BAND_24;
4948 } else {
4949 sme_set_phy_mode(hal, old_phymode);
4950 return -EIO;
4951 }
4952 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 case IEEE80211_MODE_11AC_VHT20:
4954 case IEEE80211_MODE_11AC_VHT40:
4955 case IEEE80211_MODE_11AC_VHT80:
4956 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
4957 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4958 phymode = eCSR_DOT11_MODE_11ac;
4959 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
4960 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4961 curr_band = eCSR_BAND_5G;
4962 } else {
4963 sme_set_phy_mode(hal, old_phymode);
4964 return -EIO;
4965 }
4966 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004967 case IEEE80211_MODE_2G_AUTO:
4968 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4969 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4970 phymode = eCSR_DOT11_MODE_AUTO;
4971 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4972 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4973 curr_band = eCSR_BAND_24;
4974 } else {
4975 sme_set_phy_mode(hal, old_phymode);
4976 return -EIO;
4977 }
4978 break;
4979 case IEEE80211_MODE_5G_AUTO:
4980 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4981 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4982 phymode = eCSR_DOT11_MODE_AUTO;
4983 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4984 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4985 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
4986 curr_band = eCSR_BAND_5G;
4987 } else {
4988 sme_set_phy_mode(hal, old_phymode);
4989 return -EIO;
4990 }
4991 break;
4992 case IEEE80211_MODE_11AGN:
4993 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4994 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
4995 phymode = eCSR_DOT11_MODE_11n;
4996 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4997 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4998 curr_band = eCSR_BAND_ALL;
4999 } else {
5000 sme_set_phy_mode(hal, old_phymode);
5001 return -EIO;
5002 }
5003 break;
5004 default:
5005 return -EIO;
5006 }
5007
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005008 switch (new_phymode) {
5009 case IEEE80211_MODE_11AC_VHT20:
5010 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5011 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
5012 break;
5013 case IEEE80211_MODE_11AC_VHT40:
5014 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
5015 break;
5016 case IEEE80211_MODE_11AC_VHT80:
5017 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5018 break;
5019 default:
5020 vhtchanwidth = phddctx->config->vhtChannelWidth;
5021 break;
5022 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005023
5024 if (phymode != -EIO) {
5025 sme_get_config_param(hal, &smeconfig);
5026 smeconfig.csrConfig.phyMode = phymode;
5027#ifdef QCA_HT_2040_COEX
5028 if (phymode == eCSR_DOT11_MODE_11n &&
5029 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
5030 smeconfig.csrConfig.obssEnabled = false;
5031 halStatus = sme_set_ht2040_mode(hal,
5032 pAdapter->sessionId,
5033 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305034 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005035 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005036 return -EIO;
5037 }
5038 } else if (phymode == eCSR_DOT11_MODE_11n &&
5039 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
5040 smeconfig.csrConfig.obssEnabled = true;
5041 halStatus = sme_set_ht2040_mode(hal,
5042 pAdapter->sessionId,
5043 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305044 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005045 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005046 return -EIO;
5047 }
5048 }
5049#endif
5050 smeconfig.csrConfig.eBand = curr_band;
5051 smeconfig.csrConfig.bandCapability = curr_band;
5052 if (curr_band == eCSR_BAND_24)
5053 smeconfig.csrConfig.Is11hSupportEnabled = 0;
5054 else
5055 smeconfig.csrConfig.Is11hSupportEnabled =
5056 phddctx->config->Is11hSupportEnabled;
5057 if (curr_band == eCSR_BAND_24)
5058 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5059 else if (curr_band == eCSR_BAND_24)
5060 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5061 else {
5062 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5063 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5064 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005065 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005066 sme_update_config(hal, &smeconfig);
5067
5068 phddctx->config->dot11Mode = hdd_dot11mode;
5069 phddctx->config->nBandCapability = curr_band;
5070 phddctx->config->nChannelBondingMode24GHz =
5071 smeconfig.csrConfig.channelBondingMode24GHz;
5072 phddctx->config->nChannelBondingMode5GHz =
5073 smeconfig.csrConfig.channelBondingMode5GHz;
5074 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07005075 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005076 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077 return -EIO;
5078 }
5079 if (phddctx->config->nChannelBondingMode5GHz)
Dustin Browna30892e2016-10-12 17:28:36 -07005080 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005081 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5082 else
Dustin Browna30892e2016-10-12 17:28:36 -07005083 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5085
Jeff Johnson99bac312016-06-28 10:38:18 -07005086 hdd_warn("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087 phymode, chwidth, curr_band, vhtchanwidth);
5088 }
5089
5090 return 0;
5091}
5092
5093/**
5094 * hdd_get_temperature_cb() - "Get Temperature" callback function
5095 * @temperature: measured temperature
5096 * @pContext: callback context
5097 *
5098 * This function is passed to sme_get_temperature() as the callback
5099 * function to be invoked when the temperature measurement is
5100 * available.
5101 *
5102 * Return: None
5103 */
5104static void hdd_get_temperature_cb(int temperature, void *pContext)
5105{
5106 struct statsContext *pTempContext;
5107 hdd_adapter_t *pAdapter;
5108 ENTER();
5109 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005110 hdd_err("pContext is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005111 return;
5112 }
5113 pTempContext = pContext;
5114 pAdapter = pTempContext->pAdapter;
5115 spin_lock(&hdd_context_lock);
5116 if ((NULL == pAdapter) || (TEMP_CONTEXT_MAGIC != pTempContext->magic)) {
5117 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07005118 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119 pAdapter, pTempContext->magic);
5120 return;
5121 }
5122 if (temperature != 0) {
5123 pAdapter->temperature = temperature;
5124 }
5125 complete(&pTempContext->completion);
5126 spin_unlock(&hdd_context_lock);
5127 EXIT();
5128}
5129
5130/**
5131 * wlan_hdd_get_temperature() - get current device temperature
5132 * @pAdapter: device upon which the request was made
5133 * @temperature: pointer to where the temperature is to be returned
5134 *
5135 * Return: 0 if a temperature value (either current or cached) was
5136 * returned, otherwise a negative errno is returned.
5137 *
5138 */
5139int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
5140{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305141 QDF_STATUS status;
Houston Hoffman59c097f2016-11-09 15:50:25 -08005142 static struct statsContext tempContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005143 unsigned long rc;
5144
5145 ENTER();
5146 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005147 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148 return -EPERM;
5149 }
5150 init_completion(&tempContext.completion);
5151 tempContext.pAdapter = pAdapter;
5152 tempContext.magic = TEMP_CONTEXT_MAGIC;
5153 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
5154 &tempContext, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305155 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005156 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005157 } else {
5158 rc = wait_for_completion_timeout(&tempContext.completion,
5159 msecs_to_jiffies
5160 (WLAN_WAIT_TIME_STATS));
5161 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005162 hdd_err("SME timed out while retrieving temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005163 }
5164 }
5165 spin_lock(&hdd_context_lock);
5166 tempContext.magic = 0;
5167 spin_unlock(&hdd_context_lock);
5168 *temperature = pAdapter->temperature;
5169 EXIT();
5170 return 0;
5171}
5172
5173/**
5174 * iw_setint_getnone() - Generic "set integer" private ioctl handler
5175 * @dev: device upon which the ioctl was received
5176 * @info: ioctl request information
5177 * @wrqu: ioctl request data
5178 * @extra: ioctl extra data
5179 *
5180 * Return: 0 on success, non-zero on error
5181 */
5182static int __iw_setint_getnone(struct net_device *dev,
5183 struct iw_request_info *info,
5184 union iwreq_data *wrqu, char *extra)
5185{
5186 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5187 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5188 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5189 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5190 hdd_context_t *hdd_ctx;
5191 tSmeConfigParams smeConfig;
5192 int *value = (int *)extra;
5193 int sub_cmd = value[0];
5194 int set_value = value[1];
5195 int ret;
5196 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305197 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005198
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005199 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305200
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201 INIT_COMPLETION(pWextState->completion_var);
Mukul Sharma81661ae2015-10-30 20:26:02 +05305202 memset(&smeConfig, 0x00, sizeof(smeConfig));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005203
5204 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5205 ret = wlan_hdd_validate_context(hdd_ctx);
5206 if (0 != ret)
5207 return ret;
5208
5209 switch (sub_cmd) {
5210 case WE_SET_11D_STATE:
5211 {
5212 if ((ENABLE_11D == set_value)
5213 || (DISABLE_11D == set_value)) {
5214
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005215 sme_get_config_param(hHal, &smeConfig);
5216 smeConfig.csrConfig.Is11dSupportEnabled =
5217 (bool) set_value;
5218
Jeff Johnson99bac312016-06-28 10:38:18 -07005219 hdd_notice("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005220 smeConfig.csrConfig.
5221 Is11dSupportEnabled);
5222
5223 sme_update_config(hHal, &smeConfig);
5224 } else {
5225 return -EINVAL;
5226 }
5227 break;
5228 }
5229
5230 case WE_WOWL:
5231 {
5232 switch (set_value) {
5233 case 0x00:
5234 hdd_exit_wowl(pAdapter);
5235 break;
5236 case 0x01:
5237 case 0x02:
5238 case 0x03:
5239 enable_mp = (set_value & 0x01) ? 1 : 0;
5240 enable_pbm = (set_value & 0x02) ? 1 : 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005241 hdd_err("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005242 (enable_mp ? "YES" : "NO"),
5243 (enable_pbm ? "YES" : "NO"));
5244 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5245 break;
5246 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005247 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005248 set_value);
5249 ret = -EINVAL;
5250 break;
5251 }
5252
5253 break;
5254 }
5255 case WE_SET_POWER:
5256 {
5257 switch (set_value) {
5258 case 1:
5259 /* Enable PowerSave */
5260 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5261 SME_PS_ENABLE);
5262 break;
5263 case 2:
5264 /* Disable PowerSave */
5265 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5266 SME_PS_DISABLE);
5267 break;
5268 case 3: /* Enable UASPD */
5269 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
5270 break;
5271 case 4: /* Disable UASPD */
5272 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
5273 break;
5274 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005275 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005276 set_value);
5277 ret = -EINVAL;
5278 break;
5279 }
5280 break;
5281 }
5282
5283 case WE_SET_MAX_ASSOC:
5284 {
5285 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5286 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
5287 ret = -EINVAL;
5288 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5289 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305290 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005291 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005292 ret = -EIO;
5293 }
5294 break;
5295 }
5296
5297 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5298 if (set_value == 0 || set_value == 1)
5299 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
5300 set_value;
5301 else
5302 ret = -EINVAL;
5303 break;
5304
5305 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005306 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5307 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5308 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5309 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305310 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005311 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 ret = -EINVAL;
5313 }
5314 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 case WE_SET_MC_RATE:
5316 {
5317 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
5318 break;
5319 }
5320 case WE_SET_TX_POWER:
5321 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305322 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005323
Anurag Chouhanc5548422016-02-24 18:33:27 +05305324 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005325 if (sme_set_tx_power
5326 (hHal, pAdapter->sessionId, bssid,
5327 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305328 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005329 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005330 return -EIO;
5331 }
5332 break;
5333 }
5334 case WE_SET_MAX_TX_POWER:
5335 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305336 struct qdf_mac_addr bssid;
5337 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338
Jeff Johnson99bac312016-06-28 10:38:18 -07005339 hdd_notice("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05305341 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
5342 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005343
5344 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305345 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005346 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347 return -EIO;
5348 }
5349
5350 break;
5351 }
5352 case WE_SET_MAX_TX_POWER_2_4:
5353 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005354 hdd_notice("Setting maximum tx power %d dBm for 2.4 GHz band",
5355 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005356 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305357 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005358 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005359 return -EIO;
5360 }
5361
5362 break;
5363 }
5364 case WE_SET_MAX_TX_POWER_5_0:
5365 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005366 hdd_notice("Setting maximum tx power %d dBm for 5.0 GHz band",
5367 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005368 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305369 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005370 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005371 return -EIO;
5372 }
5373
5374 break;
5375 }
5376 case WE_SET_HIGHER_DTIM_TRANSITION:
5377 {
5378 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005379 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005380 set_value);
5381 ret = -EINVAL;
5382 } else {
5383 if (pAdapter->higherDtimTransition != set_value) {
5384 pAdapter->higherDtimTransition =
5385 set_value;
Jeff Johnson99bac312016-06-28 10:38:18 -07005386 hdd_notice("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005387 pAdapter->higherDtimTransition);
5388 }
5389 }
5390
5391 break;
5392 }
5393
5394 case WE_SET_TM_LEVEL:
5395 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005396 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005397 (void)sme_set_thermal_level(hHal, set_value);
5398 break;
5399 }
5400
5401 case WE_SET_PHYMODE:
5402 {
5403 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5404
5405 ret =
5406 wlan_hdd_update_phymode(dev, hHal, set_value,
5407 phddctx);
5408 break;
5409 }
5410
5411 case WE_SET_NSS:
5412 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005413 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005414 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005415 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005416 ret = -EINVAL;
5417 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305418 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005419 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
5420 set_value))
5421 ret = -EINVAL;
5422 }
5423 break;
5424 }
5425
5426 case WE_SET_GTX_HT_MCS:
5427 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005428 hdd_notice("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005429 ret = wma_cli_set_command(pAdapter->sessionId,
5430 WMI_VDEV_PARAM_GTX_HT_MCS,
5431 set_value, GTX_CMD);
5432 break;
5433 }
5434
5435 case WE_SET_GTX_VHT_MCS:
5436 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005437 hdd_notice("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438 set_value);
5439 ret = wma_cli_set_command(pAdapter->sessionId,
5440 WMI_VDEV_PARAM_GTX_VHT_MCS,
5441 set_value, GTX_CMD);
5442 break;
5443 }
5444
5445 case WE_SET_GTX_USRCFG:
5446 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005447 hdd_notice("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005448 set_value);
5449 ret = wma_cli_set_command(pAdapter->sessionId,
5450 WMI_VDEV_PARAM_GTX_USR_CFG,
5451 set_value, GTX_CMD);
5452 break;
5453 }
5454
5455 case WE_SET_GTX_THRE:
5456 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005457 hdd_notice("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458 ret = wma_cli_set_command(pAdapter->sessionId,
5459 WMI_VDEV_PARAM_GTX_THRE,
5460 set_value, GTX_CMD);
5461 break;
5462 }
5463
5464 case WE_SET_GTX_MARGIN:
5465 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005466 hdd_notice("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005467 ret = wma_cli_set_command(pAdapter->sessionId,
5468 WMI_VDEV_PARAM_GTX_MARGIN,
5469 set_value, GTX_CMD);
5470 break;
5471 }
5472
5473 case WE_SET_GTX_STEP:
5474 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005475 hdd_notice("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005476 ret = wma_cli_set_command(pAdapter->sessionId,
5477 WMI_VDEV_PARAM_GTX_STEP,
5478 set_value, GTX_CMD);
5479 break;
5480 }
5481
5482 case WE_SET_GTX_MINTPC:
5483 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005484 hdd_notice("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005485 ret = wma_cli_set_command(pAdapter->sessionId,
5486 WMI_VDEV_PARAM_GTX_MINTPC,
5487 set_value, GTX_CMD);
5488 break;
5489 }
5490
5491 case WE_SET_GTX_BWMASK:
5492 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005493 hdd_notice("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 ret = wma_cli_set_command(pAdapter->sessionId,
5495 WMI_VDEV_PARAM_GTX_BW_MASK,
5496 set_value, GTX_CMD);
5497 break;
5498 }
5499
5500 case WE_SET_LDPC:
5501 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305502 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005503 break;
5504 }
5505
5506 case WE_SET_TX_STBC:
5507 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305508 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005509 break;
5510 }
5511
5512 case WE_SET_RX_STBC:
5513 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305514 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515 break;
5516 }
5517
5518 case WE_SET_SHORT_GI:
5519 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005520 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
5522 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
5523 set_value);
5524 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07005525 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005526 break;
5527 }
5528
5529 case WE_SET_RTSCTS:
5530 {
5531 uint32_t value;
5532
Jeff Johnson99bac312016-06-28 10:38:18 -07005533 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005534 set_value);
5535
5536 if ((set_value & HDD_RTSCTS_EN_MASK) ==
5537 HDD_RTSCTS_ENABLE)
5538 value =
5539 (WLAN_HDD_GET_CTX(pAdapter))->config->
5540 RTSThreshold;
5541 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
5542 || ((set_value & HDD_RTSCTS_EN_MASK) ==
5543 HDD_CTS_ENABLE))
5544 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
5545 else
5546 return -EIO;
5547
5548 ret = wma_cli_set_command(pAdapter->sessionId,
5549 WMI_VDEV_PARAM_ENABLE_RTSCTS,
5550 set_value, VDEV_CMD);
5551 if (!ret) {
5552 if (sme_cfg_set_int
5553 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305554 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005555 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556 return -EIO;
5557 }
5558 }
5559
5560 break;
5561 }
5562
5563 case WE_SET_CHWIDTH:
5564 {
5565 bool chwidth = false;
5566 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5567 /*updating channel bonding only on 5Ghz */
Jeff Johnson99bac312016-06-28 10:38:18 -07005568 hdd_notice("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005569 set_value);
5570 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005571 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 return -EINVAL;
5573 }
5574
5575 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5576 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
5577 nChannelBondingMode5GHz)))
5578 chwidth = true;
5579
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005580 sme_get_config_param(hHal, &smeConfig);
5581 switch (set_value) {
5582 case eHT_CHANNEL_WIDTH_20MHZ:
5583 smeConfig.csrConfig.channelBondingMode5GHz =
5584 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5585 break;
5586 case eHT_CHANNEL_WIDTH_40MHZ:
5587 if (chwidth)
5588 smeConfig.csrConfig.
5589 channelBondingMode5GHz =
5590 phddctx->config->
5591 nChannelBondingMode5GHz;
5592 else
5593 return -EINVAL;
5594
5595 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005596 case eHT_CHANNEL_WIDTH_80MHZ:
5597 if (chwidth)
5598 smeConfig.csrConfig.
5599 channelBondingMode5GHz =
5600 phddctx->config->
5601 nChannelBondingMode5GHz;
5602 else
5603 return -EINVAL;
5604
5605 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606
5607 default:
5608 return -EINVAL;
5609 }
5610
5611 ret = wma_cli_set_command(pAdapter->sessionId,
5612 WMI_VDEV_PARAM_CHWIDTH,
5613 set_value, VDEV_CMD);
5614 if (!ret)
5615 sme_update_config(hHal, &smeConfig);
5616
5617 break;
5618 }
5619
5620 case WE_SET_ANI_EN_DIS:
5621 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005622 hdd_notice("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623 set_value);
5624 ret = wma_cli_set_command(pAdapter->sessionId,
5625 WMI_PDEV_PARAM_ANI_ENABLE,
5626 set_value, PDEV_CMD);
5627 break;
5628 }
5629
5630 case WE_SET_ANI_POLL_PERIOD:
5631 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005632 hdd_notice("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005633 set_value);
5634 ret = wma_cli_set_command(pAdapter->sessionId,
5635 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
5636 set_value, PDEV_CMD);
5637 break;
5638 }
5639
5640 case WE_SET_ANI_LISTEN_PERIOD:
5641 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005642 hdd_notice("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643 set_value);
5644 ret = wma_cli_set_command(pAdapter->sessionId,
5645 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
5646 set_value, PDEV_CMD);
5647 break;
5648 }
5649
5650 case WE_SET_ANI_OFDM_LEVEL:
5651 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005652 hdd_notice("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005653 set_value);
5654 ret = wma_cli_set_command(pAdapter->sessionId,
5655 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
5656 set_value, PDEV_CMD);
5657 break;
5658 }
5659
5660 case WE_SET_ANI_CCK_LEVEL:
5661 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005662 hdd_notice("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663 set_value);
5664 ret = wma_cli_set_command(pAdapter->sessionId,
5665 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
5666 set_value, PDEV_CMD);
5667 break;
5668 }
5669
5670 case WE_SET_DYNAMIC_BW:
5671 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005672 hdd_notice("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005673 set_value);
5674 ret = wma_cli_set_command(pAdapter->sessionId,
5675 WMI_PDEV_PARAM_DYNAMIC_BW,
5676 set_value, PDEV_CMD);
5677 break;
5678 }
5679
5680 case WE_SET_CTS_CBW:
5681 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005682 hdd_notice("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005683 ret = wma_cli_set_command(pAdapter->sessionId,
5684 WMI_PDEV_PARAM_CTS_CBW,
5685 set_value, PDEV_CMD);
5686 break;
5687 }
5688
5689 case WE_SET_11N_RATE:
5690 {
5691 uint8_t preamble = 0, nss = 0, rix = 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005692 hdd_notice("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693 set_value);
5694
5695 if (set_value != 0xff) {
5696 rix = RC_2_RATE_IDX(set_value);
5697 if (set_value & 0x80) {
5698 preamble = WMI_RATE_PREAMBLE_HT;
5699 nss = HT_RC_2_STREAMS(set_value) - 1;
5700 } else {
5701 nss = 0;
5702 rix = RC_2_RATE_IDX(set_value);
5703 if (set_value & 0x10) {
5704 preamble =
5705 WMI_RATE_PREAMBLE_CCK;
5706 if (rix != 0x3)
5707 /* Enable Short
5708 * preamble always for
5709 * CCK except 1mbps
5710 */
5711 rix |= 0x4;
5712 } else {
5713 preamble =
5714 WMI_RATE_PREAMBLE_OFDM;
5715 }
5716 }
5717 set_value = (preamble << 6) | (nss << 4) | rix;
5718 }
5719 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
5720 set_value, rix, preamble, nss);
5721
5722 ret = wma_cli_set_command(pAdapter->sessionId,
5723 WMI_VDEV_PARAM_FIXED_RATE,
5724 set_value, VDEV_CMD);
5725 break;
5726 }
5727
5728 case WE_SET_VHT_RATE:
5729 {
5730 uint8_t preamble = 0, nss = 0, rix = 0;
5731
5732 if (set_value != 0xff) {
5733 rix = RC_2_RATE_IDX_11AC(set_value);
5734 preamble = WMI_RATE_PREAMBLE_VHT;
5735 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
5736
5737 set_value = (preamble << 6) | (nss << 4) | rix;
5738 }
5739 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
5740 set_value, rix, preamble, nss);
5741 ret = wma_cli_set_command(pAdapter->sessionId,
5742 WMI_VDEV_PARAM_FIXED_RATE,
5743 set_value, VDEV_CMD);
5744 break;
5745 }
5746
5747 case WE_SET_AMPDU:
5748 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005749 hdd_notice("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750 ret = wma_cli_set_command(pAdapter->sessionId,
5751 GEN_VDEV_PARAM_AMPDU,
5752 set_value, GEN_CMD);
5753 break;
5754 }
5755
5756 case WE_SET_AMSDU:
5757 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005758 hdd_notice("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005759 ret = wma_cli_set_command(pAdapter->sessionId,
5760 GEN_VDEV_PARAM_AMSDU,
5761 set_value, GEN_CMD);
5762 break;
5763 }
5764
5765 case WE_SET_BURST_ENABLE:
5766 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005767 hdd_notice("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 if ((set_value == 0) || (set_value == 1)) {
5769 ret = wma_cli_set_command(pAdapter->sessionId,
5770 WMI_PDEV_PARAM_BURST_ENABLE,
5771 set_value, PDEV_CMD);
5772 } else
5773 ret = -EINVAL;
5774 break;
5775 }
5776 case WE_SET_BURST_DUR:
5777 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005778 hdd_notice("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07005779 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005780 ret = wma_cli_set_command(pAdapter->sessionId,
5781 WMI_PDEV_PARAM_BURST_DUR,
5782 set_value, PDEV_CMD);
5783 else
5784 ret = -EINVAL;
5785 break;
5786 }
5787
5788 case WE_SET_TX_CHAINMASK:
5789 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005790 hdd_notice("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005791 set_value);
5792 ret = wma_cli_set_command(pAdapter->sessionId,
5793 WMI_PDEV_PARAM_TX_CHAIN_MASK,
5794 set_value, PDEV_CMD);
5795 break;
5796 }
5797
5798 case WE_SET_RX_CHAINMASK:
5799 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005800 hdd_notice("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005801 set_value);
5802 ret = wma_cli_set_command(pAdapter->sessionId,
5803 WMI_PDEV_PARAM_RX_CHAIN_MASK,
5804 set_value, PDEV_CMD);
5805 break;
5806 }
5807
5808 case WE_SET_TXPOW_2G:
5809 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005810 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005811 set_value);
5812 ret = wma_cli_set_command(pAdapter->sessionId,
5813 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
5814 set_value, PDEV_CMD);
5815 break;
5816 }
5817
5818 case WE_SET_TXPOW_5G:
5819 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005820 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005821 set_value);
5822 ret = wma_cli_set_command(pAdapter->sessionId,
5823 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
5824 set_value, PDEV_CMD);
5825 break;
5826 }
5827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005828 /* Firmware debug log */
5829 case WE_DBGLOG_LOG_LEVEL:
5830 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005831 hdd_notice("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005832 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
5833 ret = wma_cli_set_command(pAdapter->sessionId,
5834 WMI_DBGLOG_LOG_LEVEL,
5835 set_value, DBG_CMD);
5836 break;
5837 }
5838
5839 case WE_DBGLOG_VAP_ENABLE:
5840 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005841 hdd_notice("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005842 ret = wma_cli_set_command(pAdapter->sessionId,
5843 WMI_DBGLOG_VAP_ENABLE,
5844 set_value, DBG_CMD);
5845 break;
5846 }
5847
5848 case WE_DBGLOG_VAP_DISABLE:
5849 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005850 hdd_notice("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005851 ret = wma_cli_set_command(pAdapter->sessionId,
5852 WMI_DBGLOG_VAP_DISABLE,
5853 set_value, DBG_CMD);
5854 break;
5855 }
5856
5857 case WE_DBGLOG_MODULE_ENABLE:
5858 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005859 hdd_notice("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005860 set_value);
5861 hdd_ctx->fw_log_settings.enable = set_value;
5862 ret = wma_cli_set_command(pAdapter->sessionId,
5863 WMI_DBGLOG_MODULE_ENABLE,
5864 set_value, DBG_CMD);
5865 break;
5866 }
5867
5868 case WE_DBGLOG_MODULE_DISABLE:
5869 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005870 hdd_notice("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005871 set_value);
5872 hdd_ctx->fw_log_settings.enable = set_value;
5873 ret = wma_cli_set_command(pAdapter->sessionId,
5874 WMI_DBGLOG_MODULE_DISABLE,
5875 set_value, DBG_CMD);
5876 break;
5877 }
5878 case WE_DBGLOG_MOD_LOG_LEVEL:
5879 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005880 hdd_notice("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005881 set_value);
5882
5883 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
5884 hdd_ctx->fw_log_settings.index = 0;
5885
5886 hdd_ctx->fw_log_settings.
5887 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
5888 set_value;
5889 hdd_ctx->fw_log_settings.index++;
5890
5891 ret = wma_cli_set_command(pAdapter->sessionId,
5892 WMI_DBGLOG_MOD_LOG_LEVEL,
5893 set_value, DBG_CMD);
5894 break;
5895 }
5896
5897 case WE_DBGLOG_TYPE:
5898 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005899 hdd_notice("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005900 hdd_ctx->fw_log_settings.dl_type = set_value;
5901 ret = wma_cli_set_command(pAdapter->sessionId,
5902 WMI_DBGLOG_TYPE,
5903 set_value, DBG_CMD);
5904 break;
5905 }
5906 case WE_DBGLOG_REPORT_ENABLE:
5907 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005908 hdd_notice("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005909 set_value);
5910 hdd_ctx->fw_log_settings.dl_report = set_value;
5911 ret = wma_cli_set_command(pAdapter->sessionId,
5912 WMI_DBGLOG_REPORT_ENABLE,
5913 set_value, DBG_CMD);
5914 break;
5915 }
5916
5917 case WE_SET_TXRX_FWSTATS:
5918 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005919 hdd_notice("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005920 ret = wma_cli_set_command(pAdapter->sessionId,
5921 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
5922 set_value, VDEV_CMD);
5923 break;
5924 }
5925
5926 case WE_TXRX_FWSTATS_RESET:
5927 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005928 hdd_notice("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005929 ret = wma_cli_set_command(pAdapter->sessionId,
5930 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
5931 set_value, VDEV_CMD);
5932 break;
5933 }
5934
5935 case WE_DUMP_STATS:
5936 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005937 hdd_notice("WE_DUMP_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938 hdd_wlan_dump_stats(pAdapter, set_value);
5939 break;
5940 }
5941
5942 case WE_CLEAR_STATS:
5943 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005944 hdd_notice("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005945 switch (set_value) {
5946 case WLAN_HDD_STATS:
5947 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5948 memset(&pAdapter->hdd_stats, 0,
5949 sizeof(pAdapter->hdd_stats));
5950 break;
5951 case WLAN_TXRX_HIST_STATS:
5952 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
5953 break;
5954 case WLAN_HDD_NETIF_OPER_HISTORY:
5955 wlan_hdd_clear_netif_queue_history(hdd_ctx);
5956 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05305957 case WLAN_HIF_STATS:
5958 hdd_clear_hif_stats();
5959 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005960 default:
Leo Changfdb45c32016-10-28 11:09:23 -07005961 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
5962 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005963 }
5964 break;
5965 }
5966
5967 case WE_PPS_PAID_MATCH:
5968 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005969 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005970 return EINVAL;
5971
Jeff Johnson99bac312016-06-28 10:38:18 -07005972 hdd_notice("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005973 set_value);
5974 ret = wma_cli_set_command(pAdapter->sessionId,
5975 WMI_VDEV_PPS_PAID_MATCH,
5976 set_value, PPS_CMD);
5977 break;
5978 }
5979
5980 case WE_PPS_GID_MATCH:
5981 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005982 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005983 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07005984 hdd_notice("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005985 set_value);
5986 ret = wma_cli_set_command(pAdapter->sessionId,
5987 WMI_VDEV_PPS_GID_MATCH,
5988 set_value, PPS_CMD);
5989 break;
5990 }
5991
5992 case WE_PPS_EARLY_TIM_CLEAR:
5993 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005994 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07005996 hdd_notice(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005997 set_value);
5998 ret = wma_cli_set_command(pAdapter->sessionId,
5999 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6000 set_value, PPS_CMD);
6001 break;
6002 }
6003
6004 case WE_PPS_EARLY_DTIM_CLEAR:
6005 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006006 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006008 hdd_notice("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006009 set_value);
6010 ret = wma_cli_set_command(pAdapter->sessionId,
6011 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6012 set_value, PPS_CMD);
6013 break;
6014 }
6015
6016 case WE_PPS_EOF_PAD_DELIM:
6017 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006018 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006019 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006020 hdd_notice("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006021 set_value);
6022 ret = wma_cli_set_command(pAdapter->sessionId,
6023 WMI_VDEV_PPS_EOF_PAD_DELIM,
6024 set_value, PPS_CMD);
6025 break;
6026 }
6027
6028 case WE_PPS_MACADDR_MISMATCH:
6029 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006030 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006031 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006032 hdd_notice("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006033 set_value);
6034 ret = wma_cli_set_command(pAdapter->sessionId,
6035 WMI_VDEV_PPS_MACADDR_MISMATCH,
6036 set_value, PPS_CMD);
6037 break;
6038 }
6039
6040 case WE_PPS_DELIM_CRC_FAIL:
6041 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006042 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006043 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006044 hdd_notice("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045 set_value);
6046 ret = wma_cli_set_command(pAdapter->sessionId,
6047 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6048 set_value, PPS_CMD);
6049 break;
6050 }
6051
6052 case WE_PPS_GID_NSTS_ZERO:
6053 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006054 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006055 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006056 hdd_notice("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006057 set_value);
6058 ret = wma_cli_set_command(pAdapter->sessionId,
6059 WMI_VDEV_PPS_GID_NSTS_ZERO,
6060 set_value, PPS_CMD);
6061 break;
6062 }
6063
6064 case WE_PPS_RSSI_CHECK:
6065 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006066 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006067 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006068 hdd_notice("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006069 set_value);
6070 ret = wma_cli_set_command(pAdapter->sessionId,
6071 WMI_VDEV_PPS_RSSI_CHECK,
6072 set_value, PPS_CMD);
6073 break;
6074 }
6075
6076 case WE_PPS_5G_EBT:
6077 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006078 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006079 return -EINVAL;
6080
Jeff Johnson99bac312016-06-28 10:38:18 -07006081 hdd_notice("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006082 ret = wma_cli_set_command(pAdapter->sessionId,
6083 WMI_VDEV_PPS_5G_EBT,
6084 set_value, PPS_CMD);
6085 break;
6086 }
6087
6088 case WE_SET_HTSMPS:
6089 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006090 hdd_notice("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091 ret = wma_cli_set_command(pAdapter->sessionId,
6092 WMI_STA_SMPS_FORCE_MODE_CMDID,
6093 set_value, VDEV_CMD);
6094 break;
6095 }
6096
6097 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
6098 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006099 hdd_notice("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006100 set_value);
6101 ret = wma_cli_set_command(pAdapter->sessionId,
6102 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6103 set_value, QPOWER_CMD);
6104 break;
6105 }
6106
6107 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
6108 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006109 hdd_notice("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110 set_value);
6111 ret = wma_cli_set_command(
6112 pAdapter->sessionId,
6113 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6114 set_value, QPOWER_CMD);
6115 break;
6116 }
6117
6118 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6119 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006120 hdd_notice("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006121 set_value);
6122 ret = wma_cli_set_command(
6123 pAdapter->sessionId,
6124 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6125 set_value, QPOWER_CMD);
6126 break;
6127 }
6128
6129 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6130 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006131 hdd_notice("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006132 set_value);
6133 ret = wma_cli_set_command(
6134 pAdapter->sessionId,
6135 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6136 set_value, QPOWER_CMD);
6137 break;
6138 }
6139
6140 case WE_MCC_CONFIG_LATENCY:
6141 {
6142 cds_set_mcc_latency(pAdapter, set_value);
6143 break;
6144 }
6145
6146 case WE_MCC_CONFIG_QUOTA:
6147 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006148 hdd_notice("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006149 set_value);
6150 ret = cds_set_mcc_p2p_quota(pAdapter, set_value);
6151 break;
6152 }
6153 case WE_SET_DEBUG_LOG:
6154 {
6155 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05306156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157 hdd_ctx->config->gEnableDebugLog = set_value;
6158 sme_update_connect_debug(hdd_ctx->hHal, set_value);
6159 break;
6160 }
6161 case WE_SET_EARLY_RX_ADJUST_ENABLE:
6162 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006163 hdd_notice("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006164 if ((set_value == 0) || (set_value == 1))
6165 ret = wma_cli_set_command(
6166 pAdapter->sessionId,
6167 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
6168 set_value, VDEV_CMD);
6169 else
6170 ret = -EINVAL;
6171 break;
6172 }
6173 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
6174 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006175 hdd_notice("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006176 ret = wma_cli_set_command(pAdapter->sessionId,
6177 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
6178 set_value, VDEV_CMD);
6179 break;
6180 }
6181 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
6182 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006183 hdd_notice("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006184 set_value);
6185 ret = wma_cli_set_command(
6186 pAdapter->sessionId,
6187 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
6188 set_value, VDEV_CMD);
6189 break;
6190 }
6191 case WE_SET_EARLY_RX_SLOP_STEP:
6192 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006193 hdd_notice("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006194 set_value);
6195 ret = wma_cli_set_command(pAdapter->sessionId,
6196 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
6197 set_value, VDEV_CMD);
6198 break;
6199 }
6200 case WE_SET_EARLY_RX_INIT_SLOP:
6201 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006202 hdd_notice("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006203 set_value);
6204 ret = wma_cli_set_command(pAdapter->sessionId,
6205 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
6206 set_value, VDEV_CMD);
6207 break;
6208 }
6209 case WE_SET_EARLY_RX_ADJUST_PAUSE:
6210 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006211 hdd_notice("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006212 if ((set_value == 0) || (set_value == 1))
6213 ret = wma_cli_set_command(
6214 pAdapter->sessionId,
6215 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
6216 set_value, VDEV_CMD);
6217 else
6218 ret = -EINVAL;
6219 break;
6220 }
6221 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
6222 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006223 hdd_notice("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006224 ret = wma_cli_set_command(pAdapter->sessionId,
6225 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
6226 set_value, VDEV_CMD);
6227 break;
6228 }
6229 case WE_SET_SCAN_DISABLE:
6230 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006231 hdd_notice("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006232 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
6233 break;
6234 }
Govind Singha471e5e2015-10-12 17:11:14 +05306235 case WE_START_FW_PROFILE:
6236 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006237 hdd_notice("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05306238 ret = wma_cli_set_command(pAdapter->sessionId,
6239 WMI_WLAN_PROFILE_TRIGGER_CMDID,
6240 set_value, DBG_CMD);
6241 break;
6242 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306243 case WE_SET_CHANNEL:
6244 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006245 hdd_notice("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306246 pAdapter->sessionId, pAdapter->device_mode);
6247
Krunal Sonif07bb382016-03-10 13:02:11 -08006248 if ((QDF_STA_MODE == pAdapter->device_mode) ||
6249 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306250
6251 status = sme_ext_change_channel(hHal,
6252 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306253 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006254 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306255 status);
6256 ret = -EINVAL;
6257 }
6258 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006259 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306260 pAdapter->device_mode);
6261 ret = -EINVAL;
6262 }
6263 break;
6264 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306265 case WE_SET_CONC_SYSTEM_PREF:
6266 {
6267 hdd_info("New preference: %d", set_value);
6268 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
6269 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
6270 hdd_err("Invalid system preference %d", set_value);
6271 return -EINVAL;
6272 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306273
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306274 /* hdd_ctx, hdd_ctx->config are already checked for null */
6275 hdd_ctx->config->conc_system_pref = set_value;
6276 break;
6277 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006278 default:
6279 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006280 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006281 sub_cmd);
6282 ret = -EINVAL;
6283 break;
6284 }
6285 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306286 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006287 return ret;
6288}
6289
6290static int iw_setint_getnone(struct net_device *dev,
6291 struct iw_request_info *info,
6292 union iwreq_data *wrqu,
6293 char *extra)
6294{
6295 int ret;
6296
6297 cds_ssr_protect(__func__);
6298 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6299 cds_ssr_unprotect(__func__);
6300
6301 return ret;
6302}
6303
6304/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006305 * __iw_setnone_get_threeint() - return three value to up layer.
6306 *
6307 * @dev: pointer of net_device of this wireless card
6308 * @info: meta data about Request sent
6309 * @wrqu: include request info
6310 * @extra: buf used for in/Output
6311 *
6312 * Return: execute result
6313 */
6314static int __iw_setnone_get_threeint(struct net_device *dev,
6315 struct iw_request_info *info,
6316 union iwreq_data *wrqu, char *extra)
6317{
6318 int ret = 0; /* success */
6319 uint32_t *value = (int *)extra;
6320 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6321 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6322
6323 ENTER_DEV(dev);
6324 ret = wlan_hdd_validate_context(hdd_ctx);
6325 if (0 != ret)
6326 return ret;
6327
Jeff Johnson99bac312016-06-28 10:38:18 -07006328 hdd_info("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006329 switch (value[0]) {
6330 case WE_GET_TSF:
6331 ret = hdd_indicate_tsf(adapter, value, 3);
6332 break;
6333 default:
6334 hdd_err("Invalid IOCTL get_value command %d", value[0]);
6335 break;
6336 }
6337 return ret;
6338}
6339
6340/**
6341 * iw_setnone_get_threeint() - return three value to up layer.
6342 *
6343 * @dev: pointer of net_device of this wireless card
6344 * @info: meta data about Request sent
6345 * @wrqu: include request info
6346 * @extra: buf used for in/Output
6347 *
6348 * Return: execute result
6349 */
6350static int iw_setnone_get_threeint(struct net_device *dev,
6351 struct iw_request_info *info,
6352 union iwreq_data *wrqu, char *extra)
6353{
6354 int ret;
6355
6356 cds_ssr_protect(__func__);
6357 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
6358 cds_ssr_unprotect(__func__);
6359
6360 return ret;
6361}
6362
6363/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006364 * iw_setchar_getnone() - Generic "set string" private ioctl handler
6365 * @dev: device upon which the ioctl was received
6366 * @info: ioctl request information
6367 * @wrqu: ioctl request data
6368 * @extra: ioctl extra data
6369 *
6370 * Return: 0 on success, non-zero on error
6371 */
6372static int __iw_setchar_getnone(struct net_device *dev,
6373 struct iw_request_info *info,
6374 union iwreq_data *wrqu, char *extra)
6375{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306376 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006377 int sub_cmd;
6378 int ret;
6379 char *pBuffer = NULL;
6380 hdd_adapter_t *pAdapter = (netdev_priv(dev));
6381 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006382 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006383 struct iw_point s_priv_data;
6384
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006385 ENTER_DEV(dev);
6386
Mukul Sharma34777c62015-11-02 20:22:30 +05306387 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006388 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05306389 return -EPERM;
6390 }
6391
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006392 ret = wlan_hdd_validate_context(hdd_ctx);
6393 if (0 != ret)
6394 return ret;
6395
6396 /* helper function to get iwreq_data with compat handling. */
6397 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
6398 return -EINVAL;
6399 }
6400
6401 /* make sure all params are correctly passed to function */
6402 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
6403 return -EINVAL;
6404 }
6405
6406 sub_cmd = s_priv_data.flags;
6407
6408 /* ODD number is used for set, copy data using copy_from_user */
6409 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6410 s_priv_data.length);
6411 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006412 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006413 return -ENOMEM;
6414 }
6415
Jeff Johnson99bac312016-06-28 10:38:18 -07006416 hdd_notice("Received length %d", s_priv_data.length);
6417 hdd_notice("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006418
6419 switch (sub_cmd) {
6420 case WE_WOWL_ADD_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006421 hdd_notice("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006422 hdd_add_wowl_ptrn(pAdapter, pBuffer);
6423 break;
6424 case WE_WOWL_DEL_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006425 hdd_notice("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006426 hdd_del_wowl_ptrn(pAdapter, pBuffer);
6427 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006428 case WE_NEIGHBOR_REPORT_REQUEST:
6429 {
6430 tRrmNeighborReq neighborReq;
6431 tRrmNeighborRspCallbackInfo callbackInfo;
6432
6433 if (pConfig->fRrmEnable) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006434 hdd_notice("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006435 neighborReq.no_ssid =
6436 (s_priv_data.length - 1) ? false : true;
6437 if (!neighborReq.no_ssid) {
6438 neighborReq.ssid.length =
6439 (s_priv_data.length - 1) >
6440 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306441 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006442 pBuffer,
6443 neighborReq.ssid.length);
6444 }
6445
6446 callbackInfo.neighborRspCallback = NULL;
6447 callbackInfo.neighborRspCallbackContext = NULL;
6448 callbackInfo.timeout = 5000; /* 5 seconds */
6449 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
6450 (pAdapter),
6451 pAdapter->sessionId,
6452 &neighborReq,
6453 &callbackInfo);
6454 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006455 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006456 ret = -EINVAL;
6457 }
6458 }
6459 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006460 case WE_SET_AP_WPS_IE:
Jeff Johnson99bac312016-06-28 10:38:18 -07006461 hdd_err("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006462 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
6463 s_priv_data.length);
6464 break;
6465 case WE_SET_CONFIG:
6466 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306467 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006468 ret = -EINVAL;
6469 }
6470 break;
6471 default:
6472 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006473 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006474 sub_cmd);
6475 ret = -EINVAL;
6476 break;
6477 }
6478 }
6479 kfree(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306480 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006481 return ret;
6482}
6483
6484static int iw_setchar_getnone(struct net_device *dev,
6485 struct iw_request_info *info,
6486 union iwreq_data *wrqu, char *extra)
6487{
6488 int ret;
6489
6490 cds_ssr_protect(__func__);
6491 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6492 cds_ssr_unprotect(__func__);
6493
6494 return ret;
6495}
6496
6497/**
6498 * iw_setnone_getint() - Generic "get integer" private ioctl handler
6499 * @dev: device upon which the ioctl was received
6500 * @info: ioctl request information
6501 * @wrqu: ioctl request data
6502 * @extra: ioctl extra data
6503 *
6504 * Return: 0 on success, non-zero on error
6505 */
6506static int __iw_setnone_getint(struct net_device *dev,
6507 struct iw_request_info *info,
6508 union iwreq_data *wrqu, char *extra)
6509{
6510 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6511 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6512 int *value = (int *)extra;
6513 int ret;
6514 tSmeConfigParams smeConfig;
6515 hdd_context_t *hdd_ctx;
6516
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006517 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306518
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006519 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6520 ret = wlan_hdd_validate_context(hdd_ctx);
6521 if (0 != ret)
6522 return ret;
6523
6524 switch (value[0]) {
6525 case WE_GET_11D_STATE:
6526 {
6527 sme_get_config_param(hHal, &smeConfig);
6528
6529 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6530
Jeff Johnson99bac312016-06-28 10:38:18 -07006531 hdd_notice("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006532
6533 break;
6534 }
6535
6536 case WE_IBSS_STATUS:
Jeff Johnson99bac312016-06-28 10:38:18 -07006537 hdd_notice("****Return IBSS Status*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006538 break;
6539
6540 case WE_GET_WLAN_DBG:
6541 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306542 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006543 *value = 0;
6544 break;
6545 }
6546 case WE_GET_MAX_ASSOC:
6547 {
6548 if (sme_cfg_get_int
6549 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306550 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006551 hdd_warn("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006552 ret = -EIO;
6553 }
6554 break;
6555 }
6556 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6557 *value = (WLAN_HDD_GET_CTX(
6558 pAdapter))->config->force_sap_acs;
6559 break;
6560
6561 case WE_GET_CONCURRENCY_MODE:
6562 {
6563 *value = cds_get_concurrency_mode();
6564
Jeff Johnson99bac312016-06-28 10:38:18 -07006565 hdd_notice("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006566 break;
6567 }
6568
6569 case WE_GET_NSS:
6570 {
6571 sme_get_config_param(hHal, &smeConfig);
6572 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Jeff Johnson99bac312016-06-28 10:38:18 -07006573 hdd_notice("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006574 break;
6575 }
6576
6577 case WE_GET_GTX_HT_MCS:
6578 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006579 hdd_notice("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006580 *value = wma_cli_get_command(pAdapter->sessionId,
6581 WMI_VDEV_PARAM_GTX_HT_MCS,
6582 GTX_CMD);
6583 break;
6584 }
6585
6586 case WE_GET_GTX_VHT_MCS:
6587 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006588 hdd_notice("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006589 *value = wma_cli_get_command(pAdapter->sessionId,
6590 WMI_VDEV_PARAM_GTX_VHT_MCS,
6591 GTX_CMD);
6592 break;
6593 }
6594
6595 case WE_GET_GTX_USRCFG:
6596 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006597 hdd_notice("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006598 *value = wma_cli_get_command(pAdapter->sessionId,
6599 WMI_VDEV_PARAM_GTX_USR_CFG,
6600 GTX_CMD);
6601 break;
6602 }
6603
6604 case WE_GET_GTX_THRE:
6605 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006606 hdd_notice("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006607 *value = wma_cli_get_command(pAdapter->sessionId,
6608 WMI_VDEV_PARAM_GTX_THRE,
6609 GTX_CMD);
6610 break;
6611 }
6612
6613 case WE_GET_GTX_MARGIN:
6614 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006615 hdd_notice("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006616 *value = wma_cli_get_command(pAdapter->sessionId,
6617 WMI_VDEV_PARAM_GTX_MARGIN,
6618 GTX_CMD);
6619 break;
6620 }
6621
6622 case WE_GET_GTX_STEP:
6623 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006624 hdd_notice("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006625 *value = wma_cli_get_command(pAdapter->sessionId,
6626 WMI_VDEV_PARAM_GTX_STEP,
6627 GTX_CMD);
6628 break;
6629 }
6630
6631 case WE_GET_GTX_MINTPC:
6632 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006633 hdd_notice("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006634 *value = wma_cli_get_command(pAdapter->sessionId,
6635 WMI_VDEV_PARAM_GTX_MINTPC,
6636 GTX_CMD);
6637 break;
6638 }
6639
6640 case WE_GET_GTX_BWMASK:
6641 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006642 hdd_notice("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006643 *value = wma_cli_get_command(pAdapter->sessionId,
6644 WMI_VDEV_PARAM_GTX_BW_MASK,
6645 GTX_CMD);
6646 break;
6647 }
6648
6649 case WE_GET_LDPC:
6650 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306651 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006652 break;
6653 }
6654
6655 case WE_GET_TX_STBC:
6656 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306657 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006658 break;
6659 }
6660
6661 case WE_GET_RX_STBC:
6662 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306663 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006664 break;
6665 }
6666
6667 case WE_GET_SHORT_GI:
6668 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006669 hdd_notice("GET WMI_VDEV_PARAM_SGI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006670 *value = sme_get_ht_config(hHal, pAdapter->sessionId,
6671 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ);
6672 break;
6673 }
6674
6675 case WE_GET_RTSCTS:
6676 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006677 hdd_notice("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006678 *value = wma_cli_get_command(pAdapter->sessionId,
6679 WMI_VDEV_PARAM_ENABLE_RTSCTS,
6680 VDEV_CMD);
6681 break;
6682 }
6683
6684 case WE_GET_CHWIDTH:
6685 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006686 hdd_notice("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006687 *value = wma_cli_get_command(pAdapter->sessionId,
6688 WMI_VDEV_PARAM_CHWIDTH,
6689 VDEV_CMD);
6690 break;
6691 }
6692
6693 case WE_GET_ANI_EN_DIS:
6694 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006695 hdd_notice("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006696 *value = wma_cli_get_command(pAdapter->sessionId,
6697 WMI_PDEV_PARAM_ANI_ENABLE,
6698 PDEV_CMD);
6699 break;
6700 }
6701
6702 case WE_GET_ANI_POLL_PERIOD:
6703 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006704 hdd_notice("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006705 *value = wma_cli_get_command(pAdapter->sessionId,
6706 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
6707 PDEV_CMD);
6708 break;
6709 }
6710
6711 case WE_GET_ANI_LISTEN_PERIOD:
6712 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006713 hdd_notice("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006714 *value = wma_cli_get_command(pAdapter->sessionId,
6715 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
6716 PDEV_CMD);
6717 break;
6718 }
6719
6720 case WE_GET_ANI_OFDM_LEVEL:
6721 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006722 hdd_notice("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006723 *value = wma_cli_get_command(pAdapter->sessionId,
6724 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
6725 PDEV_CMD);
6726 break;
6727 }
6728
6729 case WE_GET_ANI_CCK_LEVEL:
6730 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006731 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006732 *value = wma_cli_get_command(pAdapter->sessionId,
6733 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
6734 PDEV_CMD);
6735 break;
6736 }
6737
6738 case WE_GET_DYNAMIC_BW:
6739 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006740 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006741 *value = wma_cli_get_command(pAdapter->sessionId,
6742 WMI_PDEV_PARAM_DYNAMIC_BW,
6743 PDEV_CMD);
6744 break;
6745 }
6746
6747 case WE_GET_11N_RATE:
6748 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006749 hdd_notice("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006750 *value = wma_cli_get_command(pAdapter->sessionId,
6751 WMI_VDEV_PARAM_FIXED_RATE,
6752 VDEV_CMD);
6753 break;
6754 }
6755
6756 case WE_GET_AMPDU:
6757 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006758 hdd_notice("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006759 *value = wma_cli_get_command(pAdapter->sessionId,
6760 GEN_VDEV_PARAM_AMPDU,
6761 GEN_CMD);
6762 break;
6763 }
6764
6765 case WE_GET_AMSDU:
6766 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006767 hdd_notice("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006768 *value = wma_cli_get_command(pAdapter->sessionId,
6769 GEN_VDEV_PARAM_AMSDU,
6770 GEN_CMD);
6771 break;
6772 }
6773
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07006774 case WE_GET_ROAM_SYNCH_DELAY:
6775 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006776 hdd_notice("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07006777 *value = wma_cli_get_command(pAdapter->sessionId,
6778 GEN_VDEV_ROAM_SYNCH_DELAY,
6779 GEN_CMD);
6780 break;
6781 }
6782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006783 case WE_GET_BURST_ENABLE:
6784 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006785 hdd_notice("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006786 *value = wma_cli_get_command(pAdapter->sessionId,
6787 WMI_PDEV_PARAM_BURST_ENABLE,
6788 PDEV_CMD);
6789 break;
6790 }
6791 case WE_GET_BURST_DUR:
6792 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006793 hdd_notice("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006794 *value = wma_cli_get_command(pAdapter->sessionId,
6795 WMI_PDEV_PARAM_BURST_DUR,
6796 PDEV_CMD);
6797 break;
6798 }
6799
6800 case WE_GET_TX_CHAINMASK:
6801 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006802 hdd_notice("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006803 *value = wma_cli_get_command(pAdapter->sessionId,
6804 WMI_PDEV_PARAM_TX_CHAIN_MASK,
6805 PDEV_CMD);
6806 break;
6807 }
6808
6809 case WE_GET_RX_CHAINMASK:
6810 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006811 hdd_notice("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006812 *value = wma_cli_get_command(pAdapter->sessionId,
6813 WMI_PDEV_PARAM_RX_CHAIN_MASK,
6814 PDEV_CMD);
6815 break;
6816 }
6817
6818 case WE_GET_TXPOW_2G:
6819 {
6820 uint32_t txpow2g = 0;
6821 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07006822 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006823 *value = wma_cli_get_command(pAdapter->sessionId,
6824 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
6825 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306826 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006827 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6828 &txpow2g)) {
6829 return -EIO;
6830 }
Jeff Johnson99bac312016-06-28 10:38:18 -07006831 hdd_notice("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006832 break;
6833 }
6834
6835 case WE_GET_TXPOW_5G:
6836 {
6837 uint32_t txpow5g = 0;
6838 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07006839 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006840 *value = wma_cli_get_command(pAdapter->sessionId,
6841 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
6842 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306843 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006844 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6845 &txpow5g)) {
6846 return -EIO;
6847 }
Jeff Johnson99bac312016-06-28 10:38:18 -07006848 hdd_notice("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006849 break;
6850 }
6851
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006852 case WE_GET_PPS_PAID_MATCH:
6853 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006854 hdd_notice("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006855 *value = wma_cli_get_command(pAdapter->sessionId,
6856 WMI_VDEV_PPS_PAID_MATCH,
6857 PPS_CMD);
6858 break;
6859 }
6860
6861 case WE_GET_PPS_GID_MATCH:
6862 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006863 hdd_notice("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006864 *value = wma_cli_get_command(pAdapter->sessionId,
6865 WMI_VDEV_PPS_GID_MATCH,
6866 PPS_CMD);
6867 break;
6868 }
6869
6870 case WE_GET_PPS_EARLY_TIM_CLEAR:
6871 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006872 hdd_notice("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006873 *value = wma_cli_get_command(pAdapter->sessionId,
6874 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6875 PPS_CMD);
6876 break;
6877 }
6878
6879 case WE_GET_PPS_EARLY_DTIM_CLEAR:
6880 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006881 hdd_notice("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006882 *value = wma_cli_get_command(pAdapter->sessionId,
6883 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6884 PPS_CMD);
6885 break;
6886 }
6887
6888 case WE_GET_PPS_EOF_PAD_DELIM:
6889 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006890 hdd_notice("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006891 *value = wma_cli_get_command(pAdapter->sessionId,
6892 WMI_VDEV_PPS_EOF_PAD_DELIM,
6893 PPS_CMD);
6894 break;
6895 }
6896
6897 case WE_GET_PPS_MACADDR_MISMATCH:
6898 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006899 hdd_notice("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006900 *value = wma_cli_get_command(pAdapter->sessionId,
6901 WMI_VDEV_PPS_MACADDR_MISMATCH,
6902 PPS_CMD);
6903 break;
6904 }
6905
6906 case WE_GET_PPS_DELIM_CRC_FAIL:
6907 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006908 hdd_notice("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006909 *value = wma_cli_get_command(pAdapter->sessionId,
6910 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6911 PPS_CMD);
6912 break;
6913 }
6914
6915 case WE_GET_PPS_GID_NSTS_ZERO:
6916 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006917 hdd_notice("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006918 *value = wma_cli_get_command(pAdapter->sessionId,
6919 WMI_VDEV_PPS_GID_NSTS_ZERO,
6920 PPS_CMD);
6921 break;
6922 }
6923
6924 case WE_GET_PPS_RSSI_CHECK:
6925 {
6926
Jeff Johnson99bac312016-06-28 10:38:18 -07006927 hdd_notice("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006928 *value = wma_cli_get_command(pAdapter->sessionId,
6929 WMI_VDEV_PPS_RSSI_CHECK,
6930 PPS_CMD);
6931 break;
6932 }
6933
6934 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
6935 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006936 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006937 *value = wma_cli_get_command(pAdapter->sessionId,
6938 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6939 QPOWER_CMD);
6940 break;
6941 }
6942
6943 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
6944 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006945 hdd_notice("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006946 *value = wma_cli_get_command(pAdapter->sessionId,
6947 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6948 QPOWER_CMD);
6949 break;
6950 }
6951
6952 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6953 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006954 hdd_notice("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006955 *value = wma_cli_get_command(pAdapter->sessionId,
6956 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6957 QPOWER_CMD);
6958 break;
6959 }
6960
6961 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6962 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006963 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006964 *value = wma_cli_get_command(pAdapter->sessionId,
6965 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6966 QPOWER_CMD);
6967 break;
6968 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006969 case WE_CAP_TSF:
6970 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
6971 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006972 case WE_GET_TEMPERATURE:
6973 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006974 hdd_notice("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006975 ret = wlan_hdd_get_temperature(pAdapter, value);
6976 break;
6977 }
6978 default:
6979 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006980 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006981 value[0]);
6982 break;
6983 }
6984 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306985 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006986 return ret;
6987}
6988
6989static int iw_setnone_getint(struct net_device *dev,
6990 struct iw_request_info *info,
6991 union iwreq_data *wrqu, char *extra)
6992{
6993 int ret;
6994
6995 cds_ssr_protect(__func__);
6996 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6997 cds_ssr_unprotect(__func__);
6998
6999 return ret;
7000}
7001
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307002static int hdd_set_fwtest(int argc, int cmd, int value)
7003{
7004 struct set_fwtest_params *fw_test;
7005
7006 /* check for max number of arguments */
7007 if (argc > (WMA_MAX_NUM_ARGS) ||
7008 argc != HDD_FWTEST_PARAMS) {
7009 hdd_err("Too Many args %d", argc);
7010 return -EINVAL;
7011 }
7012 /*
7013 * check if number of arguments are 3 then, check
7014 * then set the default value for sounding interval.
7015 */
7016 if (HDD_FWTEST_PARAMS == argc) {
7017 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
7018 value = HDD_FWTEST_SU_DEFAULT_VALUE;
7019 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
7020 value = HDD_FWTEST_MU_DEFAULT_VALUE;
7021 }
7022 /* check sounding interval value should not exceed to max */
7023 if (value > HDD_FWTEST_MAX_VALUE) {
7024 hdd_err("Invalid arguments value should not exceed max: %d",
7025 value);
7026 return -EINVAL;
7027 }
7028 fw_test = qdf_mem_malloc(sizeof(*fw_test));
7029 if (NULL == fw_test) {
7030 hdd_err("qdf_mem_malloc failed for fw_test");
7031 return -ENOMEM;
7032 }
7033 fw_test->arg = cmd;
7034 fw_test->value = value;
7035 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
7036 qdf_mem_free(fw_test);
7037 hdd_err("Not able to post FW_TEST_CMD message to WMA");
7038 return -EINVAL;
7039 }
7040 return 0;
7041}
7042
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007043/**
7044 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
7045 * @dev: device upon which the ioctl was received
7046 * @info: ioctl request information
7047 * @wrqu: ioctl request data
7048 * @extra: ioctl extra data
7049 *
7050 * Return: 0 on success, non-zero on error
7051 */
7052static int __iw_set_three_ints_getnone(struct net_device *dev,
7053 struct iw_request_info *info,
7054 union iwreq_data *wrqu, char *extra)
7055{
7056 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7057 int *value = (int *)extra;
7058 int sub_cmd = value[0];
7059 int ret;
7060 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7061
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007062 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307063
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007064 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007065 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007066 return -EPERM;
7067 }
7068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007069 ret = wlan_hdd_validate_context(hdd_ctx);
7070 if (0 != ret)
7071 return ret;
7072
7073 switch (sub_cmd) {
7074
7075 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307076 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007077 break;
7078 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307079 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007080 break;
7081
7082 /* value[3] the acs band is not required as start and end channels are
7083 * enough but this cmd is maintained under set three ints for historic
7084 * reasons.
7085 */
7086 case WE_SET_SAP_CHANNELS:
7087 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307088 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007089 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307090 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007091 ret = -EINVAL;
7092 } else {
7093 hdd_ctx->config->force_sap_acs_st_ch = value[1];
7094 hdd_ctx->config->force_sap_acs_end_ch = value[2];
7095 }
7096 break;
7097 case WE_SET_DUAL_MAC_SCAN_CONFIG:
7098 hdd_debug("Ioctl to set dual mac scan config");
7099 if (hdd_ctx->config->dual_mac_feature_disable) {
7100 hdd_err("Dual mac feature is disabled from INI");
7101 return -EPERM;
7102 }
7103 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08007104 cds_set_dual_mac_scan_config(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007105 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307106 case WE_SET_FW_TEST:
7107 {
7108 ret = hdd_set_fwtest(value[1], value[2], value[3]);
7109 if (ret) {
7110 hdd_err("Not able to set fwtest %d", ret);
7111 return ret;
7112 }
7113 }
7114 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007115 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007116 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007117 break;
7118
7119 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307120 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007121 return ret;
7122}
7123
7124int iw_set_three_ints_getnone(struct net_device *dev,
7125 struct iw_request_info *info,
7126 union iwreq_data *wrqu, char *extra)
7127{
7128 int ret;
7129
7130 cds_ssr_protect(__func__);
7131 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7132 cds_ssr_unprotect(__func__);
7133
7134 return ret;
7135}
7136
7137/**
7138 * hdd_connection_state_string() - Get connection state string
7139 * @connection_state: enum to be converted to a string
7140 *
7141 * Return: the string equivalent of @connection_state
7142 */
7143static const char *
7144hdd_connection_state_string(eConnectionState connection_state)
7145{
7146 switch (connection_state) {
7147 CASE_RETURN_STRING(eConnectionState_NotConnected);
7148 CASE_RETURN_STRING(eConnectionState_Connecting);
7149 CASE_RETURN_STRING(eConnectionState_Associated);
7150 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
7151 CASE_RETURN_STRING(eConnectionState_IbssConnected);
7152 CASE_RETURN_STRING(eConnectionState_Disconnecting);
7153 default:
7154 return "UNKNOWN";
7155 }
7156}
7157
7158/**
7159 * iw_get_char_setnone() - Generic "get string" private ioctl handler
7160 * @dev: device upon which the ioctl was received
7161 * @info: ioctl request information
7162 * @wrqu: ioctl request data
7163 * @extra: ioctl extra data
7164 *
7165 * Return: 0 on success, non-zero on error
7166 */
7167static int __iw_get_char_setnone(struct net_device *dev,
7168 struct iw_request_info *info,
7169 union iwreq_data *wrqu, char *extra)
7170{
7171 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7172 int sub_cmd = wrqu->data.flags;
7173 hdd_context_t *hdd_ctx;
7174 int ret;
7175#ifdef WLAN_FEATURE_11W
7176 hdd_wext_state_t *pWextState;
7177#endif
7178
7179#ifdef WLAN_FEATURE_11W
7180 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7181#endif
7182
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007183 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307184
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007185 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7186 ret = wlan_hdd_validate_context(hdd_ctx);
7187 if (0 != ret)
7188 return ret;
7189
7190 switch (sub_cmd) {
7191 case WE_WLAN_VERSION:
7192 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05307193 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007194 break;
7195 }
7196
7197 case WE_GET_STATS:
7198 {
7199 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
7200 extra, WE_MAX_STR_LEN);
7201 break;
7202 }
7203
Govind Singha471e5e2015-10-12 17:11:14 +05307204 case WE_LIST_FW_PROFILE:
7205 hdd_wlan_list_fw_profile(&(wrqu->data.length),
7206 extra, WE_MAX_STR_LEN);
7207 break;
7208
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007209 /* The case prints the current state of the HDD, SME, CSR, PE,
7210 * TL it can be extended for WDI Global State as well. And
7211 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
7212 * and P2P_GO have not been added as of now.
7213 */
7214 case WE_GET_STATES:
7215 {
7216 int buf = 0, len = 0;
7217 int adapter_num = 0;
7218 int count = 0, check = 1;
7219
7220 tHalHandle hHal = NULL;
7221 tpAniSirGlobal pMac = NULL;
7222 hdd_station_ctx_t *pHddStaCtx = NULL;
7223
7224 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7225 hdd_adapter_t *useAdapter = NULL;
7226
7227 /* Print wlan0 or p2p0 states based on the adapter_num
7228 * by using the correct adapter
7229 */
7230 while (adapter_num < 2) {
7231 if (WLAN_ADAPTER == adapter_num) {
7232 useAdapter = pAdapter;
7233 buf =
7234 scnprintf(extra + len,
7235 WE_MAX_STR_LEN - len,
7236 "\n\n wlan0 States:-");
7237 len += buf;
7238 } else if (P2P_ADAPTER == adapter_num) {
7239 buf =
7240 scnprintf(extra + len,
7241 WE_MAX_STR_LEN - len,
7242 "\n\n p2p0 States:-");
7243 len += buf;
7244
7245 if (!pHddCtx) {
7246 buf =
7247 scnprintf(extra + len,
7248 WE_MAX_STR_LEN -
7249 len,
7250 "\n pHddCtx is NULL");
7251 len += buf;
7252 break;
7253 }
7254
7255 /* Printing p2p0 states only in the
7256 * case when the device is configured
7257 * as a p2p_client
7258 */
7259 useAdapter =
7260 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08007261 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007262 if (!useAdapter) {
7263 buf =
7264 scnprintf(extra + len,
7265 WE_MAX_STR_LEN -
7266 len,
7267 "\n Device not configured as P2P_CLIENT.");
7268 len += buf;
7269 break;
7270 }
7271 }
7272
7273 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
7274 if (!hHal) {
7275 buf =
7276 scnprintf(extra + len,
7277 WE_MAX_STR_LEN - len,
7278 "\n pMac is NULL");
7279 len += buf;
7280 break;
7281 }
7282 pMac = PMAC_STRUCT(hHal);
7283 if (!pMac) {
7284 buf =
7285 scnprintf(extra + len,
7286 WE_MAX_STR_LEN - len,
7287 "\n pMac is NULL");
7288 len += buf;
7289 break;
7290 }
7291 pHddStaCtx =
7292 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
7293
7294
7295 buf =
7296 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7297 "\n HDD Conn State - %s "
7298 "\n \n SME State:"
7299 "\n Neighbour Roam State - %s"
7300 "\n CSR State - %s"
7301 "\n CSR Substate - %s",
7302 hdd_connection_state_string
7303 (pHddStaCtx->conn_info.connState),
7304 mac_trace_get_neighbour_roam_state
7305 (sme_get_neighbor_roam_state
7306 (hHal, useAdapter->sessionId)),
7307 mac_trace_getcsr_roam_state
7308 (sme_get_current_roam_state
7309 (hHal, useAdapter->sessionId)),
7310 mac_trace_getcsr_roam_sub_state
7311 (sme_get_current_roam_sub_state
7312 (hHal, useAdapter->sessionId))
7313 );
7314 len += buf;
7315 adapter_num++;
7316 }
7317
Mukul Sharma81661ae2015-10-30 20:26:02 +05307318 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007319 /* Printing Lim State starting with global lim states */
7320 buf =
7321 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7322 "\n \n LIM STATES:-"
7323 "\n Global Sme State - %s "
7324 "\n Global mlm State - %s " "\n",
7325 mac_trace_get_lim_sme_state
7326 (sme_get_lim_sme_state(hHal)),
7327 mac_trace_get_lim_mlm_state
7328 (sme_get_lim_sme_state(hHal))
7329 );
7330 len += buf;
7331
7332 /* Printing the PE Sme and Mlm states for valid lim sessions */
7333 while (check < 3 && count < 255) {
7334 if (sme_is_lim_session_valid(hHal, count)) {
7335 buf =
7336 scnprintf(extra + len,
7337 WE_MAX_STR_LEN -
7338 len,
7339 "\n Lim Valid Session %d:-"
7340 "\n PE Sme State - %s "
7341 "\n PE Mlm State - %s "
7342 "\n", check,
7343 mac_trace_get_lim_sme_state
7344 (sme_get_lim_sme_session_state
7345 (hHal, count)),
7346 mac_trace_get_lim_mlm_state
7347 (sme_get_lim_mlm_session_state
7348 (hHal, count))
7349 );
7350
7351 len += buf;
7352 check++;
7353 }
7354 count++;
7355 }
7356 }
7357
7358 wrqu->data.length = strlen(extra) + 1;
7359 break;
7360 }
7361
7362 case WE_GET_CFG:
7363 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007364 hdd_notice("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007365 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
7366 extra,
7367 QCSAP_IOCTL_MAX_STR_LEN);
7368 wrqu->data.length = strlen(extra) + 1;
7369 break;
7370 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007371 case WE_GET_RSSI:
7372 {
7373 int8_t s7Rssi = 0;
7374 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7375 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7376 wrqu->data.length = strlen(extra) + 1;
7377 break;
7378 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007379
7380 case WE_GET_WMM_STATUS:
7381 {
7382 snprintf(extra, WE_MAX_STR_LEN,
7383 "\nDir: 0=up, 1=down, 3=both\n"
7384 "|------------------------|\n"
7385 "|AC | ACM |Admitted| Dir |\n"
7386 "|------------------------|\n"
7387 "|VO | %d | %3s | %d |\n"
7388 "|VI | %d | %3s | %d |\n"
7389 "|BE | %d | %3s | %d |\n"
7390 "|BK | %d | %3s | %d |\n"
7391 "|------------------------|\n",
7392 pAdapter->hddWmmStatus.
7393 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
7394 pAdapter->hddWmmStatus.
7395 wmmAcStatus[SME_AC_VO].
7396 wmmAcAccessAllowed ? "YES" : "NO",
7397 pAdapter->hddWmmStatus.
7398 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
7399 ts_info.direction,
7400 pAdapter->hddWmmStatus.
7401 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
7402 pAdapter->hddWmmStatus.
7403 wmmAcStatus[SME_AC_VI].
7404 wmmAcAccessAllowed ? "YES" : "NO",
7405 pAdapter->hddWmmStatus.
7406 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
7407 ts_info.direction,
7408 pAdapter->hddWmmStatus.
7409 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
7410 pAdapter->hddWmmStatus.
7411 wmmAcStatus[SME_AC_BE].
7412 wmmAcAccessAllowed ? "YES" : "NO",
7413 pAdapter->hddWmmStatus.
7414 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
7415 ts_info.direction,
7416 pAdapter->hddWmmStatus.
7417 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
7418 pAdapter->hddWmmStatus.
7419 wmmAcStatus[SME_AC_BK].
7420 wmmAcAccessAllowed ? "YES" : "NO",
7421 pAdapter->hddWmmStatus.
7422 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
7423 ts_info.direction);
7424
7425 wrqu->data.length = strlen(extra) + 1;
7426 break;
7427 }
7428 case WE_GET_CHANNEL_LIST:
7429 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307430 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007431 uint8_t i, len;
7432 char *buf;
7433 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
7434 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
7435 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7436
7437 tChannelListInfo channel_list;
7438
7439 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05307440 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007441 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307442 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007443 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007444 return -EINVAL;
7445 }
7446 buf = extra;
7447 /*
7448 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
7449 * Maximum buffer needed = 5 * number of channels.
7450 * Check ifsufficient buffer is available and then
7451 * proceed to fill the buffer.
7452 */
7453 if (WE_MAX_STR_LEN <
7454 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007455 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007456 return -EINVAL;
7457 }
7458 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7459 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307460 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007461 ubuf, &ubuf_len)) {
7462 /* Printing Country code in getChannelList */
7463 for (i = 0; i < (ubuf_len - 1); i++)
7464 len += scnprintf(buf + len,
7465 WE_MAX_STR_LEN - len,
7466 "%c", ubuf[i]);
7467 }
7468 for (i = 0; i < channel_list.num_channels; i++) {
7469 len +=
7470 scnprintf(buf + len, WE_MAX_STR_LEN - len,
7471 " %u", channel_list.channels[i]);
7472 }
7473 wrqu->data.length = strlen(extra) + 1;
7474
7475 break;
7476 }
7477#ifdef FEATURE_WLAN_TDLS
7478 case WE_GET_TDLS_PEERS:
7479 {
7480 wrqu->data.length =
7481 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
7482 WE_MAX_STR_LEN) + 1;
7483 break;
7484 }
7485#endif
7486#ifdef WLAN_FEATURE_11W
7487 case WE_GET_11W_INFO:
7488 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007489 hdd_err("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007490 pWextState->roamProfile.MFPEnabled);
7491
7492 snprintf(extra, WE_MAX_STR_LEN,
7493 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7494 "\n Number of Unprotected Disassocs %d"
7495 "\n Number of Unprotected Deauths %d",
7496 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
7497 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
7498 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
7499 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
7500 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
7501 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
7502 pWextState->roamProfile.MFPEnabled,
7503 pAdapter->hdd_stats.hddPmfStats.
7504 numUnprotDisassocRx,
7505 pAdapter->hdd_stats.hddPmfStats.
7506 numUnprotDeauthRx);
7507
7508 wrqu->data.length = strlen(extra) + 1;
7509 break;
7510 }
7511#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007512 case WE_GET_IBSS_STA_INFO:
7513 {
7514 hdd_station_ctx_t *pHddStaCtx =
7515 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7516 int idx = 0;
7517 int length = 0, buf = 0;
7518
Naveen Rawatc45d1622016-07-05 12:20:09 -07007519 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007520 if (0 != pHddStaCtx->conn_info.staId[idx]) {
7521 buf = snprintf
7522 ((extra + length),
7523 WE_MAX_STR_LEN - length,
7524 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7525 pHddStaCtx->conn_info.staId[idx],
7526 pHddStaCtx->conn_info.
7527 peerMacAddress[idx].bytes[0],
7528 pHddStaCtx->conn_info.
7529 peerMacAddress[idx].bytes[1],
7530 pHddStaCtx->conn_info.
7531 peerMacAddress[idx].bytes[2],
7532 pHddStaCtx->conn_info.
7533 peerMacAddress[idx].bytes[3],
7534 pHddStaCtx->conn_info.
7535 peerMacAddress[idx].bytes[4],
7536 pHddStaCtx->conn_info.
7537 peerMacAddress[idx].bytes[5]
7538 );
7539 length += buf;
7540 }
7541 }
7542 wrqu->data.length = strlen(extra) + 1;
7543 break;
7544 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007545 case WE_GET_PHYMODE:
7546 {
7547 bool ch_bond24 = false, ch_bond5g = false;
7548 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
7549 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7550 eCsrPhyMode phymode;
7551 eCsrBand currBand;
7552 tSmeConfigParams smeconfig;
7553
7554 sme_get_config_param(hal, &smeconfig);
7555 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7556 smeconfig.csrConfig.channelBondingMode24GHz)
7557 ch_bond24 = true;
7558
7559 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7560 smeconfig.csrConfig.channelBondingMode5GHz)
7561 ch_bond5g = true;
7562
7563 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307564 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007565 sme_get_freq_band(hal, &currBand))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007566 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007567 return -EIO;
7568 }
7569
7570 switch (phymode) {
7571 case eCSR_DOT11_MODE_AUTO:
7572 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
7573 break;
7574 case eCSR_DOT11_MODE_11n:
7575 case eCSR_DOT11_MODE_11n_ONLY:
7576 if (currBand == eCSR_BAND_24) {
7577 if (ch_bond24)
7578 snprintf(extra, WE_MAX_STR_LEN,
7579 "11NGHT40");
7580 else
7581 snprintf(extra, WE_MAX_STR_LEN,
7582 "11NGHT20");
7583 } else if (currBand == eCSR_BAND_5G) {
7584 if (ch_bond5g)
7585 snprintf(extra, WE_MAX_STR_LEN,
7586 "11NAHT40");
7587 else
7588 snprintf(extra, WE_MAX_STR_LEN,
7589 "11NAHT20");
7590 } else {
7591 snprintf(extra, WE_MAX_STR_LEN, "11N");
7592 }
7593 break;
7594 case eCSR_DOT11_MODE_abg:
7595 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
7596 break;
7597 case eCSR_DOT11_MODE_11a:
7598 snprintf(extra, WE_MAX_STR_LEN, "11A");
7599 break;
7600 case eCSR_DOT11_MODE_11b:
7601 case eCSR_DOT11_MODE_11b_ONLY:
7602 snprintf(extra, WE_MAX_STR_LEN, "11B");
7603 break;
7604 case eCSR_DOT11_MODE_11g:
7605 case eCSR_DOT11_MODE_11g_ONLY:
7606 snprintf(extra, WE_MAX_STR_LEN, "11G");
7607 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007608 case eCSR_DOT11_MODE_11ac:
7609 case eCSR_DOT11_MODE_11ac_ONLY:
7610 if (hddctx->config->vhtChannelWidth ==
7611 eHT_CHANNEL_WIDTH_20MHZ)
7612 snprintf(extra, WE_MAX_STR_LEN,
7613 "11ACVHT20");
7614 else if (hddctx->config->vhtChannelWidth ==
7615 eHT_CHANNEL_WIDTH_40MHZ)
7616 snprintf(extra, WE_MAX_STR_LEN,
7617 "11ACVHT40");
7618 else if (hddctx->config->vhtChannelWidth ==
7619 eHT_CHANNEL_WIDTH_80MHZ)
7620 snprintf(extra, WE_MAX_STR_LEN,
7621 "11ACVHT80");
7622 else if (hddctx->config->vhtChannelWidth ==
7623 eHT_CHANNEL_WIDTH_160MHZ)
7624 snprintf(extra, WE_MAX_STR_LEN,
7625 "11ACVHT160");
7626 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007627 }
7628
7629 wrqu->data.length = strlen(extra) + 1;
7630 break;
7631 }
7632
7633#ifdef FEATURE_OEM_DATA_SUPPORT
7634 case WE_GET_OEM_DATA_CAP:
7635 {
7636 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7637 }
7638#endif /* FEATURE_OEM_DATA_SUPPORT */
7639 case WE_GET_SNR:
7640 {
7641 int8_t s7snr = 0;
7642 int status = 0;
7643 hdd_context_t *pHddCtx;
7644 hdd_station_ctx_t *pHddStaCtx;
7645 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7646 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05307647 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007648 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05307649
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007650 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7651 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
7652 eConnectionState_Associated !=
7653 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007654 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007655 pHddCtx->config->fEnableSNRMonitoring,
7656 pHddStaCtx->conn_info.connState);
7657 return -ENONET;
7658 }
7659 wlan_hdd_get_snr(pAdapter, &s7snr);
7660 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
7661 wrqu->data.length = strlen(extra) + 1;
7662 break;
7663 }
7664 default:
7665 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007666 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007667 sub_cmd);
7668 break;
7669 }
7670 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307671 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007672 return 0;
7673}
7674
7675static int iw_get_char_setnone(struct net_device *dev,
7676 struct iw_request_info *info,
7677 union iwreq_data *wrqu, char *extra)
7678{
7679 int ret;
7680
7681 cds_ssr_protect(__func__);
7682 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7683 cds_ssr_unprotect(__func__);
7684
7685 return ret;
7686}
7687
7688/**
7689 * iw_setnone_getnone() - Generic "action" private ioctl handler
7690 * @dev: device upon which the ioctl was received
7691 * @info: ioctl request information
7692 * @wrqu: ioctl request data
7693 * @extra: ioctl extra data
7694 *
7695 * Return: 0 on success, non-zero on error
7696 */
7697static int __iw_setnone_getnone(struct net_device *dev,
7698 struct iw_request_info *info,
7699 union iwreq_data *wrqu, char *extra)
7700{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007701 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007702 hdd_context_t *hdd_ctx;
7703 int ret;
7704 int sub_cmd;
7705
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007706 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307707
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007708 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007709 ret = wlan_hdd_validate_context(hdd_ctx);
7710 if (0 != ret)
7711 return ret;
7712
7713#ifdef CONFIG_COMPAT
7714 /* this ioctl is a special case where a sub-ioctl is used and both
7715 * the number of get and set args is 0. in this specific case the
7716 * logic in iwpriv places the sub_cmd in the data.flags portion of
7717 * the iwreq. unfortunately the location of this field will be
7718 * different between 32-bit and 64-bit userspace, and the standard
7719 * compat support in the kernel does not handle this case. so we
7720 * need to explicitly handle it here.
7721 */
7722 if (is_compat_task()) {
7723 struct compat_iw_point *compat_iw_point =
7724 (struct compat_iw_point *)&wrqu->data;
7725 sub_cmd = compat_iw_point->flags;
7726 } else {
7727 sub_cmd = wrqu->data.flags;
7728 }
7729#else
7730 sub_cmd = wrqu->data.flags;
7731#endif
7732
7733 switch (sub_cmd) {
7734 case WE_GET_RECOVERY_STAT:
7735 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007736 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007737 sme_get_recovery_stats(hal);
7738 break;
7739 }
7740
Govind Singha471e5e2015-10-12 17:11:14 +05307741 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007742 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +05307743 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
7744 0, DBG_CMD);
7745 break;
7746
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007747 case WE_IBSS_GET_PEER_INFO_ALL:
7748 {
7749 hdd_wlan_get_ibss_peer_info_all(adapter);
7750 break;
7751 }
7752
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007753 case WE_SET_REASSOC_TRIGGER:
7754 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007755 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7756 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307757 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007758 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307759 uint8_t operating_ch =
7760 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007761 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007762
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007763 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007764 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307765 if (roaming_offload_enabled(hdd_ctx)) {
7766 qdf_mem_copy(bssid,
7767 &adapter->sessionCtx.station.conn_info.bssId,
7768 sizeof(bssid));
7769 hdd_wma_send_fastreassoc_cmd((int)adapter->sessionId,
7770 bssid, operating_ch);
7771 } else {
7772 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
7773 NULL, modProfileFields, &roamId, 1);
7774 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007775 return 0;
7776 }
7777
7778 case WE_DUMP_AGC_START:
7779 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007780 hdd_notice("WE_DUMP_AGC_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007781 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007782 GEN_PARAM_DUMP_AGC_START,
7783 0, GEN_CMD);
7784 break;
7785 }
7786 case WE_DUMP_AGC:
7787 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007788 hdd_notice("WE_DUMP_AGC");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007789 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007790 GEN_PARAM_DUMP_AGC,
7791 0, GEN_CMD);
7792 break;
7793 }
7794
7795 case WE_DUMP_CHANINFO_START:
7796 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007797 hdd_notice("WE_DUMP_CHANINFO_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007798 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007799 GEN_PARAM_DUMP_CHANINFO_START,
7800 0, GEN_CMD);
7801 break;
7802 }
7803 case WE_DUMP_CHANINFO:
7804 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007805 hdd_notice("WE_DUMP_CHANINFO_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007806 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007807 GEN_PARAM_DUMP_CHANINFO,
7808 0, GEN_CMD);
7809 break;
7810 }
7811 case WE_DUMP_WATCHDOG:
7812 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007813 hdd_notice("WE_DUMP_WATCHDOG");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007814 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007815 GEN_PARAM_DUMP_WATCHDOG,
7816 0, GEN_CMD);
7817 break;
7818 }
7819#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
7820 case WE_DUMP_PCIE_LOG:
7821 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007822 hdd_err("WE_DUMP_PCIE_LOG");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007823 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007824 GEN_PARAM_DUMP_PCIE_ACCESS_LOG,
7825 0, GEN_CMD);
7826 break;
7827 }
7828#endif
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007829 case WE_STOP_OBSS_SCAN:
7830 {
7831 /*
7832 * 1.OBSS Scan is mandatory while operating in 2.4GHz
7833 * 2.OBSS scan is stopped by Firmware during the disassociation
7834 * 3.OBSS stop comamnd is added for debugging purpose
7835 */
7836 tHalHandle hal;
7837
7838 hal = WLAN_HDD_GET_HAL_CTX(adapter);
7839 if (hal == NULL) {
7840 hdd_err("hal context is NULL");
7841 return -EINVAL;
7842 }
7843 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
7844 }
7845 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007846 default:
7847 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007848 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007849 break;
7850 }
7851 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307852 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007853 return ret;
7854}
7855
7856static int iw_setnone_getnone(struct net_device *dev,
7857 struct iw_request_info *info,
7858 union iwreq_data *wrqu, char *extra)
7859{
7860 int ret;
7861
7862 cds_ssr_protect(__func__);
7863 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7864 cds_ssr_unprotect(__func__);
7865
7866 return ret;
7867}
7868
7869/**
7870 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
7871 * @dev: device upon which the ioctl was received
7872 * @info: ioctl request information
7873 * @wrqu: ioctl request data
7874 * @extra: ioctl extra data
7875 *
7876 * This is an SSR-protected generic handler for private ioctls which
7877 * take multiple arguments. Note that this implementation is also
7878 * somewhat unique in that it is shared by both STA-mode and SAP-mode
7879 * interfaces.
7880 *
7881 * Return: 0 on success, non-zero on error
7882 */
7883static int __iw_set_var_ints_getnone(struct net_device *dev,
7884 struct iw_request_info *info,
7885 union iwreq_data *wrqu, char *extra)
7886{
7887 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7888 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7889 int sub_cmd;
7890 int *apps_args = (int *) extra;
7891 hdd_context_t *hdd_ctx;
7892 int ret, num_args;
7893
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007894 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007896 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7897 ret = wlan_hdd_validate_context(hdd_ctx);
7898 if (0 != ret)
7899 return ret;
7900
7901 if (extra == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007902 hdd_err("NULL extra buffer pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007903 return -EINVAL;
7904 }
7905
7906 sub_cmd = wrqu->data.flags;
7907 num_args = wrqu->data.length;
7908
Jeff Johnson99bac312016-06-28 10:38:18 -07007909 hdd_notice("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007910
7911 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007912 case WE_IBSS_GET_PEER_INFO:
7913 {
7914 pr_info("Station ID = %d\n", apps_args[0]);
7915 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7916 }
7917 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007918
7919 case WE_P2P_NOA_CMD:
7920 {
7921 p2p_app_setP2pPs_t p2pNoA;
7922
Krunal Sonif07bb382016-03-10 13:02:11 -08007923 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -08007924 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
7925 hdd_device_mode_to_string(
7926 pAdapter->device_mode),
7927 pAdapter->device_mode);
7928 return -EINVAL;
7929 }
7930
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007931 p2pNoA.opp_ps = apps_args[0];
7932 p2pNoA.ctWindow = apps_args[1];
7933 p2pNoA.duration = apps_args[2];
7934 p2pNoA.interval = apps_args[3];
7935 p2pNoA.count = apps_args[4];
7936 p2pNoA.single_noa_duration = apps_args[5];
7937 p2pNoA.psSelection = apps_args[6];
7938
Jeff Johnson99bac312016-06-28 10:38:18 -07007939 hdd_notice("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
7940 apps_args[0], apps_args[1], apps_args[2],
7941 apps_args[3], apps_args[4],
7942 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007943
7944 hdd_set_p2p_ps(dev, &p2pNoA);
7945
7946 }
7947 break;
7948
7949 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7950 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007951 hdd_notice("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7952 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307953 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007954 }
7955 break;
7956
7957 case WE_MTRACE_DUMP_CMD:
7958 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007959 hdd_notice("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
7960 apps_args[0], apps_args[1],
7961 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307962 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963 apps_args[1], apps_args[2],
7964 apps_args[3]);
7965
7966 }
7967 break;
7968
7969 case WE_POLICY_MANAGER_CLIST_CMD:
7970 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007971 hdd_err("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007972 cds_incr_connection_count_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007973 apps_args[1], apps_args[2], apps_args[3],
7974 apps_args[4], apps_args[5], apps_args[6],
7975 apps_args[7]);
7976 }
7977 break;
7978
7979 case WE_POLICY_MANAGER_DLIST_CMD:
7980 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007981 hdd_err("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007982 cds_decr_connection_count_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007983 apps_args[1]);
7984 }
7985 break;
7986
7987 case WE_POLICY_MANAGER_ULIST_CMD:
7988 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007989 hdd_err("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007990 cds_update_connection_info_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007991 apps_args[1], apps_args[2], apps_args[3],
7992 apps_args[4], apps_args[5], apps_args[6],
7993 apps_args[7]);
7994 }
7995 break;
7996
7997 case WE_POLICY_MANAGER_DBS_CMD:
7998 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007999 hdd_err("<iwpriv wlan0 pm_dbs> is called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008000 if (apps_args[0] == 0)
8001 wma_set_dbs_capability_ut(0);
8002 else
8003 wma_set_dbs_capability_ut(1);
8004
8005 if (apps_args[1] >= CDS_THROUGHPUT &&
8006 apps_args[1] <= CDS_LATENCY) {
8007 pr_info("setting system pref to [%d]\n", apps_args[1]);
8008 hdd_ctx->config->conc_system_pref = apps_args[1];
8009 }
8010 }
8011 break;
8012
8013 case WE_POLICY_MANAGER_PCL_CMD:
8014 {
Manishekar Chandrasekaran1db3abe2016-06-24 03:27:07 +05308015 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
8016 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008017 uint32_t pcl_len = 0, i = 0;
8018
Jeff Johnson99bac312016-06-28 10:38:18 -07008019 hdd_err("<iwpriv wlan0 pm_pcl> is called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008020
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008021 cds_get_pcl(apps_args[0],
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308022 pcl, &pcl_len,
8023 weight_list, QDF_ARRAY_SIZE(weight_list));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008024 pr_info("PCL list for role[%d] is {", apps_args[0]);
8025 for (i = 0 ; i < pcl_len; i++)
8026 pr_info(" %d, ", pcl[i]);
8027 pr_info("}--------->\n");
8028 }
8029 break;
8030
8031 case WE_POLICY_MANAGER_CINFO_CMD:
8032 {
8033 struct cds_conc_connection_info *conn_info;
8034 uint32_t i = 0, len = 0;
8035
Jeff Johnson99bac312016-06-28 10:38:18 -07008036 hdd_err("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008037 conn_info = cds_get_conn_info(&len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008038 pr_info("+-----------------------------+\n");
8039 for (i = 0; i < len; i++) {
8040 pr_info("|table_index[%d]\t\t|\n", i);
8041 pr_info("|\t|vdev_id - %d\t\t|\n", conn_info->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008042 pr_info("|\t|chan - %d\t\t|\n", conn_info->chan);
Tushnim Bhattacharyya7624a182016-03-30 13:30:46 -07008043 pr_info("|\t|bw - %d\t\t|\n", conn_info->bw);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008044 pr_info("|\t|mode - %d\t\t|\n", conn_info->mode);
8045 pr_info("|\t|mac - %d\t\t|\n", conn_info->mac);
8046 pr_info("|\t|in_use - %d\t\t|\n", conn_info->in_use);
8047 pr_info("+-----------------------------+\n");
8048 conn_info++;
8049 }
8050 }
8051 break;
8052
8053 case WE_POLICY_SET_HW_MODE_CMD:
8054 {
8055 if (apps_args[0] == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008056 hdd_err("set hw mode for single mac");
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308057 cds_pdev_set_hw_mode(
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308058 pAdapter->sessionId,
8059 HW_MODE_SS_2x2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008060 HW_MODE_80_MHZ,
8061 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
8062 HW_MODE_DBS_NONE,
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308063 HW_MODE_AGILE_DFS_NONE,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05308064 HW_MODE_SBS_NONE,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308065 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008066 } else if (apps_args[0] == 1) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008067 hdd_err("set hw mode for dual mac");
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308068 cds_pdev_set_hw_mode(
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308069 pAdapter->sessionId,
8070 HW_MODE_SS_1x1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008071 HW_MODE_80_MHZ,
8072 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
8073 HW_MODE_DBS,
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308074 HW_MODE_AGILE_DFS_NONE,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05308075 HW_MODE_SBS_NONE,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308076 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008077 }
8078 }
8079 break;
8080
8081 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8082 {
8083 enum cds_conc_next_action action;
Jeff Johnson99bac312016-06-28 10:38:18 -07008084 hdd_err("<iwpriv wlan0 pm_query_action> is called");
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308085 action = cds_current_connections_update(pAdapter->sessionId,
8086 apps_args[0],
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308087 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008088 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
8089 }
8090 break;
8091 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8092 {
8093 bool allow;
Jeff Johnson99bac312016-06-28 10:38:18 -07008094 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008095 allow = cds_allow_concurrency(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008096 apps_args[0], apps_args[1], apps_args[2]);
8097 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
8098 }
8099 break;
8100
8101 case WE_POLICY_MANAGER_SCENARIO_CMD:
8102 {
8103 clean_report(hdd_ctx);
8104 if (apps_args[0] == 1) {
8105 wlan_hdd_one_connection_scenario(hdd_ctx);
8106 } else if (apps_args[0] == 2) {
8107 wlan_hdd_two_connections_scenario(hdd_ctx,
8108 6, CDS_TWO_TWO);
8109 wlan_hdd_two_connections_scenario(hdd_ctx,
8110 36, CDS_TWO_TWO);
8111 wlan_hdd_two_connections_scenario(hdd_ctx,
8112 6, CDS_ONE_ONE);
8113 wlan_hdd_two_connections_scenario(hdd_ctx,
8114 36, CDS_ONE_ONE);
8115 } else if (apps_args[0] == 3) {
8116 /* MCC on same band with 2x2 same mac*/
8117 wlan_hdd_three_connections_scenario(hdd_ctx,
8118 6, 11, CDS_TWO_TWO, 0);
8119 /* MCC on diff band with 2x2 same mac*/
8120 wlan_hdd_three_connections_scenario(hdd_ctx,
8121 6, 36, CDS_TWO_TWO, 0);
8122 /* MCC on diff band with 1x1 diff mac */
8123 wlan_hdd_three_connections_scenario(hdd_ctx,
8124 36, 6, CDS_ONE_ONE, 0);
8125 /* MCC on diff band with 1x1 same mac */
8126 wlan_hdd_three_connections_scenario(hdd_ctx,
8127 36, 6, CDS_ONE_ONE, 1);
8128 /* SCC on same band with 2x2 same mac */
8129 wlan_hdd_three_connections_scenario(hdd_ctx,
8130 36, 36, CDS_TWO_TWO, 0);
8131 /* SCC on same band with 1x1 same mac */
8132 wlan_hdd_three_connections_scenario(hdd_ctx,
8133 36, 36, CDS_ONE_ONE, 1);
8134 /* MCC on same band with 2x2 same mac */
8135 wlan_hdd_three_connections_scenario(hdd_ctx,
8136 36, 149, CDS_TWO_TWO, 0);
8137 /* MCC on same band with 1x1 same mac */
8138 wlan_hdd_three_connections_scenario(hdd_ctx,
8139 36, 149, CDS_ONE_ONE, 1);
8140 }
8141 print_report(hdd_ctx);
8142 }
8143 break;
8144
8145#ifdef FEATURE_WLAN_TDLS
8146 case WE_TDLS_CONFIG_PARAMS:
8147 {
8148 tdls_config_params_t tdlsParams;
8149
8150 tdlsParams.tdls = apps_args[0];
8151 tdlsParams.tx_period_t = apps_args[1];
8152 tdlsParams.tx_packet_n = apps_args[2];
8153 /* ignore args[3] as discovery_period is not used anymore */
8154 tdlsParams.discovery_tries_n = apps_args[4];
8155 /* ignore args[5] as idle_timeout is not used anymore */
8156 tdlsParams.idle_packet_n = apps_args[6];
8157 /* ignore args[7] as rssi_hysteresis is not used anymore */
8158 tdlsParams.rssi_trigger_threshold = apps_args[8];
8159 tdlsParams.rssi_teardown_threshold = apps_args[9];
8160 tdlsParams.rssi_delta = apps_args[10];
8161
8162 wlan_hdd_tdls_set_params(dev, &tdlsParams);
8163 }
8164 break;
8165#endif
8166 case WE_UNIT_TEST_CMD:
8167 {
8168 t_wma_unit_test_cmd *unitTestArgs;
8169 cds_msg_t msg = { 0 };
8170 int i, j;
8171 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
8172 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008173 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008174 apps_args[0]);
8175 return -EINVAL;
8176 }
Anurag Chouhan77564182016-09-03 16:38:01 +05308177 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
8178 (apps_args[1] < 0)) {
8179 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008180 apps_args[1]);
8181 return -EINVAL;
8182 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308183 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008184 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008185 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008186 return -ENOMEM;
8187 }
8188 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
8189 unitTestArgs->module_id = apps_args[0];
8190 unitTestArgs->num_args = apps_args[1];
8191 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
8192 unitTestArgs->args[i] = apps_args[j];
8193 }
8194 msg.type = SIR_HAL_UNIT_TEST_CMD;
8195 msg.reserved = 0;
8196 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308197 if (QDF_STATUS_SUCCESS !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05308198 cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308199 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -07008200 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008201 return -EINVAL;
8202 }
8203 }
8204 break;
8205#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8206 case WE_LED_FLASHING_PARAM:
8207 {
8208 int i;
8209 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008210 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008211 return -EINVAL;
8212 }
8213 for (i = 0; i < num_args; i++) {
8214 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008215 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008216 return -EINVAL;
8217 }
8218 }
8219 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8220 0, apps_args[0], apps_args[1]);
8221 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8222 1, apps_args[2], apps_args[3]);
8223 }
8224 break;
8225#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05308226 case WE_SET_PKTLOG:
8227 {
8228 int ret;
8229
8230 if (num_args < 1 || num_args > 2) {
8231 hdd_err("pktlog: either 1 or 2 parameters are required");
8232 return -EINVAL;
8233 }
8234
8235 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
8236 apps_args[1]);
8237 if (ret)
8238 return ret;
8239 break;
8240 }
8241
Manjeet Singhf82ed072016-07-08 11:40:00 +05308242 case WE_MAC_PWR_DEBUG_CMD:
8243 {
8244 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
8245 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8246 int i, j;
8247
8248 if (num_args < 3) {
8249 hdd_err("number of arguments can't be null %d",
8250 num_args);
8251 return -EINVAL;
8252 }
8253 if (num_args - 3 != apps_args[2]) {
8254 hdd_err("arg list of size %d doesn't match num_args %d",
8255 num_args-3, apps_args[2]);
8256 return -EINVAL;
8257 }
8258 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
8259 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
8260 hdd_err("Invalid MODULE ID %d", apps_args[1]);
8261 return -EINVAL;
8262 }
8263 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
8264 hdd_err("Too Many args %d", apps_args[2]);
8265 return -EINVAL;
8266 }
8267 mac_pwr_dbg_args.pdev_id = apps_args[0];
8268 mac_pwr_dbg_args.module_id = apps_args[1];
8269 mac_pwr_dbg_args.num_args = apps_args[2];
8270
8271 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
8272 mac_pwr_dbg_args.args[i] = apps_args[j];
8273
8274 if (QDF_STATUS_SUCCESS !=
8275 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
8276 &mac_pwr_dbg_args)) {
8277 return -EINVAL;
8278 }
8279 }
8280 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008281 default:
8282 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008283 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008284 }
8285 break;
8286 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308287 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008288 return 0;
8289}
8290
8291/**
8292 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
8293 * @dev: pointer to net_device structure
8294 * @info: pointer to iw_request_info structure
8295 * @wrqu: pointer to iwreq_data
8296 * @extra; extra
8297 *
8298 * Return: 0 on success, error number otherwise
8299 *
8300 */
8301static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8302 struct iw_request_info *info,
8303 union iwreq_data *wrqu, char *extra)
8304{
8305 union iwreq_data u_priv_wrqu;
8306 int apps_args[MAX_VAR_ARGS] = {0};
8307 int ret, num_args;
8308
Mukul Sharma64a70e82015-11-02 20:05:09 +05308309 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008310 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +05308311 return -EPERM;
8312 }
8313
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008314 /* Helper function to get iwreq_data with compat handling. */
8315 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8316 return -EINVAL;
8317
8318 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008319 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008320 return -EINVAL;
8321 }
8322
8323 num_args = u_priv_wrqu.data.length;
8324 if (num_args > MAX_VAR_ARGS)
8325 num_args = MAX_VAR_ARGS;
8326
8327 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8328 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008329 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008330 return -EFAULT;
8331 }
8332
8333 cds_ssr_protect(__func__);
8334 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8335 (char *)&apps_args);
8336 cds_ssr_unprotect(__func__);
8337 return ret;
8338}
8339
8340/**
8341 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8342 * @dev: device upon which the ioctl was received
8343 * @info: ioctl request information
8344 * @wrqu: ioctl request data
8345 * @extra: ioctl extra data
8346 *
8347 * This is a generic handler for private ioctls which take multiple
8348 * arguments. Note that this implementation is also somewhat unique
8349 * in that it is shared by both STA-mode and SAP-mode interfaces.
8350 *
8351 * Return: 0 on success, non-zero on error
8352 */
8353int iw_set_var_ints_getnone(struct net_device *dev,
8354 struct iw_request_info *info,
8355 union iwreq_data *wrqu, char *extra)
8356{
8357 int ret;
8358
8359 cds_ssr_protect(__func__);
8360 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8361 cds_ssr_unprotect(__func__);
8362 return ret;
8363}
8364
8365/**
8366 * iw_add_tspec - Add TSpec private ioctl handler
8367 * @dev: device upon which the ioctl was received
8368 * @info: ioctl request information
8369 * @wrqu: ioctl request data
8370 * @extra: ioctl extra data
8371 *
8372 * Return: 0 on success, non-zero on error
8373 */
8374static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
8375 union iwreq_data *wrqu, char *extra)
8376{
8377 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8378 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8379 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8380 int params[HDD_WLAN_WMM_PARAM_COUNT];
8381 sme_QosWmmTspecInfo tSpec;
8382 uint32_t handle;
8383 struct iw_point s_priv_data;
8384 hdd_context_t *hdd_ctx;
8385 int ret;
8386
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008387 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308388
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008389 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8390 ret = wlan_hdd_validate_context(hdd_ctx);
8391 if (0 != ret)
8392 return ret;
8393
8394 /* make sure the application is sufficiently priviledged */
8395 /* note that the kernel will do this for "set" ioctls, but since */
8396 /* this ioctl wants to return status to user space it must be */
8397 /* defined as a "get" ioctl */
8398 if (!capable(CAP_NET_ADMIN)) {
8399 return -EPERM;
8400 }
8401
8402 /* we must be associated in order to add a tspec */
8403 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
8404 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8405 return 0;
8406 }
8407 /* since we are defined to be a "get" ioctl, and since the number */
8408 /* of params exceeds the number of params that wireless extensions */
8409 /* will pass down in the iwreq_data, we must copy the "set" params. */
8410 /* We must handle the compat for iwreq_data in 32U/64K environment. */
8411
8412 /* helper function to get iwreq_data with compat handling. */
8413 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8414 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8415 return 0;
8416 }
8417 /* make sure all params are correctly passed to function */
8418 if ((NULL == s_priv_data.pointer) ||
8419 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
8420 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8421 return 0;
8422 }
8423 /* from user space ourselves */
8424 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
8425 /* hmmm, can't get them */
8426 return -EIO;
8427 }
8428 /* clear the tspec */
8429 memset(&tSpec, 0, sizeof(tSpec));
8430
8431 /* validate the handle */
8432 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8433 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8434 /* that one is reserved */
8435 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8436 return 0;
8437 }
8438 /* validate the TID */
8439 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
8440 /* out of range */
8441 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8442 return 0;
8443 }
8444 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8445
8446 /* validate the direction */
8447 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
8448 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8449 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8450 break;
8451
8452 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8453 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8454 break;
8455
8456 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8457 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8458 break;
8459
8460 default:
8461 /* unknown */
8462 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8463 return 0;
8464 }
8465
8466 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8467
8468 /* validate the user priority */
8469 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
8470 /* out of range */
8471 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8472 return 0;
8473 }
8474 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
8475 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008476 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008477 return 0;
8478 }
8479
Jeff Johnson99bac312016-06-28 10:38:18 -07008480 hdd_info("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008481 tSpec.ts_info.psb, tSpec.ts_info.up);
8482
8483 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8484 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8485 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8486 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8487 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8488 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8489 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8490 tSpec.surplus_bw_allowance =
8491 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8492 tSpec.min_service_interval =
8493 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8494 tSpec.max_service_interval =
8495 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8496 tSpec.suspension_interval =
8497 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8498 tSpec.inactivity_interval =
8499 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8500
8501 tSpec.ts_info.burst_size_defn =
8502 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8503
8504 /* validate the ts info ack policy */
8505 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
8506 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8507 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8508 break;
8509
8510 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8511 tSpec.ts_info.ack_policy =
8512 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8513 break;
8514
8515 default:
8516 /* unknown */
8517 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8518 return 0;
8519 }
8520
8521 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308522 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008523 return 0;
8524}
8525
8526static int iw_add_tspec(struct net_device *dev,
8527 struct iw_request_info *info,
8528 union iwreq_data *wrqu, char *extra)
8529{
8530 int ret;
8531
8532 cds_ssr_protect(__func__);
8533 ret = __iw_add_tspec(dev, info, wrqu, extra);
8534 cds_ssr_unprotect(__func__);
8535
8536 return ret;
8537}
8538
8539/**
8540 * iw_del_tspec - Delete TSpec private ioctl handler
8541 * @dev: device upon which the ioctl was received
8542 * @info: ioctl request information
8543 * @wrqu: ioctl request data
8544 * @extra: ioctl extra data
8545 *
8546 * Return: 0 on success, non-zero on error
8547 */
8548static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
8549 union iwreq_data *wrqu, char *extra)
8550{
8551 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8552 hdd_context_t *hdd_ctx;
8553 int *params = (int *)extra;
8554 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8555 uint32_t handle;
8556 int ret;
8557
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008558 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308559
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008560 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8561 ret = wlan_hdd_validate_context(hdd_ctx);
8562 if (0 != ret)
8563 return ret;
8564
8565 /* make sure the application is sufficiently priviledged */
8566 /* note that the kernel will do this for "set" ioctls, but since */
8567 /* this ioctl wants to return status to user space it must be */
8568 /* defined as a "get" ioctl */
8569 if (!capable(CAP_NET_ADMIN)) {
8570 return -EPERM;
8571 }
8572
8573 /* although we are defined to be a "get" ioctl, the params we require */
8574 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
8575 /* is no need to copy the params from user space */
8576
8577 /* validate the handle */
8578 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8579 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8580 /* that one is reserved */
8581 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8582 return 0;
8583 }
8584
8585 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308586 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008587 return 0;
8588}
8589
8590static int iw_del_tspec(struct net_device *dev,
8591 struct iw_request_info *info,
8592 union iwreq_data *wrqu, char *extra)
8593{
8594 int ret;
8595
8596 cds_ssr_protect(__func__);
8597 ret = __iw_del_tspec(dev, info, wrqu, extra);
8598 cds_ssr_unprotect(__func__);
8599
8600 return ret;
8601}
8602
8603/**
8604 * iw_get_tspec - Get TSpec private ioctl handler
8605 * @dev: device upon which the ioctl was received
8606 * @info: ioctl request information
8607 * @wrqu: ioctl request data
8608 * @extra: ioctl extra data
8609 *
8610 * Return: 0 on success, non-zero on error
8611 */
8612static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
8613 union iwreq_data *wrqu, char *extra)
8614{
8615 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8616 hdd_context_t *hdd_ctx;
8617 int *params = (int *)extra;
8618 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8619 uint32_t handle;
8620 int ret;
8621
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008622 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308623
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008624 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8625 ret = wlan_hdd_validate_context(hdd_ctx);
8626 if (0 != ret)
8627 return ret;
8628
8629 /* although we are defined to be a "get" ioctl, the params we require */
8630 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
8631 /* is no need to copy the params from user space */
8632
8633 /* validate the handle */
8634 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8635 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8636 /* that one is reserved */
8637 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8638 return 0;
8639 }
8640
8641 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308642 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008643 return 0;
8644}
8645
8646static int iw_get_tspec(struct net_device *dev,
8647 struct iw_request_info *info,
8648 union iwreq_data *wrqu, char *extra)
8649{
8650 int ret;
8651
8652 cds_ssr_protect(__func__);
8653 ret = __iw_get_tspec(dev, info, wrqu, extra);
8654 cds_ssr_unprotect(__func__);
8655
8656 return ret;
8657}
8658
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008659/**
8660 * iw_set_fties - Set FT IEs private ioctl handler
8661 * @dev: device upon which the ioctl was received
8662 * @info: ioctl request information
8663 * @wrqu: ioctl request data
8664 * @extra: ioctl extra data
8665 *
8666 * Each time the supplicant has the auth_request or reassoc request
8667 * IEs ready they are pushed to the driver. The driver will in turn
8668 * use it to send out the auth req and reassoc req for 11r FT Assoc.
8669 *
8670 * Return: 0 on success, non-zero on error
8671 */
8672static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
8673 union iwreq_data *wrqu, char *extra)
8674{
8675 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8676 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8677 hdd_context_t *hdd_ctx;
8678 int ret;
8679
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008680 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308681
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008682 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8683 ret = wlan_hdd_validate_context(hdd_ctx);
8684 if (0 != ret)
8685 return ret;
8686
8687 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008688 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008689 return -EINVAL;
8690 }
8691 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008692 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008693 return -EINVAL;
8694 }
8695 /* Added for debug on reception of Re-assoc Req. */
8696 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008697 hdd_err("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008698 wrqu->data.length);
Jeff Johnson99bac312016-06-28 10:38:18 -07008699 hdd_err("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008700 }
Jeff Johnson99bac312016-06-28 10:38:18 -07008701 hdd_notice("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008702
8703 /* Pass the received FT IEs to SME */
8704 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
8705 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308706 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008707 return 0;
8708}
8709
8710static int iw_set_fties(struct net_device *dev,
8711 struct iw_request_info *info,
8712 union iwreq_data *wrqu, char *extra)
8713{
8714 int ret;
8715
8716 cds_ssr_protect(__func__);
8717 ret = __iw_set_fties(dev, info, wrqu, extra);
8718 cds_ssr_unprotect(__func__);
8719
8720 return ret;
8721}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008722
8723/**
8724 * iw_set_host_offload - Set host offload ioctl handler
8725 * @dev: device upon which the ioctl was received
8726 * @info: ioctl request information
8727 * @wrqu: ioctl request data
8728 * @extra: ioctl extra data
8729 *
8730 * Return: 0 on success, non-zero on error
8731 */
8732static int __iw_set_host_offload(struct net_device *dev,
8733 struct iw_request_info *info,
8734 union iwreq_data *wrqu, char *extra)
8735{
8736 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8737 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
8738 tSirHostOffloadReq offloadRequest;
8739 hdd_context_t *hdd_ctx;
8740 int ret;
8741
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008742 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308743
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008744 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8745 ret = wlan_hdd_validate_context(hdd_ctx);
8746 if (0 != ret)
8747 return ret;
8748
8749 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008750 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008751 return -EINVAL;
8752 }
8753
8754 /* Debug display of request components. */
8755 switch (pRequest->offloadType) {
8756 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07008757 hdd_warn("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008758 switch (pRequest->enableOrDisable) {
8759 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008760 hdd_warn(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008761 break;
8762 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008763 hdd_warn(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008764 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008765 hdd_warn(" ARP offload enable");
8766 hdd_warn(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008767 pRequest->params.hostIpv4Addr[0],
8768 pRequest->params.hostIpv4Addr[1],
8769 pRequest->params.hostIpv4Addr[2],
8770 pRequest->params.hostIpv4Addr[3]);
8771 }
8772 break;
8773
8774 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07008775 hdd_info("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008776 switch (pRequest->enableOrDisable) {
8777 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008778 hdd_info(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008779 break;
8780 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008781 hdd_info(" enable");
8782 hdd_info(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008783 *(uint16_t *) (pRequest->params.hostIpv6Addr),
8784 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8785 2),
8786 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8787 4),
8788 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8789 6),
8790 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8791 8),
8792 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8793 10),
8794 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8795 12),
8796 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8797 14));
8798 }
8799 }
8800
8801 /* Execute offload request. The reason that we can copy the
8802 * request information from the ioctl structure to the SME
8803 * structure is that they are laid out exactly the same.
8804 * Otherwise, each piece of information would have to be
8805 * copied individually.
8806 */
8807 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308808 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008809 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8810 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008811 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008812 return -EINVAL;
8813 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308814 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008815 return 0;
8816}
8817
8818static int iw_set_host_offload(struct net_device *dev,
8819 struct iw_request_info *info,
8820 union iwreq_data *wrqu, char *extra)
8821{
8822 int ret;
8823
8824 cds_ssr_protect(__func__);
8825 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8826 cds_ssr_unprotect(__func__);
8827
8828 return ret;
8829}
8830
8831/**
8832 * iw_set_keepalive_params - Set keepalive params ioctl handler
8833 * @dev: device upon which the ioctl was received
8834 * @info: ioctl request information
8835 * @wrqu: ioctl request data
8836 * @extra: ioctl extra data
8837 *
8838 * Return: 0 on success, non-zero on error
8839 */
8840static int __iw_set_keepalive_params(struct net_device *dev,
8841 struct iw_request_info *info,
8842 union iwreq_data *wrqu, char *extra)
8843{
8844 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008845 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008846 hdd_context_t *hdd_ctx;
8847 int ret;
8848
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008849 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308850
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008851 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8852 ret = wlan_hdd_validate_context(hdd_ctx);
8853 if (0 != ret)
8854 return ret;
8855
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008856 if (wrqu->data.length != sizeof(*request)) {
8857 hdd_err("Invalid length %d", wrqu->data.length);
8858 return -EINVAL;
8859 }
8860
8861 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
8862 hdd_err("Value of timePeriod %d exceed Max limit %d",
8863 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008864 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
8865 return -EINVAL;
8866 }
8867
8868 /* Debug display of request components. */
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008869 hdd_info("Set Keep Alive Request : TimePeriod %d size %zu",
8870 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008871
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008872 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008873 case WLAN_KEEP_ALIVE_NULL_PKT:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008874 hdd_info("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008875 break;
8876
8877 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008878 hdd_info("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008879
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008880 hdd_info("Host IP address: %d.%d.%d.%d",
8881 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
8882 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008883
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008884 hdd_info("Dest IP address: %d.%d.%d.%d",
8885 request->destIpv4Addr[0], request->destIpv4Addr[1],
8886 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008887
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08008888 hdd_info("Dest MAC address: "MAC_ADDRESS_STR,
8889 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008890 break;
8891 }
8892
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008893 hdd_info("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008894
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308895 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008896 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008897 pAdapter->sessionId, request)) {
8898 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008899 return -EINVAL;
8900 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308901 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008902 return 0;
8903}
8904
8905static int iw_set_keepalive_params(struct net_device *dev,
8906 struct iw_request_info *info,
8907 union iwreq_data *wrqu,
8908 char *extra)
8909{
8910 int ret;
8911
8912 cds_ssr_protect(__func__);
8913 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8914 cds_ssr_unprotect(__func__);
8915
8916 return ret;
8917}
8918
8919#ifdef WLAN_FEATURE_PACKET_FILTERING
8920/**
8921 * wlan_hdd_set_filter() - Set packet filter
8922 * @hdd_ctx: Global HDD context
8923 * @request: Packet filter request struct
8924 * @sessionId: Target session for the request
8925 *
8926 * Return: 0 on success, non-zero on error
8927 */
8928static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
8929 struct pkt_filter_cfg *request,
8930 uint8_t sessionId)
8931{
8932 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8933 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8934 int i = 0;
8935
8936 if (hdd_ctx->config->disablePacketFilter) {
8937 hdd_err("packet filtering disabled in ini returning");
8938 return 0;
8939 }
8940
8941 /* Debug display of request components. */
8942 hdd_info("Packet Filter Request : FA %d params %d",
8943 request->filter_action, request->num_params);
8944
8945 switch (request->filter_action) {
8946 case HDD_RCV_FILTER_SET:
8947 hdd_info("Set Packet Filter Request for Id: %d",
8948 request->filter_id);
8949
8950 packetFilterSetReq.filterId = request->filter_id;
8951 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
8952 hdd_err("Number of Params exceed Max limit %d",
8953 request->num_params);
8954 return -EINVAL;
8955 }
8956 packetFilterSetReq.numFieldParams = request->num_params;
8957 packetFilterSetReq.coalesceTime = 0;
8958 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8959 for (i = 0; i < request->num_params; i++) {
8960 packetFilterSetReq.paramsData[i].protocolLayer =
8961 request->params_data[i].protocol_layer;
8962 packetFilterSetReq.paramsData[i].cmpFlag =
8963 request->params_data[i].compare_flag;
8964 packetFilterSetReq.paramsData[i].dataOffset =
8965 request->params_data[i].data_offset;
8966 packetFilterSetReq.paramsData[i].dataLength =
8967 request->params_data[i].data_length;
8968 packetFilterSetReq.paramsData[i].reserved = 0;
8969
8970 if (request->params_data[i].data_length >
8971 SIR_MAX_FILTER_TEST_DATA_LEN) {
8972 hdd_err("Error invalid data length %d",
8973 request->params_data[i].data_length);
8974 return -EINVAL;
8975 }
8976
8977 hdd_info("Proto %d Comp Flag %d Filter Type %d",
8978 request->params_data[i].protocol_layer,
8979 request->params_data[i].compare_flag,
8980 packetFilterSetReq.filterType);
8981
8982 hdd_info("Data Offset %d Data Len %d",
8983 request->params_data[i].data_offset,
8984 request->params_data[i].data_length);
8985
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07008986 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
8987 < (request->params_data[i].data_length)) {
8988 hdd_err("Error invalid data length %d",
8989 request->params_data[i].data_length);
8990 return -EINVAL;
8991 }
8992
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008993 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8994 request->params_data[i].compare_data,
8995 request->params_data[i].data_length);
8996 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8997 request->params_data[i].data_mask,
8998 request->params_data[i].data_length);
8999
9000 hdd_info("CData %d CData %d CData %d CData %d CData %d CData %d",
9001 request->params_data[i].compare_data[0],
9002 request->params_data[i].compare_data[1],
9003 request->params_data[i].compare_data[2],
9004 request->params_data[i].compare_data[3],
9005 request->params_data[i].compare_data[4],
9006 request->params_data[i].compare_data[5]);
9007
9008 hdd_info("MData %d MData %d MData %d MData %d MData %d MData %d",
9009 request->params_data[i].data_mask[0],
9010 request->params_data[i].data_mask[1],
9011 request->params_data[i].data_mask[2],
9012 request->params_data[i].data_mask[3],
9013 request->params_data[i].data_mask[4],
9014 request->params_data[i].data_mask[5]);
9015 }
9016
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309017 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009018 sme_receive_filter_set_filter(hdd_ctx->hHal,
9019 &packetFilterSetReq,
9020 sessionId)) {
9021 hdd_err("Failure to execute Set Filter");
9022 return -EINVAL;
9023 }
9024
9025 break;
9026
9027 case HDD_RCV_FILTER_CLEAR:
9028
9029 hdd_info("Clear Packet Filter Request for Id: %d",
9030 request->filter_id);
9031 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309032 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009033 sme_receive_filter_clear_filter(hdd_ctx->hHal,
9034 &packetFilterClrReq,
9035 sessionId)) {
9036 hdd_err("Failure to execute Clear Filter");
9037 return -EINVAL;
9038 }
9039 break;
9040
9041 default:
9042 hdd_err("Packet Filter Request: Invalid %d",
9043 request->filter_action);
9044 return -EINVAL;
9045 }
9046 return 0;
9047}
9048
9049/**
9050 * __iw_set_packet_filter_params() - set packet filter parameters in target
9051 * @dev: Pointer to netdev
9052 * @info: Pointer to iw request info
9053 * @wrqu: Pointer to data
9054 * @extra: Pointer to extra data
9055 *
9056 * Return: 0 on success, non-zero on error
9057 */
9058static int __iw_set_packet_filter_params(struct net_device *dev,
9059 struct iw_request_info *info,
9060 union iwreq_data *wrqu, char *extra)
9061{
9062 int ret;
9063 hdd_context_t *hdd_ctx;
9064 struct iw_point priv_data;
9065 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9066 struct pkt_filter_cfg *request = NULL;
9067
Mukul Sharma472382f2015-11-02 20:16:31 +05309068 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009069 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +05309070 return -EPERM;
9071 }
9072
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009073 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309074
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009075 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9076 ret = wlan_hdd_validate_context(hdd_ctx);
9077 if (0 != ret)
9078 return ret;
9079
9080 if (hdd_priv_get_data(&priv_data, wrqu)) {
9081 hdd_err("failed to get priv data");
9082 return -EINVAL;
9083 }
9084
9085 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
9086 hdd_err("invalid priv data %p or invalid priv data length %d",
9087 priv_data.pointer, priv_data.length);
9088 return -EINVAL;
9089 }
9090
9091 /* copy data using copy_from_user */
9092 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
9093 priv_data.length);
9094 if (NULL == request) {
9095 hdd_err("mem_alloc_copy_from_user_helper fail");
9096 return -ENOMEM;
9097 }
9098
9099 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
9100
9101 kfree(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309102 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009103 return ret;
9104}
9105
9106/**
9107 * iw_set_packet_filter_params() - set packet filter parameters in target
9108 * @dev: Pointer to netdev
9109 * @info: Pointer to iw request info
9110 * @wrqu: Pointer to data
9111 * @extra: Pointer to extra data
9112 *
9113 * Return: 0 on success, non-zero on error
9114 */
9115static int iw_set_packet_filter_params(struct net_device *dev,
9116 struct iw_request_info *info,
9117 union iwreq_data *wrqu, char *extra)
9118{
9119 int ret;
9120
9121 cds_ssr_protect(__func__);
9122 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9123 cds_ssr_unprotect(__func__);
9124
9125 return ret;
9126}
9127#endif
9128
9129
9130static int __iw_get_statistics(struct net_device *dev,
9131 struct iw_request_info *info,
9132 union iwreq_data *wrqu, char *extra)
9133{
9134
Anurag Chouhance0dc992016-02-16 18:18:03 +05309135 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309136 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009137 hdd_wext_state_t *pWextState;
9138 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9139 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9140 char *p = extra;
9141 int tlen = 0;
9142 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
9143 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
9144 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
9145 int ret;
9146
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009147 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009148
9149 ret = wlan_hdd_validate_context(hdd_ctx);
9150 if (0 != ret)
9151 return ret;
9152
9153 if (eConnectionState_Associated !=
9154 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9155
9156 wrqu->txpower.value = 0;
9157 } else {
9158 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9159 SME_SUMMARY_STATS |
9160 SME_GLOBAL_CLASSA_STATS |
9161 SME_GLOBAL_CLASSB_STATS |
9162 SME_GLOBAL_CLASSC_STATS |
9163 SME_GLOBAL_CLASSD_STATS |
9164 SME_PER_STA_STATS,
9165 hdd_statistics_cb, 0, false,
9166 (WLAN_HDD_GET_STATION_CTX_PTR
9167 (pAdapter))->conn_info.staId[0],
9168 pAdapter, pAdapter->sessionId);
9169
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309170 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009171 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009172 return -EINVAL;
9173 }
9174
9175 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9176
Anurag Chouhance0dc992016-02-16 18:18:03 +05309177 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05309178 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009179 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +05309180 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009181 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009182 /*Remove the SME statistics list by passing NULL in callback argument */
9183 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9184 SME_SUMMARY_STATS |
9185 SME_GLOBAL_CLASSA_STATS |
9186 SME_GLOBAL_CLASSB_STATS |
9187 SME_GLOBAL_CLASSC_STATS |
9188 SME_GLOBAL_CLASSD_STATS |
9189 SME_PER_STA_STATS,
9190 NULL, 0, false,
9191 (WLAN_HDD_GET_STATION_CTX_PTR
9192 (pAdapter))->conn_info.
9193 staId[0], pAdapter,
9194 pAdapter->sessionId);
9195
9196 return -EINVAL;
9197 }
9198 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
9199 (uint8_t) sizeof(pStats->retry_cnt),
9200 (char *)&(pStats->retry_cnt[0]), tlen);
9201
9202 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
9203 (uint8_t) sizeof(pStats->multiple_retry_cnt),
9204 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
9205
9206 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
9207 (uint8_t) sizeof(pStats->tx_frm_cnt),
9208 (char *)&(pStats->tx_frm_cnt[0]), tlen);
9209
9210 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
9211 (uint8_t) sizeof(pStats->rx_frm_cnt),
9212 (char *)&(pStats->rx_frm_cnt), tlen);
9213
9214 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
9215 (uint8_t) sizeof(pStats->frm_dup_cnt),
9216 (char *)&(pStats->frm_dup_cnt), tlen);
9217
9218 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
9219 (uint8_t) sizeof(pStats->fail_cnt),
9220 (char *)&(pStats->fail_cnt[0]), tlen);
9221
9222 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
9223 (uint8_t) sizeof(pStats->rts_fail_cnt),
9224 (char *)&(pStats->rts_fail_cnt), tlen);
9225
9226 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
9227 (uint8_t) sizeof(pStats->ack_fail_cnt),
9228 (char *)&(pStats->ack_fail_cnt), tlen);
9229
9230 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
9231 (uint8_t) sizeof(pStats->rts_succ_cnt),
9232 (char *)&(pStats->rts_succ_cnt), tlen);
9233
9234 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
9235 (uint8_t) sizeof(pStats->rx_discard_cnt),
9236 (char *)&(pStats->rx_discard_cnt), tlen);
9237
9238 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
9239 (uint8_t) sizeof(pStats->rx_error_cnt),
9240 (char *)&(pStats->rx_error_cnt), tlen);
9241
9242 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
9243 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9244 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9245
9246 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
9247 (uint8_t) sizeof(dStats->rx_byte_cnt),
9248 (char *)&(dStats->rx_byte_cnt), tlen);
9249
9250 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
9251 (uint8_t) sizeof(dStats->rx_rate),
9252 (char *)&(dStats->rx_rate), tlen);
9253
9254 /* Transmit rate, in units of 500 kbit/sec */
9255 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
9256 (uint8_t) sizeof(aStats->tx_rate),
9257 (char *)&(aStats->tx_rate), tlen);
9258
9259 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
9260 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
9261 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
9262 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
9263 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
9264 (char *)&(dStats->rx_mc_byte_cnt), tlen);
9265 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
9266 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
9267 (char *)&(dStats->rx_bc_byte_cnt), tlen);
9268 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
9269 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9270 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9271 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
9272 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
9273 (char *)&(dStats->tx_mc_byte_cnt), tlen);
9274 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
9275 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
9276 (char *)&(dStats->tx_bc_byte_cnt), tlen);
9277
9278 wrqu->data.length = tlen;
9279
9280 }
9281
9282 EXIT();
9283
9284 return 0;
9285}
9286
9287static int iw_get_statistics(struct net_device *dev,
9288 struct iw_request_info *info,
9289 union iwreq_data *wrqu, char *extra)
9290{
9291 int ret;
9292
9293 cds_ssr_protect(__func__);
9294 ret = __iw_get_statistics(dev, info, wrqu, extra);
9295 cds_ssr_unprotect(__func__);
9296
9297 return ret;
9298}
9299
9300#ifdef FEATURE_WLAN_SCAN_PNO
9301
9302/*Max Len for PNO notification*/
9303#define MAX_PNO_NOTIFY_LEN 100
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07009304static void found_pref_network_cb(void *callbackContext,
9305 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009306{
9307 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
9308 union iwreq_data wrqu;
9309 char buf[MAX_PNO_NOTIFY_LEN + 1];
9310
Jeff Johnson99bac312016-06-28 10:38:18 -07009311 hdd_warn("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009312 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9313
9314 /* create the event */
9315 memset(&wrqu, 0, sizeof(wrqu));
9316 memset(buf, 0, sizeof(buf));
9317
9318 snprintf(buf, MAX_PNO_NOTIFY_LEN,
9319 "QCOM: Found preferred network: %s with RSSI of -%u",
9320 pPrefNetworkFoundInd->ssId.ssId,
9321 (unsigned int)pPrefNetworkFoundInd->rssi);
9322
9323 wrqu.data.pointer = buf;
9324 wrqu.data.length = strlen(buf);
9325
9326 /* send the event */
9327
9328 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9329
9330}
9331
9332/**
9333 * __iw_set_pno() - Preferred Network Offload ioctl handler
9334 * @dev: device upon which the ioctl was received
9335 * @info: ioctl request information
9336 * @wrqu: ioctl request data
9337 * @extra: ioctl extra data
9338 *
9339 * This function parses a Preferred Network Offload command
9340 * Input is string based and expected to be of the form:
9341 *
9342 * <enable(1) | disable(0)>
9343 * when enabling:
9344 * <number of networks>
9345 * for each network:
9346 * <ssid_len> <ssid> <authentication> <encryption>
9347 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -07009348 * <scan_time (seconds)>
9349 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009350 * <suspend mode>
9351 *
9352 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -07009353 * 1 2 4 test 0 0 3 1 6 11 2 40 5 test2 4 4 6 1 2 3 4 5 6 1 0 5 2 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009354 *
9355 * this translates into:
9356 * -----------------------------
9357 * enable PNO
9358 * 2 networks
9359 * Network 1:
9360 * test - with authentication type 0 and encryption type 0,
9361 * search on 3 channels: 1 6 and 11,
9362 * SSID bcast type is unknown (directed probe will be sent if
9363 * AP not found) and must meet -40dBm RSSI
9364 * Network 2:
9365 * test2 - with authentication type 4 and encryption type 4,
9366 * search on 6 channels 1, 2, 3, 4, 5 and 6
9367 * bcast type is non-bcast (directed probe will be sent)
9368 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009369 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -07009370 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009371 */
9372static int __iw_set_pno(struct net_device *dev,
9373 struct iw_request_info *info,
9374 union iwreq_data *wrqu, char *extra)
9375{
9376 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9377 hdd_context_t *hdd_ctx;
9378 int ret;
9379 int offset;
9380 char *ptr;
9381 uint8_t i, j, params, mode;
9382
9383 /* request is a large struct, so we make it static to avoid
9384 * stack overflow. This API is only invoked via ioctl, so it
9385 * is serialized by the kernel rtnl_lock and hence does not
9386 * need to be reentrant
9387 */
9388 static tSirPNOScanReq request;
9389
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009390 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009391
9392 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9393 ret = wlan_hdd_validate_context(hdd_ctx);
9394 if (ret)
9395 return ret;
9396
9397 hdd_notice("PNO data len %d data %s", wrqu->data.length, extra);
9398
9399 request.enable = 0;
9400 request.ucNetworksCount = 0;
9401
9402 ptr = extra;
9403
9404 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
9405 hdd_err("PNO enable input is not valid %s", ptr);
9406 return -EINVAL;
9407 }
9408
9409 if (0 == request.enable) {
9410 /* Disable PNO, ignore any other params */
9411 memset(&request, 0, sizeof(request));
9412 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
9413 &request, adapter->sessionId,
9414 found_pref_network_cb, adapter);
9415 return 0;
9416 }
9417
9418 ptr += offset;
9419
9420 if (1 !=
9421 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
9422 hdd_err("PNO count input not valid %s", ptr);
9423 return -EINVAL;
9424
9425 }
9426
9427 hdd_info("PNO enable %d networks count %d offset %d",
9428 request.enable, request.ucNetworksCount, offset);
9429
9430 if ((0 == request.ucNetworksCount) ||
9431 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
9432 hdd_err("Network count %d invalid",
9433 request.ucNetworksCount);
9434 return -EINVAL;
9435 }
9436
9437 ptr += offset;
9438
9439 for (i = 0; i < request.ucNetworksCount; i++) {
9440
9441 request.aNetworks[i].ssId.length = 0;
9442
9443 params = sscanf(ptr, "%hhu %n",
9444 &(request.aNetworks[i].ssId.length),
9445 &offset);
9446
9447 if (1 != params) {
9448 hdd_err("PNO ssid length input is not valid %s", ptr);
9449 return -EINVAL;
9450 }
9451
9452 if ((0 == request.aNetworks[i].ssId.length) ||
9453 (request.aNetworks[i].ssId.length > 32)) {
9454 hdd_err("SSID Len %d is not correct for network %d",
9455 request.aNetworks[i].ssId.length, i);
9456 return -EINVAL;
9457 }
9458
9459 /* Advance to SSID */
9460 ptr += offset;
9461
9462 memcpy(request.aNetworks[i].ssId.ssId, ptr,
9463 request.aNetworks[i].ssId.length);
9464 ptr += request.aNetworks[i].ssId.length;
9465
9466 params = sscanf(ptr, "%u %u %hhu %n",
9467 &(request.aNetworks[i].authentication),
9468 &(request.aNetworks[i].encryption),
9469 &(request.aNetworks[i].ucChannelCount),
9470 &offset);
9471
9472 if (3 != params) {
9473 hdd_warn("Incorrect cmd %s", ptr);
9474 return -EINVAL;
9475 }
9476
9477 hdd_notice("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
9478 request.aNetworks[i].ssId.length,
9479 request.aNetworks[i].ssId.length,
9480 request.aNetworks[i].ssId.ssId,
9481 request.aNetworks[i].authentication,
9482 request.aNetworks[i].encryption,
9483 request.aNetworks[i].ucChannelCount, offset);
9484
9485 /* Advance to channel list */
9486 ptr += offset;
9487
9488 if (SIR_PNO_MAX_NETW_CHANNELS <
9489 request.aNetworks[i].ucChannelCount) {
9490 hdd_warn("Incorrect number of channels");
9491 return -EINVAL;
9492 }
9493
9494 if (0 != request.aNetworks[i].ucChannelCount) {
9495 for (j = 0; j < request.aNetworks[i].ucChannelCount;
9496 j++) {
9497 if (1 !=
9498 sscanf(ptr, "%hhu %n",
9499 &(request.aNetworks[i].
9500 aChannels[j]), &offset)) {
9501 hdd_err("PNO network channel input is not valid %s",
9502 ptr);
9503 return -EINVAL;
9504 }
9505 /* Advance to next channel number */
9506 ptr += offset;
9507 }
9508 }
9509
9510 if (1 != sscanf(ptr, "%u %n",
9511 &(request.aNetworks[i].bcastNetwType),
9512 &offset)) {
9513 hdd_err("PNO broadcast network type input is not valid %s",
9514 ptr);
9515 return -EINVAL;
9516 }
9517
9518 hdd_notice("PNO bcastNetwType %d offset %d",
9519 request.aNetworks[i].bcastNetwType, offset);
9520
9521 /* Advance to rssi Threshold */
9522 ptr += offset;
9523 if (1 != sscanf(ptr, "%d %n",
9524 &(request.aNetworks[i].rssiThreshold),
9525 &offset)) {
9526 hdd_err("PNO rssi threshold input is not valid %s",
9527 ptr);
9528 return -EINVAL;
9529 }
9530 hdd_notice("PNO rssi %d offset %d",
9531 request.aNetworks[i].rssiThreshold, offset);
9532 /* Advance to next network */
9533 ptr += offset;
9534 } /* For ucNetworkCount */
9535
Dustin Brown43e87292016-10-10 10:38:25 -07009536 request.fast_scan_period = 0;
9537 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
9538 request.fast_scan_period *= MSEC_PER_SEC;
9539 ptr += offset;
9540 }
9541
9542 request.fast_scan_max_cycles = 0;
9543 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
9544 &offset) > 0)
9545 ptr += offset;
9546
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009547 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
9548
9549 request.modePNO = mode;
9550 /* for LA we just expose suspend option */
9551 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
9552 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9553 }
9554
9555 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
9556 &request,
9557 adapter->sessionId,
9558 found_pref_network_cb, adapter);
9559
9560 return 0;
9561}
9562
9563static int iw_set_pno(struct net_device *dev,
9564 struct iw_request_info *info,
9565 union iwreq_data *wrqu, char *extra)
9566{
9567 int ret;
9568
9569 cds_ssr_protect(__func__);
9570 ret = __iw_set_pno(dev, info, wrqu, extra);
9571 cds_ssr_unprotect(__func__);
9572
9573 return ret;
9574}
9575#endif /* FEATURE_WLAN_SCAN_PNO */
9576
9577/* Common function to SetBand */
9578int hdd_set_band(struct net_device *dev, u8 ui_band)
9579{
9580 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9581 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9582 eCsrBand band;
9583
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309584 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009585 hdd_context_t *pHddCtx;
9586 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9587 eCsrBand currBand = eCSR_BAND_MAX;
9588 eCsrBand connectedBand;
9589
9590 pAdapterNode = NULL;
9591 pNext = NULL;
9592 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9593
9594 switch (ui_band) {
9595 case WLAN_HDD_UI_BAND_AUTO:
9596 band = eCSR_BAND_ALL;
9597 break;
9598 case WLAN_HDD_UI_BAND_5_GHZ:
9599 band = eCSR_BAND_5G;
9600 break;
9601 case WLAN_HDD_UI_BAND_2_4_GHZ:
9602 band = eCSR_BAND_24;
9603 break;
9604 default:
9605 band = eCSR_BAND_MAX;
9606 }
9607
Jeff Johnson99bac312016-06-28 10:38:18 -07009608 hdd_notice("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009609
9610 if (band == eCSR_BAND_MAX) {
9611 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -07009612 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009613 return -EINVAL;
9614 }
9615
9616 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
9617 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009618 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009619 band, pHddCtx->config->nBandCapability);
9620 return -EIO;
9621 }
9622
9623 if (band == eCSR_BAND_ALL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009624 hdd_notice("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009625 pHddCtx->config->nBandCapability);
9626 band = pHddCtx->config->nBandCapability;
9627 }
9628
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309629 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009630 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009631 return -EIO;
9632 }
9633
9634 if (currBand != band) {
9635 /* Change band request received.
9636 * Abort pending scan requests, flush the existing scan results,
9637 * and change the band capability
9638 */
Jeff Johnson99bac312016-06-28 10:38:18 -07009639 hdd_notice("Current band value = %u, new setting %u ",
9640 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009641
9642 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309643 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009644 pAdapter = pAdapterNode->pAdapter;
9645 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9646 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
9647 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9648 connectedBand =
9649 hdd_conn_get_connected_band
9650 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
9651
9652 /* Handling is done only for STA and P2P */
9653 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -08009654 ((pAdapter->device_mode == QDF_STA_MODE)
9655 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009656 &&
9657 (hdd_conn_is_connected
9658 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
9659 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309660 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009661 long lrc;
9662
9663 /* STA already connected on current band, So issue disconnect
9664 * first, then change the band*/
9665
Jeff Johnson99bac312016-06-28 10:38:18 -07009666 hdd_notice("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009667 hdd_device_mode_to_string(pAdapter->device_mode),
9668 pAdapter->device_mode, currBand, band);
9669 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9670
9671 status =
9672 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
9673 (pAdapter),
9674 pAdapter->sessionId,
9675 eCSR_DISCONNECT_REASON_UNSPECIFIED);
9676
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309677 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009678 hdd_err("csr_roam_disconnect failure, returned %d",
9679 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009680 return -EINVAL;
9681 }
9682
9683 lrc =
9684 wait_for_completion_timeout(&pAdapter->
9685 disconnect_comp_var,
9686 msecs_to_jiffies
9687 (WLAN_WAIT_TIME_DISCONNECT));
9688
9689 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009690 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009691 return -ETIMEDOUT;
9692 }
9693 }
9694
9695 sme_scan_flush_result(hHal);
9696
9697 status =
9698 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
9699 pAdapterNode = pNext;
9700 }
9701
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309702 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009703 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009704 hdd_alert("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009705 band);
9706 return -EINVAL;
9707 }
9708 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
9709 }
9710 return 0;
9711}
9712
9713int hdd_set_band_helper(struct net_device *dev, const char *command)
9714{
9715 uint8_t band;
9716 int ret;
9717
9718 /* Convert the band value from ascii to integer */
9719 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
9720 ret = kstrtou8(command, 10, &band);
9721 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009722 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009723 return -EINVAL;
9724 }
9725
9726 return hdd_set_band(dev, band);
9727}
9728
9729static int __iw_set_band_config(struct net_device *dev,
9730 struct iw_request_info *info,
9731 union iwreq_data *wrqu, char *extra)
9732{
9733 int *value = (int *)extra;
9734
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009735 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009736
Mukul Sharmaa5fe1982015-11-02 19:28:14 +05309737 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009738 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +05309739 return -EPERM;
9740 }
9741
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009742 return hdd_set_band(dev, value[0]);
9743}
9744
9745static int iw_set_band_config(struct net_device *dev,
9746 struct iw_request_info *info,
9747 union iwreq_data *wrqu, char *extra)
9748{
9749 int ret;
9750
9751 cds_ssr_protect(__func__);
9752 ret = __iw_set_band_config(dev, info, wrqu, extra);
9753 cds_ssr_unprotect(__func__);
9754
9755 return ret;
9756}
9757
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009758/**
9759 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
9760 * @adapter: Handle to adapter
9761 * @chan: Monitor mode channel
9762 * @bandwidth: Capture channel bandwidth
9763 *
9764 * Return: 0 on success else error code.
9765 */
9766static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
9767 uint32_t bandwidth)
9768{
9769 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9770 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
9771 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
9772 QDF_STATUS status;
9773 tHalHandle hal_hdl = hdd_ctx->hHal;
9774 struct qdf_mac_addr bssid;
9775 tCsrRoamProfile roam_profile;
9776 struct ch_params_s ch_params;
9777
9778 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
9779 hdd_err("Not supported, device is not in monitor mode");
9780 return -EINVAL;
9781 }
9782
9783 hdd_info("Set monitor mode Channel %d", chan);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009784 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
9785 roam_profile.ChannelInfo.numOfChannels = 1;
9786 roam_profile.phyMode = ch_info->phy_mode;
9787 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -07009788 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009789
9790 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
9791 QDF_MAC_ADDR_SIZE);
9792
9793 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07009794 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009795 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
9796 &roam_profile);
9797 if (status) {
9798 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
9799 status);
9800 }
9801
9802 return qdf_status_to_os_return(status);
9803}
9804
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009805static int __iw_set_two_ints_getnone(struct net_device *dev,
9806 struct iw_request_info *info,
9807 union iwreq_data *wrqu, char *extra)
9808{
9809 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9810 int *value = (int *)extra;
9811 int sub_cmd = value[0];
9812 int ret;
9813 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9814
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009815 ENTER_DEV(dev);
9816
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009817 ret = wlan_hdd_validate_context(hdd_ctx);
9818 if (0 != ret)
9819 return ret;
9820
9821 switch (sub_cmd) {
9822 case WE_SET_SMPS_PARAM:
Jeff Johnson99bac312016-06-28 10:38:18 -07009823 hdd_notice("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009824 ret = wma_cli_set_command(pAdapter->sessionId,
9825 WMI_STA_SMPS_PARAM_CMDID,
9826 value[1] << WMA_SMPS_PARAM_VALUE_S
9827 | value[2],
9828 VDEV_CMD);
9829 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -07009830#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009831 case WE_SET_FW_CRASH_INJECT:
Jeff Johnson99bac312016-06-28 10:38:18 -07009832 hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009833 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +05309834 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
9835 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009836 ret = wma_cli_set2_command(pAdapter->sessionId,
9837 GEN_PARAM_CRASH_INJECT,
9838 value[1], value[2], GEN_CMD);
9839 break;
9840#endif
Govind Singha471e5e2015-10-12 17:11:14 +05309841 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009842 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +05309843 value[1], value[2]);
9844 ret = wma_cli_set2_command(pAdapter->sessionId,
9845 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
9846 value[1], value[2], DBG_CMD);
9847 break;
9848 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -07009849 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +05309850 value[1], value[2]);
9851 ret = wma_cli_set2_command(pAdapter->sessionId,
9852 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
9853 value[1], value[2], DBG_CMD);
9854 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009855 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
9856 hdd_debug("Ioctl to set dual fw mode config");
9857 if (hdd_ctx->config->dual_mac_feature_disable) {
9858 hdd_err("Dual mac feature is disabled from INI");
9859 return -EPERM;
9860 }
9861 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08009862 cds_set_dual_mac_fw_mode_config(value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009863 break;
9864 case WE_DUMP_DP_TRACE_LEVEL:
9865 hdd_info("WE_DUMP_DP_TRACE_LEVEL: %d %d",
9866 value[1], value[2]);
9867 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309868 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +05309869 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
9870 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +05309871 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
9872 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009873 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009874 case WE_SET_MON_MODE_CHAN:
9875 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
9876 break;
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009877 case WE_SET_WLAN_SUSPEND:
Dustin Brownbc81a472016-10-26 16:56:59 -07009878 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009879 break;
9880 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -07009881 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009882 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009883 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07009884 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009885 break;
9886 }
9887
9888 return ret;
9889}
9890
9891static int iw_set_two_ints_getnone(struct net_device *dev,
9892 struct iw_request_info *info,
9893 union iwreq_data *wrqu, char *extra)
9894{
9895 int ret;
9896
9897 cds_ssr_protect(__func__);
9898 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
9899 cds_ssr_unprotect(__func__);
9900
9901 return ret;
9902}
9903
9904/* Define the Wireless Extensions to the Linux Network Device structure */
9905/* A number of these routines are NULL (meaning they are not implemented.) */
9906
9907static const iw_handler we_handler[] = {
9908 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9909 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9910 (iw_handler) NULL, /* SIOCSIWNWID */
9911 (iw_handler) NULL, /* SIOCGIWNWID */
9912 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9913 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9914 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9915 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9916 (iw_handler) NULL, /* SIOCSIWSENS */
9917 (iw_handler) NULL, /* SIOCGIWSENS */
9918 (iw_handler) NULL, /* SIOCSIWRANGE */
9919 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9920 (iw_handler) NULL, /* SIOCSIWPRIV */
9921 (iw_handler) NULL, /* SIOCGIWPRIV */
9922 (iw_handler) NULL, /* SIOCSIWSTATS */
9923 (iw_handler) NULL, /* SIOCGIWSTATS */
9924 (iw_handler) NULL, /* SIOCSIWSPY */
9925 (iw_handler) NULL, /* SIOCGIWSPY */
9926 (iw_handler) NULL, /* SIOCSIWTHRSPY */
9927 (iw_handler) NULL, /* SIOCGIWTHRSPY */
9928 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9929 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9930 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9931 (iw_handler) NULL, /* SIOCGIWAPLIST */
9932 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9933 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9934 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9935 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9936 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9937 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9938 (iw_handler) NULL, /* -- hole -- */
9939 (iw_handler) NULL, /* -- hole -- */
9940 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9941 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9942 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
9943 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
9944 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9945 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9946 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9947 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9948 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9949 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9950 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9951 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9952 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9953 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9954 (iw_handler) NULL, /* -- hole -- */
9955 (iw_handler) NULL, /* -- hole -- */
9956 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9957 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9958 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9959 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9960 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9961 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9962 (iw_handler) NULL, /* SIOCSIWPMKSA */
9963};
9964
9965static const iw_handler we_private[] = {
9966
9967 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, /* set priv ioctl */
9968 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, /* get priv ioctl */
9969 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, /* get priv ioctl */
9970 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9971 iw_set_three_ints_getnone,
9972 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9973 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, /* action priv ioctl */
9974 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9975 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009976 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
9977 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009978 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9979 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9980 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009981 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009982 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9983 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9984 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
9985 iw_set_keepalive_params,
9986#ifdef WLAN_FEATURE_PACKET_FILTERING
9987 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
9988 iw_set_packet_filter_params,
9989#endif
9990#ifdef FEATURE_WLAN_SCAN_PNO
9991 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
9992#endif
9993 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
9994 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
9995 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9996 iw_set_two_ints_getnone,
9997 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
9998 iw_set_dot11p_channel_sched,
9999};
10000
10001/*Maximum command length can be only 15 */
10002static const struct iw_priv_args we_private_args[] = {
10003
10004 /* handlers for main ioctl */
10005 {WLAN_PRIV_SET_INT_GET_NONE,
10006 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10007 0,
10008 ""},
10009
10010 /* handlers for sub-ioctl */
10011 {WE_SET_11D_STATE,
10012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10013 0,
10014 "set11Dstate"},
10015
10016 {WE_WOWL,
10017 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10018 0,
10019 "wowl"},
10020
10021 {WE_SET_POWER,
10022 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10023 0,
10024 "setPower"},
10025
10026 {WE_SET_MAX_ASSOC,
10027 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10028 0,
10029 "setMaxAssoc"},
10030
10031 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10032 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
10033 "setAutoChannel" },
10034
10035 {WE_SET_SCAN_DISABLE,
10036 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10037 0,
10038 "scan_disable"},
10039
10040 {WE_SET_DATA_INACTIVITY_TO,
10041 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10042 0,
10043 "inactivityTO"},
10044
10045 {WE_SET_MAX_TX_POWER,
10046 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10047 0,
10048 "setMaxTxPower"},
10049
10050 {WE_SET_TX_POWER,
10051 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10052 0,
10053 "setTxPower"},
10054
10055 {WE_SET_MC_RATE,
10056 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10057 0,
10058 "setMcRate"},
10059
10060 {WE_SET_MAX_TX_POWER_2_4,
10061 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10062 0,
10063 "setTxMaxPower2G"},
10064
10065 {WE_SET_MAX_TX_POWER_5_0,
10066 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10067 0,
10068 "setTxMaxPower5G"},
10069
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010070 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010071 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010072 0,
10073 "pktlog"},
10074
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010075 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10076 * as well to keep same syntax as in SAP. Now onwards, STA
10077 * will support both */
10078 {WE_SET_MAX_TX_POWER,
10079 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10080 0,
10081 "setTxMaxPower"},
10082
10083 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10084 * 1 = enable and 0 = disable */
10085 {
10086 WE_SET_HIGHER_DTIM_TRANSITION,
10087 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10088 0,
10089 "setHDtimTransn"
10090 },
10091
10092 {WE_SET_TM_LEVEL,
10093 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10094 0,
10095 "setTmLevel"},
10096
10097 {WE_SET_PHYMODE,
10098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10099 0,
10100 "setphymode"},
10101
10102 {WE_SET_NSS,
10103 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10104 0,
10105 "nss"},
10106
10107 {WE_SET_LDPC,
10108 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10109 0,
10110 "ldpc"},
10111
10112 {WE_SET_TX_STBC,
10113 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10114 0,
10115 "tx_stbc"},
10116
10117 {WE_SET_RX_STBC,
10118 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10119 0,
10120 "rx_stbc"},
10121
10122 {WE_SET_SHORT_GI,
10123 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10124 0,
10125 "shortgi"},
10126
10127 {WE_SET_RTSCTS,
10128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10129 0,
10130 "enablertscts"},
10131
10132 {WE_SET_CHWIDTH,
10133 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10134 0,
10135 "chwidth"},
10136
10137 {WE_SET_ANI_EN_DIS,
10138 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10139 0,
10140 "anienable"},
10141
10142 {WE_SET_ANI_POLL_PERIOD,
10143 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10144 0,
10145 "aniplen"},
10146
10147 {WE_SET_ANI_LISTEN_PERIOD,
10148 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10149 0,
10150 "anilislen"},
10151
10152 {WE_SET_ANI_OFDM_LEVEL,
10153 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10154 0,
10155 "aniofdmlvl"},
10156
10157 {WE_SET_ANI_CCK_LEVEL,
10158 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10159 0,
10160 "aniccklvl"},
10161
10162 {WE_SET_DYNAMIC_BW,
10163 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10164 0,
10165 "cwmenable"},
10166
10167 {WE_SET_CTS_CBW,
10168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10169 0,
10170 "cts_cbw" },
10171
10172 {WE_SET_GTX_HT_MCS,
10173 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10174 0,
10175 "gtxHTMcs"},
10176
10177 {WE_SET_GTX_VHT_MCS,
10178 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10179 0,
10180 "gtxVHTMcs"},
10181
10182 {WE_SET_GTX_USRCFG,
10183 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10184 0,
10185 "gtxUsrCfg"},
10186
10187 {WE_SET_GTX_THRE,
10188 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10189 0,
10190 "gtxThre"},
10191
10192 {WE_SET_GTX_MARGIN,
10193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10194 0,
10195 "gtxMargin"},
10196
10197 {WE_SET_GTX_STEP,
10198 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10199 0,
10200 "gtxStep"},
10201
10202 {WE_SET_GTX_MINTPC,
10203 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10204 0,
10205 "gtxMinTpc"},
10206
10207 {WE_SET_GTX_BWMASK,
10208 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10209 0,
10210 "gtxBWMask"},
10211
10212 {WE_SET_TX_CHAINMASK,
10213 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10214 0,
10215 "txchainmask"},
10216
10217 {WE_SET_RX_CHAINMASK,
10218 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10219 0,
10220 "rxchainmask"},
10221
10222 {WE_SET_11N_RATE,
10223 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10224 0,
10225 "set11NRates"},
10226
10227 {WE_SET_VHT_RATE,
10228 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10229 0,
10230 "set11ACRates"},
10231
10232 {WE_SET_AMPDU,
10233 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10234 0,
10235 "ampdu"},
10236
10237 {WE_SET_AMSDU,
10238 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10239 0,
10240 "amsdu"},
10241
10242 {WE_SET_BURST_ENABLE,
10243 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10244 0,
10245 "burst_enable"},
10246
10247 {WE_SET_BURST_DUR,
10248 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10249 0,
10250 "burst_dur"},
10251
10252 {WE_SET_TXPOW_2G,
10253 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10254 0,
10255 "txpow2g"},
10256
10257 {WE_SET_TXPOW_5G,
10258 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10259 0,
10260 "txpow5g"},
10261
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010262 /* Sub-cmds DBGLOG specific commands */
10263 {WE_DBGLOG_LOG_LEVEL,
10264 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10265 0,
10266 "dl_loglevel"},
10267
10268 {WE_DBGLOG_VAP_ENABLE,
10269 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10270 0,
10271 "dl_vapon"},
10272
10273 {WE_DBGLOG_VAP_DISABLE,
10274 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10275 0,
10276 "dl_vapoff"},
10277
10278 {WE_DBGLOG_MODULE_ENABLE,
10279 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10280 0,
10281 "dl_modon"},
10282
10283 {WE_DBGLOG_MODULE_DISABLE,
10284 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10285 0,
10286 "dl_modoff"},
10287
10288 {WE_DBGLOG_MOD_LOG_LEVEL,
10289 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10290 0,
10291 "dl_mod_loglevel"},
10292
10293 {WE_DBGLOG_TYPE,
10294 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10295 0,
10296 "dl_type"},
10297 {WE_DBGLOG_REPORT_ENABLE,
10298 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10299 0,
10300 "dl_report"},
10301
10302 {WE_SET_TXRX_FWSTATS,
10303 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10304 0,
10305 "txrx_fw_stats"},
10306
10307 {WE_TXRX_FWSTATS_RESET,
10308 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10309 0,
10310 "txrx_fw_st_rst"},
10311
10312 {WE_PPS_PAID_MATCH,
10313 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10314 0, "paid_match"},
10315
10316 {WE_PPS_GID_MATCH,
10317 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10318 0, "gid_match"},
10319
10320 {WE_PPS_EARLY_TIM_CLEAR,
10321 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10322 0, "tim_clear"},
10323
10324 {WE_PPS_EARLY_DTIM_CLEAR,
10325 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10326 0, "dtim_clear"},
10327
10328 {WE_PPS_EOF_PAD_DELIM,
10329 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10330 0, "eof_delim"},
10331
10332 {WE_PPS_MACADDR_MISMATCH,
10333 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10334 0, "mac_match"},
10335
10336 {WE_PPS_DELIM_CRC_FAIL,
10337 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10338 0, "delim_fail"},
10339
10340 {WE_PPS_GID_NSTS_ZERO,
10341 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10342 0, "nsts_zero"},
10343
10344 {WE_PPS_RSSI_CHECK,
10345 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10346 0, "rssi_chk"},
10347
10348 {WE_PPS_5G_EBT,
10349 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10350 0, "5g_ebt"},
10351
10352 {WE_SET_HTSMPS,
10353 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10354 0, "htsmps"},
10355
10356 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
10357 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10358 0, "set_qpspollcnt"},
10359
10360 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
10361 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10362 0, "set_qtxwake"},
10363
10364 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
10365 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10366 0, "set_qwakeintv"},
10367
10368 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
10369 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10370 0, "set_qnodatapoll"},
10371
10372 /* handlers for MCC time quota and latency sub ioctls */
10373 {WE_MCC_CONFIG_LATENCY,
10374 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10375 0, "setMccLatency"},
10376
10377 {WE_MCC_CONFIG_QUOTA,
10378 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10379 0, "setMccQuota"},
10380
10381 {WE_SET_DEBUG_LOG,
10382 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10383 0, "setDbgLvl"},
10384
10385 /* handlers for early_rx power save */
10386 {WE_SET_EARLY_RX_ADJUST_ENABLE,
10387 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10388 0, "erx_enable"},
10389
10390 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
10391 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10392 0, "erx_bmiss_val"},
10393
10394 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
10395 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10396 0, "erx_bmiss_smpl"},
10397
10398 {WE_SET_EARLY_RX_SLOP_STEP,
10399 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10400 0, "erx_slop_step"},
10401
10402 {WE_SET_EARLY_RX_INIT_SLOP,
10403 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10404 0, "erx_init_slop"},
10405
10406 {WE_SET_EARLY_RX_ADJUST_PAUSE,
10407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10408 0, "erx_adj_pause"},
10409
10410 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
10411 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10412 0, "erx_dri_sample"},
10413
10414 {WE_DUMP_STATS,
10415 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10416 0, "dumpStats"},
10417
10418 {WE_CLEAR_STATS,
10419 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10420 0, "clearStats"},
10421
Govind Singha471e5e2015-10-12 17:11:14 +053010422 {WE_START_FW_PROFILE,
10423 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10424 0, "startProfile"},
10425
Abhishek Singh1bdb1572015-10-16 16:24:19 +053010426 {WE_SET_CHANNEL,
10427 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10428 0, "setChanChange" },
10429
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053010430 {WE_SET_CONC_SYSTEM_PREF,
10431 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10432 0, "setConcSysPref" },
10433
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010434 {WLAN_PRIV_SET_NONE_GET_INT,
10435 0,
10436 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10437 ""},
10438
10439 /* handlers for sub-ioctl */
10440 {WE_GET_11D_STATE,
10441 0,
10442 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10443 "get11Dstate"},
10444
10445 {WE_IBSS_STATUS,
10446 0,
10447 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10448 "getAdhocStatus"},
10449
10450 {WE_GET_WLAN_DBG,
10451 0,
10452 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10453 "getwlandbg"},
10454
10455 {WE_GET_MAX_ASSOC,
10456 0,
10457 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10458 "getMaxAssoc"},
10459
10460 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10461 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10462 "getAutoChannel" },
10463
10464 {WE_GET_CONCURRENCY_MODE,
10465 0,
10466 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10467 "getconcurrency"},
10468
10469 {WE_GET_NSS,
10470 0,
10471 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10472 "get_nss"},
10473
10474 {WE_GET_LDPC,
10475 0,
10476 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10477 "get_ldpc"},
10478
10479 {WE_GET_TX_STBC,
10480 0,
10481 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10482 "get_tx_stbc"},
10483
10484 {WE_GET_RX_STBC,
10485 0,
10486 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10487 "get_rx_stbc"},
10488
10489 {WE_GET_SHORT_GI,
10490 0,
10491 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10492 "get_shortgi"},
10493
10494 {WE_GET_RTSCTS,
10495 0,
10496 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10497 "get_rtscts"},
10498
10499 {WE_GET_CHWIDTH,
10500 0,
10501 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10502 "get_chwidth"},
10503
10504 {WE_GET_ANI_EN_DIS,
10505 0,
10506 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10507 "get_anienable"},
10508
10509 {WE_GET_ANI_POLL_PERIOD,
10510 0,
10511 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10512 "get_aniplen"},
10513
10514 {WE_GET_ANI_LISTEN_PERIOD,
10515 0,
10516 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10517 "get_anilislen"},
10518
10519 {WE_GET_ANI_OFDM_LEVEL,
10520 0,
10521 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10522 "get_aniofdmlvl"},
10523
10524 {WE_GET_ANI_CCK_LEVEL,
10525 0,
10526 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10527 "get_aniccklvl"},
10528
10529 {WE_GET_DYNAMIC_BW,
10530 0,
10531 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10532 "get_cwmenable"},
10533
10534 {WE_GET_GTX_HT_MCS,
10535 0,
10536 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10537 "get_gtxHTMcs"},
10538
10539 {WE_GET_GTX_VHT_MCS,
10540 0,
10541 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10542 "get_gtxVHTMcs"},
10543
10544 {WE_GET_GTX_USRCFG,
10545 0,
10546 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10547 "get_gtxUsrCfg"},
10548
10549 {WE_GET_GTX_THRE,
10550 0,
10551 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10552 "get_gtxThre"},
10553
10554 {WE_GET_GTX_MARGIN,
10555 0,
10556 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10557 "get_gtxMargin"},
10558
10559 {WE_GET_GTX_STEP,
10560 0,
10561 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10562 "get_gtxStep"},
10563
10564 {WE_GET_GTX_MINTPC,
10565 0,
10566 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10567 "get_gtxMinTpc"},
10568
10569 {WE_GET_GTX_BWMASK,
10570 0,
10571 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10572 "get_gtxBWMask"},
10573
10574 {WE_GET_TX_CHAINMASK,
10575 0,
10576 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10577 "get_txchainmask"},
10578
10579 {WE_GET_RX_CHAINMASK,
10580 0,
10581 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10582 "get_rxchainmask"},
10583
10584 {WE_GET_11N_RATE,
10585 0,
10586 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10587 "get_11nrate"},
10588
10589 {WE_GET_AMPDU,
10590 0,
10591 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10592 "get_ampdu"},
10593
10594 {WE_GET_AMSDU,
10595 0,
10596 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10597 "get_amsdu"},
10598
10599 {WE_GET_BURST_ENABLE,
10600 0,
10601 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10602 "get_burst_en"},
10603
10604 {WE_GET_BURST_DUR,
10605 0,
10606 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10607 "get_burst_dur"},
10608
10609 {WE_GET_TXPOW_2G,
10610 0,
10611 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10612 "get_txpow2g"},
10613
10614 {WE_GET_TXPOW_5G,
10615 0,
10616 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10617 "get_txpow5g"},
10618
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010619 {WE_GET_PPS_PAID_MATCH,
10620 0,
10621 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10622 "get_paid_match"},
10623
10624 {WE_GET_PPS_GID_MATCH,
10625 0,
10626 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10627 "get_gid_match"},
10628
10629 {WE_GET_PPS_EARLY_TIM_CLEAR,
10630 0,
10631 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10632 "get_tim_clear"},
10633
10634 {WE_GET_PPS_EARLY_DTIM_CLEAR,
10635 0,
10636 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10637 "get_dtim_clear"},
10638
10639 {WE_GET_PPS_EOF_PAD_DELIM,
10640 0,
10641 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10642 "get_eof_delim"},
10643
10644 {WE_GET_PPS_MACADDR_MISMATCH,
10645 0,
10646 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10647 "get_mac_match"},
10648
10649 {WE_GET_PPS_DELIM_CRC_FAIL,
10650 0,
10651 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10652 "get_delim_fail"},
10653
10654 {WE_GET_PPS_GID_NSTS_ZERO,
10655 0,
10656 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10657 "get_nsts_zero"},
10658
10659 {WE_GET_PPS_RSSI_CHECK,
10660 0,
10661 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10662 "get_rssi_chk"},
10663
10664 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
10665 0,
10666 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10667 "get_qpspollcnt"},
10668
10669 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
10670 0,
10671 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10672 "get_qtxwake"},
10673
10674 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
10675 0,
10676 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10677 "get_qwakeintv"},
10678
10679 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
10680 0,
10681 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10682 "get_qnodatapoll"},
10683
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010684 {WE_CAP_TSF,
10685 0,
10686 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10687 "cap_tsf"},
10688
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010689 {WE_GET_TEMPERATURE,
10690 0,
10691 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10692 "get_temp"},
10693 /* handlers for main ioctl */
10694 {WLAN_PRIV_SET_CHAR_GET_NONE,
10695 IW_PRIV_TYPE_CHAR | 512,
10696 0,
10697 ""},
10698
10699 /* handlers for sub-ioctl */
10700 {WE_WOWL_ADD_PTRN,
10701 IW_PRIV_TYPE_CHAR | 512,
10702 0,
10703 "wowlAddPtrn"},
10704
10705 {WE_WOWL_DEL_PTRN,
10706 IW_PRIV_TYPE_CHAR | 512,
10707 0,
10708 "wowlDelPtrn"},
10709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010710 /* handlers for sub-ioctl */
10711 {WE_NEIGHBOR_REPORT_REQUEST,
10712 IW_PRIV_TYPE_CHAR | 512,
10713 0,
10714 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080010715
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010716 {WE_SET_AP_WPS_IE,
10717 IW_PRIV_TYPE_CHAR | 512,
10718 0,
10719 "set_ap_wps_ie"},
10720
10721 {WE_SET_CONFIG,
10722 IW_PRIV_TYPE_CHAR | 512,
10723 0,
10724 "setConfig"},
10725
10726 /* handlers for main ioctl */
10727 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
10728 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10729 0,
10730 ""},
10731
10732 /* handlers for sub-ioctl */
10733 {WE_SET_WLAN_DBG,
10734 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10735 0,
10736 "setwlandbg"},
10737
10738 /* handlers for sub-ioctl */
10739 {WE_SET_DP_TRACE,
10740 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10741 0,
10742 "set_dp_trace"},
10743
10744 {WE_SET_SAP_CHANNELS,
10745 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10746 0,
10747 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053010748
10749 {WE_SET_FW_TEST,
10750 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10751 0, "fw_test"},
10752
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010753 /* handlers for main ioctl */
10754 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
10755 0,
10756 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10757 "" },
10758 {WE_GET_TSF,
10759 0,
10760 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10761 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010762
10763 {WE_SET_DUAL_MAC_SCAN_CONFIG,
10764 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10765 0,
10766 "set_scan_cfg"},
10767
10768 /* handlers for main ioctl */
10769 {WLAN_PRIV_GET_CHAR_SET_NONE,
10770 0,
10771 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10772 ""},
10773
10774 /* handlers for sub-ioctl */
10775 {WE_WLAN_VERSION,
10776 0,
10777 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10778 "version"},
10779 {WE_GET_STATS,
10780 0,
10781 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10782 "getStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053010783 {WE_LIST_FW_PROFILE,
10784 0,
10785 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10786 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010787 {WE_GET_STATES,
10788 0,
10789 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10790 "getHostStates"},
10791 {WE_GET_CFG,
10792 0,
10793 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10794 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010795 {WE_GET_RSSI,
10796 0,
10797 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10798 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010799 {WE_GET_WMM_STATUS,
10800 0,
10801 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10802 "getWmmStatus"},
10803 {
10804 WE_GET_CHANNEL_LIST,
10805 0,
10806 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10807 "getChannelList"
10808 },
10809#ifdef FEATURE_WLAN_TDLS
10810 {
10811 WE_GET_TDLS_PEERS,
10812 0,
10813 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10814 "getTdlsPeers"
10815 },
10816#endif
10817#ifdef WLAN_FEATURE_11W
10818 {
10819 WE_GET_11W_INFO,
10820 0,
10821 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10822 "getPMFInfo"
10823 },
10824#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010825 {
10826 WE_GET_IBSS_STA_INFO,
10827 0,
10828 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10829 "getIbssSTAs"
10830 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010831 {WE_GET_PHYMODE,
10832 0,
10833 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10834 "getphymode"},
10835#ifdef FEATURE_OEM_DATA_SUPPORT
10836 {WE_GET_OEM_DATA_CAP,
10837 0,
10838 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10839 "getOemDataCap"},
10840#endif /* FEATURE_OEM_DATA_SUPPORT */
10841 {WE_GET_SNR,
10842 0,
10843 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10844 "getSNR"},
10845
10846 /* handlers for main ioctl */
10847 {WLAN_PRIV_SET_NONE_GET_NONE,
10848 0,
10849 0,
10850 ""},
10851
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010852 /* handlers for sub-ioctl */
10853 {
10854 WE_IBSS_GET_PEER_INFO_ALL,
10855 0,
10856 0,
10857 "ibssPeerInfoAll"
10858 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010859 {WE_GET_RECOVERY_STAT,
10860 0,
10861 0,
10862 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053010863
10864 {WE_GET_FW_PROFILE_DATA,
10865 0,
10866 0,
10867 "getProfileData"},
10868
10869 {WE_SET_REASSOC_TRIGGER,
10870 0,
10871 0,
10872 "reassoc"},
10873
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010874 {WE_DUMP_AGC_START,
10875 0,
10876 0,
10877 "dump_agc_start"},
10878
10879 {WE_DUMP_AGC,
10880 0,
10881 0,
10882 "dump_agc"},
10883
10884 {WE_DUMP_CHANINFO_START,
10885 0,
10886 0,
10887 "dump_chninfo_en"},
10888
10889 {WE_DUMP_CHANINFO,
10890 0,
10891 0,
10892 "dump_chninfo"},
10893
10894 {WE_DUMP_WATCHDOG,
10895 0,
10896 0,
10897 "dump_watchdog"},
10898#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
10899 {WE_DUMP_PCIE_LOG,
10900 0,
10901 0,
10902 "dump_pcie_log"},
10903#endif
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010904 {WE_STOP_OBSS_SCAN,
10905 0,
10906 0,
10907 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010908 /* handlers for main ioctl */
10909 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
10910 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10911 0,
10912 ""},
10913
10914 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010915 {WE_IBSS_GET_PEER_INFO,
10916 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10917 0,
10918 "ibssPeerInfo"},
10919
10920 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010921 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10922 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10923 0,
10924 "setdumplog"},
10925
10926 {WE_MTRACE_DUMP_CMD,
10927 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10928 0,
10929 "dumplog"},
10930#ifdef MPC_UT_FRAMEWORK
10931 {WE_POLICY_MANAGER_CLIST_CMD,
10932 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10933 0,
10934 "pm_clist"},
10935
10936 {WE_POLICY_MANAGER_DLIST_CMD,
10937 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10938 0,
10939 "pm_dlist"},
10940
10941 {WE_POLICY_MANAGER_DBS_CMD,
10942 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10943 0,
10944 "pm_dbs"},
10945
10946 {WE_POLICY_MANAGER_PCL_CMD,
10947 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10948 0,
10949 "pm_pcl"},
10950
10951 {WE_POLICY_MANAGER_CINFO_CMD,
10952 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10953 0,
10954 "pm_cinfo"},
10955
10956 {WE_POLICY_MANAGER_ULIST_CMD,
10957 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10958 0,
10959 "pm_ulist"},
10960
10961 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
10962 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10963 0,
10964 "pm_query_action"},
10965
10966 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
10967 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10968 0,
10969 "pm_query_allow"},
10970
10971 {WE_POLICY_MANAGER_SCENARIO_CMD,
10972 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10973 0,
10974 "pm_run_scenario"},
10975
10976 {WE_POLICY_SET_HW_MODE_CMD,
10977 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10978 0,
10979 "pm_set_hw_mode"},
10980#endif
10981#ifdef FEATURE_WLAN_TDLS
10982 /* handlers for sub ioctl */
10983 {
10984 WE_TDLS_CONFIG_PARAMS,
10985 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10986 0,
10987 "setTdlsConfig"
10988 },
10989#endif
10990 {
10991 WE_UNIT_TEST_CMD,
10992 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10993 0,
10994 "setUnitTestCmd"
10995 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053010996 {
10997 WE_MAC_PWR_DEBUG_CMD,
10998 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10999 0,
11000 "halPwrDebug"
11001 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011002
11003#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
11004 {WE_LED_FLASHING_PARAM,
11005 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11006 0,
11007 "gpio_control"},
11008#endif
11009 /* handlers for main ioctl */
11010 {WLAN_PRIV_ADD_TSPEC,
11011 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11013 "addTspec"},
11014
11015 /* handlers for main ioctl */
11016 {WLAN_PRIV_DEL_TSPEC,
11017 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11019 "delTspec"},
11020
11021 /* handlers for main ioctl */
11022 {WLAN_PRIV_GET_TSPEC,
11023 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11024 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11025 "getTspec"},
11026
11027 /* handlers for main ioctl - host offload */
11028 {
11029 WLAN_PRIV_SET_HOST_OFFLOAD,
11030 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11031 0,
11032 "setHostOffload"
11033 }
11034 ,
11035
11036 {
11037 WLAN_GET_WLAN_STATISTICS,
11038 0,
11039 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11040 "getWlanStats"
11041 }
11042 ,
11043
11044 {
11045 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053011046 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
11047 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011048 0,
11049 "setKeepAlive"
11050 }
11051 ,
11052#ifdef WLAN_FEATURE_PACKET_FILTERING
11053 {
11054 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053011055 IW_PRIV_TYPE_BYTE |
11056 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011057 0,
11058 "setPktFilter"
11059 }
11060 ,
11061#endif
11062#ifdef FEATURE_WLAN_SCAN_PNO
11063 {
11064 WLAN_SET_PNO,
11065 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11066 0,
11067 "setpno"
11068 }
11069 ,
11070#endif
11071 {
11072 WLAN_SET_BAND_CONFIG,
11073 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11074 0,
11075 "SETBAND"
11076 }
11077 ,
11078 {
11079 WLAN_GET_LINK_SPEED,
11080 IW_PRIV_TYPE_CHAR | 18,
11081 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
11082 }
11083 ,
11084
11085 /* handlers for main ioctl */
11086 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
11087 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11088 0,
11089 ""}
11090 ,
11091 {WE_SET_SMPS_PARAM,
11092 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11093 0, "set_smps_param"}
11094 ,
11095 {WLAN_SET_DOT11P_CHANNEL_SCHED,
11096 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
11097 0, "set_dot11p" }
11098 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070011099#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011100 {WE_SET_FW_CRASH_INJECT,
11101 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11102 0, "crash_inject"}
11103 ,
11104#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070011105#ifdef WLAN_SUSPEND_RESUME_TEST
11106 {WE_SET_WLAN_SUSPEND,
11107 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11108 0, "wlan_suspend"}
11109 ,
11110 {WE_SET_WLAN_RESUME,
11111 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11112 0, "wlan_resume"}
11113 ,
11114#endif
Govind Singha471e5e2015-10-12 17:11:14 +053011115 {WE_ENABLE_FW_PROFILE,
11116 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11117 0, "enableProfile"}
11118 ,
11119 {WE_SET_FW_PROFILE_HIST_INTVL,
11120 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11121 0, "set_hist_intvl"}
11122 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011123 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
11124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11125 0, "set_fw_mode_cfg"}
11126 ,
11127 {WE_DUMP_DP_TRACE_LEVEL,
11128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11129 0, "dump_dp_trace"}
11130 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070011131 {WE_SET_MON_MODE_CHAN,
11132 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11133 0, "setMonChan"}
11134 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070011135
11136 {WE_GET_ROAM_SYNCH_DELAY,
11137 0,
11138 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11139 "hostroamdelay"}
11140 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011141};
11142
11143const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053011144 .num_standard = QDF_ARRAY_SIZE(we_handler),
11145 .num_private = QDF_ARRAY_SIZE(we_private),
11146 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011147
11148 .standard = (iw_handler *) we_handler,
11149 .private = (iw_handler *) we_private,
11150 .private_args = we_private_args,
11151 .get_wireless_stats = NULL,
11152};
11153
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011154/* hdd_set_wext() - configures bss parameters
11155 * @pAdapter: handle to adapter context
11156 *
11157 * Returns: none
11158 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070011159static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011160{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011161 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11162 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011163
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011164 ENTER();
11165
11166 if (!pwextBuf) {
11167 hdd_err("ERROR: pwextBuf is NULL");
11168 return QDF_STATUS_E_FAILURE;
11169 }
11170
11171 if (!pHddStaCtx) {
11172 hdd_err("ERROR: pHddStaCtx is NULL");
11173 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011174 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011175
11176 /* Now configure the roaming profile links. To SSID and bssid. */
11177 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011178 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011179
11180 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011181 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011182
11183 /*Set the numOfChannels to zero to scan all the channels */
11184 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11185 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11186
11187 /* Default is no encryption */
11188 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11189 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
11190 eCSR_ENCRYPT_TYPE_NONE;
11191
11192 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11193 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
11194 eCSR_ENCRYPT_TYPE_NONE;
11195
11196 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11197
11198 /* Default is no authentication */
11199 pwextBuf->roamProfile.AuthType.numEntries = 1;
11200 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11201
11202 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
11203 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11204
11205 /*Set the default scan mode */
11206 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
11207
11208 hdd_clear_roam_profile_ie(pAdapter);
11209
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011210 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011211 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011212
11213}
11214
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011215/**
11216 * hdd_register_wext() - register wext context
11217 * @dev: net device handle
11218 *
11219 * Registers wext interface context for a given net device
11220 *
11221 * Returns: 0 on success, errno on failure
11222 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011223int hdd_register_wext(struct net_device *dev)
11224{
11225 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011226 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011227 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011228
11229 ENTER();
11230
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011231 if (!pwextBuf) {
11232 hdd_err(FL("ERROR: pwextBuf is NULL"));
11233 return QDF_STATUS_E_FAILURE;
11234 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011235
11236 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011237 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
11238
11239 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->
11240 completion_var);
11241
11242 status = hdd_set_wext(pAdapter);
11243
Anurag Chouhance0dc992016-02-16 18:18:03 +053011244 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011245
Jeff Johnson99bac312016-06-28 10:38:18 -070011246 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011247 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011248 }
11249
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011250 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->hdd_qdf_event))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011251 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011252 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011253 }
11254
Anurag Chouhance0dc992016-02-16 18:18:03 +053011255 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->scanevent))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011256 hdd_err("ERROR: HDD scan event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011257 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011258 }
11259 /* Register as a wireless device */
11260 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11261
11262 EXIT();
11263 return 0;
11264}
11265
11266int hdd_unregister_wext(struct net_device *dev)
11267{
Jeff Johnson99bac312016-06-28 10:38:18 -070011268 hdd_notice("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011269
11270 if (dev != NULL) {
11271 rtnl_lock();
11272 dev->wireless_handlers = NULL;
11273 rtnl_unlock();
11274 }
11275
11276 return 0;
11277}