blob: 7629c204152b08e1e07254fbe17104b6d567dc6a [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
436#ifdef DEBUG
437#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
658 len += ol_txrx_stats(pAdapter->sessionId,
659 &buffer[len], (buf_len - len));
660
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:
728 ol_txrx_display_stats(value);
729 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{
1225 struct statsContext context;
1226 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) {
1247 hdd_err("Not associated!, return last connected AP rssi!");
1248 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301249 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 }
1251
1252 if (pHddStaCtx->hdd_ReassocScenario) {
1253 hdd_info("Roaming in progress, return cached RSSI");
1254 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301255 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 }
1257
1258 init_completion(&context.completion);
1259 context.pAdapter = pAdapter;
1260 context.magic = RSSI_CONTEXT_MAGIC;
1261
1262 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
1263 pHddStaCtx->conn_info.staId[0],
1264 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
1265 &context, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301266 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001267 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 /* we'll returned a cached value below */
1269 } else {
1270 /* request was sent -- wait for the response */
1271 rc = wait_for_completion_timeout(&context.completion,
1272 msecs_to_jiffies
1273 (WLAN_WAIT_TIME_STATS));
1274 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001275 hdd_err("SME timed out while retrieving RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 /* we'll now returned a cached value below */
1277 }
1278 }
1279
1280 /* either we never sent a request, we sent a request and
1281 * received a response or we sent a request and timed out. if
1282 * we never sent a request or if we sent a request and got a
1283 * response, we want to clear the magic out of paranoia. if
1284 * we timed out there is a race condition such that the
1285 * callback function could be executing at the same time we
1286 * are. of primary concern is if the callback function had
1287 * already verified the "magic" but had not yet set the
1288 * completion variable when a timeout occurred. we serialize
1289 * these activities by invalidating the magic while holding a
1290 * shared spinlock which will cause us to block if the
1291 * callback is currently executing
1292 */
1293 spin_lock(&hdd_context_lock);
1294 context.magic = 0;
1295 spin_unlock(&hdd_context_lock);
1296
1297 *rssi_value = pAdapter->rssi;
1298
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301299 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300}
1301
1302/**
1303 * wlan_hdd_get_snr() - Get the current SNR
1304 * @pAdapter: adapter upon which the measurement is requested
1305 * @snr: pointer to where the SNR should be returned
1306 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301307 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301309QDF_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310{
1311 struct statsContext context;
1312 hdd_context_t *pHddCtx;
1313 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301314 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 unsigned long rc;
1316 int valid;
1317
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301318 ENTER();
1319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001321 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301322 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323 }
1324
1325 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1326
1327 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301328 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301329 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330
1331 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1332
1333 init_completion(&context.completion);
1334 context.pAdapter = pAdapter;
1335 context.magic = SNR_CONTEXT_MAGIC;
1336
1337 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
1338 pHddStaCtx->conn_info.staId[0],
1339 pHddStaCtx->conn_info.bssId, &context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301340 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001341 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 /* we'll returned a cached value below */
1343 } else {
1344 /* request was sent -- wait for the response */
1345 rc = wait_for_completion_timeout(&context.completion,
1346 msecs_to_jiffies
1347 (WLAN_WAIT_TIME_STATS));
1348 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001349 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350 /* we'll now returned a cached value below */
1351 }
1352 }
1353
1354 /* either we never sent a request, we sent a request and
1355 * received a response or we sent a request and timed out. if
1356 * we never sent a request or if we sent a request and got a
1357 * response, we want to clear the magic out of paranoia. if
1358 * we timed out there is a race condition such that the
1359 * callback function could be executing at the same time we
1360 * are. of primary concern is if the callback function had
1361 * already verified the "magic" but had not yet set the
1362 * completion variable when a timeout occurred. we serialize
1363 * these activities by invalidating the magic while holding a
1364 * shared spinlock which will cause us to block if the
1365 * callback is currently executing
1366 */
1367 spin_lock(&hdd_context_lock);
1368 context.magic = 0;
1369 spin_unlock(&hdd_context_lock);
1370
1371 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301372 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301373 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374}
1375
1376/**
1377 * hdd_get_link_speed_cb() - Get link speed callback function
1378 * @pLinkSpeed: pointer to the link speed record
1379 * @pContext: pointer to the user context passed to SME
1380 *
1381 * This function is passed as the callback function to
1382 * sme_get_link_speed() by wlan_hdd_get_linkspeed_for_peermac(). By
1383 * agreement a &struct linkspeedContext is passed as @pContext. If
1384 * the context is valid, then the contents of @pLinkSpeed are copied
1385 * into the adapter record referenced by @pContext where they can be
1386 * subsequently retrieved. If the context is invalid, then this
1387 * function does nothing since it is assumed the caller has already
1388 * timed-out and destroyed the context.
1389 *
1390 * Return: None.
1391 */
1392static void
1393hdd_get_link_speed_cb(tSirLinkSpeedInfo *pLinkSpeed, void *pContext)
1394{
1395 struct linkspeedContext *pLinkSpeedContext;
1396 hdd_adapter_t *pAdapter;
1397
1398 if ((NULL == pLinkSpeed) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001399 hdd_err("Bad param, pLinkSpeed [%p] pContext [%p]",
1400 pLinkSpeed, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 return;
1402 }
1403 spin_lock(&hdd_context_lock);
1404 pLinkSpeedContext = pContext;
1405 pAdapter = pLinkSpeedContext->pAdapter;
1406
1407 /* there is a race condition that exists between this callback
1408 * function and the caller since the caller could time out either
1409 * before or while this code is executing. we use a spinlock to
1410 * serialize these actions
1411 */
1412
1413 if ((NULL == pAdapter) ||
1414 (LINK_CONTEXT_MAGIC != pLinkSpeedContext->magic)) {
1415 /* the caller presumably timed out so there is nothing
1416 * we can do
1417 */
1418 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07001419 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
1420 pAdapter, pLinkSpeedContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421 if (ioctl_debug) {
1422 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1423 __func__, pAdapter, pLinkSpeedContext->magic);
1424 }
1425 return;
1426 }
1427
1428 /* context is valid so caller is still waiting */
1429
1430 /* paranoia: invalidate the magic */
1431 pLinkSpeedContext->magic = 0;
1432
1433 /* copy over the stats. do so as a struct copy */
1434 pAdapter->ls_stats = *pLinkSpeed;
1435
1436 /* notify the caller */
1437 complete(&pLinkSpeedContext->completion);
1438
1439 /* serialization is complete */
1440 spin_unlock(&hdd_context_lock);
1441}
1442
1443/**
1444 * wlan_hdd_get_linkspeed_for_peermac() - Get link speed for a peer
1445 * @pAdapter: adapter upon which the peer is active
1446 * @macAddress: MAC address of the peer
1447 *
1448 * This function will send a query to SME for the linkspeed of the
1449 * given peer, and then wait for the callback to be invoked.
1450 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301451 * Return: QDF_STATUS_SUCCESS if linkspeed data is available,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301452 * otherwise a QDF_STATUS_E_** error.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301454QDF_STATUS wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *pAdapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301455 struct qdf_mac_addr macAddress) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301456 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 unsigned long rc;
1458 struct linkspeedContext context;
1459 tSirLinkSpeedInfo *linkspeed_req;
1460
1461 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001462 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301463 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301465 linkspeed_req = qdf_mem_malloc(sizeof(*linkspeed_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466 if (NULL == linkspeed_req) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001467 hdd_err("Request Buffer Alloc Fail");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301468 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469 }
1470 init_completion(&context.completion);
1471 context.pAdapter = pAdapter;
1472 context.magic = LINK_CONTEXT_MAGIC;
1473
Anurag Chouhanc5548422016-02-24 18:33:27 +05301474 qdf_copy_macaddr(&linkspeed_req->peer_macaddr, &macAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001475 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(pAdapter),
1476 linkspeed_req,
1477 &context, hdd_get_link_speed_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301478 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001479 hdd_err("Unable to retrieve statistics for link speed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301480 qdf_mem_free(linkspeed_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001481 } else {
1482 rc = wait_for_completion_timeout
1483 (&context.completion,
1484 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
1485 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001486 hdd_err("SME timed out while retrieving link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487 }
1488 }
1489
1490 /* either we never sent a request, we sent a request and
1491 * received a response or we sent a request and timed out. if
1492 * we never sent a request or if we sent a request and got a
1493 * response, we want to clear the magic out of paranoia. if
1494 * we timed out there is a race condition such that the
1495 * callback function could be executing at the same time we
1496 * are. of primary concern is if the callback function had
1497 * already verified the "magic" but had not yet set the
1498 * completion variable when a timeout occurred. we serialize
1499 * these activities by invalidating the magic while holding a
1500 * shared spinlock which will cause us to block if the
1501 * callback is currently executing
1502 */
1503 spin_lock(&hdd_context_lock);
1504 context.magic = 0;
1505 spin_unlock(&hdd_context_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301506 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507}
1508
1509/**
1510 * wlan_hdd_get_link_speed() - get link speed
1511 * @pAdapter: pointer to the adapter
1512 * @link_speed: pointer to link speed
1513 *
1514 * This function fetches per bssid link speed.
1515 *
1516 * Return: if associated, link speed shall be returned.
1517 * if not associated, link speed of 0 is returned.
1518 * On error, error number will be returned.
1519 */
1520int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
1521{
1522 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
1523 hdd_station_ctx_t *hdd_stactx =
1524 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
1525 int ret;
1526
1527 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301528 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05301531 /* Linkspeed is allowed only for P2P mode */
1532 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
1533 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
1534 hdd_device_mode_to_string(sta_adapter->device_mode),
1535 sta_adapter->device_mode);
1536 return -ENOTSUPP;
1537 }
1538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
1540 /* we are not connected so we don't have a classAstats */
1541 *link_speed = 0;
1542 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301543 QDF_STATUS status;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301544 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545
Anurag Chouhanc5548422016-02-24 18:33:27 +05301546 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547
1548 status = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301549 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001550 hdd_err("Unable to retrieve SME linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 return -EINVAL;
1552 }
1553 *link_speed = sta_adapter->ls_stats.estLinkSpeed;
1554 /* linkspeed in units of 500 kbps */
1555 *link_speed = (*link_speed) / 500;
1556 }
1557 return 0;
1558}
1559
1560/**
1561 * hdd_statistics_cb() - "Get statistics" callback function
1562 * @pStats: statistics payload
1563 * @pContext: opaque context originally passed to SME. HDD always passes
1564 * a pointer to an adapter
1565 *
1566 * Return: None
1567 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07001568static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569{
1570 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
1571 hdd_stats_t *pStatsCache = NULL;
1572 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05301573 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574
1575 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1576 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1577 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1578 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1579 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1580 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1581
1582 if (pAdapter != NULL)
1583 pStatsCache = &pAdapter->hdd_stats;
1584
1585 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
1586 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
1587 pClassBStats = (tCsrGlobalClassBStatsInfo *) (pClassAStats + 1);
1588 pClassCStats = (tCsrGlobalClassCStatsInfo *) (pClassBStats + 1);
1589 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassCStats + 1);
1590 pPerStaStats = (tCsrPerStaStatsInfo *) (pClassDStats + 1);
1591
1592 if (pStatsCache != NULL) {
1593 /* copy the stats into the cache we keep in the
1594 * adapter instance structure
1595 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301596 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301598 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301600 qdf_mem_copy(&pStatsCache->ClassB_stat, pClassBStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601 sizeof(pStatsCache->ClassB_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301602 qdf_mem_copy(&pStatsCache->ClassC_stat, pClassCStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 sizeof(pStatsCache->ClassC_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301604 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605 sizeof(pStatsCache->ClassD_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301606 qdf_mem_copy(&pStatsCache->perStaStats, pPerStaStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 sizeof(pStatsCache->perStaStats));
1608 }
1609
1610 if (pAdapter) {
1611 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301612 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05301613 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001614 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 return;
1616 }
1617 }
1618}
1619
1620/**
1621 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
1622 * @pAdapter: adapter who's IEs are to be cleared
1623 *
1624 * Return: None
1625 */
1626void hdd_clear_roam_profile_ie(hdd_adapter_t *pAdapter)
1627{
1628 int i = 0;
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
1671 for (i = 0; i < CSR_MAX_NUM_KEY; i++) {
1672 if (pWextState->roamProfile.Keys.KeyMaterial[i]) {
1673 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1674 }
1675 }
1676#ifdef FEATURE_WLAN_WAPI
1677 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1678 pAdapter->wapi_info.nWapiMode = 0;
1679#endif
1680
Anurag Chouhanc5548422016-02-24 18:33:27 +05301681 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001682 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683}
1684
1685/**
1686 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
1687 * @oui: The OUI that is being searched for
1688 * @oui_size: The length of @oui
1689 * @ie: The set of IEs within which we're trying to find @oui
1690 * @ie_len: The length of @ie
1691 *
1692 * This function will scan the IEs contained within @ie looking for @oui.
1693 *
1694 * Return: Pointer to @oui embedded within @ie if it is present, NULL
1695 * if @oui is not present within @ie.
1696 */
1697uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
1698 uint8_t *ie, int ie_len)
1699{
1700 int left = ie_len;
1701 uint8_t *ptr = ie;
1702 uint8_t elem_id, elem_len;
1703 uint8_t eid = 0xDD;
1704
1705 if (NULL == ie || 0 == ie_len)
1706 return NULL;
1707
1708 while (left >= 2) {
1709 elem_id = ptr[0];
1710 elem_len = ptr[1];
1711 left -= 2;
1712 if (elem_len > left) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001713 hdd_alert("****Invalid IEs eid = %d elem_len=%d left=%d*****",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 eid, elem_len, left);
1715 return NULL;
1716 }
1717 if (elem_id == eid) {
1718 if (memcmp(&ptr[2], oui, oui_size) == 0)
1719 return ptr;
1720 }
1721
1722 left -= elem_len;
1723 ptr += (elem_len + 2);
1724 }
1725 return NULL;
1726}
1727
1728/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05301729 * hdd_get_ldpc() - Get adapter LDPC
1730 * @adapter: adapter being queried
1731 * @value: where to store the value
1732 *
1733 * Return: 0 on success, negative errno on failure
1734 */
1735int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
1736{
1737 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1738 int ret;
1739
1740 ENTER();
1741 ret = sme_get_ht_config(hal, adapter->sessionId,
1742 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
1743 if (ret < 0) {
1744 hdd_alert("Failed to get LDPC value");
1745 } else {
1746 *value = ret;
1747 ret = 0;
1748 }
1749 return ret;
1750}
1751
1752/**
1753 * hdd_set_ldpc() - Set adapter LDPC
1754 * @adapter: adapter being modified
1755 * @value: new LDPC value
1756 *
1757 * Return: 0 on success, negative errno on failure
1758 */
1759int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
1760{
1761 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1762 int ret;
1763
1764 hdd_alert("%d", value);
1765 if (value) {
1766 /* make sure HT capabilities allow this */
1767 QDF_STATUS status;
1768 uint32_t cfg_value;
1769 union {
1770 uint16_t cfg_value16;
1771 tSirMacHTCapabilityInfo ht_cap_info;
1772 } u;
1773
1774 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1775 if (QDF_STATUS_SUCCESS != status) {
1776 hdd_alert("Failed to get HT capability info");
1777 return -EIO;
1778 }
1779 u.cfg_value16 = cfg_value & 0xFFFF;
1780 if (!u.ht_cap_info.advCodingCap) {
1781 hdd_alert("LDCP not supported");
1782 return -EINVAL;
1783 }
1784 }
1785
1786 ret = sme_update_ht_config(hal, adapter->sessionId,
1787 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
1788 value);
1789 if (ret)
1790 hdd_alert("Failed to set LDPC value");
1791
1792 return ret;
1793}
1794
1795/**
1796 * hdd_get_tx_stbc() - Get adapter TX STBC
1797 * @adapter: adapter being queried
1798 * @value: where to store the value
1799 *
1800 * Return: 0 on success, negative errno on failure
1801 */
1802int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
1803{
1804 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1805 int ret;
1806
1807 ENTER();
1808 ret = sme_get_ht_config(hal, adapter->sessionId,
1809 WNI_CFG_HT_CAP_INFO_TX_STBC);
1810 if (ret < 0) {
1811 hdd_alert("Failed to get TX STBC value");
1812 } else {
1813 *value = ret;
1814 ret = 0;
1815 }
1816
1817 return ret;
1818}
1819
1820/**
1821 * hdd_set_tx_stbc() - Set adapter TX STBC
1822 * @adapter: adapter being modified
1823 * @value: new TX STBC value
1824 *
1825 * Return: 0 on success, negative errno on failure
1826 */
1827int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
1828{
1829 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1830 int ret;
1831
1832 hdd_alert("%d", value);
1833 if (value) {
1834 /* make sure HT capabilities allow this */
1835 QDF_STATUS status;
1836 uint32_t cfg_value;
1837 union {
1838 uint16_t cfg_value16;
1839 tSirMacHTCapabilityInfo ht_cap_info;
1840 } u;
1841
1842 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1843 if (QDF_STATUS_SUCCESS != status) {
1844 hdd_alert("Failed to get HT capability info");
1845 return -EIO;
1846 }
1847 u.cfg_value16 = cfg_value & 0xFFFF;
1848 if (!u.ht_cap_info.txSTBC) {
1849 hdd_alert("TX STBC not supported");
1850 return -EINVAL;
1851 }
1852 }
1853 ret = sme_update_ht_config(hal, adapter->sessionId,
1854 WNI_CFG_HT_CAP_INFO_TX_STBC,
1855 value);
1856 if (ret)
1857 hdd_alert("Failed to set TX STBC value");
1858
1859 return ret;
1860}
1861
1862/**
1863 * hdd_get_rx_stbc() - Get adapter RX STBC
1864 * @adapter: adapter being queried
1865 * @value: where to store the value
1866 *
1867 * Return: 0 on success, negative errno on failure
1868 */
1869int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
1870{
1871 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1872 int ret;
1873
1874 ENTER();
1875 ret = sme_get_ht_config(hal, adapter->sessionId,
1876 WNI_CFG_HT_CAP_INFO_RX_STBC);
1877 if (ret < 0) {
1878 hdd_alert("Failed to get RX STBC value");
1879 } else {
1880 *value = ret;
1881 ret = 0;
1882 }
1883
1884 return ret;
1885}
1886
1887/**
1888 * hdd_set_rx_stbc() - Set adapter RX STBC
1889 * @adapter: adapter being modified
1890 * @value: new RX STBC value
1891 *
1892 * Return: 0 on success, negative errno on failure
1893 */
1894int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
1895{
1896 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1897 int ret;
1898
1899 hdd_alert("%d", value);
1900 if (value) {
1901 /* make sure HT capabilities allow this */
1902 QDF_STATUS status;
1903 uint32_t cfg_value;
1904 union {
1905 uint16_t cfg_value16;
1906 tSirMacHTCapabilityInfo ht_cap_info;
1907 } u;
1908
1909 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1910 if (QDF_STATUS_SUCCESS != status) {
1911 hdd_alert("Failed to get HT capability info");
1912 return -EIO;
1913 }
1914 u.cfg_value16 = cfg_value & 0xFFFF;
1915 if (!u.ht_cap_info.rxSTBC) {
1916 hdd_alert("RX STBC not supported");
1917 return -EINVAL;
1918 }
1919 }
1920 ret = sme_update_ht_config(hal, adapter->sessionId,
1921 WNI_CFG_HT_CAP_INFO_RX_STBC,
1922 value);
1923 if (ret)
1924 hdd_alert("Failed to set RX STBC value");
1925
1926 return ret;
1927}
1928
1929/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
1931 * @dev: device upon which the ioctl was received
1932 * @info: ioctl request information
1933 * @wrqu: ioctl request data
1934 * @extra: ioctl extra data
1935 *
1936 * Return: 0 on success, non-zero on error
1937 */
1938static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1939 union iwreq_data *wrqu, char *extra)
1940{
1941 hdd_adapter_t *adapter;
1942 hdd_context_t *hdd_ctx;
1943 int ret;
1944
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08001945 ENTER_DEV(dev);
1946
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1948 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
1949 ret = wlan_hdd_validate_context(hdd_ctx);
1950 if (0 != ret)
1951 return ret;
1952
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 /* Do nothing for now */
1954 return 0;
1955}
1956
1957/**
1958 * iw_set_commit() - SSR wrapper function for __iw_set_commit
1959 * @dev: pointer to net_device
1960 * @info: pointer to iw_request_info
1961 * @wrqu: pointer to iwreq_data
1962 * @extra: extra
1963 *
1964 * Return: 0 on success, error number otherwise
1965 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07001966static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967 union iwreq_data *wrqu, char *extra)
1968{
1969 int ret;
1970
1971 cds_ssr_protect(__func__);
1972 ret = __iw_set_commit(dev, info, wrqu, extra);
1973 cds_ssr_unprotect(__func__);
1974
1975 return ret;
1976}
1977
1978/**
1979 * __iw_get_name() - SIOCGIWNAME ioctl handler
1980 * @dev: device upon which the ioctl was received
1981 * @info: ioctl request information
1982 * @wrqu: ioctl request data
1983 * @extra: ioctl extra data
1984 *
1985 * Return: 0 on success, non-zero on error
1986 */
1987static int __iw_get_name(struct net_device *dev,
1988 struct iw_request_info *info, char *wrqu, char *extra)
1989{
1990 hdd_adapter_t *adapter;
1991 hdd_context_t *hdd_ctx;
1992 int ret;
1993
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08001994 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995
1996 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1997 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
1998 ret = wlan_hdd_validate_context(hdd_ctx);
1999 if (0 != ret)
2000 return ret;
2001
2002 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
2003 EXIT();
2004 return 0;
2005}
2006
2007/**
2008 * __iw_get_name() - SSR wrapper for __iw_get_name
2009 * @dev: pointer to net_device
2010 * @info: pointer to iw_request_info
2011 * @wrqu: pointer to iwreq_data
2012 * @extra: extra
2013 *
2014 * Return: 0 on success, error number otherwise
2015 */
2016static int iw_get_name(struct net_device *dev,
2017 struct iw_request_info *info,
2018 char *wrqu, char *extra)
2019{
2020 int ret;
2021
2022 cds_ssr_protect(__func__);
2023 ret = __iw_get_name(dev, info, wrqu, extra);
2024 cds_ssr_unprotect(__func__);
2025
2026 return ret;
2027}
2028
2029/**
2030 * __iw_set_mode() - ioctl handler
2031 * @dev: device upon which the ioctl was received
2032 * @info: ioctl request information
2033 * @wrqu: ioctl request data
2034 * @extra: ioctl extra data
2035 *
2036 * Return: 0 on success, non-zero on error
2037 */
2038static int __iw_set_mode(struct net_device *dev,
2039 struct iw_request_info *info,
2040 union iwreq_data *wrqu, char *extra)
2041{
2042 hdd_wext_state_t *pWextState;
2043 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2044 hdd_context_t *hdd_ctx;
2045 tCsrRoamProfile *pRoamProfile;
2046 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 struct hdd_config *pConfig;
2048 struct wireless_dev *wdev;
2049 int ret;
2050
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002051 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052
2053 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2054 ret = wlan_hdd_validate_context(hdd_ctx);
2055 if (0 != ret)
2056 return ret;
2057
2058 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2059 wdev = dev->ieee80211_ptr;
2060 pRoamProfile = &pWextState->roamProfile;
2061 LastBSSType = pRoamProfile->BSSType;
2062
Jeff Johnson99bac312016-06-28 10:38:18 -07002063 hdd_notice("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064
2065 switch (wrqu->mode) {
2066 case IW_MODE_ADHOC:
Jeff Johnson99bac312016-06-28 10:38:18 -07002067 hdd_notice("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2069 /* Set the phymode correctly for IBSS. */
2070 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
2071 pWextState->roamProfile.phyMode =
2072 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08002073 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 wdev->iftype = NL80211_IFTYPE_ADHOC;
2075 break;
2076 case IW_MODE_INFRA:
Jeff Johnson99bac312016-06-28 10:38:18 -07002077 hdd_notice("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
2079 wdev->iftype = NL80211_IFTYPE_STATION;
2080 break;
2081 case IW_MODE_AUTO:
Jeff Johnson99bac312016-06-28 10:38:18 -07002082 hdd_notice("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
2084 break;
2085 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002086 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 return -EOPNOTSUPP;
2088 }
2089
2090 if (LastBSSType != pRoamProfile->BSSType) {
2091 /* the BSS mode changed. We need to issue disconnect
2092 * if connected or in IBSS disconnect state
2093 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07002094 if (hdd_conn_is_connected
2095 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302097 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098 /* need to issue a disconnect to CSR. */
2099 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302100 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
2102 pAdapter->sessionId,
2103 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302104 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 unsigned long rc;
2106 rc = wait_for_completion_timeout(&pAdapter->
2107 disconnect_comp_var,
2108 msecs_to_jiffies
2109 (WLAN_WAIT_TIME_DISCONNECT));
2110 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07002111 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 }
2113 }
2114 }
2115
2116 EXIT();
2117 return 0;
2118}
2119
2120/**
2121 * iw_set_mode() - SSR wrapper for __iw_set_mode()
2122 * @dev: pointer to net_device
2123 * @info: pointer to iw_request_info
2124 * @wrqu: pointer to iwreq_data
2125 * @extra: pointer to extra ioctl payload
2126 *
2127 * Return: 0 on success, error number otherwise
2128 */
2129static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
2130 union iwreq_data *wrqu, char *extra)
2131{
2132 int ret;
2133
2134 cds_ssr_protect(__func__);
2135 ret = __iw_set_mode(dev, info, wrqu, extra);
2136 cds_ssr_unprotect(__func__);
2137
2138 return ret;
2139}
2140
2141/**
2142 * __iw_get_mode() - SIOCGIWMODE ioctl handler
2143 * @dev: device upon which the ioctl was received
2144 * @info: ioctl request information
2145 * @wrqu: ioctl request data
2146 * @extra: ioctl extra data
2147 *
2148 * Return: 0 on success, non-zero on error
2149 */
2150static int
2151__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2152 union iwreq_data *wrqu, char *extra)
2153{
2154 hdd_wext_state_t *pWextState;
2155 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2156 hdd_context_t *hdd_ctx;
2157 int ret;
2158
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002159 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160
2161 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2162 ret = wlan_hdd_validate_context(hdd_ctx);
2163 if (0 != ret)
2164 return ret;
2165
2166 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2167
2168 switch (pWextState->roamProfile.BSSType) {
2169 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Jeff Johnson99bac312016-06-28 10:38:18 -07002170 hdd_notice("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171 wrqu->mode = IW_MODE_INFRA;
2172 break;
2173 case eCSR_BSS_TYPE_IBSS:
2174 case eCSR_BSS_TYPE_START_IBSS:
Jeff Johnson99bac312016-06-28 10:38:18 -07002175 hdd_notice("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176 wrqu->mode = IW_MODE_ADHOC;
2177 break;
2178 case eCSR_BSS_TYPE_ANY:
2179 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002180 hdd_notice("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 wrqu->mode = IW_MODE_AUTO;
2182 break;
2183 }
2184
2185 EXIT();
2186 return 0;
2187}
2188
2189/**
2190 * iw_get_mode() - SSR wrapper for __iw_get_mode()
2191 * @dev: pointer to net_device
2192 * @info: pointer to iw_request_info
2193 * @wrqu: pointer to iwreq_data
2194 * @extra: pointer to extra ioctl payload
2195 *
2196 * Return: 0 on success, error number otherwise
2197 */
2198static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2199 union iwreq_data *wrqu, char *extra)
2200{
2201 int ret;
2202
2203 cds_ssr_protect(__func__);
2204 ret = __iw_get_mode(dev, info, wrqu, extra);
2205 cds_ssr_unprotect(__func__);
2206
2207 return ret;
2208}
2209
2210/**
2211 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
2212 * @dev: device upon which the ioctl was received
2213 * @info: ioctl request information
2214 * @wrqu: ioctl request data
2215 * @extra: ioctl extra data
2216 *
2217 * Return: 0 on success, non-zero on error
2218 */
2219static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2220 union iwreq_data *wrqu, char *extra)
2221{
2222 uint32_t numChans = 0;
2223 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2224 uint32_t indx = 0;
2225 int ret;
2226 hdd_wext_state_t *pWextState;
2227 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2228 hdd_context_t *hdd_ctx;
2229 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2230 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2231 tCsrRoamProfile *pRoamProfile;
2232
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002233 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234
2235 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2236 ret = wlan_hdd_validate_context(hdd_ctx);
2237 if (0 != ret)
2238 return ret;
2239
2240 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2241
2242 pRoamProfile = &pWextState->roamProfile;
2243
Jeff Johnson99bac312016-06-28 10:38:18 -07002244 hdd_notice("setCHANNEL ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245
2246 /* Link is up then return cant set channel */
2247 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
2248 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002249 hdd_err("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 return -EOPNOTSUPP;
2251 }
2252
2253 /* Settings by Frequency as input */
2254 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
2255 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
2256 uint32_t freq = wrqu->freq.m / 100000;
2257
2258 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
2259 && (freq != freq_chan_map[indx].freq))
2260 indx++;
2261 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) {
2262 return -EINVAL;
2263 }
2264 wrqu->freq.e = 0;
2265 wrqu->freq.m = freq_chan_map[indx].chan;
2266
2267 }
2268
2269 if (wrqu->freq.e == 0) {
2270 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
2271 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002272 hdd_notice("Channel %d is outside valid range from %d to %d",
2273 wrqu->freq.m,
2274 WNI_CFG_CURRENT_CHANNEL_STAMIN,
2275 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 return -EINVAL;
2277 }
2278
2279 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2280
2281 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2282 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302283 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002284 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002285 return -EIO;
2286 }
2287
2288 for (indx = 0; indx < numChans; indx++) {
2289 if (wrqu->freq.m == validChan[indx]) {
2290 break;
2291 }
2292 }
2293 } else {
2294
2295 return -EINVAL;
2296 }
2297
2298 if (indx >= numChans) {
2299 return -EINVAL;
2300 }
2301
2302 /* Set the Operational Channel */
2303 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2304 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2305 pRoamProfile->ChannelInfo.ChannelList =
2306 &pHddStaCtx->conn_info.operationChannel;
2307
Jeff Johnson99bac312016-06-28 10:38:18 -07002308 hdd_notice("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309
2310 EXIT();
2311
2312 return ret;
2313}
2314
2315/**
2316 * iw_set_freq() - SSR wrapper for __iw_set_freq()
2317 * @dev: pointer to net_device
2318 * @info: pointer to iw_request_info
2319 * @wrqu: pointer to iwreq_data
2320 * @extra: pointer to extra ioctl payload
2321 *
2322 * Return: 0 on success, error number otherwise
2323 */
2324static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2325 union iwreq_data *wrqu, char *extra)
2326{
2327 int ret;
2328
2329 cds_ssr_protect(__func__);
2330 ret = __iw_set_freq(dev, info, wrqu, extra);
2331 cds_ssr_unprotect(__func__);
2332
2333 return ret;
2334}
2335
2336/**
2337 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
2338 * @dev: device upon which the ioctl was received
2339 * @info: ioctl request information
2340 * @wrqu: ioctl request data
2341 * @extra: ioctl extra data
2342 *
2343 * Return: 0 on success, non-zero on error
2344 */
2345static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2346 struct iw_freq *fwrq, char *extra)
2347{
2348 uint32_t status = false, channel = 0, freq = 0;
2349 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2350 tHalHandle hHal;
2351 hdd_wext_state_t *pWextState;
2352 tCsrRoamProfile *pRoamProfile;
2353 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2354 hdd_context_t *hdd_ctx;
2355 int ret;
2356
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002357 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002358
2359 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2360 ret = wlan_hdd_validate_context(hdd_ctx);
2361 if (0 != ret)
2362 return ret;
2363
2364 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2365 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2366
2367 pRoamProfile = &pWextState->roamProfile;
2368
2369 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
2370 if (sme_get_operation_channel(hHal, &channel, pAdapter->sessionId)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302371 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002372 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002373 pAdapter->sessionId);
2374 return -EIO;
2375 } else {
2376 status = hdd_wlan_get_freq(channel, &freq);
2377 if (true == status) {
2378 /* Set Exponent parameter as 6 (MHZ)
2379 * in struct iw_freq iwlist & iwconfig
2380 * command shows frequency into proper
2381 * format (2.412 GHz instead of 246.2
2382 * MHz)
2383 */
2384 fwrq->m = freq;
2385 fwrq->e = MHZ;
2386 }
2387 }
2388 } else {
2389 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2390 * iwlist & iwconfig command shows frequency into proper
2391 * format (2.412 GHz instead of 246.2 MHz)
2392 */
2393 fwrq->m = 0;
2394 fwrq->e = MHZ;
2395 }
2396 return 0;
2397}
2398
2399/**
2400 * iw_get_freq() - SSR wrapper for __iw_get_freq()
2401 * @dev: pointer to net_device
2402 * @info: pointer to iw_request_info
2403 * @fwrq: pointer to frequency data
2404 * @extra: pointer to extra ioctl payload
2405 *
2406 * Return: 0 on success, error number otherwise
2407 */
2408static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2409 struct iw_freq *fwrq, char *extra)
2410{
2411 int ret;
2412
2413 cds_ssr_protect(__func__);
2414 ret = __iw_get_freq(dev, info, fwrq, extra);
2415 cds_ssr_unprotect(__func__);
2416
2417 return ret;
2418}
2419
2420/**
2421 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
2422 * @dev: device upon which the ioctl was received
2423 * @info: ioctl request information
2424 * @wrqu: ioctl request data
2425 * @extra: ioctl extra data
2426 *
2427 * Return: 0 on success, non-zero on error
2428 */
2429static int __iw_get_tx_power(struct net_device *dev,
2430 struct iw_request_info *info,
2431 union iwreq_data *wrqu, char *extra)
2432{
2433
2434 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2435 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2436 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2437 int ret;
2438
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002439 ENTER_DEV(dev);
2440
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 ret = wlan_hdd_validate_context(hdd_ctx);
2442 if (0 != ret)
2443 return ret;
2444
2445 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2446 wrqu->txpower.value = 0;
2447 return 0;
2448 }
2449 wlan_hdd_get_class_astats(pAdapter);
2450 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2451
2452 return 0;
2453}
2454
2455/**
2456 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
2457 * @dev: pointer to net_device
2458 * @info: pointer to iw_request_info
2459 * @wrqu: pointer to iwreq_data
2460 * @extra: pointer to extra ioctl payload
2461 *
2462 * Return: 0 on success, error number otherwise
2463 */
2464static int iw_get_tx_power(struct net_device *dev,
2465 struct iw_request_info *info,
2466 union iwreq_data *wrqu, char *extra)
2467{
2468 int ret;
2469
2470 cds_ssr_protect(__func__);
2471 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2472 cds_ssr_unprotect(__func__);
2473
2474 return ret;
2475}
2476
2477/**
2478 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
2479 * @dev: device upon which the ioctl was received
2480 * @info: ioctl request information
2481 * @wrqu: ioctl request data
2482 * @extra: ioctl extra data
2483 *
2484 * Return: 0 on success, non-zero on error
2485 */
2486static int __iw_set_tx_power(struct net_device *dev,
2487 struct iw_request_info *info,
2488 union iwreq_data *wrqu, char *extra)
2489{
2490 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2491 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2492 hdd_context_t *hdd_ctx;
2493 int ret;
2494
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002495 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496
2497 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2498 ret = wlan_hdd_validate_context(hdd_ctx);
2499 if (0 != ret)
2500 return ret;
2501
2502 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302503 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002504 hdd_err("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 return -EIO;
2506 }
2507
2508 EXIT();
2509
2510 return 0;
2511}
2512
2513/**
2514 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
2515 * @dev: pointer to net_device
2516 * @info: pointer to iw_request_info
2517 * @wrqu: pointer to iwreq_data
2518 * @extra: pointer to extra ioctl payload
2519 *
2520 * Return: 0 on success, error number otherwise
2521 */
2522static int iw_set_tx_power(struct net_device *dev,
2523 struct iw_request_info *info,
2524 union iwreq_data *wrqu, char *extra)
2525{
2526 int ret;
2527
2528 cds_ssr_protect(__func__);
2529 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2530 cds_ssr_unprotect(__func__);
2531
2532 return ret;
2533}
2534
2535/**
2536 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
2537 * @dev: device upon which the ioctl was received
2538 * @info: ioctl request information
2539 * @wrqu: ioctl request data
2540 * @extra: ioctl extra data
2541 *
2542 * Return: 0 on success, non-zero on error
2543 */
2544static int __iw_get_bitrate(struct net_device *dev,
2545 struct iw_request_info *info,
2546 union iwreq_data *wrqu, char *extra)
2547{
Anurag Chouhance0dc992016-02-16 18:18:03 +05302548 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302549 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550 hdd_wext_state_t *pWextState;
2551 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2552 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2553 hdd_context_t *hdd_ctx;
2554 int ret;
2555
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002556 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557
2558 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2559 ret = wlan_hdd_validate_context(hdd_ctx);
2560 if (0 != ret)
2561 return ret;
2562
Prashanth Bhatta9e143052015-12-04 11:56:47 -08002563 if (cds_is_driver_recovering()) {
2564 hdd_alert("Recovery in Progress. State: 0x%x Ignore!!!",
2565 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002566 return status;
2567 }
2568
2569 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2570 wrqu->bitrate.value = 0;
2571 } else {
2572 status =
2573 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2574 eCSR_HDD,
2575 SME_SUMMARY_STATS |
2576 SME_GLOBAL_CLASSA_STATS |
2577 SME_GLOBAL_CLASSB_STATS |
2578 SME_GLOBAL_CLASSC_STATS |
2579 SME_GLOBAL_CLASSD_STATS |
2580 SME_PER_STA_STATS,
2581 hdd_statistics_cb, 0,
2582 false,
2583 pHddStaCtx->conn_info.staId[0],
2584 pAdapter, pAdapter->sessionId);
2585
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302586 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002587 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 return status;
2589 }
2590
2591 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2592
Anurag Chouhance0dc992016-02-16 18:18:03 +05302593 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302594 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 WLAN_WAIT_TIME_STATS);
2596
Anurag Chouhance0dc992016-02-16 18:18:03 +05302597 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002598 hdd_err("SME timeout while retrieving statistics");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302599 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 }
2601
2602 wrqu->bitrate.value =
2603 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
2604 }
2605
2606 EXIT();
2607
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302608 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609}
2610
2611/**
2612 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
2613 * @dev: pointer to net_device
2614 * @info: pointer to iw_request_info
2615 * @wrqu: pointer to iwreq_data
2616 * @extra: pointer to extra ioctl payload
2617 *
2618 * Return: 0 on success, error number otherwise
2619 */
2620static int iw_get_bitrate(struct net_device *dev,
2621 struct iw_request_info *info,
2622 union iwreq_data *wrqu, char *extra)
2623{
2624 int ret;
2625
2626 cds_ssr_protect(__func__);
2627 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2628 cds_ssr_unprotect(__func__);
2629
2630 return ret;
2631}
2632
2633/**
2634 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
2635 * @dev: device upon which the ioctl was received
2636 * @info: ioctl request information
2637 * @wrqu: ioctl request data
2638 * @extra: ioctl extra data
2639 *
2640 * Return: 0 on success, non-zero on error
2641 */
2642static int __iw_set_bitrate(struct net_device *dev,
2643 struct iw_request_info *info,
2644 union iwreq_data *wrqu, char *extra)
2645{
2646 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2647 hdd_wext_state_t *pWextState;
2648 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2649 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2650 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2651 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2652 uint32_t i, rate;
2653 uint32_t valid_rate = false, active_phy_mode = 0;
2654 hdd_context_t *hdd_ctx;
2655 int ret;
2656
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002657 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658
2659 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2660 ret = wlan_hdd_validate_context(hdd_ctx);
2661 if (0 != ret)
2662 return ret;
2663
2664 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2665
2666 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2667 return -ENXIO;
2668 }
2669
2670 rate = wrqu->bitrate.value;
2671
2672 if (rate == -1) {
2673 rate = WNI_CFG_FIXED_RATE_AUTO;
2674 valid_rate = true;
2675 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
2676 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302677 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
2679 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2680 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
2681 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
2682 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302683 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 &&
2685 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
2686 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302687 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688 for (i = 0; i < (b_len + a_len); ++i) {
2689 /* supported rates returned is double
2690 * the actual rate so we divide it by 2
2691 */
2692 if ((supp_rates[i] & 0x7F) / 2 ==
2693 rate) {
2694 valid_rate = true;
2695 rate = i +
2696 WNI_CFG_FIXED_RATE_1MBPS;
2697 break;
2698 }
2699 }
2700 }
2701 }
2702 }
2703 if (valid_rate != true) {
2704 return -EINVAL;
2705 }
2706 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302707 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002708 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 return -EIO;
2710 }
2711 return 0;
2712}
2713
2714/**
2715 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
2716 * @dev: pointer to net_device
2717 * @info: pointer to iw_request_info
2718 * @wrqu: pointer to iwreq_data
2719 * @extra: pointer to extra ioctl payload
2720 *
2721 * Return: 0 on success, error number otherwise
2722 */
2723static int iw_set_bitrate(struct net_device *dev,
2724 struct iw_request_info *info,
2725 union iwreq_data *wrqu, char *extra)
2726{
2727 int ret;
2728
2729 cds_ssr_protect(__func__);
2730 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2731 cds_ssr_unprotect(__func__);
2732
2733 return ret;
2734}
2735
2736/**
2737 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
2738 * @dev: device upon which the ioctl was received
2739 * @info: ioctl request information
2740 * @wrqu: ioctl request data
2741 * @extra: ioctl extra data
2742 *
2743 * Return: 0 on success, non-zero on error
2744 */
2745static int __iw_set_genie(struct net_device *dev,
2746 struct iw_request_info *info,
2747 union iwreq_data *wrqu, char *extra)
2748{
2749 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2750 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2751 uint8_t *genie = NULL;
2752 uint8_t *base_genie = NULL;
2753 uint16_t remLen;
2754 hdd_context_t *hdd_ctx;
2755 int ret;
2756
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002757 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758
2759 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2760 ret = wlan_hdd_validate_context(hdd_ctx);
2761 if (0 != ret)
2762 return ret;
2763
2764 if (!wrqu->data.length) {
2765 hdd_clear_roam_profile_ie(pAdapter);
2766 EXIT();
2767 return 0;
2768 }
2769
2770 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2771 wrqu->data.length);
2772 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002773 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 return -ENOMEM;
2775 }
2776
2777 genie = base_genie;
2778
2779 remLen = wrqu->data.length;
2780
Jeff Johnson99bac312016-06-28 10:38:18 -07002781 hdd_notice("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782 genie[1]);
2783
2784 /* clear any previous genIE before this call */
2785 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
2786
2787 while (remLen >= 2) {
2788 uint16_t eLen = 0;
2789 uint8_t elementId;
2790 elementId = *genie++;
2791 eLen = *genie++;
2792 remLen -= 2;
2793
Jeff Johnson99bac312016-06-28 10:38:18 -07002794 hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795
2796 switch (elementId) {
2797 case IE_EID_VENDOR:
2798 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 +05302799 ret = -EINVAL;
2800 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801 }
2802
2803 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
2804 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07002805 hdd_notice("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2806 genie[0], genie[1], genie[2],
2807 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808
2809 if (SIR_MAC_MAX_IE_LENGTH <
2810 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002811 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302812 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302813 ret = -ENOMEM;
2814 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815 }
2816 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
2817 memcpy(pWextState->genIE.addIEdata +
2818 curGenIELen, genie - 2, eLen + 2);
2819 pWextState->genIE.length += eLen + 2;
2820 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002821 hdd_notice("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302822 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
2823 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
2824 ret = -EINVAL;
2825 QDF_ASSERT(0);
2826 goto exit;
2827 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 memset(pWextState->WPARSNIE, 0,
2829 MAX_WPA_RSN_IE_LEN);
2830 memcpy(pWextState->WPARSNIE, genie - 2,
2831 (eLen + 2));
2832 pWextState->roamProfile.pWPAReqIE =
2833 pWextState->WPARSNIE;
2834 pWextState->roamProfile.nWPAReqIELength =
2835 eLen + 2;
2836 } else { /* any vendorId except WPA IE should be accumulated to genIE */
2837
2838 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07002839 hdd_notice("Set OUI(%02x %02x %02x %02x) IE(len %d)",
2840 genie[0], genie[1], genie[2],
2841 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842
2843 if (SIR_MAC_MAX_IE_LENGTH <
2844 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002845 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302846 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302847 ret = -ENOMEM;
2848 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 }
2850 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
2851 memcpy(pWextState->genIE.addIEdata +
2852 curGenIELen, genie - 2, eLen + 2);
2853 pWextState->genIE.length += eLen + 2;
2854 }
2855 break;
2856 case DOT11F_EID_RSN:
Jeff Johnson99bac312016-06-28 10:38:18 -07002857 hdd_notice("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302858 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
2859 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
2860 ret = -EINVAL;
2861 QDF_ASSERT(0);
2862 goto exit;
2863 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
2865 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
2866 pWextState->roamProfile.pRSNReqIE =
2867 pWextState->WPARSNIE;
2868 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2869 break;
2870
2871 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002872 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302873 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 }
2875 genie += eLen;
2876 remLen -= eLen;
2877 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302878exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 EXIT();
2880 kfree(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302881 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002882}
2883
2884/**
2885 * iw_set_genie() - SSR wrapper for __iw_set_genie()
2886 * @dev: pointer to net_device
2887 * @info: pointer to iw_request_info
2888 * @wrqu: pointer to iwreq_data
2889 * @extra: pointer to extra ioctl payload
2890 *
2891 * Return: 0 on success, error number otherwise
2892 */
2893static int iw_set_genie(struct net_device *dev,
2894 struct iw_request_info *info,
2895 union iwreq_data *wrqu, char *extra)
2896{
2897 int ret;
2898
2899 cds_ssr_protect(__func__);
2900 ret = __iw_set_genie(dev, info, wrqu, extra);
2901 cds_ssr_unprotect(__func__);
2902
2903 return ret;
2904}
2905
2906/**
2907 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
2908 * @dev: device upon which the ioctl was received
2909 * @info: ioctl request information
2910 * @wrqu: ioctl request data
2911 * @extra: ioctl extra data
2912 *
2913 * Return: 0 on success, non-zero on error
2914 */
2915static int __iw_get_genie(struct net_device *dev,
2916 struct iw_request_info *info,
2917 union iwreq_data *wrqu, char *extra)
2918{
2919 hdd_wext_state_t *pWextState;
2920 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2921 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302922 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
2924 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2925 hdd_context_t *hdd_ctx;
2926 int ret;
2927
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002928 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929
2930 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2931 ret = wlan_hdd_validate_context(hdd_ctx);
2932 if (0 != ret)
2933 return ret;
2934
Jeff Johnson99bac312016-06-28 10:38:18 -07002935 hdd_notice("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936
2937 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2938
2939 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
2940 return -ENXIO;
2941 }
2942
2943 /* Return something ONLY if we are associated with an RSN or
2944 * WPA network
2945 */
2946 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
2947 return -ENXIO;
2948 }
2949
2950 /* Actually retrieve the RSN IE from CSR. (We previously sent
2951 * it down in the CSR Roam Profile.)
2952 */
2953 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
2954 pAdapter->sessionId,
2955 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05302956 if (QDF_STATUS_SUCCESS != status) {
2957 hdd_notice("failed to get WPA-RSN IE data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 return -EFAULT;
2959 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05302961 if (length > DOT11F_IE_RSN_MAX_LEN) {
2962 hdd_notice("invalid buffer length length:%d", length);
2963 return -E2BIG;
2964 }
2965 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966
Jeff Johnson99bac312016-06-28 10:38:18 -07002967 hdd_notice("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 wrqu->data.length);
2969
2970 EXIT();
2971
2972 return 0;
2973}
2974
2975/**
2976 * iw_get_genie() - SSR wrapper for __iw_get_genie()
2977 * @dev: pointer to net_device
2978 * @info: pointer to iw_request_info
2979 * @wrqu: pointer to iwreq_data
2980 * @extra: pointer to extra ioctl payload
2981 *
2982 * Return: 0 on success, error number otherwise
2983 */
2984static int iw_get_genie(struct net_device *dev,
2985 struct iw_request_info *info,
2986 union iwreq_data *wrqu, char *extra)
2987{
2988 int ret;
2989
2990 cds_ssr_protect(__func__);
2991 ret = __iw_get_genie(dev, info, wrqu, extra);
2992 cds_ssr_unprotect(__func__);
2993
2994 return ret;
2995}
2996
2997/**
2998 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
2999 * @dev: device upon which the ioctl was received
3000 * @info: ioctl request information
3001 * @wrqu: ioctl request data
3002 * @extra: ioctl extra data
3003 *
3004 * Return: 0 on success, non-zero on error
3005 */
3006static int __iw_get_encode(struct net_device *dev,
3007 struct iw_request_info *info,
3008 struct iw_point *dwrq, char *extra)
3009{
3010 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3011 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3012 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3013 int keyId;
3014 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3015 int i;
3016 hdd_context_t *hdd_ctx;
3017 int ret;
3018
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003019 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020
3021 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3022 ret = wlan_hdd_validate_context(hdd_ctx);
3023 if (0 != ret)
3024 return ret;
3025
3026 keyId = pRoamProfile->Keys.defaultIndex;
3027
3028 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003029 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030 return -EINVAL;
3031 }
3032
3033 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
3034 dwrq->flags |= IW_ENCODE_ENABLED;
3035 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303036 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 pRoamProfile->Keys.KeyLength[keyId]);
3038
3039 dwrq->flags |= (keyId + 1);
3040
3041 } else {
3042 dwrq->flags |= IW_ENCODE_DISABLED;
3043 }
3044
3045 for (i = 0; i < MAX_WEP_KEYS; i++) {
3046 if (pRoamProfile->Keys.KeyMaterial[i] == NULL) {
3047 continue;
3048 } else {
3049 break;
3050 }
3051 }
3052
3053 if (MAX_WEP_KEYS == i) {
3054 dwrq->flags |= IW_ENCODE_NOKEY;
3055 }
3056
3057 authType =
3058 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
3059 conn_info.authType;
3060
3061 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
3062 dwrq->flags |= IW_ENCODE_OPEN;
3063 } else {
3064 dwrq->flags |= IW_ENCODE_RESTRICTED;
3065 }
3066 EXIT();
3067 return 0;
3068}
3069
3070/**
3071 * iw_get_encode() - SSR wrapper for __iw_get_encode()
3072 * @dev: pointer to net_device
3073 * @info: pointer to iw_request_info
3074 * @dwrq: pointer to encoding information
3075 * @extra: pointer to extra ioctl payload
3076 *
3077 * Return: 0 on success, error number otherwise
3078 */
3079static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
3080 struct iw_point *dwrq, char *extra)
3081{
3082 int ret;
3083
3084 cds_ssr_protect(__func__);
3085 ret = __iw_get_encode(dev, info, dwrq, extra);
3086 cds_ssr_unprotect(__func__);
3087
3088 return ret;
3089}
3090
3091/**
3092 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
3093 * @dev: device upon which the ioctl was received
3094 * @info: ioctl request information
3095 * @wrqu: ioctl request data
3096 * @extra: ioctl extra data
3097 *
3098 * Return: 0 on success, non-zero on error
3099 */
3100static int __iw_get_rts_threshold(struct net_device *dev,
3101 struct iw_request_info *info,
3102 union iwreq_data *wrqu, char *extra)
3103{
3104 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3105 uint32_t status = 0;
3106
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003107 ENTER_DEV(dev);
3108
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003109 status = hdd_wlan_get_rts_threshold(pAdapter, wrqu);
3110
3111 return status;
3112}
3113
3114/**
3115 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
3116 * @dev: device upon which the ioctl was received
3117 * @info: ioctl request information
3118 * @wrqu: ioctl request data
3119 * @extra: ioctl extra data
3120 *
3121 * Return: 0 on success, non-zero on error
3122 */
3123static int __iw_set_rts_threshold(struct net_device *dev,
3124 struct iw_request_info *info,
3125 union iwreq_data *wrqu, char *extra)
3126{
3127 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3128 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3129 hdd_context_t *hdd_ctx;
3130 int ret;
3131
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003132 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133
3134 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3135 ret = wlan_hdd_validate_context(hdd_ctx);
3136 if (0 != ret)
3137 return ret;
3138
3139 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
3140 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
3141 return -EINVAL;
3142 }
3143
3144 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303145 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003146 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 return -EIO;
3148 }
3149
3150 EXIT();
3151
3152 return 0;
3153}
3154
3155/**
3156 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
3157 * @dev: pointer to net_device
3158 * @info: pointer to iw_request_info
3159 * @wrqu: pointer to iwreq_data
3160 * @extra: pointer to extra ioctl payload
3161 *
3162 * Return: 0 on success, error number otherwise
3163 */
3164static int iw_get_rts_threshold(struct net_device *dev,
3165 struct iw_request_info *info,
3166 union iwreq_data *wrqu, char *extra)
3167{
3168 int ret;
3169
3170 cds_ssr_protect(__func__);
3171 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
3172 cds_ssr_unprotect(__func__);
3173
3174 return ret;
3175}
3176
3177/**
3178 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
3179 * @dev: pointer to net_device
3180 * @info: pointer to iw_request_info
3181 * @wrqu: pointer to iwreq_data
3182 * @extra: pointer to extra ioctl payload
3183 *
3184 * Return: 0 on success, error number otherwise
3185 */
3186static int iw_set_rts_threshold(struct net_device *dev,
3187 struct iw_request_info *info,
3188 union iwreq_data *wrqu, char *extra)
3189{
3190 int ret;
3191
3192 cds_ssr_protect(__func__);
3193 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
3194 cds_ssr_unprotect(__func__);
3195
3196 return ret;
3197}
3198
3199/**
3200 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
3201 * @dev: device upon which the ioctl was received
3202 * @info: ioctl request information
3203 * @wrqu: ioctl request data
3204 * @extra: ioctl extra data
3205 *
3206 * Return: 0 on success, non-zero on error
3207 */
3208static int __iw_get_frag_threshold(struct net_device *dev,
3209 struct iw_request_info *info,
3210 union iwreq_data *wrqu, char *extra)
3211{
3212 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3213 uint32_t status = 0;
3214
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003215 ENTER_DEV(dev);
3216
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 status = hdd_wlan_get_frag_threshold(pAdapter, wrqu);
3218
3219 return status;
3220}
3221
3222/**
3223 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
3224 * @dev: pointer to net_device
3225 * @info: pointer to iw_request_info
3226 * @wrqu: pointer to iwreq_data
3227 * @extra: pointer to extra ioctl payload
3228 *
3229 * Return: 0 on success, error number otherwise
3230 */
3231static int iw_get_frag_threshold(struct net_device *dev,
3232 struct iw_request_info *info,
3233 union iwreq_data *wrqu, char *extra)
3234{
3235 int ret;
3236
3237 cds_ssr_protect(__func__);
3238 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
3239 cds_ssr_unprotect(__func__);
3240
3241 return ret;
3242}
3243
3244/**
3245 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
3246 * @dev: device upon which the ioctl was received
3247 * @info: ioctl request information
3248 * @wrqu: ioctl request data
3249 * @extra: ioctl extra data
3250 *
3251 * Return: 0 on success, non-zero on error
3252 */
3253static int __iw_set_frag_threshold(struct net_device *dev,
3254 struct iw_request_info *info,
3255 union iwreq_data *wrqu, char *extra)
3256{
3257 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3258 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3259 hdd_context_t *hdd_ctx;
3260 int ret;
3261
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003262 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263
3264 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3265 ret = wlan_hdd_validate_context(hdd_ctx);
3266 if (0 != ret)
3267 return ret;
3268
3269 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
3270 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
3271 return -EINVAL;
3272 }
3273
3274 if (sme_cfg_set_int
3275 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303276 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003277 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 return -EIO;
3279 }
3280
3281 EXIT();
3282
3283 return 0;
3284}
3285
3286/**
3287 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
3288 * @dev: pointer to net_device
3289 * @info: pointer to iw_request_info
3290 * @wrqu: pointer to iwreq_data
3291 * @extra: pointer to extra ioctl payload
3292 *
3293 * Return: 0 on success, error number otherwise
3294 */
3295static int iw_set_frag_threshold(struct net_device *dev,
3296 struct iw_request_info *info,
3297 union iwreq_data *wrqu, char *extra)
3298{
3299 int ret;
3300
3301 cds_ssr_protect(__func__);
3302 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3303 cds_ssr_unprotect(__func__);
3304
3305 return ret;
3306}
3307
3308/**
3309 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
3310 * @dev: device upon which the ioctl was received
3311 * @info: ioctl request information
3312 * @wrqu: ioctl request data
3313 * @extra: ioctl extra data
3314 *
3315 * Return: 0 on success, non-zero on error
3316 */
3317static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003318 struct iw_request_info *info,
3319 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320{
3321 hdd_adapter_t *adapter;
3322 hdd_context_t *hdd_ctx;
3323 int ret;
3324
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003325 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326
3327 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3328 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3329 ret = wlan_hdd_validate_context(hdd_ctx);
3330 if (0 != ret)
3331 return ret;
3332
3333 return -EOPNOTSUPP;
3334}
3335
3336/**
3337 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
3338 * @dev: pointer to net_device
3339 * @info: pointer to iw_request_info
3340 * @wrqu: pointer to iwreq_data
3341 * @extra: extra
3342 *
3343 * Return: 0 on success, error number otherwise
3344 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003345static int iw_get_power_mode(struct net_device *dev,
3346 struct iw_request_info *info,
3347 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348{
3349 int ret;
3350
3351 cds_ssr_protect(__func__);
3352 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3353 cds_ssr_unprotect(__func__);
3354
3355 return ret;
3356}
3357
3358/**
3359 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
3360 * @dev: device upon which the ioctl was received
3361 * @info: ioctl request information
3362 * @wrqu: ioctl request data
3363 * @extra: ioctl extra data
3364 *
3365 * Return: 0 on success, non-zero on error
3366 */
3367static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003368 struct iw_request_info *info,
3369 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370{
3371 hdd_adapter_t *adapter;
3372 hdd_context_t *hdd_ctx;
3373 int ret;
3374
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003375 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376
3377 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3378 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3379 ret = wlan_hdd_validate_context(hdd_ctx);
3380 if (0 != ret)
3381 return ret;
3382
3383 return -EOPNOTSUPP;
3384}
3385
3386/**
3387 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
3388 * @dev: pointer to net_device
3389 * @info: pointer to iw_request_info
3390 * @wrqu: pointer to iwreq_data
3391 * @extra: extra
3392 *
3393 * Return: 0 on success, error number otherwise
3394 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003395static int iw_set_power_mode(struct net_device *dev,
3396 struct iw_request_info *info,
3397 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398{
3399 int ret;
3400
3401 cds_ssr_protect(__func__);
3402 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3403 cds_ssr_unprotect(__func__);
3404
3405 return ret;
3406}
3407
3408/**
3409 * __iw_get_range() - SIOCGIWRANGE ioctl handler
3410 * @dev: device upon which the ioctl was received
3411 * @info: ioctl request information
3412 * @wrqu: ioctl request data
3413 * @extra: ioctl extra data
3414 *
3415 * Return: 0 on success, non-zero on error
3416 */
3417static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
3418 union iwreq_data *wrqu, char *extra)
3419{
3420 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3421 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3422 struct iw_range *range = (struct iw_range *)extra;
3423
3424 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3425
3426 uint32_t num_channels = sizeof(channels);
3427 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3428 uint32_t a_len;
3429 uint32_t b_len;
3430 uint32_t active_phy_mode = 0;
3431 uint8_t index = 0, i;
3432 hdd_context_t *hdd_ctx;
3433 int ret;
3434
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003435 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436
3437 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3438 ret = wlan_hdd_validate_context(hdd_ctx);
3439 if (0 != ret)
3440 return ret;
3441
3442 wrqu->data.length = sizeof(struct iw_range);
3443 memset(range, 0, sizeof(struct iw_range));
3444
3445
3446 /*Get the phy mode */
3447 if (sme_cfg_get_int(hHal,
3448 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303449 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003450 hdd_notice("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003451
3452 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
3453 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
3454 /*Get the supported rates for 11G band */
3455 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3456 if (sme_cfg_get_str(hHal,
3457 WNI_CFG_SUPPORTED_RATES_11A,
3458 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303459 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
3461 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3462 }
3463 for (i = 0; i < a_len; i++) {
3464 range->bitrate[i] =
3465 ((supp_rates[i] & 0x7F) / 2) *
3466 1000000;
3467 }
3468 range->num_bitrates = a_len;
3469 } else {
3470 return -EIO;
3471 }
3472 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
3473 /*Get the supported rates for 11B band */
3474 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3475 if (sme_cfg_get_str(hHal,
3476 WNI_CFG_SUPPORTED_RATES_11B,
3477 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303478 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003479 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
3480 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3481 }
3482 for (i = 0; i < b_len; i++) {
3483 range->bitrate[i] =
3484 ((supp_rates[i] & 0x7F) / 2) *
3485 1000000;
3486 }
3487 range->num_bitrates = b_len;
3488 } else {
3489 return -EIO;
3490 }
3491 }
3492 }
3493
3494 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3495 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3496 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3497
3498 range->encoding_size[0] = 5;
3499 range->encoding_size[1] = 13;
3500 range->num_encoding_sizes = 2;
3501 range->max_encoding_tokens = MAX_WEP_KEYS;
3502
3503 /* we support through Wireless Extensions 22 */
3504 range->we_version_compiled = WIRELESS_EXT;
3505 range->we_version_source = 22;
3506
3507 /*Supported Channels and Frequencies */
3508 if (sme_cfg_get_str
3509 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303510 &num_channels) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003511 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 return -EIO;
3513 }
3514 if (num_channels > IW_MAX_FREQUENCIES) {
3515 num_channels = IW_MAX_FREQUENCIES;
3516 }
3517
3518 range->num_channels = num_channels;
3519 range->num_frequency = num_channels;
3520
3521 for (index = 0; index < num_channels; index++) {
3522 uint32_t frq_indx = 0;
3523
3524 range->freq[index].i = channels[index];
3525 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
3526 if (channels[index] == freq_chan_map[frq_indx].chan) {
3527 range->freq[index].m =
3528 freq_chan_map[frq_indx].freq * 100000;
3529 range->freq[index].e = 1;
3530 break;
3531 }
3532 frq_indx++;
3533 }
3534 }
3535
3536 /* Event capability (kernel + driver) */
3537 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3538 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3539 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3540 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3541
3542 /*Encryption capability */
3543 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3544 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3545
3546 /* Txpower capability */
3547 range->txpower_capa = IW_TXPOW_MWATT;
3548
3549 /*Scanning capability */
3550#if WIRELESS_EXT >= 22
3551 range->scan_capa =
3552 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3553#endif
3554
3555 EXIT();
3556 return 0;
3557}
3558
3559/**
3560 * iw_get_range() - SSR wrapper for __iw_get_range()
3561 * @dev: pointer to net_device
3562 * @info: pointer to iw_request_info
3563 * @wrqu: pointer to iwreq_data
3564 * @extra: pointer to extra ioctl payload
3565 *
3566 * Return: 0 on success, error number otherwise
3567 */
3568static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
3569 union iwreq_data *wrqu, char *extra)
3570{
3571 int ret;
3572
3573 cds_ssr_protect(__func__);
3574 ret = __iw_get_range(dev, info, wrqu, extra);
3575 cds_ssr_unprotect(__func__);
3576
3577 return ret;
3578}
3579
3580/**
3581 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
3582 * @pStats: pointer to Class A stats
3583 * @pContext: user context originally registered with SME
3584 *
3585 * Return: None
3586 */
3587static void hdd_get_class_a_statistics_cb(void *pStats, void *pContext)
3588{
3589 struct statsContext *pStatsContext;
3590 tCsrGlobalClassAStatsInfo *pClassAStats;
3591 hdd_adapter_t *pAdapter;
3592
3593 if (ioctl_debug) {
3594 pr_info("%s: pStats [%p] pContext [%p]\n",
3595 __func__, pStats, pContext);
3596 }
3597
3598 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003599 hdd_err("Bad param, pStats [%p] pContext [%p]",
3600 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 return;
3602 }
3603
3604 pClassAStats = pStats;
3605 pStatsContext = pContext;
3606 pAdapter = pStatsContext->pAdapter;
3607
3608 /* there is a race condition that exists between this callback
3609 * function and the caller since the caller could time out
3610 * either before or while this code is executing. we use a
3611 * spinlock to serialize these actions
3612 */
3613 spin_lock(&hdd_context_lock);
3614
3615 if ((NULL == pAdapter) ||
3616 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
3617 /* the caller presumably timed out so there is nothing
3618 * we can do
3619 */
3620 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07003621 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
3622 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623 if (ioctl_debug) {
3624 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
3625 __func__, pAdapter, pStatsContext->magic);
3626 }
3627 return;
3628 }
3629
3630 /* context is valid so caller is still waiting */
3631
3632 /* paranoia: invalidate the magic */
3633 pStatsContext->magic = 0;
3634
3635 /* copy over the stats. do so as a struct copy */
3636 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3637
3638 /* notify the caller */
3639 complete(&pStatsContext->completion);
3640
3641 /* serialization is complete */
3642 spin_unlock(&hdd_context_lock);
3643}
3644
3645/**
3646 * wlan_hdd_get_class_astats() - Get Class A statistics
3647 * @pAdapter: adapter for which statistics are desired
3648 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303649 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303651QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652{
3653 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303654 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 unsigned long rc;
3656 struct statsContext context;
3657
3658 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003659 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303660 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003662 if (cds_is_driver_recovering()) {
3663 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3664 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303665 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 }
3667
3668 /* we are connected so prepare our callback context */
3669 init_completion(&context.completion);
3670 context.pAdapter = pAdapter;
3671 context.magic = STATS_CONTEXT_MAGIC;
3672 /* query only for Class A statistics (which include link speed) */
3673 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3674 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
3675 hdd_get_class_a_statistics_cb,
3676 0, /* not periodic */
3677 false, /* non-cached results */
3678 pHddStaCtx->conn_info.staId[0],
3679 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303680 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07003681 hdd_warn("Unable to retrieve Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682 /* we'll returned a cached value below */
3683 } else {
3684 /* request was sent -- wait for the response */
3685 rc = wait_for_completion_timeout
3686 (&context.completion,
3687 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3688 if (!rc) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07003689 hdd_warn("SME timed out while retrieving Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690 }
3691 }
3692
3693 /* either we never sent a request, we sent a request and
3694 * received a response or we sent a request and timed out. if
3695 * we never sent a request or if we sent a request and got a
3696 * response, we want to clear the magic out of paranoia. if
3697 * we timed out there is a race condition such that the
3698 * callback function could be executing at the same time we
3699 * are. of primary concern is if the callback function had
3700 * already verified the "magic" but had not yet set the
3701 * completion variable when a timeout occurred. we serialize
3702 * these activities by invalidating the magic while holding a
3703 * shared spinlock which will cause us to block if the
3704 * callback is currently executing
3705 */
3706 spin_lock(&hdd_context_lock);
3707 context.magic = 0;
3708 spin_unlock(&hdd_context_lock);
3709
3710 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303711 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003712}
3713
3714/**
3715 * hdd_get_station_statistics_cb() - Get stats callback function
3716 * @pStats: pointer to Class A stats
3717 * @pContext: user context originally registered with SME
3718 *
3719 * Return: None
3720 */
3721static void hdd_get_station_statistics_cb(void *pStats, void *pContext)
3722{
3723 struct statsContext *pStatsContext;
3724 tCsrSummaryStatsInfo *pSummaryStats;
3725 tCsrGlobalClassAStatsInfo *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303726 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727 hdd_adapter_t *pAdapter;
3728
3729 if (ioctl_debug) {
3730 pr_info("%s: pStats [%p] pContext [%p]\n",
3731 __func__, pStats, pContext);
3732 }
3733
3734 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003735 hdd_err("Bad param, pStats [%p] pContext [%p]",
3736 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737 return;
3738 }
3739
3740 /* there is a race condition that exists between this callback
3741 * function and the caller since the caller could time out
3742 * either before or while this code is executing. we use a
3743 * spinlock to serialize these actions
3744 */
3745 spin_lock(&hdd_context_lock);
3746
3747 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
3748 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303749 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
3750 (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003751 pStatsContext = pContext;
3752 pAdapter = pStatsContext->pAdapter;
3753 if ((NULL == pAdapter) ||
3754 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
3755 /* the caller presumably timed out so there is nothing
3756 * we can do
3757 */
3758 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07003759 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
3760 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003761 if (ioctl_debug) {
3762 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
3763 __func__, pAdapter, pStatsContext->magic);
3764 }
3765 return;
3766 }
3767
3768 /* context is valid so caller is still waiting */
3769
3770 /* paranoia: invalidate the magic */
3771 pStatsContext->magic = 0;
3772
3773 /* copy over the stats. do so as a struct copy */
3774 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3775 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303776 pAdapter->hdd_stats.per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003777
3778 /* notify the caller */
3779 complete(&pStatsContext->completion);
3780
3781 /* serialization is complete */
3782 spin_unlock(&hdd_context_lock);
3783}
3784
3785/**
3786 * wlan_hdd_get_station_stats() - Get station statistics
3787 * @pAdapter: adapter for which statistics are desired
3788 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303789 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303791QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792{
3793 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303794 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 unsigned long rc;
3796 struct statsContext context;
3797
3798 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003799 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303800 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 }
3802
3803 /* we are connected so prepare our callback context */
3804 init_completion(&context.completion);
3805 context.pAdapter = pAdapter;
3806 context.magic = STATS_CONTEXT_MAGIC;
3807
3808 /* query only for Summary & Class A statistics */
3809 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3810 eCSR_HDD,
3811 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303812 SME_GLOBAL_CLASSA_STATS |
3813 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814 hdd_get_station_statistics_cb,
3815 0, /* not periodic */
3816 false, /* non-cached results */
3817 pHddStaCtx->conn_info.staId[0],
3818 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303819 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003820 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003821 /* we'll return with cached values */
3822 } else {
3823 /* request was sent -- wait for the response */
3824 rc = wait_for_completion_timeout
3825 (&context.completion,
3826 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3827
3828 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003829 hdd_err("SME timed out while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003830 }
3831 }
3832
3833 /* either we never sent a request, we sent a request and
3834 * received a response or we sent a request and timed out. if
3835 * we never sent a request or if we sent a request and got a
3836 * response, we want to clear the magic out of paranoia. if
3837 * we timed out there is a race condition such that the
3838 * callback function could be executing at the same time we
3839 * are. of primary concern is if the callback function had
3840 * already verified the "magic" but had not yet set the
3841 * completion variable when a timeout occurred. we serialize
3842 * these activities by invalidating the magic while holding a
3843 * shared spinlock which will cause us to block if the
3844 * callback is currently executing
3845 */
3846 spin_lock(&hdd_context_lock);
3847 context.magic = 0;
3848 spin_unlock(&hdd_context_lock);
3849
3850 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303851 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003852}
3853
3854/**
3855 * iw_get_linkspeed() - Get current link speed ioctl
3856 * @dev: device upon which the ioctl was received
3857 * @info: ioctl request information
3858 * @wrqu: ioctl request data
3859 * @extra: extra ioctl buffer
3860 *
3861 * Return: 0 on success, non-zero on error
3862 */
3863static int __iw_get_linkspeed(struct net_device *dev,
3864 struct iw_request_info *info,
3865 union iwreq_data *wrqu, char *extra)
3866{
3867 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3868 char *pLinkSpeed = (char *)extra;
3869 int len = sizeof(uint32_t) + 1;
3870 uint32_t link_speed = 0;
3871 hdd_context_t *hdd_ctx;
3872 int rc, valid;
3873
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08003874 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303875
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3877 valid = wlan_hdd_validate_context(hdd_ctx);
3878 if (0 != valid)
3879 return valid;
3880
3881 rc = wlan_hdd_get_link_speed(pAdapter, &link_speed);
3882 if (0 != rc) {
3883 return rc;
3884 }
3885
3886 wrqu->data.length = len;
3887 /* return the linkspeed as a string */
3888 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
3889 if ((rc < 0) || (rc >= len)) {
3890 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07003891 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 return -EIO;
3893 }
3894
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303895 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896 /* a value is being successfully returned */
3897 return 0;
3898}
3899
3900static int iw_get_linkspeed(struct net_device *dev,
3901 struct iw_request_info *info,
3902 union iwreq_data *wrqu, char *extra)
3903{
3904 int ret;
3905
3906 cds_ssr_protect(__func__);
3907 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
3908 cds_ssr_unprotect(__func__);
3909
3910 return ret;
3911}
3912
3913/**
3914 * wlan_hdd_change_country_code_callback() - Change country code callback
3915 * @context: opaque context originally passed to SME. All functions
3916 * which use this callback pass the adapter upon which the country
3917 * code change is active
3918 *
3919 * This function is registered as the callback function when
3920 * sme_change_country_code() is invoked. Callers of
3921 * sme_change_country_code() subsequently wait for the adapter's
3922 * @change_country_code completion variable, so all this function
3923 * needs to do is set that completion variable so that execution can
3924 * continue.
3925 *
3926 * Return: none
3927 */
3928void wlan_hdd_change_country_code_callback(void *context)
3929{
3930
3931 hdd_adapter_t *adapter = context;
3932
3933 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
3934 complete(&adapter->change_country_code);
3935
3936 return;
3937}
3938
3939/**
3940 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
3941 * @dev: device upon which the ioctl was received
3942 * @info: ioctl request information
3943 * @wrqu: ioctl request data
3944 * @extra: ioctl extra data
3945 *
3946 * Return: 0 on success, non-zero on error
3947 */
3948static int __iw_set_nick(struct net_device *dev,
3949 struct iw_request_info *info,
3950 union iwreq_data *wrqu, char *extra)
3951{
3952 hdd_adapter_t *adapter;
3953 hdd_context_t *hdd_ctx;
3954 int ret;
3955
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003956 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003957
3958 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3959 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3960 ret = wlan_hdd_validate_context(hdd_ctx);
3961 if (0 != ret)
3962 return ret;
3963
3964 return 0;
3965}
3966
3967/**
3968 * iw_set_nick() - SSR wrapper for __iw_set_nick
3969 * @dev: pointer to net_device
3970 * @info: pointer to iw_request_info
3971 * @wrqu: pointer to iwreq_data
3972 * @extra: extra
3973 *
3974 * Return: 0 on success, error number otherwise
3975 */
3976static int iw_set_nick(struct net_device *dev,
3977 struct iw_request_info *info,
3978 union iwreq_data *wrqu, char *extra)
3979{
3980 int ret;
3981
3982 cds_ssr_protect(__func__);
3983 ret = __iw_set_nick(dev, info, wrqu, extra);
3984 cds_ssr_unprotect(__func__);
3985
3986 return ret;
3987}
3988
3989/**
3990 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
3991 * @dev: device upon which the ioctl was received
3992 * @info: ioctl request information
3993 * @wrqu: ioctl request data
3994 * @extra: ioctl extra data
3995 *
3996 * Return: 0 on success, non-zero on error
3997 */
3998static int __iw_get_nick(struct net_device *dev,
3999 struct iw_request_info *info,
4000 union iwreq_data *wrqu, char *extra)
4001{
4002 hdd_adapter_t *adapter;
4003 hdd_context_t *hdd_ctx;
4004 int ret;
4005
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004006 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007
4008 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4009 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4010 ret = wlan_hdd_validate_context(hdd_ctx);
4011 if (0 != ret)
4012 return ret;
4013
4014 return 0;
4015}
4016
4017/**
4018 * iw_get_nick() - SSR wrapper for __iw_get_nick
4019 * @dev: pointer to net_device
4020 * @info: pointer to iw_request_info
4021 * @wrqu: pointer to iwreq_data
4022 * @extra: extra
4023 *
4024 * Return: 0 on success, error number otherwise
4025 */
4026static int iw_get_nick(struct net_device *dev,
4027 struct iw_request_info *info,
4028 union iwreq_data *wrqu, char *extra)
4029{
4030 int ret;
4031
4032 cds_ssr_protect(__func__);
4033 ret = __iw_get_nick(dev, info, wrqu, extra);
4034 cds_ssr_unprotect(__func__);
4035
4036 return ret;
4037}
4038
4039/**
4040 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
4041 * @dev: device upon which the ioctl was received
4042 * @info: ioctl request information
4043 * @wrqu: ioctl request data
4044 * @extra: ioctl extra data
4045 *
4046 * Return: 0 on success, non-zero on error
4047 */
4048static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4049 union iwreq_data *wrqu, char *extra)
4050{
4051 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4052 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4053 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4054 hdd_context_t *hdd_ctx;
4055 struct iw_point *encoderq = &(wrqu->encoding);
4056 uint32_t keyId;
4057 uint8_t key_length;
4058 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4059 bool fKeyPresent = 0;
4060 int i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304061 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062 int ret;
4063
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004064 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004065
4066 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4067 ret = wlan_hdd_validate_context(hdd_ctx);
4068 if (0 != ret)
4069 return ret;
4070
4071 keyId = encoderq->flags & IW_ENCODE_INDEX;
4072
4073 if (keyId) {
4074 if (keyId > MAX_WEP_KEYS) {
4075 return -EINVAL;
4076 }
4077
4078 fKeyPresent = 1;
4079 keyId--;
4080 } else {
4081 fKeyPresent = 0;
4082 }
4083
4084 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004085 hdd_notice("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 if (!fKeyPresent) {
4087
4088 for (i = 0; i < CSR_MAX_NUM_KEY; i++) {
4089
4090 if (pWextState->roamProfile.Keys.KeyMaterial[i])
4091 pWextState->roamProfile.Keys.
4092 KeyLength[i] = 0;
4093 }
4094 }
4095 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4096 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4097 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4098 eCSR_ENCRYPT_TYPE_NONE;
4099 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4100 eCSR_ENCRYPT_TYPE_NONE;
4101
4102 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4103 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4104
4105 if (eConnectionState_Associated ==
4106 pHddStaCtx->conn_info.connState) {
4107 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4108 status =
4109 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4110 pAdapter->sessionId,
4111 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304112 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 unsigned long rc;
4114 rc = wait_for_completion_timeout(&pAdapter->
4115 disconnect_comp_var,
4116 msecs_to_jiffies
4117 (WLAN_WAIT_TIME_DISCONNECT));
4118 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004119 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120 }
4121 }
4122
4123 return status;
4124
4125 }
4126
4127 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004128 hdd_notice("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129
4130 pHddStaCtx->conn_info.authType =
4131 (encoderq->
4132 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
4133 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4134
4135 }
4136
4137 if (wrqu->data.length > 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004138 hdd_notice("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139
4140 key_length = wrqu->data.length;
4141
4142 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
4143
4144 if (5 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004145 hdd_notice("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146 key_length);
4147
4148 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4149 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4150 pHddStaCtx->conn_info.authType)) {
4151 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4152 } else {
4153 encryptionType =
4154 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4155 }
4156 } else if (13 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004157 hdd_notice("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 key_length);
4159
4160 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4161 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4162 pHddStaCtx->conn_info.authType)) {
4163 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4164 } else {
4165 encryptionType =
4166 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4167 }
4168 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004169 hdd_warn("Invalid WEP key length :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170 key_length);
4171 return -EINVAL;
4172 }
4173
4174 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4175 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4176 pWextState->roamProfile.EncryptionType.numEntries = 1;
4177 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4178 encryptionType;
4179 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4180 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4181 encryptionType;
4182
4183 if ((eConnectionState_NotConnected ==
4184 pHddStaCtx->conn_info.connState)
4185 &&
4186 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4187 pHddStaCtx->conn_info.authType)
4188 || (eCSR_AUTH_TYPE_SHARED_KEY ==
4189 pHddStaCtx->conn_info.authType))) {
4190
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304191 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 KeyMaterial[keyId][0], extra, key_length);
4193
4194 pWextState->roamProfile.Keys.KeyLength[keyId] =
4195 (uint8_t) key_length;
4196 pWextState->roamProfile.Keys.defaultIndex =
4197 (uint8_t) keyId;
4198
4199 return status;
4200 }
4201 }
4202
4203 return 0;
4204}
4205
4206/**
4207 * iw_set_encode() - SSR wrapper for __iw_set_encode()
4208 * @dev: pointer to net_device
4209 * @info: pointer to iw_request_info
4210 * @wrqu: pointer to iwreq_data
4211 * @extra: pointer to extra ioctl payload
4212 *
4213 * Return: 0 on success, error number otherwise
4214 */
4215static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4216 union iwreq_data *wrqu, char *extra)
4217{
4218 int ret;
4219
4220 cds_ssr_protect(__func__);
4221 ret = __iw_set_encode(dev, info, wrqu, extra);
4222 cds_ssr_unprotect(__func__);
4223
4224 return ret;
4225}
4226
4227/**
4228 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
4229 * @dev: device upon which the ioctl was received
4230 * @info: ioctl request information
4231 * @wrqu: ioctl request data
4232 * @extra: ioctl extra data
4233 *
4234 * Return: 0 on success, non-zero on error
4235 */
4236static int __iw_get_encodeext(struct net_device *dev,
4237 struct iw_request_info *info,
4238 struct iw_point *dwrq, char *extra)
4239{
4240 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4241 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4242 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4243 int keyId;
4244 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4245 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
4246 int i, ret;
4247 hdd_context_t *hdd_ctx;
4248
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004249 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004250
4251 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4252 ret = wlan_hdd_validate_context(hdd_ctx);
4253 if (0 != ret)
4254 return ret;
4255
4256 keyId = pRoamProfile->Keys.defaultIndex;
4257
4258 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004259 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 return -EINVAL;
4261 }
4262
4263 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
4264 dwrq->flags |= IW_ENCODE_ENABLED;
4265 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304266 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 pRoamProfile->Keys.KeyLength[keyId]);
4268 } else {
4269 dwrq->flags |= IW_ENCODE_DISABLED;
4270 }
4271
4272 for (i = 0; i < MAX_WEP_KEYS; i++) {
4273 if (pRoamProfile->Keys.KeyMaterial[i] == NULL) {
4274 continue;
4275 } else {
4276 break;
4277 }
4278 }
4279
4280 if (MAX_WEP_KEYS == i) {
4281 dwrq->flags |= IW_ENCODE_NOKEY;
4282 } else {
4283 dwrq->flags |= IW_ENCODE_ENABLED;
4284 }
4285
4286 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4287
4288 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
4289 dwrq->flags |= IW_ENCODE_DISABLED;
4290 }
4291
4292 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4293
4294 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
4295 dwrq->flags |= IW_ENCODE_OPEN;
4296 } else {
4297 dwrq->flags |= IW_ENCODE_RESTRICTED;
4298 }
4299 EXIT();
4300 return 0;
4301
4302}
4303
4304/**
4305 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
4306 * @dev: pointer to net_device
4307 * @info: pointer to iw_request_info
4308 * @dwrq: pointer to encoding information
4309 * @extra: pointer to extra ioctl payload
4310 *
4311 * Return: 0 on success, error number otherwise
4312 */
4313static int iw_get_encodeext(struct net_device *dev,
4314 struct iw_request_info *info,
4315 struct iw_point *dwrq, char *extra)
4316{
4317 int ret;
4318
4319 cds_ssr_protect(__func__);
4320 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4321 cds_ssr_unprotect(__func__);
4322
4323 return ret;
4324}
4325
4326/**
4327 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
4328 * @dev: device upon which the ioctl was received
4329 * @info: ioctl request information
4330 * @wrqu: ioctl request data
4331 * @extra: ioctl extra data
4332 *
4333 * Return: 0 on success, non-zero on error
4334 */
4335static int __iw_set_encodeext(struct net_device *dev,
4336 struct iw_request_info *info,
4337 union iwreq_data *wrqu, char *extra)
4338{
4339 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4340 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4341 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4342 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304343 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4345 int ret;
4346 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
4347 int key_index;
4348 struct iw_point *encoding = &wrqu->encoding;
4349 tCsrRoamSetKey setKey;
4350 uint32_t roamId = 0xFF;
4351
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004352 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353
4354 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4355 ret = wlan_hdd_validate_context(hdd_ctx);
4356 if (0 != ret)
4357 return ret;
4358
4359 key_index = encoding->flags & IW_ENCODE_INDEX;
4360
4361 if (key_index > 0) {
4362
4363 /*Convert from 1-based to 0-based keying */
4364 key_index--;
4365 }
4366 if (!ext->key_len) {
4367
4368 /*Set the encrytion type to NONE */
4369 pRoamProfile->EncryptionType.encryptionType[0] =
4370 eCSR_ENCRYPT_TYPE_NONE;
4371 return ret;
4372 }
4373
4374 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4375 (IW_ENCODE_ALG_WEP == ext->alg)) {
4376 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4377
Jeff Johnson99bac312016-06-28 10:38:18 -07004378 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379 return -EINVAL;
4380 } else {
4381 /*Static wep, update the roam profile with the keys */
4382 if (ext->key
4383 && (ext->key_len <=
4384 eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES)
4385 && key_index < CSR_MAX_NUM_KEY) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304386 qdf_mem_copy(&pRoamProfile->Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387 KeyMaterial[key_index][0],
4388 ext->key, ext->key_len);
4389 pRoamProfile->Keys.KeyLength[key_index] =
4390 (uint8_t) ext->key_len;
4391
4392 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4393 pRoamProfile->Keys.defaultIndex =
4394 (uint8_t) key_index;
4395
4396 }
4397 }
4398 return ret;
4399 }
4400
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304401 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402
4403 setKey.keyId = key_index;
4404 setKey.keyLength = ext->key_len;
4405
4406 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304407 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 }
4409
4410 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4411 /*Key direction for group is RX only */
4412 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05304413 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 } else {
4415
4416 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304417 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304418 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 }
4420
4421 /*For supplicant pae role is zero */
4422 setKey.paeRole = 0;
4423
4424 switch (ext->alg) {
4425 case IW_ENCODE_ALG_NONE:
4426 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4427 break;
4428
4429 case IW_ENCODE_ALG_WEP:
4430 setKey.encType =
4431 (ext->key_len ==
4432 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
4433 break;
4434
4435 case IW_ENCODE_ALG_TKIP:
4436 {
4437 uint8_t *pKey = &setKey.Key[0];
4438
4439 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4440
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304441 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442
4443 /* Supplicant sends the 32bytes key in this order
4444 * |--------------|----------|----------|
4445 * | Tk1 | TX MIC | RX MIC |
4446 * |--------------|----------|----------|
4447 * <---16bytes---><--8bytes--><--8bytes-->
4448 *
4449 *
4450 * Sme expects the 32 bytes key to be in the below order
4451 * |--------------|----------|----------|
4452 * | Tk1 | RX MIC | TX MIC |
4453 * |--------------|----------|----------|
4454 * <---16bytes---><--8bytes--><--8bytes-->
4455 */
4456
4457 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304458 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459
4460 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304461 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462
4463 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304464 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465
4466 }
4467 break;
4468
4469 case IW_ENCODE_ALG_CCMP:
4470 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4471 break;
4472
4473#ifdef FEATURE_WLAN_ESE
4474#define IW_ENCODE_ALG_KRK 6
4475 case IW_ENCODE_ALG_KRK:
4476 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4477 break;
4478#endif /* FEATURE_WLAN_ESE */
4479
4480 default:
4481 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4482 break;
4483 }
4484
Jeff Johnson99bac312016-06-28 10:38:18 -07004485 hdd_notice("cipher_alg:%d key_len:%d EncryptionType:%d",
4486 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488 /* The supplicant may attempt to set the PTK once
4489 * pre-authentication is done. Save the key in the UMAC and
4490 * include it in the ADD BSS request
4491 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304492 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004493 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304494 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004495 hdd_info("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304497 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004498 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 return -EINVAL;
4500 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501
4502 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4503
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304504 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 pAdapter->sessionId,
4506 &setKey, &roamId);
4507
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304508 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004509 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304510 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511
4512 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4513 }
4514
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304515 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516}
4517
4518/**
4519 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
4520 * @dev: pointer to net_device
4521 * @info: pointer to iw_request_info
4522 * @wrqu: pointer to iwreq_data
4523 * @extra: pointer to extra ioctl payload
4524 *
4525 * Return: 0 on success, error number otherwise
4526 */
4527static int iw_set_encodeext(struct net_device *dev,
4528 struct iw_request_info *info,
4529 union iwreq_data *wrqu, char *extra)
4530{
4531 int ret;
4532
4533 cds_ssr_protect(__func__);
4534 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4535 cds_ssr_unprotect(__func__);
4536
4537 return ret;
4538}
4539
4540/**
4541 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
4542 * @dev: device upon which the ioctl was received
4543 * @info: ioctl request information
4544 * @wrqu: ioctl request data
4545 * @extra: ioctl extra data
4546 *
4547 * Return: 0 on success, non-zero on error
4548 */
4549static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
4550 union iwreq_data *wrqu, char *extra)
4551{
4552 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4553 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4554 hdd_context_t *hdd_ctx;
4555 int ret;
4556
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004557 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558
4559 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4560 ret = wlan_hdd_validate_context(hdd_ctx);
4561 if (0 != ret)
4562 return ret;
4563
4564 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4565 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4566
Jeff Johnson99bac312016-06-28 10:38:18 -07004567 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568
4569 return -EINVAL;
4570 }
4571
4572 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
4573
4574 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
4575 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
4576 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304577 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004578 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 return -EIO;
4580 }
4581 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
4582 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
4583 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304584 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05304585 hdd_err("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 return -EIO;
4587 }
4588 }
4589 } else {
4590 return -EOPNOTSUPP;
4591 }
4592
Jeff Johnson99bac312016-06-28 10:38:18 -07004593 hdd_notice("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594
4595 EXIT();
4596
4597 return 0;
4598
4599}
4600
4601/**
4602 * iw_set_retry() - SSR wrapper for __iw_set_retry()
4603 * @dev: pointer to net_device
4604 * @info: pointer to iw_request_info
4605 * @wrqu: pointer to iwreq_data
4606 * @extra: pointer to extra ioctl payload
4607 *
4608 * Return: 0 on success, error number otherwise
4609 */
4610static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
4611 union iwreq_data *wrqu, char *extra)
4612{
4613 int ret;
4614
4615 cds_ssr_protect(__func__);
4616 ret = __iw_set_retry(dev, info, wrqu, extra);
4617 cds_ssr_unprotect(__func__);
4618
4619 return ret;
4620}
4621
4622/**
4623 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
4624 * @dev: device upon which the ioctl was received
4625 * @info: ioctl request information
4626 * @wrqu: ioctl request data
4627 * @extra: ioctl extra data
4628 *
4629 * Return: 0 on success, non-zero on error
4630 */
4631static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
4632 union iwreq_data *wrqu, char *extra)
4633{
4634 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4635 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4636 uint32_t retry = 0;
4637 hdd_context_t *hdd_ctx;
4638 int ret;
4639
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004640 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641
4642 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4643 ret = wlan_hdd_validate_context(hdd_ctx);
4644 if (0 != ret)
4645 return ret;
4646
4647 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
4648 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
4649
4650 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304651 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004652 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 return -EIO;
4654 }
4655
4656 wrqu->retry.value = retry;
4657 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
4658 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
4659
4660 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304661 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05304662 hdd_warn("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663 return -EIO;
4664 }
4665
4666 wrqu->retry.value = retry;
4667 } else {
4668 return -EOPNOTSUPP;
4669 }
4670
Jeff Johnson99bac312016-06-28 10:38:18 -07004671 hdd_notice("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672
4673 EXIT();
4674
4675 return 0;
4676}
4677
4678/**
4679 * iw_get_retry() - SSR wrapper for __iw_get_retry()
4680 * @dev: pointer to net_device
4681 * @info: pointer to iw_request_info
4682 * @wrqu: pointer to iwreq_data
4683 * @extra: pointer to extra ioctl payload
4684 *
4685 * Return: 0 on success, error number otherwise
4686 */
4687static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
4688 union iwreq_data *wrqu, char *extra)
4689{
4690 int ret;
4691
4692 cds_ssr_protect(__func__);
4693 ret = __iw_get_retry(dev, info, wrqu, extra);
4694 cds_ssr_unprotect(__func__);
4695
4696 return ret;
4697}
4698
4699/**
4700 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
4701 * @dev: device upon which the ioctl was received
4702 * @info: ioctl request information
4703 * @wrqu: ioctl request data
4704 * @extra: ioctl extra data
4705 *
4706 * Return: 0 on success, non-zero on error
4707 */
4708static int __iw_set_mlme(struct net_device *dev,
4709 struct iw_request_info *info,
4710 union iwreq_data *wrqu, char *extra)
4711{
4712 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4713 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4714 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304715 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 hdd_context_t *hdd_ctx;
4717 int ret;
4718
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004719 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720
4721 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4722 ret = wlan_hdd_validate_context(hdd_ctx);
4723 if (0 != ret)
4724 return ret;
4725
4726 /* reason_code is unused. By default it is set to
4727 * eCSR_DISCONNECT_REASON_UNSPECIFIED
4728 */
4729 switch (mlme->cmd) {
4730 case IW_MLME_DISASSOC:
4731 case IW_MLME_DEAUTH:
4732
4733 if (pHddStaCtx->conn_info.connState ==
4734 eConnectionState_Associated) {
4735 eCsrRoamDisconnectReason reason =
4736 eCSR_DISCONNECT_REASON_UNSPECIFIED;
4737
4738 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
4739 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4740
4741 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4742 status =
4743 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4744 pAdapter->sessionId, reason);
4745
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304746 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747 unsigned long rc;
4748 rc = wait_for_completion_timeout(&pAdapter->
4749 disconnect_comp_var,
4750 msecs_to_jiffies
4751 (WLAN_WAIT_TIME_DISCONNECT));
4752 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004753 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07004755 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
4756 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004757
4758 /* Resetting authKeyMgmt */
4759 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
4760 0;
4761
Jeff Johnson99bac312016-06-28 10:38:18 -07004762 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763 wlan_hdd_netif_queue_control(pAdapter,
4764 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4765 WLAN_CONTROL_PATH);
4766
4767 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004768 hdd_err("%d Command Disassociate/Deauthenticate called but station is not in associated state",
4769 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770 }
4771 break;
4772 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004773 hdd_err("%d Command should be Disassociate/Deauthenticate",
4774 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775 return -EINVAL;
4776 } /* end of switch */
4777
4778 EXIT();
4779
4780 return status;
4781
4782}
4783
4784/**
4785 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
4786 * @dev: pointer to net_device
4787 * @info: pointer to iw_request_info
4788 * @wrqu: pointer to iwreq_data
4789 * @extra: pointer to extra ioctl payload
4790 *
4791 * Return: 0 on success, error number otherwise
4792 */
4793static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
4794 union iwreq_data *wrqu, char *extra)
4795{
4796 int ret;
4797
4798 cds_ssr_protect(__func__);
4799 ret = __iw_set_mlme(dev, info, wrqu, extra);
4800 cds_ssr_unprotect(__func__);
4801
4802 return ret;
4803}
4804
4805/**
4806 * wlan_hdd_update_phymode() - handle change in PHY mode
4807 * @net: device upon which PHY mode change was received
4808 * @hal: umac handle for the driver
4809 * @new_phymode: new PHY mode for the device
4810 * @phddctx: pointer to the HDD context
4811 *
4812 * This function is called when the device is set to a new PHY mode.
4813 * It takes a holistic look at the desired PHY mode along with the
4814 * configured capabilities of the driver and the reported capabilities
4815 * of the hardware in order to correctly configure all PHY-related
4816 * parameters.
4817 *
4818 * Return: 0 on success, negative errno value on error
4819 */
4820int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
4821 int new_phymode, hdd_context_t *phddctx)
4822{
4823#ifdef QCA_HT_2040_COEX
4824 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304825 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004826#endif
4827 bool band_24 = false, band_5g = false;
4828 bool ch_bond24 = false, ch_bond5g = false;
4829 tSmeConfigParams smeconfig;
4830 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 eCsrPhyMode phymode = -EIO, old_phymode;
4833 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
4834 eCsrBand curr_band = eCSR_BAND_ALL;
4835
4836 old_phymode = sme_get_phy_mode(hal);
4837
4838 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
4839 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
4840 nChannelBondingMode24GHz))
4841 ch_bond24 = true;
4842
4843 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
4844 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
4845 nChannelBondingMode5GHz))
4846 ch_bond5g = true;
4847
4848 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
4849 band_24 = band_5g = true;
4850 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
4851 band_24 = true;
4852 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
4853 band_5g = true;
4854 }
4855
4856 vhtchanwidth = phddctx->config->vhtChannelWidth;
Jeff Johnson99bac312016-06-28 10:38:18 -07004857 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 -08004858 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
4859
4860 switch (new_phymode) {
4861 case IEEE80211_MODE_AUTO:
4862 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4863 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
4864 phymode = eCSR_DOT11_MODE_AUTO;
4865 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4866 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4867 curr_band = eCSR_BAND_ALL;
4868 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
4869 } else {
4870 sme_set_phy_mode(hal, old_phymode);
4871 return -EIO;
4872 }
4873 break;
4874 case IEEE80211_MODE_11A:
4875 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
4876 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4877 phymode = eCSR_DOT11_MODE_11a;
4878 hdd_dot11mode = eHDD_DOT11_MODE_11a;
4879 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4880 curr_band = eCSR_BAND_5G;
4881 } else {
4882 sme_set_phy_mode(hal, old_phymode);
4883 return -EIO;
4884 }
4885 break;
4886 case IEEE80211_MODE_11B:
4887 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
4888 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4889 phymode = eCSR_DOT11_MODE_11b;
4890 hdd_dot11mode = eHDD_DOT11_MODE_11b;
4891 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4892 curr_band = eCSR_BAND_24;
4893 } else {
4894 sme_set_phy_mode(hal, old_phymode);
4895 return -EIO;
4896 }
4897 break;
4898 case IEEE80211_MODE_11G:
4899 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
4900 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4901 phymode = eCSR_DOT11_MODE_11g;
4902 hdd_dot11mode = eHDD_DOT11_MODE_11g;
4903 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4904 curr_band = eCSR_BAND_24;
4905 } else {
4906 sme_set_phy_mode(hal, old_phymode);
4907 return -EIO;
4908 }
4909 break;
4910 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
4911 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
4912 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
4913 */
4914 case IEEE80211_MODE_11NA_HT20:
4915 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4916 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4917 phymode = eCSR_DOT11_MODE_11n;
4918 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4919 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4920 curr_band = eCSR_BAND_5G;
4921 } else {
4922 sme_set_phy_mode(hal, old_phymode);
4923 return -EIO;
4924 }
4925 break;
4926 case IEEE80211_MODE_11NA_HT40:
4927 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4928 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4929 phymode = eCSR_DOT11_MODE_11n;
4930 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4931 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4932 curr_band = eCSR_BAND_5G;
4933 } else {
4934 sme_set_phy_mode(hal, old_phymode);
4935 return -EIO;
4936 }
4937 break;
4938 case IEEE80211_MODE_11NG_HT20:
4939 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4940 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4941 phymode = eCSR_DOT11_MODE_11n;
4942 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4943 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4944 curr_band = eCSR_BAND_24;
4945 } else {
4946 sme_set_phy_mode(hal, old_phymode);
4947 return -EIO;
4948 }
4949 break;
4950 case IEEE80211_MODE_11NG_HT40:
4951 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4952 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4953 phymode = eCSR_DOT11_MODE_11n;
4954 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4955 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4956 curr_band = eCSR_BAND_24;
4957 } else {
4958 sme_set_phy_mode(hal, old_phymode);
4959 return -EIO;
4960 }
4961 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004962 case IEEE80211_MODE_11AC_VHT20:
4963 case IEEE80211_MODE_11AC_VHT40:
4964 case IEEE80211_MODE_11AC_VHT80:
4965 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
4966 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4967 phymode = eCSR_DOT11_MODE_11ac;
4968 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
4969 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4970 curr_band = eCSR_BAND_5G;
4971 } else {
4972 sme_set_phy_mode(hal, old_phymode);
4973 return -EIO;
4974 }
4975 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976 case IEEE80211_MODE_2G_AUTO:
4977 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4978 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4979 phymode = eCSR_DOT11_MODE_AUTO;
4980 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4981 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4982 curr_band = eCSR_BAND_24;
4983 } else {
4984 sme_set_phy_mode(hal, old_phymode);
4985 return -EIO;
4986 }
4987 break;
4988 case IEEE80211_MODE_5G_AUTO:
4989 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4990 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4991 phymode = eCSR_DOT11_MODE_AUTO;
4992 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4993 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4994 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
4995 curr_band = eCSR_BAND_5G;
4996 } else {
4997 sme_set_phy_mode(hal, old_phymode);
4998 return -EIO;
4999 }
5000 break;
5001 case IEEE80211_MODE_11AGN:
5002 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5003 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
5004 phymode = eCSR_DOT11_MODE_11n;
5005 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5006 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5007 curr_band = eCSR_BAND_ALL;
5008 } else {
5009 sme_set_phy_mode(hal, old_phymode);
5010 return -EIO;
5011 }
5012 break;
5013 default:
5014 return -EIO;
5015 }
5016
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017 switch (new_phymode) {
5018 case IEEE80211_MODE_11AC_VHT20:
5019 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5020 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
5021 break;
5022 case IEEE80211_MODE_11AC_VHT40:
5023 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
5024 break;
5025 case IEEE80211_MODE_11AC_VHT80:
5026 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5027 break;
5028 default:
5029 vhtchanwidth = phddctx->config->vhtChannelWidth;
5030 break;
5031 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005032
5033 if (phymode != -EIO) {
5034 sme_get_config_param(hal, &smeconfig);
5035 smeconfig.csrConfig.phyMode = phymode;
5036#ifdef QCA_HT_2040_COEX
5037 if (phymode == eCSR_DOT11_MODE_11n &&
5038 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
5039 smeconfig.csrConfig.obssEnabled = false;
5040 halStatus = sme_set_ht2040_mode(hal,
5041 pAdapter->sessionId,
5042 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305043 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005044 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005045 return -EIO;
5046 }
5047 } else if (phymode == eCSR_DOT11_MODE_11n &&
5048 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
5049 smeconfig.csrConfig.obssEnabled = true;
5050 halStatus = sme_set_ht2040_mode(hal,
5051 pAdapter->sessionId,
5052 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305053 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005054 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055 return -EIO;
5056 }
5057 }
5058#endif
5059 smeconfig.csrConfig.eBand = curr_band;
5060 smeconfig.csrConfig.bandCapability = curr_band;
5061 if (curr_band == eCSR_BAND_24)
5062 smeconfig.csrConfig.Is11hSupportEnabled = 0;
5063 else
5064 smeconfig.csrConfig.Is11hSupportEnabled =
5065 phddctx->config->Is11hSupportEnabled;
5066 if (curr_band == eCSR_BAND_24)
5067 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5068 else if (curr_band == eCSR_BAND_24)
5069 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5070 else {
5071 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5072 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5073 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075 sme_update_config(hal, &smeconfig);
5076
5077 phddctx->config->dot11Mode = hdd_dot11mode;
5078 phddctx->config->nBandCapability = curr_band;
5079 phddctx->config->nChannelBondingMode24GHz =
5080 smeconfig.csrConfig.channelBondingMode24GHz;
5081 phddctx->config->nChannelBondingMode5GHz =
5082 smeconfig.csrConfig.channelBondingMode5GHz;
5083 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07005084 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005085 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005086 return -EIO;
5087 }
5088 if (phddctx->config->nChannelBondingMode5GHz)
5089 phddctx->wiphy->bands[IEEE80211_BAND_5GHZ]->ht_cap.cap
5090 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5091 else
5092 phddctx->wiphy->bands[IEEE80211_BAND_5GHZ]->ht_cap.cap
5093 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5094
Jeff Johnson99bac312016-06-28 10:38:18 -07005095 hdd_warn("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005096 phymode, chwidth, curr_band, vhtchanwidth);
5097 }
5098
5099 return 0;
5100}
5101
5102/**
5103 * hdd_get_temperature_cb() - "Get Temperature" callback function
5104 * @temperature: measured temperature
5105 * @pContext: callback context
5106 *
5107 * This function is passed to sme_get_temperature() as the callback
5108 * function to be invoked when the temperature measurement is
5109 * available.
5110 *
5111 * Return: None
5112 */
5113static void hdd_get_temperature_cb(int temperature, void *pContext)
5114{
5115 struct statsContext *pTempContext;
5116 hdd_adapter_t *pAdapter;
5117 ENTER();
5118 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005119 hdd_err("pContext is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005120 return;
5121 }
5122 pTempContext = pContext;
5123 pAdapter = pTempContext->pAdapter;
5124 spin_lock(&hdd_context_lock);
5125 if ((NULL == pAdapter) || (TEMP_CONTEXT_MAGIC != pTempContext->magic)) {
5126 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07005127 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005128 pAdapter, pTempContext->magic);
5129 return;
5130 }
5131 if (temperature != 0) {
5132 pAdapter->temperature = temperature;
5133 }
5134 complete(&pTempContext->completion);
5135 spin_unlock(&hdd_context_lock);
5136 EXIT();
5137}
5138
5139/**
5140 * wlan_hdd_get_temperature() - get current device temperature
5141 * @pAdapter: device upon which the request was made
5142 * @temperature: pointer to where the temperature is to be returned
5143 *
5144 * Return: 0 if a temperature value (either current or cached) was
5145 * returned, otherwise a negative errno is returned.
5146 *
5147 */
5148int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
5149{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305150 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 struct statsContext tempContext;
5152 unsigned long rc;
5153
5154 ENTER();
5155 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005156 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005157 return -EPERM;
5158 }
5159 init_completion(&tempContext.completion);
5160 tempContext.pAdapter = pAdapter;
5161 tempContext.magic = TEMP_CONTEXT_MAGIC;
5162 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
5163 &tempContext, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305164 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005165 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005166 } else {
5167 rc = wait_for_completion_timeout(&tempContext.completion,
5168 msecs_to_jiffies
5169 (WLAN_WAIT_TIME_STATS));
5170 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005171 hdd_err("SME timed out while retrieving temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005172 }
5173 }
5174 spin_lock(&hdd_context_lock);
5175 tempContext.magic = 0;
5176 spin_unlock(&hdd_context_lock);
5177 *temperature = pAdapter->temperature;
5178 EXIT();
5179 return 0;
5180}
5181
5182/**
5183 * iw_setint_getnone() - Generic "set integer" private ioctl handler
5184 * @dev: device upon which the ioctl was received
5185 * @info: ioctl request information
5186 * @wrqu: ioctl request data
5187 * @extra: ioctl extra data
5188 *
5189 * Return: 0 on success, non-zero on error
5190 */
5191static int __iw_setint_getnone(struct net_device *dev,
5192 struct iw_request_info *info,
5193 union iwreq_data *wrqu, char *extra)
5194{
5195 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5196 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5197 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5198 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5199 hdd_context_t *hdd_ctx;
5200 tSmeConfigParams smeConfig;
5201 int *value = (int *)extra;
5202 int sub_cmd = value[0];
5203 int set_value = value[1];
5204 int ret;
5205 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305206 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005207
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005208 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210 INIT_COMPLETION(pWextState->completion_var);
Mukul Sharma81661ae2015-10-30 20:26:02 +05305211 memset(&smeConfig, 0x00, sizeof(smeConfig));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005212
5213 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5214 ret = wlan_hdd_validate_context(hdd_ctx);
5215 if (0 != ret)
5216 return ret;
5217
5218 switch (sub_cmd) {
5219 case WE_SET_11D_STATE:
5220 {
5221 if ((ENABLE_11D == set_value)
5222 || (DISABLE_11D == set_value)) {
5223
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224 sme_get_config_param(hHal, &smeConfig);
5225 smeConfig.csrConfig.Is11dSupportEnabled =
5226 (bool) set_value;
5227
Jeff Johnson99bac312016-06-28 10:38:18 -07005228 hdd_notice("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229 smeConfig.csrConfig.
5230 Is11dSupportEnabled);
5231
5232 sme_update_config(hHal, &smeConfig);
5233 } else {
5234 return -EINVAL;
5235 }
5236 break;
5237 }
5238
5239 case WE_WOWL:
5240 {
5241 switch (set_value) {
5242 case 0x00:
5243 hdd_exit_wowl(pAdapter);
5244 break;
5245 case 0x01:
5246 case 0x02:
5247 case 0x03:
5248 enable_mp = (set_value & 0x01) ? 1 : 0;
5249 enable_pbm = (set_value & 0x02) ? 1 : 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005250 hdd_err("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005251 (enable_mp ? "YES" : "NO"),
5252 (enable_pbm ? "YES" : "NO"));
5253 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5254 break;
5255 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005256 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005257 set_value);
5258 ret = -EINVAL;
5259 break;
5260 }
5261
5262 break;
5263 }
5264 case WE_SET_POWER:
5265 {
5266 switch (set_value) {
5267 case 1:
5268 /* Enable PowerSave */
5269 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5270 SME_PS_ENABLE);
5271 break;
5272 case 2:
5273 /* Disable PowerSave */
5274 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5275 SME_PS_DISABLE);
5276 break;
5277 case 3: /* Enable UASPD */
5278 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
5279 break;
5280 case 4: /* Disable UASPD */
5281 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
5282 break;
5283 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005284 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005285 set_value);
5286 ret = -EINVAL;
5287 break;
5288 }
5289 break;
5290 }
5291
5292 case WE_SET_MAX_ASSOC:
5293 {
5294 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5295 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
5296 ret = -EINVAL;
5297 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5298 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305299 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005300 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005301 ret = -EIO;
5302 }
5303 break;
5304 }
5305
5306 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5307 if (set_value == 0 || set_value == 1)
5308 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
5309 set_value;
5310 else
5311 ret = -EINVAL;
5312 break;
5313
5314 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5316 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5317 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5318 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305319 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005320 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321 ret = -EINVAL;
5322 }
5323 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324 case WE_SET_MC_RATE:
5325 {
5326 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
5327 break;
5328 }
5329 case WE_SET_TX_POWER:
5330 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305331 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332
Anurag Chouhanc5548422016-02-24 18:33:27 +05305333 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005334 if (sme_set_tx_power
5335 (hHal, pAdapter->sessionId, bssid,
5336 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305337 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005338 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005339 return -EIO;
5340 }
5341 break;
5342 }
5343 case WE_SET_MAX_TX_POWER:
5344 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305345 struct qdf_mac_addr bssid;
5346 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347
Jeff Johnson99bac312016-06-28 10:38:18 -07005348 hdd_notice("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05305350 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
5351 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005352
5353 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305354 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005355 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005356 return -EIO;
5357 }
5358
5359 break;
5360 }
5361 case WE_SET_MAX_TX_POWER_2_4:
5362 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005363 hdd_notice("Setting maximum tx power %d dBm for 2.4 GHz band",
5364 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005365 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305366 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005367 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005368 return -EIO;
5369 }
5370
5371 break;
5372 }
5373 case WE_SET_MAX_TX_POWER_5_0:
5374 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005375 hdd_notice("Setting maximum tx power %d dBm for 5.0 GHz band",
5376 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005377 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305378 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005379 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005380 return -EIO;
5381 }
5382
5383 break;
5384 }
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08005385 case WE_SET_PKTLOG:
5386 {
5387 hdd_process_pktlog_command(hdd_ctx, set_value);
5388 break;
5389 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005390 case WE_SET_HIGHER_DTIM_TRANSITION:
5391 {
5392 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005393 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 set_value);
5395 ret = -EINVAL;
5396 } else {
5397 if (pAdapter->higherDtimTransition != set_value) {
5398 pAdapter->higherDtimTransition =
5399 set_value;
Jeff Johnson99bac312016-06-28 10:38:18 -07005400 hdd_notice("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005401 pAdapter->higherDtimTransition);
5402 }
5403 }
5404
5405 break;
5406 }
5407
5408 case WE_SET_TM_LEVEL:
5409 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005410 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005411 (void)sme_set_thermal_level(hHal, set_value);
5412 break;
5413 }
5414
5415 case WE_SET_PHYMODE:
5416 {
5417 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5418
5419 ret =
5420 wlan_hdd_update_phymode(dev, hHal, set_value,
5421 phddctx);
5422 break;
5423 }
5424
5425 case WE_SET_NSS:
5426 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005427 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005429 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430 ret = -EINVAL;
5431 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305432 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
5434 set_value))
5435 ret = -EINVAL;
5436 }
5437 break;
5438 }
5439
5440 case WE_SET_GTX_HT_MCS:
5441 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005442 hdd_notice("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005443 ret = wma_cli_set_command(pAdapter->sessionId,
5444 WMI_VDEV_PARAM_GTX_HT_MCS,
5445 set_value, GTX_CMD);
5446 break;
5447 }
5448
5449 case WE_SET_GTX_VHT_MCS:
5450 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005451 hdd_notice("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005452 set_value);
5453 ret = wma_cli_set_command(pAdapter->sessionId,
5454 WMI_VDEV_PARAM_GTX_VHT_MCS,
5455 set_value, GTX_CMD);
5456 break;
5457 }
5458
5459 case WE_SET_GTX_USRCFG:
5460 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005461 hdd_notice("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005462 set_value);
5463 ret = wma_cli_set_command(pAdapter->sessionId,
5464 WMI_VDEV_PARAM_GTX_USR_CFG,
5465 set_value, GTX_CMD);
5466 break;
5467 }
5468
5469 case WE_SET_GTX_THRE:
5470 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005471 hdd_notice("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005472 ret = wma_cli_set_command(pAdapter->sessionId,
5473 WMI_VDEV_PARAM_GTX_THRE,
5474 set_value, GTX_CMD);
5475 break;
5476 }
5477
5478 case WE_SET_GTX_MARGIN:
5479 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005480 hdd_notice("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005481 ret = wma_cli_set_command(pAdapter->sessionId,
5482 WMI_VDEV_PARAM_GTX_MARGIN,
5483 set_value, GTX_CMD);
5484 break;
5485 }
5486
5487 case WE_SET_GTX_STEP:
5488 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005489 hdd_notice("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005490 ret = wma_cli_set_command(pAdapter->sessionId,
5491 WMI_VDEV_PARAM_GTX_STEP,
5492 set_value, GTX_CMD);
5493 break;
5494 }
5495
5496 case WE_SET_GTX_MINTPC:
5497 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005498 hdd_notice("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005499 ret = wma_cli_set_command(pAdapter->sessionId,
5500 WMI_VDEV_PARAM_GTX_MINTPC,
5501 set_value, GTX_CMD);
5502 break;
5503 }
5504
5505 case WE_SET_GTX_BWMASK:
5506 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005507 hdd_notice("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508 ret = wma_cli_set_command(pAdapter->sessionId,
5509 WMI_VDEV_PARAM_GTX_BW_MASK,
5510 set_value, GTX_CMD);
5511 break;
5512 }
5513
5514 case WE_SET_LDPC:
5515 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305516 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517 break;
5518 }
5519
5520 case WE_SET_TX_STBC:
5521 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305522 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005523 break;
5524 }
5525
5526 case WE_SET_RX_STBC:
5527 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305528 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005529 break;
5530 }
5531
5532 case WE_SET_SHORT_GI:
5533 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005534 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005535 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
5536 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
5537 set_value);
5538 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07005539 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005540 break;
5541 }
5542
5543 case WE_SET_RTSCTS:
5544 {
5545 uint32_t value;
5546
Jeff Johnson99bac312016-06-28 10:38:18 -07005547 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005548 set_value);
5549
5550 if ((set_value & HDD_RTSCTS_EN_MASK) ==
5551 HDD_RTSCTS_ENABLE)
5552 value =
5553 (WLAN_HDD_GET_CTX(pAdapter))->config->
5554 RTSThreshold;
5555 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
5556 || ((set_value & HDD_RTSCTS_EN_MASK) ==
5557 HDD_CTS_ENABLE))
5558 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
5559 else
5560 return -EIO;
5561
5562 ret = wma_cli_set_command(pAdapter->sessionId,
5563 WMI_VDEV_PARAM_ENABLE_RTSCTS,
5564 set_value, VDEV_CMD);
5565 if (!ret) {
5566 if (sme_cfg_set_int
5567 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305568 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005569 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570 return -EIO;
5571 }
5572 }
5573
5574 break;
5575 }
5576
5577 case WE_SET_CHWIDTH:
5578 {
5579 bool chwidth = false;
5580 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5581 /*updating channel bonding only on 5Ghz */
Jeff Johnson99bac312016-06-28 10:38:18 -07005582 hdd_notice("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005583 set_value);
5584 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005585 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005586 return -EINVAL;
5587 }
5588
5589 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5590 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
5591 nChannelBondingMode5GHz)))
5592 chwidth = true;
5593
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005594 sme_get_config_param(hHal, &smeConfig);
5595 switch (set_value) {
5596 case eHT_CHANNEL_WIDTH_20MHZ:
5597 smeConfig.csrConfig.channelBondingMode5GHz =
5598 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5599 break;
5600 case eHT_CHANNEL_WIDTH_40MHZ:
5601 if (chwidth)
5602 smeConfig.csrConfig.
5603 channelBondingMode5GHz =
5604 phddctx->config->
5605 nChannelBondingMode5GHz;
5606 else
5607 return -EINVAL;
5608
5609 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005610 case eHT_CHANNEL_WIDTH_80MHZ:
5611 if (chwidth)
5612 smeConfig.csrConfig.
5613 channelBondingMode5GHz =
5614 phddctx->config->
5615 nChannelBondingMode5GHz;
5616 else
5617 return -EINVAL;
5618
5619 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620
5621 default:
5622 return -EINVAL;
5623 }
5624
5625 ret = wma_cli_set_command(pAdapter->sessionId,
5626 WMI_VDEV_PARAM_CHWIDTH,
5627 set_value, VDEV_CMD);
5628 if (!ret)
5629 sme_update_config(hHal, &smeConfig);
5630
5631 break;
5632 }
5633
5634 case WE_SET_ANI_EN_DIS:
5635 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005636 hdd_notice("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637 set_value);
5638 ret = wma_cli_set_command(pAdapter->sessionId,
5639 WMI_PDEV_PARAM_ANI_ENABLE,
5640 set_value, PDEV_CMD);
5641 break;
5642 }
5643
5644 case WE_SET_ANI_POLL_PERIOD:
5645 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005646 hdd_notice("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005647 set_value);
5648 ret = wma_cli_set_command(pAdapter->sessionId,
5649 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
5650 set_value, PDEV_CMD);
5651 break;
5652 }
5653
5654 case WE_SET_ANI_LISTEN_PERIOD:
5655 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005656 hdd_notice("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657 set_value);
5658 ret = wma_cli_set_command(pAdapter->sessionId,
5659 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
5660 set_value, PDEV_CMD);
5661 break;
5662 }
5663
5664 case WE_SET_ANI_OFDM_LEVEL:
5665 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005666 hdd_notice("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667 set_value);
5668 ret = wma_cli_set_command(pAdapter->sessionId,
5669 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
5670 set_value, PDEV_CMD);
5671 break;
5672 }
5673
5674 case WE_SET_ANI_CCK_LEVEL:
5675 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005676 hdd_notice("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005677 set_value);
5678 ret = wma_cli_set_command(pAdapter->sessionId,
5679 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
5680 set_value, PDEV_CMD);
5681 break;
5682 }
5683
5684 case WE_SET_DYNAMIC_BW:
5685 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005686 hdd_notice("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005687 set_value);
5688 ret = wma_cli_set_command(pAdapter->sessionId,
5689 WMI_PDEV_PARAM_DYNAMIC_BW,
5690 set_value, PDEV_CMD);
5691 break;
5692 }
5693
5694 case WE_SET_CTS_CBW:
5695 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005696 hdd_notice("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005697 ret = wma_cli_set_command(pAdapter->sessionId,
5698 WMI_PDEV_PARAM_CTS_CBW,
5699 set_value, PDEV_CMD);
5700 break;
5701 }
5702
5703 case WE_SET_11N_RATE:
5704 {
5705 uint8_t preamble = 0, nss = 0, rix = 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005706 hdd_notice("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707 set_value);
5708
5709 if (set_value != 0xff) {
5710 rix = RC_2_RATE_IDX(set_value);
5711 if (set_value & 0x80) {
5712 preamble = WMI_RATE_PREAMBLE_HT;
5713 nss = HT_RC_2_STREAMS(set_value) - 1;
5714 } else {
5715 nss = 0;
5716 rix = RC_2_RATE_IDX(set_value);
5717 if (set_value & 0x10) {
5718 preamble =
5719 WMI_RATE_PREAMBLE_CCK;
5720 if (rix != 0x3)
5721 /* Enable Short
5722 * preamble always for
5723 * CCK except 1mbps
5724 */
5725 rix |= 0x4;
5726 } else {
5727 preamble =
5728 WMI_RATE_PREAMBLE_OFDM;
5729 }
5730 }
5731 set_value = (preamble << 6) | (nss << 4) | rix;
5732 }
5733 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
5734 set_value, rix, preamble, nss);
5735
5736 ret = wma_cli_set_command(pAdapter->sessionId,
5737 WMI_VDEV_PARAM_FIXED_RATE,
5738 set_value, VDEV_CMD);
5739 break;
5740 }
5741
5742 case WE_SET_VHT_RATE:
5743 {
5744 uint8_t preamble = 0, nss = 0, rix = 0;
5745
5746 if (set_value != 0xff) {
5747 rix = RC_2_RATE_IDX_11AC(set_value);
5748 preamble = WMI_RATE_PREAMBLE_VHT;
5749 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
5750
5751 set_value = (preamble << 6) | (nss << 4) | rix;
5752 }
5753 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
5754 set_value, rix, preamble, nss);
5755 ret = wma_cli_set_command(pAdapter->sessionId,
5756 WMI_VDEV_PARAM_FIXED_RATE,
5757 set_value, VDEV_CMD);
5758 break;
5759 }
5760
5761 case WE_SET_AMPDU:
5762 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005763 hdd_notice("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005764 ret = wma_cli_set_command(pAdapter->sessionId,
5765 GEN_VDEV_PARAM_AMPDU,
5766 set_value, GEN_CMD);
5767 break;
5768 }
5769
5770 case WE_SET_AMSDU:
5771 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005772 hdd_notice("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773 ret = wma_cli_set_command(pAdapter->sessionId,
5774 GEN_VDEV_PARAM_AMSDU,
5775 set_value, GEN_CMD);
5776 break;
5777 }
5778
5779 case WE_SET_BURST_ENABLE:
5780 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005781 hdd_notice("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005782 if ((set_value == 0) || (set_value == 1)) {
5783 ret = wma_cli_set_command(pAdapter->sessionId,
5784 WMI_PDEV_PARAM_BURST_ENABLE,
5785 set_value, PDEV_CMD);
5786 } else
5787 ret = -EINVAL;
5788 break;
5789 }
5790 case WE_SET_BURST_DUR:
5791 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005792 hdd_notice("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07005793 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794 ret = wma_cli_set_command(pAdapter->sessionId,
5795 WMI_PDEV_PARAM_BURST_DUR,
5796 set_value, PDEV_CMD);
5797 else
5798 ret = -EINVAL;
5799 break;
5800 }
5801
5802 case WE_SET_TX_CHAINMASK:
5803 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005804 hdd_notice("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005805 set_value);
5806 ret = wma_cli_set_command(pAdapter->sessionId,
5807 WMI_PDEV_PARAM_TX_CHAIN_MASK,
5808 set_value, PDEV_CMD);
5809 break;
5810 }
5811
5812 case WE_SET_RX_CHAINMASK:
5813 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005814 hdd_notice("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005815 set_value);
5816 ret = wma_cli_set_command(pAdapter->sessionId,
5817 WMI_PDEV_PARAM_RX_CHAIN_MASK,
5818 set_value, PDEV_CMD);
5819 break;
5820 }
5821
5822 case WE_SET_TXPOW_2G:
5823 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005824 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005825 set_value);
5826 ret = wma_cli_set_command(pAdapter->sessionId,
5827 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
5828 set_value, PDEV_CMD);
5829 break;
5830 }
5831
5832 case WE_SET_TXPOW_5G:
5833 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005834 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835 set_value);
5836 ret = wma_cli_set_command(pAdapter->sessionId,
5837 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
5838 set_value, PDEV_CMD);
5839 break;
5840 }
5841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005842 /* Firmware debug log */
5843 case WE_DBGLOG_LOG_LEVEL:
5844 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005845 hdd_notice("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005846 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
5847 ret = wma_cli_set_command(pAdapter->sessionId,
5848 WMI_DBGLOG_LOG_LEVEL,
5849 set_value, DBG_CMD);
5850 break;
5851 }
5852
5853 case WE_DBGLOG_VAP_ENABLE:
5854 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005855 hdd_notice("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005856 ret = wma_cli_set_command(pAdapter->sessionId,
5857 WMI_DBGLOG_VAP_ENABLE,
5858 set_value, DBG_CMD);
5859 break;
5860 }
5861
5862 case WE_DBGLOG_VAP_DISABLE:
5863 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005864 hdd_notice("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005865 ret = wma_cli_set_command(pAdapter->sessionId,
5866 WMI_DBGLOG_VAP_DISABLE,
5867 set_value, DBG_CMD);
5868 break;
5869 }
5870
5871 case WE_DBGLOG_MODULE_ENABLE:
5872 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005873 hdd_notice("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005874 set_value);
5875 hdd_ctx->fw_log_settings.enable = set_value;
5876 ret = wma_cli_set_command(pAdapter->sessionId,
5877 WMI_DBGLOG_MODULE_ENABLE,
5878 set_value, DBG_CMD);
5879 break;
5880 }
5881
5882 case WE_DBGLOG_MODULE_DISABLE:
5883 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005884 hdd_notice("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005885 set_value);
5886 hdd_ctx->fw_log_settings.enable = set_value;
5887 ret = wma_cli_set_command(pAdapter->sessionId,
5888 WMI_DBGLOG_MODULE_DISABLE,
5889 set_value, DBG_CMD);
5890 break;
5891 }
5892 case WE_DBGLOG_MOD_LOG_LEVEL:
5893 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005894 hdd_notice("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005895 set_value);
5896
5897 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
5898 hdd_ctx->fw_log_settings.index = 0;
5899
5900 hdd_ctx->fw_log_settings.
5901 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
5902 set_value;
5903 hdd_ctx->fw_log_settings.index++;
5904
5905 ret = wma_cli_set_command(pAdapter->sessionId,
5906 WMI_DBGLOG_MOD_LOG_LEVEL,
5907 set_value, DBG_CMD);
5908 break;
5909 }
5910
5911 case WE_DBGLOG_TYPE:
5912 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005913 hdd_notice("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005914 hdd_ctx->fw_log_settings.dl_type = set_value;
5915 ret = wma_cli_set_command(pAdapter->sessionId,
5916 WMI_DBGLOG_TYPE,
5917 set_value, DBG_CMD);
5918 break;
5919 }
5920 case WE_DBGLOG_REPORT_ENABLE:
5921 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005922 hdd_notice("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005923 set_value);
5924 hdd_ctx->fw_log_settings.dl_report = set_value;
5925 ret = wma_cli_set_command(pAdapter->sessionId,
5926 WMI_DBGLOG_REPORT_ENABLE,
5927 set_value, DBG_CMD);
5928 break;
5929 }
5930
5931 case WE_SET_TXRX_FWSTATS:
5932 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005933 hdd_notice("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005934 ret = wma_cli_set_command(pAdapter->sessionId,
5935 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
5936 set_value, VDEV_CMD);
5937 break;
5938 }
5939
5940 case WE_TXRX_FWSTATS_RESET:
5941 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005942 hdd_notice("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005943 ret = wma_cli_set_command(pAdapter->sessionId,
5944 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
5945 set_value, VDEV_CMD);
5946 break;
5947 }
5948
5949 case WE_DUMP_STATS:
5950 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005951 hdd_notice("WE_DUMP_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005952 hdd_wlan_dump_stats(pAdapter, set_value);
5953 break;
5954 }
5955
5956 case WE_CLEAR_STATS:
5957 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005958 hdd_notice("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005959 switch (set_value) {
5960 case WLAN_HDD_STATS:
5961 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5962 memset(&pAdapter->hdd_stats, 0,
5963 sizeof(pAdapter->hdd_stats));
5964 break;
5965 case WLAN_TXRX_HIST_STATS:
5966 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
5967 break;
5968 case WLAN_HDD_NETIF_OPER_HISTORY:
5969 wlan_hdd_clear_netif_queue_history(hdd_ctx);
5970 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05305971 case WLAN_HIF_STATS:
5972 hdd_clear_hif_stats();
5973 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005974 default:
5975 ol_txrx_clear_stats(set_value);
5976 }
5977 break;
5978 }
5979
5980 case WE_PPS_PAID_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;
5984
Jeff Johnson99bac312016-06-28 10:38:18 -07005985 hdd_notice("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005986 set_value);
5987 ret = wma_cli_set_command(pAdapter->sessionId,
5988 WMI_VDEV_PPS_PAID_MATCH,
5989 set_value, PPS_CMD);
5990 break;
5991 }
5992
5993 case WE_PPS_GID_MATCH:
5994 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005995 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005996 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07005997 hdd_notice("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005998 set_value);
5999 ret = wma_cli_set_command(pAdapter->sessionId,
6000 WMI_VDEV_PPS_GID_MATCH,
6001 set_value, PPS_CMD);
6002 break;
6003 }
6004
6005 case WE_PPS_EARLY_TIM_CLEAR:
6006 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006007 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006008 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006009 hdd_notice(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010 set_value);
6011 ret = wma_cli_set_command(pAdapter->sessionId,
6012 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6013 set_value, PPS_CMD);
6014 break;
6015 }
6016
6017 case WE_PPS_EARLY_DTIM_CLEAR:
6018 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006019 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006020 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006021 hdd_notice("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006022 set_value);
6023 ret = wma_cli_set_command(pAdapter->sessionId,
6024 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6025 set_value, PPS_CMD);
6026 break;
6027 }
6028
6029 case WE_PPS_EOF_PAD_DELIM:
6030 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006031 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006032 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006033 hdd_notice("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006034 set_value);
6035 ret = wma_cli_set_command(pAdapter->sessionId,
6036 WMI_VDEV_PPS_EOF_PAD_DELIM,
6037 set_value, PPS_CMD);
6038 break;
6039 }
6040
6041 case WE_PPS_MACADDR_MISMATCH:
6042 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006043 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006044 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006045 hdd_notice("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 set_value);
6047 ret = wma_cli_set_command(pAdapter->sessionId,
6048 WMI_VDEV_PPS_MACADDR_MISMATCH,
6049 set_value, PPS_CMD);
6050 break;
6051 }
6052
6053 case WE_PPS_DELIM_CRC_FAIL:
6054 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006055 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006057 hdd_notice("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006058 set_value);
6059 ret = wma_cli_set_command(pAdapter->sessionId,
6060 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6061 set_value, PPS_CMD);
6062 break;
6063 }
6064
6065 case WE_PPS_GID_NSTS_ZERO:
6066 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006067 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006068 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006069 hdd_notice("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006070 set_value);
6071 ret = wma_cli_set_command(pAdapter->sessionId,
6072 WMI_VDEV_PPS_GID_NSTS_ZERO,
6073 set_value, PPS_CMD);
6074 break;
6075 }
6076
6077 case WE_PPS_RSSI_CHECK:
6078 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006079 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006080 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006081 hdd_notice("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006082 set_value);
6083 ret = wma_cli_set_command(pAdapter->sessionId,
6084 WMI_VDEV_PPS_RSSI_CHECK,
6085 set_value, PPS_CMD);
6086 break;
6087 }
6088
6089 case WE_PPS_5G_EBT:
6090 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006091 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092 return -EINVAL;
6093
Jeff Johnson99bac312016-06-28 10:38:18 -07006094 hdd_notice("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006095 ret = wma_cli_set_command(pAdapter->sessionId,
6096 WMI_VDEV_PPS_5G_EBT,
6097 set_value, PPS_CMD);
6098 break;
6099 }
6100
6101 case WE_SET_HTSMPS:
6102 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006103 hdd_notice("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006104 ret = wma_cli_set_command(pAdapter->sessionId,
6105 WMI_STA_SMPS_FORCE_MODE_CMDID,
6106 set_value, VDEV_CMD);
6107 break;
6108 }
6109
6110 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
6111 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006112 hdd_notice("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006113 set_value);
6114 ret = wma_cli_set_command(pAdapter->sessionId,
6115 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6116 set_value, QPOWER_CMD);
6117 break;
6118 }
6119
6120 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
6121 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006122 hdd_notice("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123 set_value);
6124 ret = wma_cli_set_command(
6125 pAdapter->sessionId,
6126 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6127 set_value, QPOWER_CMD);
6128 break;
6129 }
6130
6131 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6132 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006133 hdd_notice("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006134 set_value);
6135 ret = wma_cli_set_command(
6136 pAdapter->sessionId,
6137 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6138 set_value, QPOWER_CMD);
6139 break;
6140 }
6141
6142 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6143 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006144 hdd_notice("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006145 set_value);
6146 ret = wma_cli_set_command(
6147 pAdapter->sessionId,
6148 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6149 set_value, QPOWER_CMD);
6150 break;
6151 }
6152
6153 case WE_MCC_CONFIG_LATENCY:
6154 {
6155 cds_set_mcc_latency(pAdapter, set_value);
6156 break;
6157 }
6158
6159 case WE_MCC_CONFIG_QUOTA:
6160 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006161 hdd_notice("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006162 set_value);
6163 ret = cds_set_mcc_p2p_quota(pAdapter, set_value);
6164 break;
6165 }
6166 case WE_SET_DEBUG_LOG:
6167 {
6168 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05306169
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006170 hdd_ctx->config->gEnableDebugLog = set_value;
6171 sme_update_connect_debug(hdd_ctx->hHal, set_value);
6172 break;
6173 }
6174 case WE_SET_EARLY_RX_ADJUST_ENABLE:
6175 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006176 hdd_notice("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006177 if ((set_value == 0) || (set_value == 1))
6178 ret = wma_cli_set_command(
6179 pAdapter->sessionId,
6180 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
6181 set_value, VDEV_CMD);
6182 else
6183 ret = -EINVAL;
6184 break;
6185 }
6186 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
6187 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006188 hdd_notice("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006189 ret = wma_cli_set_command(pAdapter->sessionId,
6190 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
6191 set_value, VDEV_CMD);
6192 break;
6193 }
6194 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
6195 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006196 hdd_notice("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006197 set_value);
6198 ret = wma_cli_set_command(
6199 pAdapter->sessionId,
6200 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
6201 set_value, VDEV_CMD);
6202 break;
6203 }
6204 case WE_SET_EARLY_RX_SLOP_STEP:
6205 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006206 hdd_notice("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006207 set_value);
6208 ret = wma_cli_set_command(pAdapter->sessionId,
6209 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
6210 set_value, VDEV_CMD);
6211 break;
6212 }
6213 case WE_SET_EARLY_RX_INIT_SLOP:
6214 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006215 hdd_notice("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006216 set_value);
6217 ret = wma_cli_set_command(pAdapter->sessionId,
6218 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
6219 set_value, VDEV_CMD);
6220 break;
6221 }
6222 case WE_SET_EARLY_RX_ADJUST_PAUSE:
6223 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006224 hdd_notice("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006225 if ((set_value == 0) || (set_value == 1))
6226 ret = wma_cli_set_command(
6227 pAdapter->sessionId,
6228 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
6229 set_value, VDEV_CMD);
6230 else
6231 ret = -EINVAL;
6232 break;
6233 }
6234 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
6235 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006236 hdd_notice("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006237 ret = wma_cli_set_command(pAdapter->sessionId,
6238 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
6239 set_value, VDEV_CMD);
6240 break;
6241 }
6242 case WE_SET_SCAN_DISABLE:
6243 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006244 hdd_notice("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006245 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
6246 break;
6247 }
Govind Singha471e5e2015-10-12 17:11:14 +05306248 case WE_START_FW_PROFILE:
6249 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006250 hdd_notice("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05306251 ret = wma_cli_set_command(pAdapter->sessionId,
6252 WMI_WLAN_PROFILE_TRIGGER_CMDID,
6253 set_value, DBG_CMD);
6254 break;
6255 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306256 case WE_SET_CHANNEL:
6257 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006258 hdd_notice("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306259 pAdapter->sessionId, pAdapter->device_mode);
6260
Krunal Sonif07bb382016-03-10 13:02:11 -08006261 if ((QDF_STA_MODE == pAdapter->device_mode) ||
6262 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306263
6264 status = sme_ext_change_channel(hHal,
6265 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306266 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006267 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306268 status);
6269 ret = -EINVAL;
6270 }
6271 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006272 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306273 pAdapter->device_mode);
6274 ret = -EINVAL;
6275 }
6276 break;
6277 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306278 case WE_SET_CONC_SYSTEM_PREF:
6279 {
6280 hdd_info("New preference: %d", set_value);
6281 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
6282 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
6283 hdd_err("Invalid system preference %d", set_value);
6284 return -EINVAL;
6285 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306286
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306287 /* hdd_ctx, hdd_ctx->config are already checked for null */
6288 hdd_ctx->config->conc_system_pref = set_value;
6289 break;
6290 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006291 default:
6292 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006293 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006294 sub_cmd);
6295 ret = -EINVAL;
6296 break;
6297 }
6298 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306299 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006300 return ret;
6301}
6302
6303static int iw_setint_getnone(struct net_device *dev,
6304 struct iw_request_info *info,
6305 union iwreq_data *wrqu,
6306 char *extra)
6307{
6308 int ret;
6309
6310 cds_ssr_protect(__func__);
6311 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6312 cds_ssr_unprotect(__func__);
6313
6314 return ret;
6315}
6316
6317/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006318 * __iw_setnone_get_threeint() - return three value to up layer.
6319 *
6320 * @dev: pointer of net_device of this wireless card
6321 * @info: meta data about Request sent
6322 * @wrqu: include request info
6323 * @extra: buf used for in/Output
6324 *
6325 * Return: execute result
6326 */
6327static int __iw_setnone_get_threeint(struct net_device *dev,
6328 struct iw_request_info *info,
6329 union iwreq_data *wrqu, char *extra)
6330{
6331 int ret = 0; /* success */
6332 uint32_t *value = (int *)extra;
6333 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6334 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6335
6336 ENTER_DEV(dev);
6337 ret = wlan_hdd_validate_context(hdd_ctx);
6338 if (0 != ret)
6339 return ret;
6340
Jeff Johnson99bac312016-06-28 10:38:18 -07006341 hdd_info("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006342 switch (value[0]) {
6343 case WE_GET_TSF:
6344 ret = hdd_indicate_tsf(adapter, value, 3);
6345 break;
6346 default:
6347 hdd_err("Invalid IOCTL get_value command %d", value[0]);
6348 break;
6349 }
6350 return ret;
6351}
6352
6353/**
6354 * iw_setnone_get_threeint() - return three value to up layer.
6355 *
6356 * @dev: pointer of net_device of this wireless card
6357 * @info: meta data about Request sent
6358 * @wrqu: include request info
6359 * @extra: buf used for in/Output
6360 *
6361 * Return: execute result
6362 */
6363static int iw_setnone_get_threeint(struct net_device *dev,
6364 struct iw_request_info *info,
6365 union iwreq_data *wrqu, char *extra)
6366{
6367 int ret;
6368
6369 cds_ssr_protect(__func__);
6370 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
6371 cds_ssr_unprotect(__func__);
6372
6373 return ret;
6374}
6375
6376/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006377 * iw_setchar_getnone() - Generic "set string" private ioctl handler
6378 * @dev: device upon which the ioctl was received
6379 * @info: ioctl request information
6380 * @wrqu: ioctl request data
6381 * @extra: ioctl extra data
6382 *
6383 * Return: 0 on success, non-zero on error
6384 */
6385static int __iw_setchar_getnone(struct net_device *dev,
6386 struct iw_request_info *info,
6387 union iwreq_data *wrqu, char *extra)
6388{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306389 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006390 int sub_cmd;
6391 int ret;
6392 char *pBuffer = NULL;
6393 hdd_adapter_t *pAdapter = (netdev_priv(dev));
6394 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006395 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006396 struct iw_point s_priv_data;
6397
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006398 ENTER_DEV(dev);
6399
Mukul Sharma34777c62015-11-02 20:22:30 +05306400 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006401 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05306402 return -EPERM;
6403 }
6404
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006405 ret = wlan_hdd_validate_context(hdd_ctx);
6406 if (0 != ret)
6407 return ret;
6408
6409 /* helper function to get iwreq_data with compat handling. */
6410 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
6411 return -EINVAL;
6412 }
6413
6414 /* make sure all params are correctly passed to function */
6415 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
6416 return -EINVAL;
6417 }
6418
6419 sub_cmd = s_priv_data.flags;
6420
6421 /* ODD number is used for set, copy data using copy_from_user */
6422 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6423 s_priv_data.length);
6424 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006425 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006426 return -ENOMEM;
6427 }
6428
Jeff Johnson99bac312016-06-28 10:38:18 -07006429 hdd_notice("Received length %d", s_priv_data.length);
6430 hdd_notice("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006431
6432 switch (sub_cmd) {
6433 case WE_WOWL_ADD_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006434 hdd_notice("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006435 hdd_add_wowl_ptrn(pAdapter, pBuffer);
6436 break;
6437 case WE_WOWL_DEL_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006438 hdd_notice("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006439 hdd_del_wowl_ptrn(pAdapter, pBuffer);
6440 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006441 case WE_NEIGHBOR_REPORT_REQUEST:
6442 {
6443 tRrmNeighborReq neighborReq;
6444 tRrmNeighborRspCallbackInfo callbackInfo;
6445
6446 if (pConfig->fRrmEnable) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006447 hdd_notice("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006448 neighborReq.no_ssid =
6449 (s_priv_data.length - 1) ? false : true;
6450 if (!neighborReq.no_ssid) {
6451 neighborReq.ssid.length =
6452 (s_priv_data.length - 1) >
6453 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306454 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006455 pBuffer,
6456 neighborReq.ssid.length);
6457 }
6458
6459 callbackInfo.neighborRspCallback = NULL;
6460 callbackInfo.neighborRspCallbackContext = NULL;
6461 callbackInfo.timeout = 5000; /* 5 seconds */
6462 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
6463 (pAdapter),
6464 pAdapter->sessionId,
6465 &neighborReq,
6466 &callbackInfo);
6467 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006468 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006469 ret = -EINVAL;
6470 }
6471 }
6472 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006473 case WE_SET_AP_WPS_IE:
Jeff Johnson99bac312016-06-28 10:38:18 -07006474 hdd_err("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006475 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
6476 s_priv_data.length);
6477 break;
6478 case WE_SET_CONFIG:
6479 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306480 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006481 ret = -EINVAL;
6482 }
6483 break;
6484 default:
6485 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006486 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006487 sub_cmd);
6488 ret = -EINVAL;
6489 break;
6490 }
6491 }
6492 kfree(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306493 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006494 return ret;
6495}
6496
6497static int iw_setchar_getnone(struct net_device *dev,
6498 struct iw_request_info *info,
6499 union iwreq_data *wrqu, char *extra)
6500{
6501 int ret;
6502
6503 cds_ssr_protect(__func__);
6504 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6505 cds_ssr_unprotect(__func__);
6506
6507 return ret;
6508}
6509
6510/**
6511 * iw_setnone_getint() - Generic "get integer" private ioctl handler
6512 * @dev: device upon which the ioctl was received
6513 * @info: ioctl request information
6514 * @wrqu: ioctl request data
6515 * @extra: ioctl extra data
6516 *
6517 * Return: 0 on success, non-zero on error
6518 */
6519static int __iw_setnone_getint(struct net_device *dev,
6520 struct iw_request_info *info,
6521 union iwreq_data *wrqu, char *extra)
6522{
6523 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6524 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6525 int *value = (int *)extra;
6526 int ret;
6527 tSmeConfigParams smeConfig;
6528 hdd_context_t *hdd_ctx;
6529
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006530 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306531
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006532 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6533 ret = wlan_hdd_validate_context(hdd_ctx);
6534 if (0 != ret)
6535 return ret;
6536
6537 switch (value[0]) {
6538 case WE_GET_11D_STATE:
6539 {
6540 sme_get_config_param(hHal, &smeConfig);
6541
6542 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6543
Jeff Johnson99bac312016-06-28 10:38:18 -07006544 hdd_notice("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006545
6546 break;
6547 }
6548
6549 case WE_IBSS_STATUS:
Jeff Johnson99bac312016-06-28 10:38:18 -07006550 hdd_notice("****Return IBSS Status*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006551 break;
6552
6553 case WE_GET_WLAN_DBG:
6554 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306555 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006556 *value = 0;
6557 break;
6558 }
6559 case WE_GET_MAX_ASSOC:
6560 {
6561 if (sme_cfg_get_int
6562 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306563 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006564 hdd_warn("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006565 ret = -EIO;
6566 }
6567 break;
6568 }
6569 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6570 *value = (WLAN_HDD_GET_CTX(
6571 pAdapter))->config->force_sap_acs;
6572 break;
6573
6574 case WE_GET_CONCURRENCY_MODE:
6575 {
6576 *value = cds_get_concurrency_mode();
6577
Jeff Johnson99bac312016-06-28 10:38:18 -07006578 hdd_notice("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006579 break;
6580 }
6581
6582 case WE_GET_NSS:
6583 {
6584 sme_get_config_param(hHal, &smeConfig);
6585 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Jeff Johnson99bac312016-06-28 10:38:18 -07006586 hdd_notice("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006587 break;
6588 }
6589
6590 case WE_GET_GTX_HT_MCS:
6591 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006592 hdd_notice("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006593 *value = wma_cli_get_command(pAdapter->sessionId,
6594 WMI_VDEV_PARAM_GTX_HT_MCS,
6595 GTX_CMD);
6596 break;
6597 }
6598
6599 case WE_GET_GTX_VHT_MCS:
6600 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006601 hdd_notice("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006602 *value = wma_cli_get_command(pAdapter->sessionId,
6603 WMI_VDEV_PARAM_GTX_VHT_MCS,
6604 GTX_CMD);
6605 break;
6606 }
6607
6608 case WE_GET_GTX_USRCFG:
6609 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006610 hdd_notice("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006611 *value = wma_cli_get_command(pAdapter->sessionId,
6612 WMI_VDEV_PARAM_GTX_USR_CFG,
6613 GTX_CMD);
6614 break;
6615 }
6616
6617 case WE_GET_GTX_THRE:
6618 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006619 hdd_notice("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006620 *value = wma_cli_get_command(pAdapter->sessionId,
6621 WMI_VDEV_PARAM_GTX_THRE,
6622 GTX_CMD);
6623 break;
6624 }
6625
6626 case WE_GET_GTX_MARGIN:
6627 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006628 hdd_notice("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006629 *value = wma_cli_get_command(pAdapter->sessionId,
6630 WMI_VDEV_PARAM_GTX_MARGIN,
6631 GTX_CMD);
6632 break;
6633 }
6634
6635 case WE_GET_GTX_STEP:
6636 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006637 hdd_notice("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006638 *value = wma_cli_get_command(pAdapter->sessionId,
6639 WMI_VDEV_PARAM_GTX_STEP,
6640 GTX_CMD);
6641 break;
6642 }
6643
6644 case WE_GET_GTX_MINTPC:
6645 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006646 hdd_notice("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006647 *value = wma_cli_get_command(pAdapter->sessionId,
6648 WMI_VDEV_PARAM_GTX_MINTPC,
6649 GTX_CMD);
6650 break;
6651 }
6652
6653 case WE_GET_GTX_BWMASK:
6654 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006655 hdd_notice("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006656 *value = wma_cli_get_command(pAdapter->sessionId,
6657 WMI_VDEV_PARAM_GTX_BW_MASK,
6658 GTX_CMD);
6659 break;
6660 }
6661
6662 case WE_GET_LDPC:
6663 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306664 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006665 break;
6666 }
6667
6668 case WE_GET_TX_STBC:
6669 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306670 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006671 break;
6672 }
6673
6674 case WE_GET_RX_STBC:
6675 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306676 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006677 break;
6678 }
6679
6680 case WE_GET_SHORT_GI:
6681 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006682 hdd_notice("GET WMI_VDEV_PARAM_SGI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006683 *value = sme_get_ht_config(hHal, pAdapter->sessionId,
6684 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ);
6685 break;
6686 }
6687
6688 case WE_GET_RTSCTS:
6689 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006690 hdd_notice("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006691 *value = wma_cli_get_command(pAdapter->sessionId,
6692 WMI_VDEV_PARAM_ENABLE_RTSCTS,
6693 VDEV_CMD);
6694 break;
6695 }
6696
6697 case WE_GET_CHWIDTH:
6698 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006699 hdd_notice("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006700 *value = wma_cli_get_command(pAdapter->sessionId,
6701 WMI_VDEV_PARAM_CHWIDTH,
6702 VDEV_CMD);
6703 break;
6704 }
6705
6706 case WE_GET_ANI_EN_DIS:
6707 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006708 hdd_notice("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006709 *value = wma_cli_get_command(pAdapter->sessionId,
6710 WMI_PDEV_PARAM_ANI_ENABLE,
6711 PDEV_CMD);
6712 break;
6713 }
6714
6715 case WE_GET_ANI_POLL_PERIOD:
6716 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006717 hdd_notice("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006718 *value = wma_cli_get_command(pAdapter->sessionId,
6719 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
6720 PDEV_CMD);
6721 break;
6722 }
6723
6724 case WE_GET_ANI_LISTEN_PERIOD:
6725 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006726 hdd_notice("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006727 *value = wma_cli_get_command(pAdapter->sessionId,
6728 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
6729 PDEV_CMD);
6730 break;
6731 }
6732
6733 case WE_GET_ANI_OFDM_LEVEL:
6734 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006735 hdd_notice("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006736 *value = wma_cli_get_command(pAdapter->sessionId,
6737 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
6738 PDEV_CMD);
6739 break;
6740 }
6741
6742 case WE_GET_ANI_CCK_LEVEL:
6743 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006744 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006745 *value = wma_cli_get_command(pAdapter->sessionId,
6746 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
6747 PDEV_CMD);
6748 break;
6749 }
6750
6751 case WE_GET_DYNAMIC_BW:
6752 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006753 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006754 *value = wma_cli_get_command(pAdapter->sessionId,
6755 WMI_PDEV_PARAM_DYNAMIC_BW,
6756 PDEV_CMD);
6757 break;
6758 }
6759
6760 case WE_GET_11N_RATE:
6761 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006762 hdd_notice("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006763 *value = wma_cli_get_command(pAdapter->sessionId,
6764 WMI_VDEV_PARAM_FIXED_RATE,
6765 VDEV_CMD);
6766 break;
6767 }
6768
6769 case WE_GET_AMPDU:
6770 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006771 hdd_notice("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006772 *value = wma_cli_get_command(pAdapter->sessionId,
6773 GEN_VDEV_PARAM_AMPDU,
6774 GEN_CMD);
6775 break;
6776 }
6777
6778 case WE_GET_AMSDU:
6779 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006780 hdd_notice("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006781 *value = wma_cli_get_command(pAdapter->sessionId,
6782 GEN_VDEV_PARAM_AMSDU,
6783 GEN_CMD);
6784 break;
6785 }
6786
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07006787 case WE_GET_ROAM_SYNCH_DELAY:
6788 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006789 hdd_notice("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07006790 *value = wma_cli_get_command(pAdapter->sessionId,
6791 GEN_VDEV_ROAM_SYNCH_DELAY,
6792 GEN_CMD);
6793 break;
6794 }
6795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006796 case WE_GET_BURST_ENABLE:
6797 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006798 hdd_notice("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006799 *value = wma_cli_get_command(pAdapter->sessionId,
6800 WMI_PDEV_PARAM_BURST_ENABLE,
6801 PDEV_CMD);
6802 break;
6803 }
6804 case WE_GET_BURST_DUR:
6805 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006806 hdd_notice("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006807 *value = wma_cli_get_command(pAdapter->sessionId,
6808 WMI_PDEV_PARAM_BURST_DUR,
6809 PDEV_CMD);
6810 break;
6811 }
6812
6813 case WE_GET_TX_CHAINMASK:
6814 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006815 hdd_notice("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006816 *value = wma_cli_get_command(pAdapter->sessionId,
6817 WMI_PDEV_PARAM_TX_CHAIN_MASK,
6818 PDEV_CMD);
6819 break;
6820 }
6821
6822 case WE_GET_RX_CHAINMASK:
6823 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006824 hdd_notice("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006825 *value = wma_cli_get_command(pAdapter->sessionId,
6826 WMI_PDEV_PARAM_RX_CHAIN_MASK,
6827 PDEV_CMD);
6828 break;
6829 }
6830
6831 case WE_GET_TXPOW_2G:
6832 {
6833 uint32_t txpow2g = 0;
6834 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07006835 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006836 *value = wma_cli_get_command(pAdapter->sessionId,
6837 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
6838 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306839 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006840 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6841 &txpow2g)) {
6842 return -EIO;
6843 }
Jeff Johnson99bac312016-06-28 10:38:18 -07006844 hdd_notice("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006845 break;
6846 }
6847
6848 case WE_GET_TXPOW_5G:
6849 {
6850 uint32_t txpow5g = 0;
6851 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07006852 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006853 *value = wma_cli_get_command(pAdapter->sessionId,
6854 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
6855 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306856 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006857 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6858 &txpow5g)) {
6859 return -EIO;
6860 }
Jeff Johnson99bac312016-06-28 10:38:18 -07006861 hdd_notice("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006862 break;
6863 }
6864
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006865 case WE_GET_PPS_PAID_MATCH:
6866 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006867 hdd_notice("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006868 *value = wma_cli_get_command(pAdapter->sessionId,
6869 WMI_VDEV_PPS_PAID_MATCH,
6870 PPS_CMD);
6871 break;
6872 }
6873
6874 case WE_GET_PPS_GID_MATCH:
6875 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006876 hdd_notice("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006877 *value = wma_cli_get_command(pAdapter->sessionId,
6878 WMI_VDEV_PPS_GID_MATCH,
6879 PPS_CMD);
6880 break;
6881 }
6882
6883 case WE_GET_PPS_EARLY_TIM_CLEAR:
6884 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006885 hdd_notice("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006886 *value = wma_cli_get_command(pAdapter->sessionId,
6887 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6888 PPS_CMD);
6889 break;
6890 }
6891
6892 case WE_GET_PPS_EARLY_DTIM_CLEAR:
6893 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006894 hdd_notice("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006895 *value = wma_cli_get_command(pAdapter->sessionId,
6896 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6897 PPS_CMD);
6898 break;
6899 }
6900
6901 case WE_GET_PPS_EOF_PAD_DELIM:
6902 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006903 hdd_notice("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006904 *value = wma_cli_get_command(pAdapter->sessionId,
6905 WMI_VDEV_PPS_EOF_PAD_DELIM,
6906 PPS_CMD);
6907 break;
6908 }
6909
6910 case WE_GET_PPS_MACADDR_MISMATCH:
6911 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006912 hdd_notice("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006913 *value = wma_cli_get_command(pAdapter->sessionId,
6914 WMI_VDEV_PPS_MACADDR_MISMATCH,
6915 PPS_CMD);
6916 break;
6917 }
6918
6919 case WE_GET_PPS_DELIM_CRC_FAIL:
6920 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006921 hdd_notice("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006922 *value = wma_cli_get_command(pAdapter->sessionId,
6923 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6924 PPS_CMD);
6925 break;
6926 }
6927
6928 case WE_GET_PPS_GID_NSTS_ZERO:
6929 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006930 hdd_notice("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006931 *value = wma_cli_get_command(pAdapter->sessionId,
6932 WMI_VDEV_PPS_GID_NSTS_ZERO,
6933 PPS_CMD);
6934 break;
6935 }
6936
6937 case WE_GET_PPS_RSSI_CHECK:
6938 {
6939
Jeff Johnson99bac312016-06-28 10:38:18 -07006940 hdd_notice("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006941 *value = wma_cli_get_command(pAdapter->sessionId,
6942 WMI_VDEV_PPS_RSSI_CHECK,
6943 PPS_CMD);
6944 break;
6945 }
6946
6947 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
6948 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006949 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006950 *value = wma_cli_get_command(pAdapter->sessionId,
6951 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6952 QPOWER_CMD);
6953 break;
6954 }
6955
6956 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
6957 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006958 hdd_notice("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006959 *value = wma_cli_get_command(pAdapter->sessionId,
6960 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6961 QPOWER_CMD);
6962 break;
6963 }
6964
6965 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6966 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006967 hdd_notice("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006968 *value = wma_cli_get_command(pAdapter->sessionId,
6969 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6970 QPOWER_CMD);
6971 break;
6972 }
6973
6974 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6975 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006976 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006977 *value = wma_cli_get_command(pAdapter->sessionId,
6978 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6979 QPOWER_CMD);
6980 break;
6981 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006982 case WE_CAP_TSF:
6983 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
6984 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006985 case WE_GET_TEMPERATURE:
6986 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006987 hdd_notice("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006988 ret = wlan_hdd_get_temperature(pAdapter, value);
6989 break;
6990 }
6991 default:
6992 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006993 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006994 value[0]);
6995 break;
6996 }
6997 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306998 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006999 return ret;
7000}
7001
7002static int iw_setnone_getint(struct net_device *dev,
7003 struct iw_request_info *info,
7004 union iwreq_data *wrqu, char *extra)
7005{
7006 int ret;
7007
7008 cds_ssr_protect(__func__);
7009 ret = __iw_setnone_getint(dev, info, wrqu, extra);
7010 cds_ssr_unprotect(__func__);
7011
7012 return ret;
7013}
7014
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307015static int hdd_set_fwtest(int argc, int cmd, int value)
7016{
7017 struct set_fwtest_params *fw_test;
7018
7019 /* check for max number of arguments */
7020 if (argc > (WMA_MAX_NUM_ARGS) ||
7021 argc != HDD_FWTEST_PARAMS) {
7022 hdd_err("Too Many args %d", argc);
7023 return -EINVAL;
7024 }
7025 /*
7026 * check if number of arguments are 3 then, check
7027 * then set the default value for sounding interval.
7028 */
7029 if (HDD_FWTEST_PARAMS == argc) {
7030 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
7031 value = HDD_FWTEST_SU_DEFAULT_VALUE;
7032 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
7033 value = HDD_FWTEST_MU_DEFAULT_VALUE;
7034 }
7035 /* check sounding interval value should not exceed to max */
7036 if (value > HDD_FWTEST_MAX_VALUE) {
7037 hdd_err("Invalid arguments value should not exceed max: %d",
7038 value);
7039 return -EINVAL;
7040 }
7041 fw_test = qdf_mem_malloc(sizeof(*fw_test));
7042 if (NULL == fw_test) {
7043 hdd_err("qdf_mem_malloc failed for fw_test");
7044 return -ENOMEM;
7045 }
7046 fw_test->arg = cmd;
7047 fw_test->value = value;
7048 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
7049 qdf_mem_free(fw_test);
7050 hdd_err("Not able to post FW_TEST_CMD message to WMA");
7051 return -EINVAL;
7052 }
7053 return 0;
7054}
7055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007056/**
7057 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
7058 * @dev: device upon which the ioctl was received
7059 * @info: ioctl request information
7060 * @wrqu: ioctl request data
7061 * @extra: ioctl extra data
7062 *
7063 * Return: 0 on success, non-zero on error
7064 */
7065static int __iw_set_three_ints_getnone(struct net_device *dev,
7066 struct iw_request_info *info,
7067 union iwreq_data *wrqu, char *extra)
7068{
7069 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7070 int *value = (int *)extra;
7071 int sub_cmd = value[0];
7072 int ret;
7073 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7074
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007075 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307076
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007077 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007078 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007079 return -EPERM;
7080 }
7081
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007082 ret = wlan_hdd_validate_context(hdd_ctx);
7083 if (0 != ret)
7084 return ret;
7085
7086 switch (sub_cmd) {
7087
7088 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307089 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007090 break;
7091 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307092 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007093 break;
7094
7095 /* value[3] the acs band is not required as start and end channels are
7096 * enough but this cmd is maintained under set three ints for historic
7097 * reasons.
7098 */
7099 case WE_SET_SAP_CHANNELS:
7100 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307101 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007102 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307103 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007104 ret = -EINVAL;
7105 } else {
7106 hdd_ctx->config->force_sap_acs_st_ch = value[1];
7107 hdd_ctx->config->force_sap_acs_end_ch = value[2];
7108 }
7109 break;
7110 case WE_SET_DUAL_MAC_SCAN_CONFIG:
7111 hdd_debug("Ioctl to set dual mac scan config");
7112 if (hdd_ctx->config->dual_mac_feature_disable) {
7113 hdd_err("Dual mac feature is disabled from INI");
7114 return -EPERM;
7115 }
7116 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08007117 cds_set_dual_mac_scan_config(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007118 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307119 case WE_SET_FW_TEST:
7120 {
7121 ret = hdd_set_fwtest(value[1], value[2], value[3]);
7122 if (ret) {
7123 hdd_err("Not able to set fwtest %d", ret);
7124 return ret;
7125 }
7126 }
7127 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007128 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007129 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007130 break;
7131
7132 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307133 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007134 return ret;
7135}
7136
7137int iw_set_three_ints_getnone(struct net_device *dev,
7138 struct iw_request_info *info,
7139 union iwreq_data *wrqu, char *extra)
7140{
7141 int ret;
7142
7143 cds_ssr_protect(__func__);
7144 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7145 cds_ssr_unprotect(__func__);
7146
7147 return ret;
7148}
7149
7150/**
7151 * hdd_connection_state_string() - Get connection state string
7152 * @connection_state: enum to be converted to a string
7153 *
7154 * Return: the string equivalent of @connection_state
7155 */
7156static const char *
7157hdd_connection_state_string(eConnectionState connection_state)
7158{
7159 switch (connection_state) {
7160 CASE_RETURN_STRING(eConnectionState_NotConnected);
7161 CASE_RETURN_STRING(eConnectionState_Connecting);
7162 CASE_RETURN_STRING(eConnectionState_Associated);
7163 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
7164 CASE_RETURN_STRING(eConnectionState_IbssConnected);
7165 CASE_RETURN_STRING(eConnectionState_Disconnecting);
7166 default:
7167 return "UNKNOWN";
7168 }
7169}
7170
7171/**
7172 * iw_get_char_setnone() - Generic "get string" private ioctl handler
7173 * @dev: device upon which the ioctl was received
7174 * @info: ioctl request information
7175 * @wrqu: ioctl request data
7176 * @extra: ioctl extra data
7177 *
7178 * Return: 0 on success, non-zero on error
7179 */
7180static int __iw_get_char_setnone(struct net_device *dev,
7181 struct iw_request_info *info,
7182 union iwreq_data *wrqu, char *extra)
7183{
7184 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7185 int sub_cmd = wrqu->data.flags;
7186 hdd_context_t *hdd_ctx;
7187 int ret;
7188#ifdef WLAN_FEATURE_11W
7189 hdd_wext_state_t *pWextState;
7190#endif
7191
7192#ifdef WLAN_FEATURE_11W
7193 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7194#endif
7195
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007196 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307197
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007198 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7199 ret = wlan_hdd_validate_context(hdd_ctx);
7200 if (0 != ret)
7201 return ret;
7202
7203 switch (sub_cmd) {
7204 case WE_WLAN_VERSION:
7205 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05307206 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007207 break;
7208 }
7209
7210 case WE_GET_STATS:
7211 {
7212 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
7213 extra, WE_MAX_STR_LEN);
7214 break;
7215 }
7216
Govind Singha471e5e2015-10-12 17:11:14 +05307217 case WE_LIST_FW_PROFILE:
7218 hdd_wlan_list_fw_profile(&(wrqu->data.length),
7219 extra, WE_MAX_STR_LEN);
7220 break;
7221
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007222 /* The case prints the current state of the HDD, SME, CSR, PE,
7223 * TL it can be extended for WDI Global State as well. And
7224 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
7225 * and P2P_GO have not been added as of now.
7226 */
7227 case WE_GET_STATES:
7228 {
7229 int buf = 0, len = 0;
7230 int adapter_num = 0;
7231 int count = 0, check = 1;
7232
7233 tHalHandle hHal = NULL;
7234 tpAniSirGlobal pMac = NULL;
7235 hdd_station_ctx_t *pHddStaCtx = NULL;
7236
7237 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7238 hdd_adapter_t *useAdapter = NULL;
7239
7240 /* Print wlan0 or p2p0 states based on the adapter_num
7241 * by using the correct adapter
7242 */
7243 while (adapter_num < 2) {
7244 if (WLAN_ADAPTER == adapter_num) {
7245 useAdapter = pAdapter;
7246 buf =
7247 scnprintf(extra + len,
7248 WE_MAX_STR_LEN - len,
7249 "\n\n wlan0 States:-");
7250 len += buf;
7251 } else if (P2P_ADAPTER == adapter_num) {
7252 buf =
7253 scnprintf(extra + len,
7254 WE_MAX_STR_LEN - len,
7255 "\n\n p2p0 States:-");
7256 len += buf;
7257
7258 if (!pHddCtx) {
7259 buf =
7260 scnprintf(extra + len,
7261 WE_MAX_STR_LEN -
7262 len,
7263 "\n pHddCtx is NULL");
7264 len += buf;
7265 break;
7266 }
7267
7268 /* Printing p2p0 states only in the
7269 * case when the device is configured
7270 * as a p2p_client
7271 */
7272 useAdapter =
7273 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08007274 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007275 if (!useAdapter) {
7276 buf =
7277 scnprintf(extra + len,
7278 WE_MAX_STR_LEN -
7279 len,
7280 "\n Device not configured as P2P_CLIENT.");
7281 len += buf;
7282 break;
7283 }
7284 }
7285
7286 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
7287 if (!hHal) {
7288 buf =
7289 scnprintf(extra + len,
7290 WE_MAX_STR_LEN - len,
7291 "\n pMac is NULL");
7292 len += buf;
7293 break;
7294 }
7295 pMac = PMAC_STRUCT(hHal);
7296 if (!pMac) {
7297 buf =
7298 scnprintf(extra + len,
7299 WE_MAX_STR_LEN - len,
7300 "\n pMac is NULL");
7301 len += buf;
7302 break;
7303 }
7304 pHddStaCtx =
7305 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
7306
7307
7308 buf =
7309 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7310 "\n HDD Conn State - %s "
7311 "\n \n SME State:"
7312 "\n Neighbour Roam State - %s"
7313 "\n CSR State - %s"
7314 "\n CSR Substate - %s",
7315 hdd_connection_state_string
7316 (pHddStaCtx->conn_info.connState),
7317 mac_trace_get_neighbour_roam_state
7318 (sme_get_neighbor_roam_state
7319 (hHal, useAdapter->sessionId)),
7320 mac_trace_getcsr_roam_state
7321 (sme_get_current_roam_state
7322 (hHal, useAdapter->sessionId)),
7323 mac_trace_getcsr_roam_sub_state
7324 (sme_get_current_roam_sub_state
7325 (hHal, useAdapter->sessionId))
7326 );
7327 len += buf;
7328 adapter_num++;
7329 }
7330
Mukul Sharma81661ae2015-10-30 20:26:02 +05307331 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007332 /* Printing Lim State starting with global lim states */
7333 buf =
7334 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7335 "\n \n LIM STATES:-"
7336 "\n Global Sme State - %s "
7337 "\n Global mlm State - %s " "\n",
7338 mac_trace_get_lim_sme_state
7339 (sme_get_lim_sme_state(hHal)),
7340 mac_trace_get_lim_mlm_state
7341 (sme_get_lim_sme_state(hHal))
7342 );
7343 len += buf;
7344
7345 /* Printing the PE Sme and Mlm states for valid lim sessions */
7346 while (check < 3 && count < 255) {
7347 if (sme_is_lim_session_valid(hHal, count)) {
7348 buf =
7349 scnprintf(extra + len,
7350 WE_MAX_STR_LEN -
7351 len,
7352 "\n Lim Valid Session %d:-"
7353 "\n PE Sme State - %s "
7354 "\n PE Mlm State - %s "
7355 "\n", check,
7356 mac_trace_get_lim_sme_state
7357 (sme_get_lim_sme_session_state
7358 (hHal, count)),
7359 mac_trace_get_lim_mlm_state
7360 (sme_get_lim_mlm_session_state
7361 (hHal, count))
7362 );
7363
7364 len += buf;
7365 check++;
7366 }
7367 count++;
7368 }
7369 }
7370
7371 wrqu->data.length = strlen(extra) + 1;
7372 break;
7373 }
7374
7375 case WE_GET_CFG:
7376 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007377 hdd_notice("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007378 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
7379 extra,
7380 QCSAP_IOCTL_MAX_STR_LEN);
7381 wrqu->data.length = strlen(extra) + 1;
7382 break;
7383 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007384 case WE_GET_RSSI:
7385 {
7386 int8_t s7Rssi = 0;
7387 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7388 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7389 wrqu->data.length = strlen(extra) + 1;
7390 break;
7391 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007392
7393 case WE_GET_WMM_STATUS:
7394 {
7395 snprintf(extra, WE_MAX_STR_LEN,
7396 "\nDir: 0=up, 1=down, 3=both\n"
7397 "|------------------------|\n"
7398 "|AC | ACM |Admitted| Dir |\n"
7399 "|------------------------|\n"
7400 "|VO | %d | %3s | %d |\n"
7401 "|VI | %d | %3s | %d |\n"
7402 "|BE | %d | %3s | %d |\n"
7403 "|BK | %d | %3s | %d |\n"
7404 "|------------------------|\n",
7405 pAdapter->hddWmmStatus.
7406 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
7407 pAdapter->hddWmmStatus.
7408 wmmAcStatus[SME_AC_VO].
7409 wmmAcAccessAllowed ? "YES" : "NO",
7410 pAdapter->hddWmmStatus.
7411 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
7412 ts_info.direction,
7413 pAdapter->hddWmmStatus.
7414 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
7415 pAdapter->hddWmmStatus.
7416 wmmAcStatus[SME_AC_VI].
7417 wmmAcAccessAllowed ? "YES" : "NO",
7418 pAdapter->hddWmmStatus.
7419 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
7420 ts_info.direction,
7421 pAdapter->hddWmmStatus.
7422 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
7423 pAdapter->hddWmmStatus.
7424 wmmAcStatus[SME_AC_BE].
7425 wmmAcAccessAllowed ? "YES" : "NO",
7426 pAdapter->hddWmmStatus.
7427 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
7428 ts_info.direction,
7429 pAdapter->hddWmmStatus.
7430 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
7431 pAdapter->hddWmmStatus.
7432 wmmAcStatus[SME_AC_BK].
7433 wmmAcAccessAllowed ? "YES" : "NO",
7434 pAdapter->hddWmmStatus.
7435 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
7436 ts_info.direction);
7437
7438 wrqu->data.length = strlen(extra) + 1;
7439 break;
7440 }
7441 case WE_GET_CHANNEL_LIST:
7442 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307443 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007444 uint8_t i, len;
7445 char *buf;
7446 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
7447 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
7448 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7449
7450 tChannelListInfo channel_list;
7451
7452 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05307453 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007454 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307455 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007456 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007457 return -EINVAL;
7458 }
7459 buf = extra;
7460 /*
7461 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
7462 * Maximum buffer needed = 5 * number of channels.
7463 * Check ifsufficient buffer is available and then
7464 * proceed to fill the buffer.
7465 */
7466 if (WE_MAX_STR_LEN <
7467 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007468 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007469 return -EINVAL;
7470 }
7471 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7472 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307473 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007474 ubuf, &ubuf_len)) {
7475 /* Printing Country code in getChannelList */
7476 for (i = 0; i < (ubuf_len - 1); i++)
7477 len += scnprintf(buf + len,
7478 WE_MAX_STR_LEN - len,
7479 "%c", ubuf[i]);
7480 }
7481 for (i = 0; i < channel_list.num_channels; i++) {
7482 len +=
7483 scnprintf(buf + len, WE_MAX_STR_LEN - len,
7484 " %u", channel_list.channels[i]);
7485 }
7486 wrqu->data.length = strlen(extra) + 1;
7487
7488 break;
7489 }
7490#ifdef FEATURE_WLAN_TDLS
7491 case WE_GET_TDLS_PEERS:
7492 {
7493 wrqu->data.length =
7494 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
7495 WE_MAX_STR_LEN) + 1;
7496 break;
7497 }
7498#endif
7499#ifdef WLAN_FEATURE_11W
7500 case WE_GET_11W_INFO:
7501 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007502 hdd_err("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007503 pWextState->roamProfile.MFPEnabled);
7504
7505 snprintf(extra, WE_MAX_STR_LEN,
7506 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7507 "\n Number of Unprotected Disassocs %d"
7508 "\n Number of Unprotected Deauths %d",
7509 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
7510 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
7511 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
7512 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
7513 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
7514 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
7515 pWextState->roamProfile.MFPEnabled,
7516 pAdapter->hdd_stats.hddPmfStats.
7517 numUnprotDisassocRx,
7518 pAdapter->hdd_stats.hddPmfStats.
7519 numUnprotDeauthRx);
7520
7521 wrqu->data.length = strlen(extra) + 1;
7522 break;
7523 }
7524#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007525 case WE_GET_IBSS_STA_INFO:
7526 {
7527 hdd_station_ctx_t *pHddStaCtx =
7528 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7529 int idx = 0;
7530 int length = 0, buf = 0;
7531
Naveen Rawatc45d1622016-07-05 12:20:09 -07007532 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007533 if (0 != pHddStaCtx->conn_info.staId[idx]) {
7534 buf = snprintf
7535 ((extra + length),
7536 WE_MAX_STR_LEN - length,
7537 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7538 pHddStaCtx->conn_info.staId[idx],
7539 pHddStaCtx->conn_info.
7540 peerMacAddress[idx].bytes[0],
7541 pHddStaCtx->conn_info.
7542 peerMacAddress[idx].bytes[1],
7543 pHddStaCtx->conn_info.
7544 peerMacAddress[idx].bytes[2],
7545 pHddStaCtx->conn_info.
7546 peerMacAddress[idx].bytes[3],
7547 pHddStaCtx->conn_info.
7548 peerMacAddress[idx].bytes[4],
7549 pHddStaCtx->conn_info.
7550 peerMacAddress[idx].bytes[5]
7551 );
7552 length += buf;
7553 }
7554 }
7555 wrqu->data.length = strlen(extra) + 1;
7556 break;
7557 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007558 case WE_GET_PHYMODE:
7559 {
7560 bool ch_bond24 = false, ch_bond5g = false;
7561 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
7562 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7563 eCsrPhyMode phymode;
7564 eCsrBand currBand;
7565 tSmeConfigParams smeconfig;
7566
7567 sme_get_config_param(hal, &smeconfig);
7568 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7569 smeconfig.csrConfig.channelBondingMode24GHz)
7570 ch_bond24 = true;
7571
7572 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7573 smeconfig.csrConfig.channelBondingMode5GHz)
7574 ch_bond5g = true;
7575
7576 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307577 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007578 sme_get_freq_band(hal, &currBand))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007579 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007580 return -EIO;
7581 }
7582
7583 switch (phymode) {
7584 case eCSR_DOT11_MODE_AUTO:
7585 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
7586 break;
7587 case eCSR_DOT11_MODE_11n:
7588 case eCSR_DOT11_MODE_11n_ONLY:
7589 if (currBand == eCSR_BAND_24) {
7590 if (ch_bond24)
7591 snprintf(extra, WE_MAX_STR_LEN,
7592 "11NGHT40");
7593 else
7594 snprintf(extra, WE_MAX_STR_LEN,
7595 "11NGHT20");
7596 } else if (currBand == eCSR_BAND_5G) {
7597 if (ch_bond5g)
7598 snprintf(extra, WE_MAX_STR_LEN,
7599 "11NAHT40");
7600 else
7601 snprintf(extra, WE_MAX_STR_LEN,
7602 "11NAHT20");
7603 } else {
7604 snprintf(extra, WE_MAX_STR_LEN, "11N");
7605 }
7606 break;
7607 case eCSR_DOT11_MODE_abg:
7608 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
7609 break;
7610 case eCSR_DOT11_MODE_11a:
7611 snprintf(extra, WE_MAX_STR_LEN, "11A");
7612 break;
7613 case eCSR_DOT11_MODE_11b:
7614 case eCSR_DOT11_MODE_11b_ONLY:
7615 snprintf(extra, WE_MAX_STR_LEN, "11B");
7616 break;
7617 case eCSR_DOT11_MODE_11g:
7618 case eCSR_DOT11_MODE_11g_ONLY:
7619 snprintf(extra, WE_MAX_STR_LEN, "11G");
7620 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007621 case eCSR_DOT11_MODE_11ac:
7622 case eCSR_DOT11_MODE_11ac_ONLY:
7623 if (hddctx->config->vhtChannelWidth ==
7624 eHT_CHANNEL_WIDTH_20MHZ)
7625 snprintf(extra, WE_MAX_STR_LEN,
7626 "11ACVHT20");
7627 else if (hddctx->config->vhtChannelWidth ==
7628 eHT_CHANNEL_WIDTH_40MHZ)
7629 snprintf(extra, WE_MAX_STR_LEN,
7630 "11ACVHT40");
7631 else if (hddctx->config->vhtChannelWidth ==
7632 eHT_CHANNEL_WIDTH_80MHZ)
7633 snprintf(extra, WE_MAX_STR_LEN,
7634 "11ACVHT80");
7635 else if (hddctx->config->vhtChannelWidth ==
7636 eHT_CHANNEL_WIDTH_160MHZ)
7637 snprintf(extra, WE_MAX_STR_LEN,
7638 "11ACVHT160");
7639 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007640 }
7641
7642 wrqu->data.length = strlen(extra) + 1;
7643 break;
7644 }
7645
7646#ifdef FEATURE_OEM_DATA_SUPPORT
7647 case WE_GET_OEM_DATA_CAP:
7648 {
7649 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7650 }
7651#endif /* FEATURE_OEM_DATA_SUPPORT */
7652 case WE_GET_SNR:
7653 {
7654 int8_t s7snr = 0;
7655 int status = 0;
7656 hdd_context_t *pHddCtx;
7657 hdd_station_ctx_t *pHddStaCtx;
7658 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7659 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05307660 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007661 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05307662
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007663 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7664 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
7665 eConnectionState_Associated !=
7666 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007667 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007668 pHddCtx->config->fEnableSNRMonitoring,
7669 pHddStaCtx->conn_info.connState);
7670 return -ENONET;
7671 }
7672 wlan_hdd_get_snr(pAdapter, &s7snr);
7673 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
7674 wrqu->data.length = strlen(extra) + 1;
7675 break;
7676 }
7677 default:
7678 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007679 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007680 sub_cmd);
7681 break;
7682 }
7683 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307684 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007685 return 0;
7686}
7687
7688static int iw_get_char_setnone(struct net_device *dev,
7689 struct iw_request_info *info,
7690 union iwreq_data *wrqu, char *extra)
7691{
7692 int ret;
7693
7694 cds_ssr_protect(__func__);
7695 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7696 cds_ssr_unprotect(__func__);
7697
7698 return ret;
7699}
7700
7701/**
7702 * iw_setnone_getnone() - Generic "action" private ioctl handler
7703 * @dev: device upon which the ioctl was received
7704 * @info: ioctl request information
7705 * @wrqu: ioctl request data
7706 * @extra: ioctl extra data
7707 *
7708 * Return: 0 on success, non-zero on error
7709 */
7710static int __iw_setnone_getnone(struct net_device *dev,
7711 struct iw_request_info *info,
7712 union iwreq_data *wrqu, char *extra)
7713{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007714 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007715 hdd_context_t *hdd_ctx;
7716 int ret;
7717 int sub_cmd;
7718
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007719 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307720
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007721 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007722 ret = wlan_hdd_validate_context(hdd_ctx);
7723 if (0 != ret)
7724 return ret;
7725
7726#ifdef CONFIG_COMPAT
7727 /* this ioctl is a special case where a sub-ioctl is used and both
7728 * the number of get and set args is 0. in this specific case the
7729 * logic in iwpriv places the sub_cmd in the data.flags portion of
7730 * the iwreq. unfortunately the location of this field will be
7731 * different between 32-bit and 64-bit userspace, and the standard
7732 * compat support in the kernel does not handle this case. so we
7733 * need to explicitly handle it here.
7734 */
7735 if (is_compat_task()) {
7736 struct compat_iw_point *compat_iw_point =
7737 (struct compat_iw_point *)&wrqu->data;
7738 sub_cmd = compat_iw_point->flags;
7739 } else {
7740 sub_cmd = wrqu->data.flags;
7741 }
7742#else
7743 sub_cmd = wrqu->data.flags;
7744#endif
7745
7746 switch (sub_cmd) {
7747 case WE_GET_RECOVERY_STAT:
7748 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007749 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007750 sme_get_recovery_stats(hal);
7751 break;
7752 }
7753
Govind Singha471e5e2015-10-12 17:11:14 +05307754 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007755 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +05307756 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
7757 0, DBG_CMD);
7758 break;
7759
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007760 case WE_IBSS_GET_PEER_INFO_ALL:
7761 {
7762 hdd_wlan_get_ibss_peer_info_all(adapter);
7763 break;
7764 }
7765
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007766 case WE_SET_REASSOC_TRIGGER:
7767 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007768 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7769 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307770 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007771 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307772 uint8_t operating_ch =
7773 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007774 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007775
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007776 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007777 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307778 if (roaming_offload_enabled(hdd_ctx)) {
7779 qdf_mem_copy(bssid,
7780 &adapter->sessionCtx.station.conn_info.bssId,
7781 sizeof(bssid));
7782 hdd_wma_send_fastreassoc_cmd((int)adapter->sessionId,
7783 bssid, operating_ch);
7784 } else {
7785 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
7786 NULL, modProfileFields, &roamId, 1);
7787 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007788 return 0;
7789 }
7790
7791 case WE_DUMP_AGC_START:
7792 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007793 hdd_notice("WE_DUMP_AGC_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007794 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007795 GEN_PARAM_DUMP_AGC_START,
7796 0, GEN_CMD);
7797 break;
7798 }
7799 case WE_DUMP_AGC:
7800 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007801 hdd_notice("WE_DUMP_AGC");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007802 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007803 GEN_PARAM_DUMP_AGC,
7804 0, GEN_CMD);
7805 break;
7806 }
7807
7808 case WE_DUMP_CHANINFO_START:
7809 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007810 hdd_notice("WE_DUMP_CHANINFO_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007811 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007812 GEN_PARAM_DUMP_CHANINFO_START,
7813 0, GEN_CMD);
7814 break;
7815 }
7816 case WE_DUMP_CHANINFO:
7817 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007818 hdd_notice("WE_DUMP_CHANINFO_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007819 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007820 GEN_PARAM_DUMP_CHANINFO,
7821 0, GEN_CMD);
7822 break;
7823 }
7824 case WE_DUMP_WATCHDOG:
7825 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007826 hdd_notice("WE_DUMP_WATCHDOG");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007827 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007828 GEN_PARAM_DUMP_WATCHDOG,
7829 0, GEN_CMD);
7830 break;
7831 }
7832#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
7833 case WE_DUMP_PCIE_LOG:
7834 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007835 hdd_err("WE_DUMP_PCIE_LOG");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007836 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007837 GEN_PARAM_DUMP_PCIE_ACCESS_LOG,
7838 0, GEN_CMD);
7839 break;
7840 }
7841#endif
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007842 case WE_STOP_OBSS_SCAN:
7843 {
7844 /*
7845 * 1.OBSS Scan is mandatory while operating in 2.4GHz
7846 * 2.OBSS scan is stopped by Firmware during the disassociation
7847 * 3.OBSS stop comamnd is added for debugging purpose
7848 */
7849 tHalHandle hal;
7850
7851 hal = WLAN_HDD_GET_HAL_CTX(adapter);
7852 if (hal == NULL) {
7853 hdd_err("hal context is NULL");
7854 return -EINVAL;
7855 }
7856 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
7857 }
7858 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007859 default:
7860 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007861 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007862 break;
7863 }
7864 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307865 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007866 return ret;
7867}
7868
7869static int iw_setnone_getnone(struct net_device *dev,
7870 struct iw_request_info *info,
7871 union iwreq_data *wrqu, char *extra)
7872{
7873 int ret;
7874
7875 cds_ssr_protect(__func__);
7876 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7877 cds_ssr_unprotect(__func__);
7878
7879 return ret;
7880}
7881
7882/**
7883 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
7884 * @dev: device upon which the ioctl was received
7885 * @info: ioctl request information
7886 * @wrqu: ioctl request data
7887 * @extra: ioctl extra data
7888 *
7889 * This is an SSR-protected generic handler for private ioctls which
7890 * take multiple arguments. Note that this implementation is also
7891 * somewhat unique in that it is shared by both STA-mode and SAP-mode
7892 * interfaces.
7893 *
7894 * Return: 0 on success, non-zero on error
7895 */
7896static int __iw_set_var_ints_getnone(struct net_device *dev,
7897 struct iw_request_info *info,
7898 union iwreq_data *wrqu, char *extra)
7899{
7900 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7901 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7902 int sub_cmd;
7903 int *apps_args = (int *) extra;
7904 hdd_context_t *hdd_ctx;
7905 int ret, num_args;
7906
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007907 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307908
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007909 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7910 ret = wlan_hdd_validate_context(hdd_ctx);
7911 if (0 != ret)
7912 return ret;
7913
7914 if (extra == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007915 hdd_err("NULL extra buffer pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007916 return -EINVAL;
7917 }
7918
7919 sub_cmd = wrqu->data.flags;
7920 num_args = wrqu->data.length;
7921
Jeff Johnson99bac312016-06-28 10:38:18 -07007922 hdd_notice("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007923
7924 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007925 case WE_IBSS_GET_PEER_INFO:
7926 {
7927 pr_info("Station ID = %d\n", apps_args[0]);
7928 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7929 }
7930 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007931
7932 case WE_P2P_NOA_CMD:
7933 {
7934 p2p_app_setP2pPs_t p2pNoA;
7935
Krunal Sonif07bb382016-03-10 13:02:11 -08007936 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -08007937 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
7938 hdd_device_mode_to_string(
7939 pAdapter->device_mode),
7940 pAdapter->device_mode);
7941 return -EINVAL;
7942 }
7943
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007944 p2pNoA.opp_ps = apps_args[0];
7945 p2pNoA.ctWindow = apps_args[1];
7946 p2pNoA.duration = apps_args[2];
7947 p2pNoA.interval = apps_args[3];
7948 p2pNoA.count = apps_args[4];
7949 p2pNoA.single_noa_duration = apps_args[5];
7950 p2pNoA.psSelection = apps_args[6];
7951
Jeff Johnson99bac312016-06-28 10:38:18 -07007952 hdd_notice("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
7953 apps_args[0], apps_args[1], apps_args[2],
7954 apps_args[3], apps_args[4],
7955 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007956
7957 hdd_set_p2p_ps(dev, &p2pNoA);
7958
7959 }
7960 break;
7961
7962 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7963 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007964 hdd_notice("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7965 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307966 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007967 }
7968 break;
7969
7970 case WE_MTRACE_DUMP_CMD:
7971 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007972 hdd_notice("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
7973 apps_args[0], apps_args[1],
7974 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307975 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007976 apps_args[1], apps_args[2],
7977 apps_args[3]);
7978
7979 }
7980 break;
7981
7982 case WE_POLICY_MANAGER_CLIST_CMD:
7983 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007984 hdd_err("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007985 cds_incr_connection_count_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007986 apps_args[1], apps_args[2], apps_args[3],
7987 apps_args[4], apps_args[5], apps_args[6],
7988 apps_args[7]);
7989 }
7990 break;
7991
7992 case WE_POLICY_MANAGER_DLIST_CMD:
7993 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007994 hdd_err("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007995 cds_decr_connection_count_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007996 apps_args[1]);
7997 }
7998 break;
7999
8000 case WE_POLICY_MANAGER_ULIST_CMD:
8001 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008002 hdd_err("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008003 cds_update_connection_info_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008004 apps_args[1], apps_args[2], apps_args[3],
8005 apps_args[4], apps_args[5], apps_args[6],
8006 apps_args[7]);
8007 }
8008 break;
8009
8010 case WE_POLICY_MANAGER_DBS_CMD:
8011 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008012 hdd_err("<iwpriv wlan0 pm_dbs> is called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008013 if (apps_args[0] == 0)
8014 wma_set_dbs_capability_ut(0);
8015 else
8016 wma_set_dbs_capability_ut(1);
8017
8018 if (apps_args[1] >= CDS_THROUGHPUT &&
8019 apps_args[1] <= CDS_LATENCY) {
8020 pr_info("setting system pref to [%d]\n", apps_args[1]);
8021 hdd_ctx->config->conc_system_pref = apps_args[1];
8022 }
8023 }
8024 break;
8025
8026 case WE_POLICY_MANAGER_PCL_CMD:
8027 {
Manishekar Chandrasekaran1db3abe2016-06-24 03:27:07 +05308028 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
8029 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008030 uint32_t pcl_len = 0, i = 0;
8031
Jeff Johnson99bac312016-06-28 10:38:18 -07008032 hdd_err("<iwpriv wlan0 pm_pcl> is called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008033
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008034 cds_get_pcl(apps_args[0],
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308035 pcl, &pcl_len,
8036 weight_list, QDF_ARRAY_SIZE(weight_list));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008037 pr_info("PCL list for role[%d] is {", apps_args[0]);
8038 for (i = 0 ; i < pcl_len; i++)
8039 pr_info(" %d, ", pcl[i]);
8040 pr_info("}--------->\n");
8041 }
8042 break;
8043
8044 case WE_POLICY_MANAGER_CINFO_CMD:
8045 {
8046 struct cds_conc_connection_info *conn_info;
8047 uint32_t i = 0, len = 0;
8048
Jeff Johnson99bac312016-06-28 10:38:18 -07008049 hdd_err("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008050 conn_info = cds_get_conn_info(&len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008051 pr_info("+-----------------------------+\n");
8052 for (i = 0; i < len; i++) {
8053 pr_info("|table_index[%d]\t\t|\n", i);
8054 pr_info("|\t|vdev_id - %d\t\t|\n", conn_info->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008055 pr_info("|\t|chan - %d\t\t|\n", conn_info->chan);
Tushnim Bhattacharyya7624a182016-03-30 13:30:46 -07008056 pr_info("|\t|bw - %d\t\t|\n", conn_info->bw);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008057 pr_info("|\t|mode - %d\t\t|\n", conn_info->mode);
8058 pr_info("|\t|mac - %d\t\t|\n", conn_info->mac);
8059 pr_info("|\t|in_use - %d\t\t|\n", conn_info->in_use);
8060 pr_info("+-----------------------------+\n");
8061 conn_info++;
8062 }
8063 }
8064 break;
8065
8066 case WE_POLICY_SET_HW_MODE_CMD:
8067 {
8068 if (apps_args[0] == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008069 hdd_err("set hw mode for single mac");
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308070 cds_pdev_set_hw_mode(
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308071 pAdapter->sessionId,
8072 HW_MODE_SS_2x2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008073 HW_MODE_80_MHZ,
8074 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
8075 HW_MODE_DBS_NONE,
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308076 HW_MODE_AGILE_DFS_NONE,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05308077 HW_MODE_SBS_NONE,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308078 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008079 } else if (apps_args[0] == 1) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008080 hdd_err("set hw mode for dual mac");
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308081 cds_pdev_set_hw_mode(
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308082 pAdapter->sessionId,
8083 HW_MODE_SS_1x1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008084 HW_MODE_80_MHZ,
8085 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
8086 HW_MODE_DBS,
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308087 HW_MODE_AGILE_DFS_NONE,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05308088 HW_MODE_SBS_NONE,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308089 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008090 }
8091 }
8092 break;
8093
8094 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8095 {
8096 enum cds_conc_next_action action;
Jeff Johnson99bac312016-06-28 10:38:18 -07008097 hdd_err("<iwpriv wlan0 pm_query_action> is called");
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308098 action = cds_current_connections_update(pAdapter->sessionId,
8099 apps_args[0],
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308100 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008101 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
8102 }
8103 break;
8104 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8105 {
8106 bool allow;
Jeff Johnson99bac312016-06-28 10:38:18 -07008107 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008108 allow = cds_allow_concurrency(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008109 apps_args[0], apps_args[1], apps_args[2]);
8110 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
8111 }
8112 break;
8113
8114 case WE_POLICY_MANAGER_SCENARIO_CMD:
8115 {
8116 clean_report(hdd_ctx);
8117 if (apps_args[0] == 1) {
8118 wlan_hdd_one_connection_scenario(hdd_ctx);
8119 } else if (apps_args[0] == 2) {
8120 wlan_hdd_two_connections_scenario(hdd_ctx,
8121 6, CDS_TWO_TWO);
8122 wlan_hdd_two_connections_scenario(hdd_ctx,
8123 36, CDS_TWO_TWO);
8124 wlan_hdd_two_connections_scenario(hdd_ctx,
8125 6, CDS_ONE_ONE);
8126 wlan_hdd_two_connections_scenario(hdd_ctx,
8127 36, CDS_ONE_ONE);
8128 } else if (apps_args[0] == 3) {
8129 /* MCC on same band with 2x2 same mac*/
8130 wlan_hdd_three_connections_scenario(hdd_ctx,
8131 6, 11, CDS_TWO_TWO, 0);
8132 /* MCC on diff band with 2x2 same mac*/
8133 wlan_hdd_three_connections_scenario(hdd_ctx,
8134 6, 36, CDS_TWO_TWO, 0);
8135 /* MCC on diff band with 1x1 diff mac */
8136 wlan_hdd_three_connections_scenario(hdd_ctx,
8137 36, 6, CDS_ONE_ONE, 0);
8138 /* MCC on diff band with 1x1 same mac */
8139 wlan_hdd_three_connections_scenario(hdd_ctx,
8140 36, 6, CDS_ONE_ONE, 1);
8141 /* SCC on same band with 2x2 same mac */
8142 wlan_hdd_three_connections_scenario(hdd_ctx,
8143 36, 36, CDS_TWO_TWO, 0);
8144 /* SCC on same band with 1x1 same mac */
8145 wlan_hdd_three_connections_scenario(hdd_ctx,
8146 36, 36, CDS_ONE_ONE, 1);
8147 /* MCC on same band with 2x2 same mac */
8148 wlan_hdd_three_connections_scenario(hdd_ctx,
8149 36, 149, CDS_TWO_TWO, 0);
8150 /* MCC on same band with 1x1 same mac */
8151 wlan_hdd_three_connections_scenario(hdd_ctx,
8152 36, 149, CDS_ONE_ONE, 1);
8153 }
8154 print_report(hdd_ctx);
8155 }
8156 break;
8157
8158#ifdef FEATURE_WLAN_TDLS
8159 case WE_TDLS_CONFIG_PARAMS:
8160 {
8161 tdls_config_params_t tdlsParams;
8162
8163 tdlsParams.tdls = apps_args[0];
8164 tdlsParams.tx_period_t = apps_args[1];
8165 tdlsParams.tx_packet_n = apps_args[2];
8166 /* ignore args[3] as discovery_period is not used anymore */
8167 tdlsParams.discovery_tries_n = apps_args[4];
8168 /* ignore args[5] as idle_timeout is not used anymore */
8169 tdlsParams.idle_packet_n = apps_args[6];
8170 /* ignore args[7] as rssi_hysteresis is not used anymore */
8171 tdlsParams.rssi_trigger_threshold = apps_args[8];
8172 tdlsParams.rssi_teardown_threshold = apps_args[9];
8173 tdlsParams.rssi_delta = apps_args[10];
8174
8175 wlan_hdd_tdls_set_params(dev, &tdlsParams);
8176 }
8177 break;
8178#endif
8179 case WE_UNIT_TEST_CMD:
8180 {
8181 t_wma_unit_test_cmd *unitTestArgs;
8182 cds_msg_t msg = { 0 };
8183 int i, j;
8184 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
8185 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008186 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008187 apps_args[0]);
8188 return -EINVAL;
8189 }
Anurag Chouhan77564182016-09-03 16:38:01 +05308190 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
8191 (apps_args[1] < 0)) {
8192 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008193 apps_args[1]);
8194 return -EINVAL;
8195 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308196 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008197 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008198 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008199 return -ENOMEM;
8200 }
8201 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
8202 unitTestArgs->module_id = apps_args[0];
8203 unitTestArgs->num_args = apps_args[1];
8204 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
8205 unitTestArgs->args[i] = apps_args[j];
8206 }
8207 msg.type = SIR_HAL_UNIT_TEST_CMD;
8208 msg.reserved = 0;
8209 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308210 if (QDF_STATUS_SUCCESS !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05308211 cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308212 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -07008213 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008214 return -EINVAL;
8215 }
8216 }
8217 break;
8218#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8219 case WE_LED_FLASHING_PARAM:
8220 {
8221 int i;
8222 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008223 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008224 return -EINVAL;
8225 }
8226 for (i = 0; i < num_args; i++) {
8227 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008228 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008229 return -EINVAL;
8230 }
8231 }
8232 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8233 0, apps_args[0], apps_args[1]);
8234 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8235 1, apps_args[2], apps_args[3]);
8236 }
8237 break;
8238#endif
Manjeet Singhf82ed072016-07-08 11:40:00 +05308239 case WE_MAC_PWR_DEBUG_CMD:
8240 {
8241 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
8242 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8243 int i, j;
8244
8245 if (num_args < 3) {
8246 hdd_err("number of arguments can't be null %d",
8247 num_args);
8248 return -EINVAL;
8249 }
8250 if (num_args - 3 != apps_args[2]) {
8251 hdd_err("arg list of size %d doesn't match num_args %d",
8252 num_args-3, apps_args[2]);
8253 return -EINVAL;
8254 }
8255 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
8256 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
8257 hdd_err("Invalid MODULE ID %d", apps_args[1]);
8258 return -EINVAL;
8259 }
8260 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
8261 hdd_err("Too Many args %d", apps_args[2]);
8262 return -EINVAL;
8263 }
8264 mac_pwr_dbg_args.pdev_id = apps_args[0];
8265 mac_pwr_dbg_args.module_id = apps_args[1];
8266 mac_pwr_dbg_args.num_args = apps_args[2];
8267
8268 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
8269 mac_pwr_dbg_args.args[i] = apps_args[j];
8270
8271 if (QDF_STATUS_SUCCESS !=
8272 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
8273 &mac_pwr_dbg_args)) {
8274 return -EINVAL;
8275 }
8276 }
8277 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008278 default:
8279 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008280 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008281 }
8282 break;
8283 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308284 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008285 return 0;
8286}
8287
8288/**
8289 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
8290 * @dev: pointer to net_device structure
8291 * @info: pointer to iw_request_info structure
8292 * @wrqu: pointer to iwreq_data
8293 * @extra; extra
8294 *
8295 * Return: 0 on success, error number otherwise
8296 *
8297 */
8298static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8299 struct iw_request_info *info,
8300 union iwreq_data *wrqu, char *extra)
8301{
8302 union iwreq_data u_priv_wrqu;
8303 int apps_args[MAX_VAR_ARGS] = {0};
8304 int ret, num_args;
8305
Mukul Sharma64a70e82015-11-02 20:05:09 +05308306 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008307 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +05308308 return -EPERM;
8309 }
8310
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008311 /* Helper function to get iwreq_data with compat handling. */
8312 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8313 return -EINVAL;
8314
8315 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008316 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008317 return -EINVAL;
8318 }
8319
8320 num_args = u_priv_wrqu.data.length;
8321 if (num_args > MAX_VAR_ARGS)
8322 num_args = MAX_VAR_ARGS;
8323
8324 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8325 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008326 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008327 return -EFAULT;
8328 }
8329
8330 cds_ssr_protect(__func__);
8331 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8332 (char *)&apps_args);
8333 cds_ssr_unprotect(__func__);
8334 return ret;
8335}
8336
8337/**
8338 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8339 * @dev: device upon which the ioctl was received
8340 * @info: ioctl request information
8341 * @wrqu: ioctl request data
8342 * @extra: ioctl extra data
8343 *
8344 * This is a generic handler for private ioctls which take multiple
8345 * arguments. Note that this implementation is also somewhat unique
8346 * in that it is shared by both STA-mode and SAP-mode interfaces.
8347 *
8348 * Return: 0 on success, non-zero on error
8349 */
8350int iw_set_var_ints_getnone(struct net_device *dev,
8351 struct iw_request_info *info,
8352 union iwreq_data *wrqu, char *extra)
8353{
8354 int ret;
8355
8356 cds_ssr_protect(__func__);
8357 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8358 cds_ssr_unprotect(__func__);
8359 return ret;
8360}
8361
8362/**
8363 * iw_add_tspec - Add TSpec private ioctl handler
8364 * @dev: device upon which the ioctl was received
8365 * @info: ioctl request information
8366 * @wrqu: ioctl request data
8367 * @extra: ioctl extra data
8368 *
8369 * Return: 0 on success, non-zero on error
8370 */
8371static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
8372 union iwreq_data *wrqu, char *extra)
8373{
8374 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8375 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8376 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8377 int params[HDD_WLAN_WMM_PARAM_COUNT];
8378 sme_QosWmmTspecInfo tSpec;
8379 uint32_t handle;
8380 struct iw_point s_priv_data;
8381 hdd_context_t *hdd_ctx;
8382 int ret;
8383
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008384 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308385
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008386 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8387 ret = wlan_hdd_validate_context(hdd_ctx);
8388 if (0 != ret)
8389 return ret;
8390
8391 /* make sure the application is sufficiently priviledged */
8392 /* note that the kernel will do this for "set" ioctls, but since */
8393 /* this ioctl wants to return status to user space it must be */
8394 /* defined as a "get" ioctl */
8395 if (!capable(CAP_NET_ADMIN)) {
8396 return -EPERM;
8397 }
8398
8399 /* we must be associated in order to add a tspec */
8400 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
8401 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8402 return 0;
8403 }
8404 /* since we are defined to be a "get" ioctl, and since the number */
8405 /* of params exceeds the number of params that wireless extensions */
8406 /* will pass down in the iwreq_data, we must copy the "set" params. */
8407 /* We must handle the compat for iwreq_data in 32U/64K environment. */
8408
8409 /* helper function to get iwreq_data with compat handling. */
8410 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8411 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8412 return 0;
8413 }
8414 /* make sure all params are correctly passed to function */
8415 if ((NULL == s_priv_data.pointer) ||
8416 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
8417 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8418 return 0;
8419 }
8420 /* from user space ourselves */
8421 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
8422 /* hmmm, can't get them */
8423 return -EIO;
8424 }
8425 /* clear the tspec */
8426 memset(&tSpec, 0, sizeof(tSpec));
8427
8428 /* validate the handle */
8429 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8430 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8431 /* that one is reserved */
8432 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8433 return 0;
8434 }
8435 /* validate the TID */
8436 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
8437 /* out of range */
8438 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8439 return 0;
8440 }
8441 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8442
8443 /* validate the direction */
8444 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
8445 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8446 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8447 break;
8448
8449 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8450 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8451 break;
8452
8453 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8454 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8455 break;
8456
8457 default:
8458 /* unknown */
8459 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8460 return 0;
8461 }
8462
8463 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8464
8465 /* validate the user priority */
8466 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
8467 /* out of range */
8468 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8469 return 0;
8470 }
8471 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
8472 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008473 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008474 return 0;
8475 }
8476
Jeff Johnson99bac312016-06-28 10:38:18 -07008477 hdd_info("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008478 tSpec.ts_info.psb, tSpec.ts_info.up);
8479
8480 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8481 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8482 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8483 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8484 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8485 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8486 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8487 tSpec.surplus_bw_allowance =
8488 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8489 tSpec.min_service_interval =
8490 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8491 tSpec.max_service_interval =
8492 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8493 tSpec.suspension_interval =
8494 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8495 tSpec.inactivity_interval =
8496 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8497
8498 tSpec.ts_info.burst_size_defn =
8499 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8500
8501 /* validate the ts info ack policy */
8502 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
8503 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8504 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8505 break;
8506
8507 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8508 tSpec.ts_info.ack_policy =
8509 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8510 break;
8511
8512 default:
8513 /* unknown */
8514 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8515 return 0;
8516 }
8517
8518 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308519 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008520 return 0;
8521}
8522
8523static int iw_add_tspec(struct net_device *dev,
8524 struct iw_request_info *info,
8525 union iwreq_data *wrqu, char *extra)
8526{
8527 int ret;
8528
8529 cds_ssr_protect(__func__);
8530 ret = __iw_add_tspec(dev, info, wrqu, extra);
8531 cds_ssr_unprotect(__func__);
8532
8533 return ret;
8534}
8535
8536/**
8537 * iw_del_tspec - Delete TSpec private ioctl handler
8538 * @dev: device upon which the ioctl was received
8539 * @info: ioctl request information
8540 * @wrqu: ioctl request data
8541 * @extra: ioctl extra data
8542 *
8543 * Return: 0 on success, non-zero on error
8544 */
8545static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
8546 union iwreq_data *wrqu, char *extra)
8547{
8548 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8549 hdd_context_t *hdd_ctx;
8550 int *params = (int *)extra;
8551 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8552 uint32_t handle;
8553 int ret;
8554
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008555 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308556
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008557 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8558 ret = wlan_hdd_validate_context(hdd_ctx);
8559 if (0 != ret)
8560 return ret;
8561
8562 /* make sure the application is sufficiently priviledged */
8563 /* note that the kernel will do this for "set" ioctls, but since */
8564 /* this ioctl wants to return status to user space it must be */
8565 /* defined as a "get" ioctl */
8566 if (!capable(CAP_NET_ADMIN)) {
8567 return -EPERM;
8568 }
8569
8570 /* although we are defined to be a "get" ioctl, the params we require */
8571 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
8572 /* is no need to copy the params from user space */
8573
8574 /* validate the handle */
8575 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8576 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8577 /* that one is reserved */
8578 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8579 return 0;
8580 }
8581
8582 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308583 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008584 return 0;
8585}
8586
8587static int iw_del_tspec(struct net_device *dev,
8588 struct iw_request_info *info,
8589 union iwreq_data *wrqu, char *extra)
8590{
8591 int ret;
8592
8593 cds_ssr_protect(__func__);
8594 ret = __iw_del_tspec(dev, info, wrqu, extra);
8595 cds_ssr_unprotect(__func__);
8596
8597 return ret;
8598}
8599
8600/**
8601 * iw_get_tspec - Get TSpec private ioctl handler
8602 * @dev: device upon which the ioctl was received
8603 * @info: ioctl request information
8604 * @wrqu: ioctl request data
8605 * @extra: ioctl extra data
8606 *
8607 * Return: 0 on success, non-zero on error
8608 */
8609static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
8610 union iwreq_data *wrqu, char *extra)
8611{
8612 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8613 hdd_context_t *hdd_ctx;
8614 int *params = (int *)extra;
8615 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8616 uint32_t handle;
8617 int ret;
8618
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008619 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308620
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008621 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8622 ret = wlan_hdd_validate_context(hdd_ctx);
8623 if (0 != ret)
8624 return ret;
8625
8626 /* although we are defined to be a "get" ioctl, the params we require */
8627 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
8628 /* is no need to copy the params from user space */
8629
8630 /* validate the handle */
8631 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8632 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8633 /* that one is reserved */
8634 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8635 return 0;
8636 }
8637
8638 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308639 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008640 return 0;
8641}
8642
8643static int iw_get_tspec(struct net_device *dev,
8644 struct iw_request_info *info,
8645 union iwreq_data *wrqu, char *extra)
8646{
8647 int ret;
8648
8649 cds_ssr_protect(__func__);
8650 ret = __iw_get_tspec(dev, info, wrqu, extra);
8651 cds_ssr_unprotect(__func__);
8652
8653 return ret;
8654}
8655
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008656/**
8657 * iw_set_fties - Set FT IEs private ioctl handler
8658 * @dev: device upon which the ioctl was received
8659 * @info: ioctl request information
8660 * @wrqu: ioctl request data
8661 * @extra: ioctl extra data
8662 *
8663 * Each time the supplicant has the auth_request or reassoc request
8664 * IEs ready they are pushed to the driver. The driver will in turn
8665 * use it to send out the auth req and reassoc req for 11r FT Assoc.
8666 *
8667 * Return: 0 on success, non-zero on error
8668 */
8669static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
8670 union iwreq_data *wrqu, char *extra)
8671{
8672 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8673 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8674 hdd_context_t *hdd_ctx;
8675 int ret;
8676
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008677 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308678
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008679 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8680 ret = wlan_hdd_validate_context(hdd_ctx);
8681 if (0 != ret)
8682 return ret;
8683
8684 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008685 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008686 return -EINVAL;
8687 }
8688 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008689 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008690 return -EINVAL;
8691 }
8692 /* Added for debug on reception of Re-assoc Req. */
8693 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008694 hdd_err("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008695 wrqu->data.length);
Jeff Johnson99bac312016-06-28 10:38:18 -07008696 hdd_err("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008697 }
Jeff Johnson99bac312016-06-28 10:38:18 -07008698 hdd_notice("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008699
8700 /* Pass the received FT IEs to SME */
8701 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
8702 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308703 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008704 return 0;
8705}
8706
8707static int iw_set_fties(struct net_device *dev,
8708 struct iw_request_info *info,
8709 union iwreq_data *wrqu, char *extra)
8710{
8711 int ret;
8712
8713 cds_ssr_protect(__func__);
8714 ret = __iw_set_fties(dev, info, wrqu, extra);
8715 cds_ssr_unprotect(__func__);
8716
8717 return ret;
8718}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008719
8720/**
8721 * iw_set_host_offload - Set host offload ioctl handler
8722 * @dev: device upon which the ioctl was received
8723 * @info: ioctl request information
8724 * @wrqu: ioctl request data
8725 * @extra: ioctl extra data
8726 *
8727 * Return: 0 on success, non-zero on error
8728 */
8729static int __iw_set_host_offload(struct net_device *dev,
8730 struct iw_request_info *info,
8731 union iwreq_data *wrqu, char *extra)
8732{
8733 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8734 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
8735 tSirHostOffloadReq offloadRequest;
8736 hdd_context_t *hdd_ctx;
8737 int ret;
8738
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008739 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308740
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008741 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8742 ret = wlan_hdd_validate_context(hdd_ctx);
8743 if (0 != ret)
8744 return ret;
8745
8746 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008747 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008748 return -EINVAL;
8749 }
8750
8751 /* Debug display of request components. */
8752 switch (pRequest->offloadType) {
8753 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07008754 hdd_warn("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008755 switch (pRequest->enableOrDisable) {
8756 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008757 hdd_warn(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008758 break;
8759 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008760 hdd_warn(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008761 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008762 hdd_warn(" ARP offload enable");
8763 hdd_warn(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008764 pRequest->params.hostIpv4Addr[0],
8765 pRequest->params.hostIpv4Addr[1],
8766 pRequest->params.hostIpv4Addr[2],
8767 pRequest->params.hostIpv4Addr[3]);
8768 }
8769 break;
8770
8771 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07008772 hdd_info("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008773 switch (pRequest->enableOrDisable) {
8774 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008775 hdd_info(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008776 break;
8777 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008778 hdd_info(" enable");
8779 hdd_info(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008780 *(uint16_t *) (pRequest->params.hostIpv6Addr),
8781 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8782 2),
8783 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8784 4),
8785 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8786 6),
8787 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8788 8),
8789 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8790 10),
8791 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8792 12),
8793 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8794 14));
8795 }
8796 }
8797
8798 /* Execute offload request. The reason that we can copy the
8799 * request information from the ioctl structure to the SME
8800 * structure is that they are laid out exactly the same.
8801 * Otherwise, each piece of information would have to be
8802 * copied individually.
8803 */
8804 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308805 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008806 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8807 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008808 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008809 return -EINVAL;
8810 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308811 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008812 return 0;
8813}
8814
8815static int iw_set_host_offload(struct net_device *dev,
8816 struct iw_request_info *info,
8817 union iwreq_data *wrqu, char *extra)
8818{
8819 int ret;
8820
8821 cds_ssr_protect(__func__);
8822 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8823 cds_ssr_unprotect(__func__);
8824
8825 return ret;
8826}
8827
8828/**
8829 * iw_set_keepalive_params - Set keepalive params ioctl handler
8830 * @dev: device upon which the ioctl was received
8831 * @info: ioctl request information
8832 * @wrqu: ioctl request data
8833 * @extra: ioctl extra data
8834 *
8835 * Return: 0 on success, non-zero on error
8836 */
8837static int __iw_set_keepalive_params(struct net_device *dev,
8838 struct iw_request_info *info,
8839 union iwreq_data *wrqu, char *extra)
8840{
8841 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008842 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008843 hdd_context_t *hdd_ctx;
8844 int ret;
8845
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008846 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008848 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8849 ret = wlan_hdd_validate_context(hdd_ctx);
8850 if (0 != ret)
8851 return ret;
8852
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008853 if (wrqu->data.length != sizeof(*request)) {
8854 hdd_err("Invalid length %d", wrqu->data.length);
8855 return -EINVAL;
8856 }
8857
8858 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
8859 hdd_err("Value of timePeriod %d exceed Max limit %d",
8860 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008861 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
8862 return -EINVAL;
8863 }
8864
8865 /* Debug display of request components. */
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008866 hdd_info("Set Keep Alive Request : TimePeriod %d size %zu",
8867 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008868
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008869 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008870 case WLAN_KEEP_ALIVE_NULL_PKT:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008871 hdd_info("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008872 break;
8873
8874 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008875 hdd_info("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008876
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008877 hdd_info("Host IP address: %d.%d.%d.%d",
8878 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
8879 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008880
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008881 hdd_info("Dest IP address: %d.%d.%d.%d",
8882 request->destIpv4Addr[0], request->destIpv4Addr[1],
8883 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008884
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08008885 hdd_info("Dest MAC address: "MAC_ADDRESS_STR,
8886 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008887 break;
8888 }
8889
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008890 hdd_info("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008891
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308892 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008893 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008894 pAdapter->sessionId, request)) {
8895 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008896 return -EINVAL;
8897 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308898 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008899 return 0;
8900}
8901
8902static int iw_set_keepalive_params(struct net_device *dev,
8903 struct iw_request_info *info,
8904 union iwreq_data *wrqu,
8905 char *extra)
8906{
8907 int ret;
8908
8909 cds_ssr_protect(__func__);
8910 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8911 cds_ssr_unprotect(__func__);
8912
8913 return ret;
8914}
8915
8916#ifdef WLAN_FEATURE_PACKET_FILTERING
8917/**
8918 * wlan_hdd_set_filter() - Set packet filter
8919 * @hdd_ctx: Global HDD context
8920 * @request: Packet filter request struct
8921 * @sessionId: Target session for the request
8922 *
8923 * Return: 0 on success, non-zero on error
8924 */
8925static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
8926 struct pkt_filter_cfg *request,
8927 uint8_t sessionId)
8928{
8929 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8930 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8931 int i = 0;
8932
8933 if (hdd_ctx->config->disablePacketFilter) {
8934 hdd_err("packet filtering disabled in ini returning");
8935 return 0;
8936 }
8937
8938 /* Debug display of request components. */
8939 hdd_info("Packet Filter Request : FA %d params %d",
8940 request->filter_action, request->num_params);
8941
8942 switch (request->filter_action) {
8943 case HDD_RCV_FILTER_SET:
8944 hdd_info("Set Packet Filter Request for Id: %d",
8945 request->filter_id);
8946
8947 packetFilterSetReq.filterId = request->filter_id;
8948 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
8949 hdd_err("Number of Params exceed Max limit %d",
8950 request->num_params);
8951 return -EINVAL;
8952 }
8953 packetFilterSetReq.numFieldParams = request->num_params;
8954 packetFilterSetReq.coalesceTime = 0;
8955 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8956 for (i = 0; i < request->num_params; i++) {
8957 packetFilterSetReq.paramsData[i].protocolLayer =
8958 request->params_data[i].protocol_layer;
8959 packetFilterSetReq.paramsData[i].cmpFlag =
8960 request->params_data[i].compare_flag;
8961 packetFilterSetReq.paramsData[i].dataOffset =
8962 request->params_data[i].data_offset;
8963 packetFilterSetReq.paramsData[i].dataLength =
8964 request->params_data[i].data_length;
8965 packetFilterSetReq.paramsData[i].reserved = 0;
8966
8967 if (request->params_data[i].data_length >
8968 SIR_MAX_FILTER_TEST_DATA_LEN) {
8969 hdd_err("Error invalid data length %d",
8970 request->params_data[i].data_length);
8971 return -EINVAL;
8972 }
8973
8974 hdd_info("Proto %d Comp Flag %d Filter Type %d",
8975 request->params_data[i].protocol_layer,
8976 request->params_data[i].compare_flag,
8977 packetFilterSetReq.filterType);
8978
8979 hdd_info("Data Offset %d Data Len %d",
8980 request->params_data[i].data_offset,
8981 request->params_data[i].data_length);
8982
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07008983 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
8984 < (request->params_data[i].data_length)) {
8985 hdd_err("Error invalid data length %d",
8986 request->params_data[i].data_length);
8987 return -EINVAL;
8988 }
8989
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008990 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8991 request->params_data[i].compare_data,
8992 request->params_data[i].data_length);
8993 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8994 request->params_data[i].data_mask,
8995 request->params_data[i].data_length);
8996
8997 hdd_info("CData %d CData %d CData %d CData %d CData %d CData %d",
8998 request->params_data[i].compare_data[0],
8999 request->params_data[i].compare_data[1],
9000 request->params_data[i].compare_data[2],
9001 request->params_data[i].compare_data[3],
9002 request->params_data[i].compare_data[4],
9003 request->params_data[i].compare_data[5]);
9004
9005 hdd_info("MData %d MData %d MData %d MData %d MData %d MData %d",
9006 request->params_data[i].data_mask[0],
9007 request->params_data[i].data_mask[1],
9008 request->params_data[i].data_mask[2],
9009 request->params_data[i].data_mask[3],
9010 request->params_data[i].data_mask[4],
9011 request->params_data[i].data_mask[5]);
9012 }
9013
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309014 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009015 sme_receive_filter_set_filter(hdd_ctx->hHal,
9016 &packetFilterSetReq,
9017 sessionId)) {
9018 hdd_err("Failure to execute Set Filter");
9019 return -EINVAL;
9020 }
9021
9022 break;
9023
9024 case HDD_RCV_FILTER_CLEAR:
9025
9026 hdd_info("Clear Packet Filter Request for Id: %d",
9027 request->filter_id);
9028 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309029 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009030 sme_receive_filter_clear_filter(hdd_ctx->hHal,
9031 &packetFilterClrReq,
9032 sessionId)) {
9033 hdd_err("Failure to execute Clear Filter");
9034 return -EINVAL;
9035 }
9036 break;
9037
9038 default:
9039 hdd_err("Packet Filter Request: Invalid %d",
9040 request->filter_action);
9041 return -EINVAL;
9042 }
9043 return 0;
9044}
9045
9046/**
9047 * __iw_set_packet_filter_params() - set packet filter parameters in target
9048 * @dev: Pointer to netdev
9049 * @info: Pointer to iw request info
9050 * @wrqu: Pointer to data
9051 * @extra: Pointer to extra data
9052 *
9053 * Return: 0 on success, non-zero on error
9054 */
9055static int __iw_set_packet_filter_params(struct net_device *dev,
9056 struct iw_request_info *info,
9057 union iwreq_data *wrqu, char *extra)
9058{
9059 int ret;
9060 hdd_context_t *hdd_ctx;
9061 struct iw_point priv_data;
9062 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9063 struct pkt_filter_cfg *request = NULL;
9064
Mukul Sharma472382f2015-11-02 20:16:31 +05309065 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009066 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +05309067 return -EPERM;
9068 }
9069
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009070 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009072 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9073 ret = wlan_hdd_validate_context(hdd_ctx);
9074 if (0 != ret)
9075 return ret;
9076
9077 if (hdd_priv_get_data(&priv_data, wrqu)) {
9078 hdd_err("failed to get priv data");
9079 return -EINVAL;
9080 }
9081
9082 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
9083 hdd_err("invalid priv data %p or invalid priv data length %d",
9084 priv_data.pointer, priv_data.length);
9085 return -EINVAL;
9086 }
9087
9088 /* copy data using copy_from_user */
9089 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
9090 priv_data.length);
9091 if (NULL == request) {
9092 hdd_err("mem_alloc_copy_from_user_helper fail");
9093 return -ENOMEM;
9094 }
9095
9096 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
9097
9098 kfree(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309099 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009100 return ret;
9101}
9102
9103/**
9104 * iw_set_packet_filter_params() - set packet filter parameters in target
9105 * @dev: Pointer to netdev
9106 * @info: Pointer to iw request info
9107 * @wrqu: Pointer to data
9108 * @extra: Pointer to extra data
9109 *
9110 * Return: 0 on success, non-zero on error
9111 */
9112static int iw_set_packet_filter_params(struct net_device *dev,
9113 struct iw_request_info *info,
9114 union iwreq_data *wrqu, char *extra)
9115{
9116 int ret;
9117
9118 cds_ssr_protect(__func__);
9119 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9120 cds_ssr_unprotect(__func__);
9121
9122 return ret;
9123}
9124#endif
9125
9126
9127static int __iw_get_statistics(struct net_device *dev,
9128 struct iw_request_info *info,
9129 union iwreq_data *wrqu, char *extra)
9130{
9131
Anurag Chouhance0dc992016-02-16 18:18:03 +05309132 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309133 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009134 hdd_wext_state_t *pWextState;
9135 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9136 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9137 char *p = extra;
9138 int tlen = 0;
9139 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
9140 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
9141 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
9142 int ret;
9143
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009144 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009145
9146 ret = wlan_hdd_validate_context(hdd_ctx);
9147 if (0 != ret)
9148 return ret;
9149
9150 if (eConnectionState_Associated !=
9151 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9152
9153 wrqu->txpower.value = 0;
9154 } else {
9155 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9156 SME_SUMMARY_STATS |
9157 SME_GLOBAL_CLASSA_STATS |
9158 SME_GLOBAL_CLASSB_STATS |
9159 SME_GLOBAL_CLASSC_STATS |
9160 SME_GLOBAL_CLASSD_STATS |
9161 SME_PER_STA_STATS,
9162 hdd_statistics_cb, 0, false,
9163 (WLAN_HDD_GET_STATION_CTX_PTR
9164 (pAdapter))->conn_info.staId[0],
9165 pAdapter, pAdapter->sessionId);
9166
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309167 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009168 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009169 return -EINVAL;
9170 }
9171
9172 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9173
Anurag Chouhance0dc992016-02-16 18:18:03 +05309174 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05309175 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009176 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +05309177 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009178 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009179 /*Remove the SME statistics list by passing NULL in callback argument */
9180 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9181 SME_SUMMARY_STATS |
9182 SME_GLOBAL_CLASSA_STATS |
9183 SME_GLOBAL_CLASSB_STATS |
9184 SME_GLOBAL_CLASSC_STATS |
9185 SME_GLOBAL_CLASSD_STATS |
9186 SME_PER_STA_STATS,
9187 NULL, 0, false,
9188 (WLAN_HDD_GET_STATION_CTX_PTR
9189 (pAdapter))->conn_info.
9190 staId[0], pAdapter,
9191 pAdapter->sessionId);
9192
9193 return -EINVAL;
9194 }
9195 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
9196 (uint8_t) sizeof(pStats->retry_cnt),
9197 (char *)&(pStats->retry_cnt[0]), tlen);
9198
9199 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
9200 (uint8_t) sizeof(pStats->multiple_retry_cnt),
9201 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
9202
9203 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
9204 (uint8_t) sizeof(pStats->tx_frm_cnt),
9205 (char *)&(pStats->tx_frm_cnt[0]), tlen);
9206
9207 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
9208 (uint8_t) sizeof(pStats->rx_frm_cnt),
9209 (char *)&(pStats->rx_frm_cnt), tlen);
9210
9211 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
9212 (uint8_t) sizeof(pStats->frm_dup_cnt),
9213 (char *)&(pStats->frm_dup_cnt), tlen);
9214
9215 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
9216 (uint8_t) sizeof(pStats->fail_cnt),
9217 (char *)&(pStats->fail_cnt[0]), tlen);
9218
9219 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
9220 (uint8_t) sizeof(pStats->rts_fail_cnt),
9221 (char *)&(pStats->rts_fail_cnt), tlen);
9222
9223 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
9224 (uint8_t) sizeof(pStats->ack_fail_cnt),
9225 (char *)&(pStats->ack_fail_cnt), tlen);
9226
9227 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
9228 (uint8_t) sizeof(pStats->rts_succ_cnt),
9229 (char *)&(pStats->rts_succ_cnt), tlen);
9230
9231 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
9232 (uint8_t) sizeof(pStats->rx_discard_cnt),
9233 (char *)&(pStats->rx_discard_cnt), tlen);
9234
9235 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
9236 (uint8_t) sizeof(pStats->rx_error_cnt),
9237 (char *)&(pStats->rx_error_cnt), tlen);
9238
9239 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
9240 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9241 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9242
9243 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
9244 (uint8_t) sizeof(dStats->rx_byte_cnt),
9245 (char *)&(dStats->rx_byte_cnt), tlen);
9246
9247 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
9248 (uint8_t) sizeof(dStats->rx_rate),
9249 (char *)&(dStats->rx_rate), tlen);
9250
9251 /* Transmit rate, in units of 500 kbit/sec */
9252 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
9253 (uint8_t) sizeof(aStats->tx_rate),
9254 (char *)&(aStats->tx_rate), tlen);
9255
9256 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
9257 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
9258 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
9259 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
9260 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
9261 (char *)&(dStats->rx_mc_byte_cnt), tlen);
9262 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
9263 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
9264 (char *)&(dStats->rx_bc_byte_cnt), tlen);
9265 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
9266 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9267 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9268 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
9269 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
9270 (char *)&(dStats->tx_mc_byte_cnt), tlen);
9271 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
9272 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
9273 (char *)&(dStats->tx_bc_byte_cnt), tlen);
9274
9275 wrqu->data.length = tlen;
9276
9277 }
9278
9279 EXIT();
9280
9281 return 0;
9282}
9283
9284static int iw_get_statistics(struct net_device *dev,
9285 struct iw_request_info *info,
9286 union iwreq_data *wrqu, char *extra)
9287{
9288 int ret;
9289
9290 cds_ssr_protect(__func__);
9291 ret = __iw_get_statistics(dev, info, wrqu, extra);
9292 cds_ssr_unprotect(__func__);
9293
9294 return ret;
9295}
9296
9297#ifdef FEATURE_WLAN_SCAN_PNO
9298
9299/*Max Len for PNO notification*/
9300#define MAX_PNO_NOTIFY_LEN 100
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07009301static void found_pref_network_cb(void *callbackContext,
9302 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009303{
9304 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
9305 union iwreq_data wrqu;
9306 char buf[MAX_PNO_NOTIFY_LEN + 1];
9307
Jeff Johnson99bac312016-06-28 10:38:18 -07009308 hdd_warn("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009309 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9310
9311 /* create the event */
9312 memset(&wrqu, 0, sizeof(wrqu));
9313 memset(buf, 0, sizeof(buf));
9314
9315 snprintf(buf, MAX_PNO_NOTIFY_LEN,
9316 "QCOM: Found preferred network: %s with RSSI of -%u",
9317 pPrefNetworkFoundInd->ssId.ssId,
9318 (unsigned int)pPrefNetworkFoundInd->rssi);
9319
9320 wrqu.data.pointer = buf;
9321 wrqu.data.length = strlen(buf);
9322
9323 /* send the event */
9324
9325 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9326
9327}
9328
9329/**
9330 * __iw_set_pno() - Preferred Network Offload ioctl handler
9331 * @dev: device upon which the ioctl was received
9332 * @info: ioctl request information
9333 * @wrqu: ioctl request data
9334 * @extra: ioctl extra data
9335 *
9336 * This function parses a Preferred Network Offload command
9337 * Input is string based and expected to be of the form:
9338 *
9339 * <enable(1) | disable(0)>
9340 * when enabling:
9341 * <number of networks>
9342 * for each network:
9343 * <ssid_len> <ssid> <authentication> <encryption>
9344 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -07009345 * <scan_time (seconds)>
9346 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009347 * <suspend mode>
9348 *
9349 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -07009350 * 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 -08009351 *
9352 * this translates into:
9353 * -----------------------------
9354 * enable PNO
9355 * 2 networks
9356 * Network 1:
9357 * test - with authentication type 0 and encryption type 0,
9358 * search on 3 channels: 1 6 and 11,
9359 * SSID bcast type is unknown (directed probe will be sent if
9360 * AP not found) and must meet -40dBm RSSI
9361 * Network 2:
9362 * test2 - with authentication type 4 and encryption type 4,
9363 * search on 6 channels 1, 2, 3, 4, 5 and 6
9364 * bcast type is non-bcast (directed probe will be sent)
9365 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009366 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -07009367 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009368 */
9369static int __iw_set_pno(struct net_device *dev,
9370 struct iw_request_info *info,
9371 union iwreq_data *wrqu, char *extra)
9372{
9373 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9374 hdd_context_t *hdd_ctx;
9375 int ret;
9376 int offset;
9377 char *ptr;
9378 uint8_t i, j, params, mode;
9379
9380 /* request is a large struct, so we make it static to avoid
9381 * stack overflow. This API is only invoked via ioctl, so it
9382 * is serialized by the kernel rtnl_lock and hence does not
9383 * need to be reentrant
9384 */
9385 static tSirPNOScanReq request;
9386
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009387 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009388
9389 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9390 ret = wlan_hdd_validate_context(hdd_ctx);
9391 if (ret)
9392 return ret;
9393
9394 hdd_notice("PNO data len %d data %s", wrqu->data.length, extra);
9395
9396 request.enable = 0;
9397 request.ucNetworksCount = 0;
9398
9399 ptr = extra;
9400
9401 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
9402 hdd_err("PNO enable input is not valid %s", ptr);
9403 return -EINVAL;
9404 }
9405
9406 if (0 == request.enable) {
9407 /* Disable PNO, ignore any other params */
9408 memset(&request, 0, sizeof(request));
9409 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
9410 &request, adapter->sessionId,
9411 found_pref_network_cb, adapter);
9412 return 0;
9413 }
9414
9415 ptr += offset;
9416
9417 if (1 !=
9418 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
9419 hdd_err("PNO count input not valid %s", ptr);
9420 return -EINVAL;
9421
9422 }
9423
9424 hdd_info("PNO enable %d networks count %d offset %d",
9425 request.enable, request.ucNetworksCount, offset);
9426
9427 if ((0 == request.ucNetworksCount) ||
9428 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
9429 hdd_err("Network count %d invalid",
9430 request.ucNetworksCount);
9431 return -EINVAL;
9432 }
9433
9434 ptr += offset;
9435
9436 for (i = 0; i < request.ucNetworksCount; i++) {
9437
9438 request.aNetworks[i].ssId.length = 0;
9439
9440 params = sscanf(ptr, "%hhu %n",
9441 &(request.aNetworks[i].ssId.length),
9442 &offset);
9443
9444 if (1 != params) {
9445 hdd_err("PNO ssid length input is not valid %s", ptr);
9446 return -EINVAL;
9447 }
9448
9449 if ((0 == request.aNetworks[i].ssId.length) ||
9450 (request.aNetworks[i].ssId.length > 32)) {
9451 hdd_err("SSID Len %d is not correct for network %d",
9452 request.aNetworks[i].ssId.length, i);
9453 return -EINVAL;
9454 }
9455
9456 /* Advance to SSID */
9457 ptr += offset;
9458
9459 memcpy(request.aNetworks[i].ssId.ssId, ptr,
9460 request.aNetworks[i].ssId.length);
9461 ptr += request.aNetworks[i].ssId.length;
9462
9463 params = sscanf(ptr, "%u %u %hhu %n",
9464 &(request.aNetworks[i].authentication),
9465 &(request.aNetworks[i].encryption),
9466 &(request.aNetworks[i].ucChannelCount),
9467 &offset);
9468
9469 if (3 != params) {
9470 hdd_warn("Incorrect cmd %s", ptr);
9471 return -EINVAL;
9472 }
9473
9474 hdd_notice("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
9475 request.aNetworks[i].ssId.length,
9476 request.aNetworks[i].ssId.length,
9477 request.aNetworks[i].ssId.ssId,
9478 request.aNetworks[i].authentication,
9479 request.aNetworks[i].encryption,
9480 request.aNetworks[i].ucChannelCount, offset);
9481
9482 /* Advance to channel list */
9483 ptr += offset;
9484
9485 if (SIR_PNO_MAX_NETW_CHANNELS <
9486 request.aNetworks[i].ucChannelCount) {
9487 hdd_warn("Incorrect number of channels");
9488 return -EINVAL;
9489 }
9490
9491 if (0 != request.aNetworks[i].ucChannelCount) {
9492 for (j = 0; j < request.aNetworks[i].ucChannelCount;
9493 j++) {
9494 if (1 !=
9495 sscanf(ptr, "%hhu %n",
9496 &(request.aNetworks[i].
9497 aChannels[j]), &offset)) {
9498 hdd_err("PNO network channel input is not valid %s",
9499 ptr);
9500 return -EINVAL;
9501 }
9502 /* Advance to next channel number */
9503 ptr += offset;
9504 }
9505 }
9506
9507 if (1 != sscanf(ptr, "%u %n",
9508 &(request.aNetworks[i].bcastNetwType),
9509 &offset)) {
9510 hdd_err("PNO broadcast network type input is not valid %s",
9511 ptr);
9512 return -EINVAL;
9513 }
9514
9515 hdd_notice("PNO bcastNetwType %d offset %d",
9516 request.aNetworks[i].bcastNetwType, offset);
9517
9518 /* Advance to rssi Threshold */
9519 ptr += offset;
9520 if (1 != sscanf(ptr, "%d %n",
9521 &(request.aNetworks[i].rssiThreshold),
9522 &offset)) {
9523 hdd_err("PNO rssi threshold input is not valid %s",
9524 ptr);
9525 return -EINVAL;
9526 }
9527 hdd_notice("PNO rssi %d offset %d",
9528 request.aNetworks[i].rssiThreshold, offset);
9529 /* Advance to next network */
9530 ptr += offset;
9531 } /* For ucNetworkCount */
9532
Dustin Brown43e87292016-10-10 10:38:25 -07009533 request.fast_scan_period = 0;
9534 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
9535 request.fast_scan_period *= MSEC_PER_SEC;
9536 ptr += offset;
9537 }
9538
9539 request.fast_scan_max_cycles = 0;
9540 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
9541 &offset) > 0)
9542 ptr += offset;
9543
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009544 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
9545
9546 request.modePNO = mode;
9547 /* for LA we just expose suspend option */
9548 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
9549 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9550 }
9551
9552 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
9553 &request,
9554 adapter->sessionId,
9555 found_pref_network_cb, adapter);
9556
9557 return 0;
9558}
9559
9560static int iw_set_pno(struct net_device *dev,
9561 struct iw_request_info *info,
9562 union iwreq_data *wrqu, char *extra)
9563{
9564 int ret;
9565
9566 cds_ssr_protect(__func__);
9567 ret = __iw_set_pno(dev, info, wrqu, extra);
9568 cds_ssr_unprotect(__func__);
9569
9570 return ret;
9571}
9572#endif /* FEATURE_WLAN_SCAN_PNO */
9573
9574/* Common function to SetBand */
9575int hdd_set_band(struct net_device *dev, u8 ui_band)
9576{
9577 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9578 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9579 eCsrBand band;
9580
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309581 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009582 hdd_context_t *pHddCtx;
9583 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9584 eCsrBand currBand = eCSR_BAND_MAX;
9585 eCsrBand connectedBand;
9586
9587 pAdapterNode = NULL;
9588 pNext = NULL;
9589 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9590
9591 switch (ui_band) {
9592 case WLAN_HDD_UI_BAND_AUTO:
9593 band = eCSR_BAND_ALL;
9594 break;
9595 case WLAN_HDD_UI_BAND_5_GHZ:
9596 band = eCSR_BAND_5G;
9597 break;
9598 case WLAN_HDD_UI_BAND_2_4_GHZ:
9599 band = eCSR_BAND_24;
9600 break;
9601 default:
9602 band = eCSR_BAND_MAX;
9603 }
9604
Jeff Johnson99bac312016-06-28 10:38:18 -07009605 hdd_notice("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009606
9607 if (band == eCSR_BAND_MAX) {
9608 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -07009609 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009610 return -EINVAL;
9611 }
9612
9613 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
9614 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009615 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009616 band, pHddCtx->config->nBandCapability);
9617 return -EIO;
9618 }
9619
9620 if (band == eCSR_BAND_ALL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009621 hdd_notice("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009622 pHddCtx->config->nBandCapability);
9623 band = pHddCtx->config->nBandCapability;
9624 }
9625
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309626 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009627 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009628 return -EIO;
9629 }
9630
9631 if (currBand != band) {
9632 /* Change band request received.
9633 * Abort pending scan requests, flush the existing scan results,
9634 * and change the band capability
9635 */
Jeff Johnson99bac312016-06-28 10:38:18 -07009636 hdd_notice("Current band value = %u, new setting %u ",
9637 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009638
9639 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309640 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009641 pAdapter = pAdapterNode->pAdapter;
9642 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9643 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
9644 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9645 connectedBand =
9646 hdd_conn_get_connected_band
9647 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
9648
9649 /* Handling is done only for STA and P2P */
9650 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -08009651 ((pAdapter->device_mode == QDF_STA_MODE)
9652 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009653 &&
9654 (hdd_conn_is_connected
9655 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
9656 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309657 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009658 long lrc;
9659
9660 /* STA already connected on current band, So issue disconnect
9661 * first, then change the band*/
9662
Jeff Johnson99bac312016-06-28 10:38:18 -07009663 hdd_notice("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009664 hdd_device_mode_to_string(pAdapter->device_mode),
9665 pAdapter->device_mode, currBand, band);
9666 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9667
9668 status =
9669 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
9670 (pAdapter),
9671 pAdapter->sessionId,
9672 eCSR_DISCONNECT_REASON_UNSPECIFIED);
9673
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309674 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009675 hdd_err("csr_roam_disconnect failure, returned %d",
9676 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009677 return -EINVAL;
9678 }
9679
9680 lrc =
9681 wait_for_completion_timeout(&pAdapter->
9682 disconnect_comp_var,
9683 msecs_to_jiffies
9684 (WLAN_WAIT_TIME_DISCONNECT));
9685
9686 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009687 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009688 return -ETIMEDOUT;
9689 }
9690 }
9691
9692 sme_scan_flush_result(hHal);
9693
9694 status =
9695 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
9696 pAdapterNode = pNext;
9697 }
9698
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309699 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009700 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009701 hdd_alert("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009702 band);
9703 return -EINVAL;
9704 }
9705 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
9706 }
9707 return 0;
9708}
9709
9710int hdd_set_band_helper(struct net_device *dev, const char *command)
9711{
9712 uint8_t band;
9713 int ret;
9714
9715 /* Convert the band value from ascii to integer */
9716 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
9717 ret = kstrtou8(command, 10, &band);
9718 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009719 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009720 return -EINVAL;
9721 }
9722
9723 return hdd_set_band(dev, band);
9724}
9725
9726static int __iw_set_band_config(struct net_device *dev,
9727 struct iw_request_info *info,
9728 union iwreq_data *wrqu, char *extra)
9729{
9730 int *value = (int *)extra;
9731
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009732 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009733
Mukul Sharmaa5fe1982015-11-02 19:28:14 +05309734 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009735 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +05309736 return -EPERM;
9737 }
9738
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009739 return hdd_set_band(dev, value[0]);
9740}
9741
9742static int iw_set_band_config(struct net_device *dev,
9743 struct iw_request_info *info,
9744 union iwreq_data *wrqu, char *extra)
9745{
9746 int ret;
9747
9748 cds_ssr_protect(__func__);
9749 ret = __iw_set_band_config(dev, info, wrqu, extra);
9750 cds_ssr_unprotect(__func__);
9751
9752 return ret;
9753}
9754
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009755/**
9756 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
9757 * @adapter: Handle to adapter
9758 * @chan: Monitor mode channel
9759 * @bandwidth: Capture channel bandwidth
9760 *
9761 * Return: 0 on success else error code.
9762 */
9763static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
9764 uint32_t bandwidth)
9765{
9766 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9767 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
9768 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
9769 QDF_STATUS status;
9770 tHalHandle hal_hdl = hdd_ctx->hHal;
9771 struct qdf_mac_addr bssid;
9772 tCsrRoamProfile roam_profile;
9773 struct ch_params_s ch_params;
9774
9775 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
9776 hdd_err("Not supported, device is not in monitor mode");
9777 return -EINVAL;
9778 }
9779
9780 hdd_info("Set monitor mode Channel %d", chan);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009781 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
9782 roam_profile.ChannelInfo.numOfChannels = 1;
9783 roam_profile.phyMode = ch_info->phy_mode;
9784 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -07009785 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009786
9787 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
9788 QDF_MAC_ADDR_SIZE);
9789
9790 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07009791 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009792 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
9793 &roam_profile);
9794 if (status) {
9795 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
9796 status);
9797 }
9798
9799 return qdf_status_to_os_return(status);
9800}
9801
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009802static int __iw_set_two_ints_getnone(struct net_device *dev,
9803 struct iw_request_info *info,
9804 union iwreq_data *wrqu, char *extra)
9805{
9806 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9807 int *value = (int *)extra;
9808 int sub_cmd = value[0];
9809 int ret;
9810 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9811
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009812 ENTER_DEV(dev);
9813
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009814 ret = wlan_hdd_validate_context(hdd_ctx);
9815 if (0 != ret)
9816 return ret;
9817
9818 switch (sub_cmd) {
9819 case WE_SET_SMPS_PARAM:
Jeff Johnson99bac312016-06-28 10:38:18 -07009820 hdd_notice("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009821 ret = wma_cli_set_command(pAdapter->sessionId,
9822 WMI_STA_SMPS_PARAM_CMDID,
9823 value[1] << WMA_SMPS_PARAM_VALUE_S
9824 | value[2],
9825 VDEV_CMD);
9826 break;
9827#ifdef DEBUG
9828 case WE_SET_FW_CRASH_INJECT:
Jeff Johnson99bac312016-06-28 10:38:18 -07009829 hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009830 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +05309831 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
9832 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009833 ret = wma_cli_set2_command(pAdapter->sessionId,
9834 GEN_PARAM_CRASH_INJECT,
9835 value[1], value[2], GEN_CMD);
9836 break;
9837#endif
Govind Singha471e5e2015-10-12 17:11:14 +05309838 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009839 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +05309840 value[1], value[2]);
9841 ret = wma_cli_set2_command(pAdapter->sessionId,
9842 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
9843 value[1], value[2], DBG_CMD);
9844 break;
9845 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -07009846 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +05309847 value[1], value[2]);
9848 ret = wma_cli_set2_command(pAdapter->sessionId,
9849 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
9850 value[1], value[2], DBG_CMD);
9851 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009852 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
9853 hdd_debug("Ioctl to set dual fw mode config");
9854 if (hdd_ctx->config->dual_mac_feature_disable) {
9855 hdd_err("Dual mac feature is disabled from INI");
9856 return -EPERM;
9857 }
9858 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08009859 cds_set_dual_mac_fw_mode_config(value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009860 break;
9861 case WE_DUMP_DP_TRACE_LEVEL:
9862 hdd_info("WE_DUMP_DP_TRACE_LEVEL: %d %d",
9863 value[1], value[2]);
9864 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309865 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +05309866 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
9867 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +05309868 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
9869 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009870 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009871 case WE_SET_MON_MODE_CHAN:
9872 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
9873 break;
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009874 case WE_SET_WLAN_SUSPEND:
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07009875 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy);
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009876 break;
9877 case WE_SET_WLAN_RESUME:
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07009878 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy);
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009879 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009880 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07009881 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009882 break;
9883 }
9884
9885 return ret;
9886}
9887
9888static int iw_set_two_ints_getnone(struct net_device *dev,
9889 struct iw_request_info *info,
9890 union iwreq_data *wrqu, char *extra)
9891{
9892 int ret;
9893
9894 cds_ssr_protect(__func__);
9895 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
9896 cds_ssr_unprotect(__func__);
9897
9898 return ret;
9899}
9900
9901/* Define the Wireless Extensions to the Linux Network Device structure */
9902/* A number of these routines are NULL (meaning they are not implemented.) */
9903
9904static const iw_handler we_handler[] = {
9905 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9906 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9907 (iw_handler) NULL, /* SIOCSIWNWID */
9908 (iw_handler) NULL, /* SIOCGIWNWID */
9909 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9910 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9911 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9912 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9913 (iw_handler) NULL, /* SIOCSIWSENS */
9914 (iw_handler) NULL, /* SIOCGIWSENS */
9915 (iw_handler) NULL, /* SIOCSIWRANGE */
9916 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9917 (iw_handler) NULL, /* SIOCSIWPRIV */
9918 (iw_handler) NULL, /* SIOCGIWPRIV */
9919 (iw_handler) NULL, /* SIOCSIWSTATS */
9920 (iw_handler) NULL, /* SIOCGIWSTATS */
9921 (iw_handler) NULL, /* SIOCSIWSPY */
9922 (iw_handler) NULL, /* SIOCGIWSPY */
9923 (iw_handler) NULL, /* SIOCSIWTHRSPY */
9924 (iw_handler) NULL, /* SIOCGIWTHRSPY */
9925 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9926 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9927 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9928 (iw_handler) NULL, /* SIOCGIWAPLIST */
9929 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9930 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9931 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9932 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9933 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9934 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9935 (iw_handler) NULL, /* -- hole -- */
9936 (iw_handler) NULL, /* -- hole -- */
9937 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9938 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9939 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
9940 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
9941 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9942 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9943 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9944 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9945 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9946 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9947 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9948 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9949 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9950 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9951 (iw_handler) NULL, /* -- hole -- */
9952 (iw_handler) NULL, /* -- hole -- */
9953 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9954 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9955 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9956 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9957 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9958 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9959 (iw_handler) NULL, /* SIOCSIWPMKSA */
9960};
9961
9962static const iw_handler we_private[] = {
9963
9964 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, /* set priv ioctl */
9965 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, /* get priv ioctl */
9966 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, /* get priv ioctl */
9967 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9968 iw_set_three_ints_getnone,
9969 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9970 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, /* action priv ioctl */
9971 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9972 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009973 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
9974 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009975 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9976 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9977 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009978 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009979 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9980 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9981 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
9982 iw_set_keepalive_params,
9983#ifdef WLAN_FEATURE_PACKET_FILTERING
9984 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
9985 iw_set_packet_filter_params,
9986#endif
9987#ifdef FEATURE_WLAN_SCAN_PNO
9988 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
9989#endif
9990 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
9991 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
9992 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9993 iw_set_two_ints_getnone,
9994 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
9995 iw_set_dot11p_channel_sched,
9996};
9997
9998/*Maximum command length can be only 15 */
9999static const struct iw_priv_args we_private_args[] = {
10000
10001 /* handlers for main ioctl */
10002 {WLAN_PRIV_SET_INT_GET_NONE,
10003 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10004 0,
10005 ""},
10006
10007 /* handlers for sub-ioctl */
10008 {WE_SET_11D_STATE,
10009 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10010 0,
10011 "set11Dstate"},
10012
10013 {WE_WOWL,
10014 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10015 0,
10016 "wowl"},
10017
10018 {WE_SET_POWER,
10019 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10020 0,
10021 "setPower"},
10022
10023 {WE_SET_MAX_ASSOC,
10024 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10025 0,
10026 "setMaxAssoc"},
10027
10028 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10029 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
10030 "setAutoChannel" },
10031
10032 {WE_SET_SCAN_DISABLE,
10033 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10034 0,
10035 "scan_disable"},
10036
10037 {WE_SET_DATA_INACTIVITY_TO,
10038 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10039 0,
10040 "inactivityTO"},
10041
10042 {WE_SET_MAX_TX_POWER,
10043 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10044 0,
10045 "setMaxTxPower"},
10046
10047 {WE_SET_TX_POWER,
10048 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10049 0,
10050 "setTxPower"},
10051
10052 {WE_SET_MC_RATE,
10053 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10054 0,
10055 "setMcRate"},
10056
10057 {WE_SET_MAX_TX_POWER_2_4,
10058 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10059 0,
10060 "setTxMaxPower2G"},
10061
10062 {WE_SET_MAX_TX_POWER_5_0,
10063 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10064 0,
10065 "setTxMaxPower5G"},
10066
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010067 {WE_SET_PKTLOG,
10068 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10069 0,
10070 "pktlog"},
10071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010072 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10073 * as well to keep same syntax as in SAP. Now onwards, STA
10074 * will support both */
10075 {WE_SET_MAX_TX_POWER,
10076 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10077 0,
10078 "setTxMaxPower"},
10079
10080 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10081 * 1 = enable and 0 = disable */
10082 {
10083 WE_SET_HIGHER_DTIM_TRANSITION,
10084 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10085 0,
10086 "setHDtimTransn"
10087 },
10088
10089 {WE_SET_TM_LEVEL,
10090 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10091 0,
10092 "setTmLevel"},
10093
10094 {WE_SET_PHYMODE,
10095 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10096 0,
10097 "setphymode"},
10098
10099 {WE_SET_NSS,
10100 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10101 0,
10102 "nss"},
10103
10104 {WE_SET_LDPC,
10105 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10106 0,
10107 "ldpc"},
10108
10109 {WE_SET_TX_STBC,
10110 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10111 0,
10112 "tx_stbc"},
10113
10114 {WE_SET_RX_STBC,
10115 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10116 0,
10117 "rx_stbc"},
10118
10119 {WE_SET_SHORT_GI,
10120 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10121 0,
10122 "shortgi"},
10123
10124 {WE_SET_RTSCTS,
10125 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10126 0,
10127 "enablertscts"},
10128
10129 {WE_SET_CHWIDTH,
10130 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10131 0,
10132 "chwidth"},
10133
10134 {WE_SET_ANI_EN_DIS,
10135 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10136 0,
10137 "anienable"},
10138
10139 {WE_SET_ANI_POLL_PERIOD,
10140 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10141 0,
10142 "aniplen"},
10143
10144 {WE_SET_ANI_LISTEN_PERIOD,
10145 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10146 0,
10147 "anilislen"},
10148
10149 {WE_SET_ANI_OFDM_LEVEL,
10150 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10151 0,
10152 "aniofdmlvl"},
10153
10154 {WE_SET_ANI_CCK_LEVEL,
10155 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10156 0,
10157 "aniccklvl"},
10158
10159 {WE_SET_DYNAMIC_BW,
10160 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10161 0,
10162 "cwmenable"},
10163
10164 {WE_SET_CTS_CBW,
10165 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10166 0,
10167 "cts_cbw" },
10168
10169 {WE_SET_GTX_HT_MCS,
10170 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10171 0,
10172 "gtxHTMcs"},
10173
10174 {WE_SET_GTX_VHT_MCS,
10175 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10176 0,
10177 "gtxVHTMcs"},
10178
10179 {WE_SET_GTX_USRCFG,
10180 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10181 0,
10182 "gtxUsrCfg"},
10183
10184 {WE_SET_GTX_THRE,
10185 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10186 0,
10187 "gtxThre"},
10188
10189 {WE_SET_GTX_MARGIN,
10190 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10191 0,
10192 "gtxMargin"},
10193
10194 {WE_SET_GTX_STEP,
10195 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10196 0,
10197 "gtxStep"},
10198
10199 {WE_SET_GTX_MINTPC,
10200 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10201 0,
10202 "gtxMinTpc"},
10203
10204 {WE_SET_GTX_BWMASK,
10205 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10206 0,
10207 "gtxBWMask"},
10208
10209 {WE_SET_TX_CHAINMASK,
10210 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10211 0,
10212 "txchainmask"},
10213
10214 {WE_SET_RX_CHAINMASK,
10215 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10216 0,
10217 "rxchainmask"},
10218
10219 {WE_SET_11N_RATE,
10220 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10221 0,
10222 "set11NRates"},
10223
10224 {WE_SET_VHT_RATE,
10225 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10226 0,
10227 "set11ACRates"},
10228
10229 {WE_SET_AMPDU,
10230 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10231 0,
10232 "ampdu"},
10233
10234 {WE_SET_AMSDU,
10235 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10236 0,
10237 "amsdu"},
10238
10239 {WE_SET_BURST_ENABLE,
10240 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10241 0,
10242 "burst_enable"},
10243
10244 {WE_SET_BURST_DUR,
10245 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10246 0,
10247 "burst_dur"},
10248
10249 {WE_SET_TXPOW_2G,
10250 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10251 0,
10252 "txpow2g"},
10253
10254 {WE_SET_TXPOW_5G,
10255 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10256 0,
10257 "txpow5g"},
10258
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010259 /* Sub-cmds DBGLOG specific commands */
10260 {WE_DBGLOG_LOG_LEVEL,
10261 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10262 0,
10263 "dl_loglevel"},
10264
10265 {WE_DBGLOG_VAP_ENABLE,
10266 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10267 0,
10268 "dl_vapon"},
10269
10270 {WE_DBGLOG_VAP_DISABLE,
10271 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10272 0,
10273 "dl_vapoff"},
10274
10275 {WE_DBGLOG_MODULE_ENABLE,
10276 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10277 0,
10278 "dl_modon"},
10279
10280 {WE_DBGLOG_MODULE_DISABLE,
10281 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10282 0,
10283 "dl_modoff"},
10284
10285 {WE_DBGLOG_MOD_LOG_LEVEL,
10286 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10287 0,
10288 "dl_mod_loglevel"},
10289
10290 {WE_DBGLOG_TYPE,
10291 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10292 0,
10293 "dl_type"},
10294 {WE_DBGLOG_REPORT_ENABLE,
10295 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10296 0,
10297 "dl_report"},
10298
10299 {WE_SET_TXRX_FWSTATS,
10300 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10301 0,
10302 "txrx_fw_stats"},
10303
10304 {WE_TXRX_FWSTATS_RESET,
10305 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10306 0,
10307 "txrx_fw_st_rst"},
10308
10309 {WE_PPS_PAID_MATCH,
10310 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10311 0, "paid_match"},
10312
10313 {WE_PPS_GID_MATCH,
10314 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10315 0, "gid_match"},
10316
10317 {WE_PPS_EARLY_TIM_CLEAR,
10318 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10319 0, "tim_clear"},
10320
10321 {WE_PPS_EARLY_DTIM_CLEAR,
10322 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10323 0, "dtim_clear"},
10324
10325 {WE_PPS_EOF_PAD_DELIM,
10326 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10327 0, "eof_delim"},
10328
10329 {WE_PPS_MACADDR_MISMATCH,
10330 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10331 0, "mac_match"},
10332
10333 {WE_PPS_DELIM_CRC_FAIL,
10334 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10335 0, "delim_fail"},
10336
10337 {WE_PPS_GID_NSTS_ZERO,
10338 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10339 0, "nsts_zero"},
10340
10341 {WE_PPS_RSSI_CHECK,
10342 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10343 0, "rssi_chk"},
10344
10345 {WE_PPS_5G_EBT,
10346 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10347 0, "5g_ebt"},
10348
10349 {WE_SET_HTSMPS,
10350 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10351 0, "htsmps"},
10352
10353 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
10354 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10355 0, "set_qpspollcnt"},
10356
10357 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
10358 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10359 0, "set_qtxwake"},
10360
10361 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
10362 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10363 0, "set_qwakeintv"},
10364
10365 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
10366 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10367 0, "set_qnodatapoll"},
10368
10369 /* handlers for MCC time quota and latency sub ioctls */
10370 {WE_MCC_CONFIG_LATENCY,
10371 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10372 0, "setMccLatency"},
10373
10374 {WE_MCC_CONFIG_QUOTA,
10375 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10376 0, "setMccQuota"},
10377
10378 {WE_SET_DEBUG_LOG,
10379 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10380 0, "setDbgLvl"},
10381
10382 /* handlers for early_rx power save */
10383 {WE_SET_EARLY_RX_ADJUST_ENABLE,
10384 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10385 0, "erx_enable"},
10386
10387 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
10388 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10389 0, "erx_bmiss_val"},
10390
10391 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
10392 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10393 0, "erx_bmiss_smpl"},
10394
10395 {WE_SET_EARLY_RX_SLOP_STEP,
10396 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10397 0, "erx_slop_step"},
10398
10399 {WE_SET_EARLY_RX_INIT_SLOP,
10400 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10401 0, "erx_init_slop"},
10402
10403 {WE_SET_EARLY_RX_ADJUST_PAUSE,
10404 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10405 0, "erx_adj_pause"},
10406
10407 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
10408 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10409 0, "erx_dri_sample"},
10410
10411 {WE_DUMP_STATS,
10412 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10413 0, "dumpStats"},
10414
10415 {WE_CLEAR_STATS,
10416 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10417 0, "clearStats"},
10418
Govind Singha471e5e2015-10-12 17:11:14 +053010419 {WE_START_FW_PROFILE,
10420 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10421 0, "startProfile"},
10422
Abhishek Singh1bdb1572015-10-16 16:24:19 +053010423 {WE_SET_CHANNEL,
10424 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10425 0, "setChanChange" },
10426
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053010427 {WE_SET_CONC_SYSTEM_PREF,
10428 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10429 0, "setConcSysPref" },
10430
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010431 {WLAN_PRIV_SET_NONE_GET_INT,
10432 0,
10433 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10434 ""},
10435
10436 /* handlers for sub-ioctl */
10437 {WE_GET_11D_STATE,
10438 0,
10439 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10440 "get11Dstate"},
10441
10442 {WE_IBSS_STATUS,
10443 0,
10444 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10445 "getAdhocStatus"},
10446
10447 {WE_GET_WLAN_DBG,
10448 0,
10449 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10450 "getwlandbg"},
10451
10452 {WE_GET_MAX_ASSOC,
10453 0,
10454 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10455 "getMaxAssoc"},
10456
10457 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10458 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10459 "getAutoChannel" },
10460
10461 {WE_GET_CONCURRENCY_MODE,
10462 0,
10463 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10464 "getconcurrency"},
10465
10466 {WE_GET_NSS,
10467 0,
10468 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10469 "get_nss"},
10470
10471 {WE_GET_LDPC,
10472 0,
10473 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10474 "get_ldpc"},
10475
10476 {WE_GET_TX_STBC,
10477 0,
10478 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10479 "get_tx_stbc"},
10480
10481 {WE_GET_RX_STBC,
10482 0,
10483 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10484 "get_rx_stbc"},
10485
10486 {WE_GET_SHORT_GI,
10487 0,
10488 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10489 "get_shortgi"},
10490
10491 {WE_GET_RTSCTS,
10492 0,
10493 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10494 "get_rtscts"},
10495
10496 {WE_GET_CHWIDTH,
10497 0,
10498 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10499 "get_chwidth"},
10500
10501 {WE_GET_ANI_EN_DIS,
10502 0,
10503 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10504 "get_anienable"},
10505
10506 {WE_GET_ANI_POLL_PERIOD,
10507 0,
10508 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10509 "get_aniplen"},
10510
10511 {WE_GET_ANI_LISTEN_PERIOD,
10512 0,
10513 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10514 "get_anilislen"},
10515
10516 {WE_GET_ANI_OFDM_LEVEL,
10517 0,
10518 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10519 "get_aniofdmlvl"},
10520
10521 {WE_GET_ANI_CCK_LEVEL,
10522 0,
10523 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10524 "get_aniccklvl"},
10525
10526 {WE_GET_DYNAMIC_BW,
10527 0,
10528 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10529 "get_cwmenable"},
10530
10531 {WE_GET_GTX_HT_MCS,
10532 0,
10533 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10534 "get_gtxHTMcs"},
10535
10536 {WE_GET_GTX_VHT_MCS,
10537 0,
10538 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10539 "get_gtxVHTMcs"},
10540
10541 {WE_GET_GTX_USRCFG,
10542 0,
10543 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10544 "get_gtxUsrCfg"},
10545
10546 {WE_GET_GTX_THRE,
10547 0,
10548 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10549 "get_gtxThre"},
10550
10551 {WE_GET_GTX_MARGIN,
10552 0,
10553 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10554 "get_gtxMargin"},
10555
10556 {WE_GET_GTX_STEP,
10557 0,
10558 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10559 "get_gtxStep"},
10560
10561 {WE_GET_GTX_MINTPC,
10562 0,
10563 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10564 "get_gtxMinTpc"},
10565
10566 {WE_GET_GTX_BWMASK,
10567 0,
10568 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10569 "get_gtxBWMask"},
10570
10571 {WE_GET_TX_CHAINMASK,
10572 0,
10573 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10574 "get_txchainmask"},
10575
10576 {WE_GET_RX_CHAINMASK,
10577 0,
10578 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10579 "get_rxchainmask"},
10580
10581 {WE_GET_11N_RATE,
10582 0,
10583 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10584 "get_11nrate"},
10585
10586 {WE_GET_AMPDU,
10587 0,
10588 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10589 "get_ampdu"},
10590
10591 {WE_GET_AMSDU,
10592 0,
10593 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10594 "get_amsdu"},
10595
10596 {WE_GET_BURST_ENABLE,
10597 0,
10598 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10599 "get_burst_en"},
10600
10601 {WE_GET_BURST_DUR,
10602 0,
10603 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10604 "get_burst_dur"},
10605
10606 {WE_GET_TXPOW_2G,
10607 0,
10608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10609 "get_txpow2g"},
10610
10611 {WE_GET_TXPOW_5G,
10612 0,
10613 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10614 "get_txpow5g"},
10615
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010616 {WE_GET_PPS_PAID_MATCH,
10617 0,
10618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10619 "get_paid_match"},
10620
10621 {WE_GET_PPS_GID_MATCH,
10622 0,
10623 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10624 "get_gid_match"},
10625
10626 {WE_GET_PPS_EARLY_TIM_CLEAR,
10627 0,
10628 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10629 "get_tim_clear"},
10630
10631 {WE_GET_PPS_EARLY_DTIM_CLEAR,
10632 0,
10633 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10634 "get_dtim_clear"},
10635
10636 {WE_GET_PPS_EOF_PAD_DELIM,
10637 0,
10638 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10639 "get_eof_delim"},
10640
10641 {WE_GET_PPS_MACADDR_MISMATCH,
10642 0,
10643 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10644 "get_mac_match"},
10645
10646 {WE_GET_PPS_DELIM_CRC_FAIL,
10647 0,
10648 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10649 "get_delim_fail"},
10650
10651 {WE_GET_PPS_GID_NSTS_ZERO,
10652 0,
10653 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10654 "get_nsts_zero"},
10655
10656 {WE_GET_PPS_RSSI_CHECK,
10657 0,
10658 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10659 "get_rssi_chk"},
10660
10661 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
10662 0,
10663 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10664 "get_qpspollcnt"},
10665
10666 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
10667 0,
10668 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10669 "get_qtxwake"},
10670
10671 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
10672 0,
10673 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10674 "get_qwakeintv"},
10675
10676 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
10677 0,
10678 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10679 "get_qnodatapoll"},
10680
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010681 {WE_CAP_TSF,
10682 0,
10683 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10684 "cap_tsf"},
10685
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010686 {WE_GET_TEMPERATURE,
10687 0,
10688 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10689 "get_temp"},
10690 /* handlers for main ioctl */
10691 {WLAN_PRIV_SET_CHAR_GET_NONE,
10692 IW_PRIV_TYPE_CHAR | 512,
10693 0,
10694 ""},
10695
10696 /* handlers for sub-ioctl */
10697 {WE_WOWL_ADD_PTRN,
10698 IW_PRIV_TYPE_CHAR | 512,
10699 0,
10700 "wowlAddPtrn"},
10701
10702 {WE_WOWL_DEL_PTRN,
10703 IW_PRIV_TYPE_CHAR | 512,
10704 0,
10705 "wowlDelPtrn"},
10706
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010707 /* handlers for sub-ioctl */
10708 {WE_NEIGHBOR_REPORT_REQUEST,
10709 IW_PRIV_TYPE_CHAR | 512,
10710 0,
10711 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080010712
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010713 {WE_SET_AP_WPS_IE,
10714 IW_PRIV_TYPE_CHAR | 512,
10715 0,
10716 "set_ap_wps_ie"},
10717
10718 {WE_SET_CONFIG,
10719 IW_PRIV_TYPE_CHAR | 512,
10720 0,
10721 "setConfig"},
10722
10723 /* handlers for main ioctl */
10724 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
10725 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10726 0,
10727 ""},
10728
10729 /* handlers for sub-ioctl */
10730 {WE_SET_WLAN_DBG,
10731 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10732 0,
10733 "setwlandbg"},
10734
10735 /* handlers for sub-ioctl */
10736 {WE_SET_DP_TRACE,
10737 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10738 0,
10739 "set_dp_trace"},
10740
10741 {WE_SET_SAP_CHANNELS,
10742 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10743 0,
10744 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053010745
10746 {WE_SET_FW_TEST,
10747 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10748 0, "fw_test"},
10749
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010750 /* handlers for main ioctl */
10751 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
10752 0,
10753 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10754 "" },
10755 {WE_GET_TSF,
10756 0,
10757 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10758 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010759
10760 {WE_SET_DUAL_MAC_SCAN_CONFIG,
10761 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10762 0,
10763 "set_scan_cfg"},
10764
10765 /* handlers for main ioctl */
10766 {WLAN_PRIV_GET_CHAR_SET_NONE,
10767 0,
10768 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10769 ""},
10770
10771 /* handlers for sub-ioctl */
10772 {WE_WLAN_VERSION,
10773 0,
10774 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10775 "version"},
10776 {WE_GET_STATS,
10777 0,
10778 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10779 "getStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053010780 {WE_LIST_FW_PROFILE,
10781 0,
10782 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10783 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010784 {WE_GET_STATES,
10785 0,
10786 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10787 "getHostStates"},
10788 {WE_GET_CFG,
10789 0,
10790 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10791 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010792 {WE_GET_RSSI,
10793 0,
10794 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10795 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010796 {WE_GET_WMM_STATUS,
10797 0,
10798 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10799 "getWmmStatus"},
10800 {
10801 WE_GET_CHANNEL_LIST,
10802 0,
10803 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10804 "getChannelList"
10805 },
10806#ifdef FEATURE_WLAN_TDLS
10807 {
10808 WE_GET_TDLS_PEERS,
10809 0,
10810 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10811 "getTdlsPeers"
10812 },
10813#endif
10814#ifdef WLAN_FEATURE_11W
10815 {
10816 WE_GET_11W_INFO,
10817 0,
10818 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10819 "getPMFInfo"
10820 },
10821#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010822 {
10823 WE_GET_IBSS_STA_INFO,
10824 0,
10825 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10826 "getIbssSTAs"
10827 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010828 {WE_GET_PHYMODE,
10829 0,
10830 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10831 "getphymode"},
10832#ifdef FEATURE_OEM_DATA_SUPPORT
10833 {WE_GET_OEM_DATA_CAP,
10834 0,
10835 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10836 "getOemDataCap"},
10837#endif /* FEATURE_OEM_DATA_SUPPORT */
10838 {WE_GET_SNR,
10839 0,
10840 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10841 "getSNR"},
10842
10843 /* handlers for main ioctl */
10844 {WLAN_PRIV_SET_NONE_GET_NONE,
10845 0,
10846 0,
10847 ""},
10848
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010849 /* handlers for sub-ioctl */
10850 {
10851 WE_IBSS_GET_PEER_INFO_ALL,
10852 0,
10853 0,
10854 "ibssPeerInfoAll"
10855 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010856 {WE_GET_RECOVERY_STAT,
10857 0,
10858 0,
10859 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053010860
10861 {WE_GET_FW_PROFILE_DATA,
10862 0,
10863 0,
10864 "getProfileData"},
10865
10866 {WE_SET_REASSOC_TRIGGER,
10867 0,
10868 0,
10869 "reassoc"},
10870
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010871 {WE_DUMP_AGC_START,
10872 0,
10873 0,
10874 "dump_agc_start"},
10875
10876 {WE_DUMP_AGC,
10877 0,
10878 0,
10879 "dump_agc"},
10880
10881 {WE_DUMP_CHANINFO_START,
10882 0,
10883 0,
10884 "dump_chninfo_en"},
10885
10886 {WE_DUMP_CHANINFO,
10887 0,
10888 0,
10889 "dump_chninfo"},
10890
10891 {WE_DUMP_WATCHDOG,
10892 0,
10893 0,
10894 "dump_watchdog"},
10895#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
10896 {WE_DUMP_PCIE_LOG,
10897 0,
10898 0,
10899 "dump_pcie_log"},
10900#endif
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010901 {WE_STOP_OBSS_SCAN,
10902 0,
10903 0,
10904 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010905 /* handlers for main ioctl */
10906 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
10907 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10908 0,
10909 ""},
10910
10911 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010912 {WE_IBSS_GET_PEER_INFO,
10913 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10914 0,
10915 "ibssPeerInfo"},
10916
10917 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010918 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10919 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10920 0,
10921 "setdumplog"},
10922
10923 {WE_MTRACE_DUMP_CMD,
10924 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10925 0,
10926 "dumplog"},
10927#ifdef MPC_UT_FRAMEWORK
10928 {WE_POLICY_MANAGER_CLIST_CMD,
10929 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10930 0,
10931 "pm_clist"},
10932
10933 {WE_POLICY_MANAGER_DLIST_CMD,
10934 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10935 0,
10936 "pm_dlist"},
10937
10938 {WE_POLICY_MANAGER_DBS_CMD,
10939 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10940 0,
10941 "pm_dbs"},
10942
10943 {WE_POLICY_MANAGER_PCL_CMD,
10944 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10945 0,
10946 "pm_pcl"},
10947
10948 {WE_POLICY_MANAGER_CINFO_CMD,
10949 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10950 0,
10951 "pm_cinfo"},
10952
10953 {WE_POLICY_MANAGER_ULIST_CMD,
10954 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10955 0,
10956 "pm_ulist"},
10957
10958 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
10959 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10960 0,
10961 "pm_query_action"},
10962
10963 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
10964 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10965 0,
10966 "pm_query_allow"},
10967
10968 {WE_POLICY_MANAGER_SCENARIO_CMD,
10969 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10970 0,
10971 "pm_run_scenario"},
10972
10973 {WE_POLICY_SET_HW_MODE_CMD,
10974 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10975 0,
10976 "pm_set_hw_mode"},
10977#endif
10978#ifdef FEATURE_WLAN_TDLS
10979 /* handlers for sub ioctl */
10980 {
10981 WE_TDLS_CONFIG_PARAMS,
10982 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10983 0,
10984 "setTdlsConfig"
10985 },
10986#endif
10987 {
10988 WE_UNIT_TEST_CMD,
10989 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10990 0,
10991 "setUnitTestCmd"
10992 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053010993 {
10994 WE_MAC_PWR_DEBUG_CMD,
10995 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10996 0,
10997 "halPwrDebug"
10998 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010999
11000#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
11001 {WE_LED_FLASHING_PARAM,
11002 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11003 0,
11004 "gpio_control"},
11005#endif
11006 /* handlers for main ioctl */
11007 {WLAN_PRIV_ADD_TSPEC,
11008 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11009 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11010 "addTspec"},
11011
11012 /* handlers for main ioctl */
11013 {WLAN_PRIV_DEL_TSPEC,
11014 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11015 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11016 "delTspec"},
11017
11018 /* handlers for main ioctl */
11019 {WLAN_PRIV_GET_TSPEC,
11020 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11021 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11022 "getTspec"},
11023
11024 /* handlers for main ioctl - host offload */
11025 {
11026 WLAN_PRIV_SET_HOST_OFFLOAD,
11027 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11028 0,
11029 "setHostOffload"
11030 }
11031 ,
11032
11033 {
11034 WLAN_GET_WLAN_STATISTICS,
11035 0,
11036 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11037 "getWlanStats"
11038 }
11039 ,
11040
11041 {
11042 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053011043 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
11044 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011045 0,
11046 "setKeepAlive"
11047 }
11048 ,
11049#ifdef WLAN_FEATURE_PACKET_FILTERING
11050 {
11051 WLAN_SET_PACKET_FILTER_PARAMS,
11052 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED |
11053 sizeof(struct pkt_filter_cfg),
11054 0,
11055 "setPktFilter"
11056 }
11057 ,
11058#endif
11059#ifdef FEATURE_WLAN_SCAN_PNO
11060 {
11061 WLAN_SET_PNO,
11062 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11063 0,
11064 "setpno"
11065 }
11066 ,
11067#endif
11068 {
11069 WLAN_SET_BAND_CONFIG,
11070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11071 0,
11072 "SETBAND"
11073 }
11074 ,
11075 {
11076 WLAN_GET_LINK_SPEED,
11077 IW_PRIV_TYPE_CHAR | 18,
11078 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
11079 }
11080 ,
11081
11082 /* handlers for main ioctl */
11083 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
11084 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11085 0,
11086 ""}
11087 ,
11088 {WE_SET_SMPS_PARAM,
11089 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11090 0, "set_smps_param"}
11091 ,
11092 {WLAN_SET_DOT11P_CHANNEL_SCHED,
11093 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
11094 0, "set_dot11p" }
11095 ,
11096#ifdef DEBUG
11097 {WE_SET_FW_CRASH_INJECT,
11098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11099 0, "crash_inject"}
11100 ,
11101#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070011102#ifdef WLAN_SUSPEND_RESUME_TEST
11103 {WE_SET_WLAN_SUSPEND,
11104 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11105 0, "wlan_suspend"}
11106 ,
11107 {WE_SET_WLAN_RESUME,
11108 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11109 0, "wlan_resume"}
11110 ,
11111#endif
Govind Singha471e5e2015-10-12 17:11:14 +053011112 {WE_ENABLE_FW_PROFILE,
11113 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11114 0, "enableProfile"}
11115 ,
11116 {WE_SET_FW_PROFILE_HIST_INTVL,
11117 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11118 0, "set_hist_intvl"}
11119 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011120 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
11121 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11122 0, "set_fw_mode_cfg"}
11123 ,
11124 {WE_DUMP_DP_TRACE_LEVEL,
11125 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11126 0, "dump_dp_trace"}
11127 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070011128 {WE_SET_MON_MODE_CHAN,
11129 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11130 0, "setMonChan"}
11131 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070011132
11133 {WE_GET_ROAM_SYNCH_DELAY,
11134 0,
11135 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11136 "hostroamdelay"}
11137 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011138};
11139
11140const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053011141 .num_standard = QDF_ARRAY_SIZE(we_handler),
11142 .num_private = QDF_ARRAY_SIZE(we_private),
11143 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011144
11145 .standard = (iw_handler *) we_handler,
11146 .private = (iw_handler *) we_private,
11147 .private_args = we_private_args,
11148 .get_wireless_stats = NULL,
11149};
11150
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011151/* hdd_set_wext() - configures bss parameters
11152 * @pAdapter: handle to adapter context
11153 *
11154 * Returns: none
11155 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070011156static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011157{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011158 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11159 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011160
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011161 ENTER();
11162
11163 if (!pwextBuf) {
11164 hdd_err("ERROR: pwextBuf is NULL");
11165 return QDF_STATUS_E_FAILURE;
11166 }
11167
11168 if (!pHddStaCtx) {
11169 hdd_err("ERROR: pHddStaCtx is NULL");
11170 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011171 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011172
11173 /* Now configure the roaming profile links. To SSID and bssid. */
11174 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011175 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011176
11177 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011178 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011179
11180 /*Set the numOfChannels to zero to scan all the channels */
11181 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11182 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11183
11184 /* Default is no encryption */
11185 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11186 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
11187 eCSR_ENCRYPT_TYPE_NONE;
11188
11189 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11190 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
11191 eCSR_ENCRYPT_TYPE_NONE;
11192
11193 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11194
11195 /* Default is no authentication */
11196 pwextBuf->roamProfile.AuthType.numEntries = 1;
11197 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11198
11199 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
11200 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11201
11202 /*Set the default scan mode */
11203 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
11204
11205 hdd_clear_roam_profile_ie(pAdapter);
11206
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011207 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011208 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011209
11210}
11211
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011212/**
11213 * hdd_register_wext() - register wext context
11214 * @dev: net device handle
11215 *
11216 * Registers wext interface context for a given net device
11217 *
11218 * Returns: 0 on success, errno on failure
11219 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011220int hdd_register_wext(struct net_device *dev)
11221{
11222 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011223 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011224 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011225
11226 ENTER();
11227
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011228 if (!pwextBuf) {
11229 hdd_err(FL("ERROR: pwextBuf is NULL"));
11230 return QDF_STATUS_E_FAILURE;
11231 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011232
11233 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011234 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
11235
11236 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->
11237 completion_var);
11238
11239 status = hdd_set_wext(pAdapter);
11240
Anurag Chouhance0dc992016-02-16 18:18:03 +053011241 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011242
Jeff Johnson99bac312016-06-28 10:38:18 -070011243 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011244 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011245 }
11246
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011247 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->hdd_qdf_event))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011248 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011249 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011250 }
11251
Anurag Chouhance0dc992016-02-16 18:18:03 +053011252 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->scanevent))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011253 hdd_err("ERROR: HDD scan event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011254 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011255 }
11256 /* Register as a wireless device */
11257 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11258
11259 EXIT();
11260 return 0;
11261}
11262
11263int hdd_unregister_wext(struct net_device *dev)
11264{
Jeff Johnson99bac312016-06-28 10:38:18 -070011265 hdd_notice("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011266
11267 if (dev != NULL) {
11268 rtnl_lock();
11269 dev->wireless_handlers = NULL;
11270 rtnl_unlock();
11271 }
11272
11273 return 0;
11274}