blob: cffa762b64761909b2ad4145eedd37669161fa40 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_wext.c
30 *
31 * Linux Wireless Extensions Implementation
32 */
33
Jeff Johnson99bac312016-06-28 10:38:18 -070034/* denote that this file does not allow legacy hddLog */
35#define HDD_DISALLOW_LEGACY_HDDLOG 1
36
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037#include <linux/version.h>
38#include <linux/module.h>
39#include <linux/kernel.h>
40#include <linux/init.h>
41#include <linux/wireless.h>
42#include <mac_trace.h>
43#include <wlan_hdd_includes.h>
44#include <cds_api.h>
45#include <net/arp.h>
Manjunathappa Prakash3454fd62016-04-01 08:52:06 -070046#include <cdp_txrx_stats.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "sir_params.h"
48#include "csr_api.h"
49#include "csr_inside_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "sme_rrm_internal.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051#include <ani_global.h>
52#include "dot11f.h"
53#include <wlan_hdd_wowl.h>
54#include <wlan_hdd_cfg.h>
55#include <wlan_hdd_wmm.h>
56#include "utils_api.h"
57#include "wlan_hdd_p2p.h"
58#ifdef FEATURE_WLAN_TDLS
59#include "wlan_hdd_tdls.h"
60#endif
61
62#include "cds_ieee80211_common.h"
63#include "ol_if_athvar.h"
64#include "dbglog_host.h"
65#include "wma.h"
66
67#include "wlan_hdd_power.h"
68#include "qwlan_version.h"
69#include "wlan_hdd_host_offload.h"
70
71#include <linux/wireless.h>
72#include <net/cfg80211.h>
73
74#include "wlan_hdd_misc.h"
75
76#include "qc_sap_ioctl.h"
77#include "sme_api.h"
78#include "wma_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053079#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080#include "wlan_hdd_assoc.h"
81#include "wlan_hdd_ioctl.h"
82#include "wlan_hdd_scan.h"
83#include "sme_power_save_api.h"
84#include "cds_concurrency.h"
85#include "wlan_hdd_conc_ut.h"
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070086#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087#include "wlan_hdd_ocb.h"
88#include "wlan_hdd_napi.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080089#include "cdp_txrx_flow_ctrl_legacy.h"
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070090#include "wlan_hdd_nan_datapath.h"
Nirav Shahbf1b0332016-05-25 14:27:39 +053091#include "wlan_hdd_stats.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070092#ifdef WLAN_SUSPEND_RESUME_TEST
93#include "wlan_hdd_driver_ops.h"
94#include "hif.h"
Rajeev Kumar9bb2e852016-09-24 12:29:25 -070095#include "pld_common.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070096#endif
Dhanashri Atree7d442a2016-07-14 18:20:29 -070097#include "wlan_hdd_lro.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099#define HDD_FINISH_ULA_TIME_OUT 800
100#define HDD_SET_MCBC_FILTERS_TO_FW 1
101#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103static int ioctl_debug;
104module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
105
106/* To Validate Channel against the Frequency and Vice-Versa */
107static const hdd_freq_chan_map_t freq_chan_map[] = {
108 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
109 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
110 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
111 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
112 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
113 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
114 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
115 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
116 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
117 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
118 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
119 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
120
121#define FREQ_CHAN_MAP_TABLE_SIZE \
122 (sizeof(freq_chan_map) / sizeof(freq_chan_map[0]))
123
124/* Private ioctls and their sub-ioctls */
125#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
126#define WE_SET_11D_STATE 1
127#define WE_WOWL 2
128#define WE_SET_POWER 3
129#define WE_SET_MAX_ASSOC 4
130#define WE_SET_SCAN_DISABLE 5
131#define WE_SET_DATA_INACTIVITY_TO 6
132#define WE_SET_MAX_TX_POWER 7
133#define WE_SET_HIGHER_DTIM_TRANSITION 8
134#define WE_SET_TM_LEVEL 9
135#define WE_SET_PHYMODE 10
136#define WE_SET_NSS 11
137#define WE_SET_LDPC 12
138#define WE_SET_TX_STBC 13
139#define WE_SET_RX_STBC 14
140#define WE_SET_SHORT_GI 15
141#define WE_SET_RTSCTS 16
142#define WE_SET_CHWIDTH 17
143#define WE_SET_ANI_EN_DIS 18
144#define WE_SET_ANI_POLL_PERIOD 19
145#define WE_SET_ANI_LISTEN_PERIOD 20
146#define WE_SET_ANI_OFDM_LEVEL 21
147#define WE_SET_ANI_CCK_LEVEL 22
148#define WE_SET_DYNAMIC_BW 23
149#define WE_SET_TX_CHAINMASK 24
150#define WE_SET_RX_CHAINMASK 25
151#define WE_SET_11N_RATE 26
152#define WE_SET_AMPDU 27
153#define WE_SET_AMSDU 28
154#define WE_SET_TXPOW_2G 29
155#define WE_SET_TXPOW_5G 30
156/* Private ioctl for firmware debug log */
157#define WE_DBGLOG_LOG_LEVEL 31
158#define WE_DBGLOG_VAP_ENABLE 32
159#define WE_DBGLOG_VAP_DISABLE 33
160#define WE_DBGLOG_MODULE_ENABLE 34
161#define WE_DBGLOG_MODULE_DISABLE 35
162#define WE_DBGLOG_MOD_LOG_LEVEL 36
163#define WE_DBGLOG_TYPE 37
164#define WE_SET_TXRX_FWSTATS 38
165#define WE_SET_VHT_RATE 39
166#define WE_DBGLOG_REPORT_ENABLE 40
167#define WE_TXRX_FWSTATS_RESET 41
168#define WE_SET_MAX_TX_POWER_2_4 42
169#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800170#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171/* Private ioctl for packet powe save */
172#define WE_PPS_PAID_MATCH 45
173#define WE_PPS_GID_MATCH 46
174#define WE_PPS_EARLY_TIM_CLEAR 47
175#define WE_PPS_EARLY_DTIM_CLEAR 48
176#define WE_PPS_EOF_PAD_DELIM 49
177#define WE_PPS_MACADDR_MISMATCH 50
178#define WE_PPS_DELIM_CRC_FAIL 51
179#define WE_PPS_GID_NSTS_ZERO 52
180#define WE_PPS_RSSI_CHECK 53
181#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
182#define WE_SET_HTSMPS 55
183/* Private ioctl for QPower */
184#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
185#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
186#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
187#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
188
189#define WE_SET_BURST_ENABLE 60
190#define WE_SET_BURST_DUR 61
191/* GTX Commands */
192#define WE_SET_GTX_HT_MCS 62
193#define WE_SET_GTX_VHT_MCS 63
194#define WE_SET_GTX_USRCFG 64
195#define WE_SET_GTX_THRE 65
196#define WE_SET_GTX_MARGIN 66
197#define WE_SET_GTX_STEP 67
198#define WE_SET_GTX_MINTPC 68
199#define WE_SET_GTX_BWMASK 69
200/* Private ioctl to configure MCC home channels time quota and latency */
201#define WE_MCC_CONFIG_LATENCY 70
202#define WE_MCC_CONFIG_QUOTA 71
203/* Private IOCTL for debug connection issues */
204#define WE_SET_DEBUG_LOG 72
205#ifdef WE_SET_TX_POWER
206#undef WE_SET_TX_POWER
207#endif
208#define WE_SET_TX_POWER 74
209/* Private ioctl for earlyrx power save feature */
210#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
211#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
212#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
213#define WE_SET_EARLY_RX_SLOP_STEP 78
214#define WE_SET_EARLY_RX_INIT_SLOP 79
215#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
216#define WE_SET_MC_RATE 81
217#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
218/* Private ioctl for packet power save */
219#define WE_PPS_5G_EBT 83
220#define WE_SET_CTS_CBW 84
221#define WE_DUMP_STATS 85
222#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +0530223/* Private sub ioctl for starting/stopping the profiling */
224#define WE_START_FW_PROFILE 87
Abhishek Singh1bdb1572015-10-16 16:24:19 +0530225#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +0530226#define WE_SET_CONC_SYSTEM_PREF 89
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227
228/* Private ioctls and their sub-ioctls */
229#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
230#define WE_GET_11D_STATE 1
231#define WE_IBSS_STATUS 2
232#define WE_SET_SAP_CHANNELS 3
233#define WE_GET_WLAN_DBG 4
234#define WE_GET_MAX_ASSOC 6
235/* 7 is unused */
236#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
237#define WE_GET_CONCURRENCY_MODE 9
238#define WE_GET_NSS 11
239#define WE_GET_LDPC 12
240#define WE_GET_TX_STBC 13
241#define WE_GET_RX_STBC 14
242#define WE_GET_SHORT_GI 15
243#define WE_GET_RTSCTS 16
244#define WE_GET_CHWIDTH 17
245#define WE_GET_ANI_EN_DIS 18
246#define WE_GET_ANI_POLL_PERIOD 19
247#define WE_GET_ANI_LISTEN_PERIOD 20
248#define WE_GET_ANI_OFDM_LEVEL 21
249#define WE_GET_ANI_CCK_LEVEL 22
250#define WE_GET_DYNAMIC_BW 23
251#define WE_GET_TX_CHAINMASK 24
252#define WE_GET_RX_CHAINMASK 25
253#define WE_GET_11N_RATE 26
254#define WE_GET_AMPDU 27
255#define WE_GET_AMSDU 28
256#define WE_GET_TXPOW_2G 29
257#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -0800258/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259#define WE_GET_PPS_PAID_MATCH 32
260#define WE_GET_PPS_GID_MATCH 33
261#define WE_GET_PPS_EARLY_TIM_CLEAR 34
262#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
263#define WE_GET_PPS_EOF_PAD_DELIM 36
264#define WE_GET_PPS_MACADDR_MISMATCH 37
265#define WE_GET_PPS_DELIM_CRC_FAIL 38
266#define WE_GET_PPS_GID_NSTS_ZERO 39
267#define WE_GET_PPS_RSSI_CHECK 40
268/* Private ioctl for QPower */
269#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
270#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
271#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
272#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
273#define WE_GET_BURST_ENABLE 45
274#define WE_GET_BURST_DUR 46
275/* GTX Commands */
276#define WE_GET_GTX_HT_MCS 47
277#define WE_GET_GTX_VHT_MCS 48
278#define WE_GET_GTX_USRCFG 49
279#define WE_GET_GTX_THRE 50
280#define WE_GET_GTX_MARGIN 51
281#define WE_GET_GTX_STEP 52
282#define WE_GET_GTX_MINTPC 53
283#define WE_GET_GTX_BWMASK 54
284#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700285#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700286#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287
288/* Private ioctls and their sub-ioctls */
289#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
290
291/* Private ioctls and their sub-ioctls */
292#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
293#define WE_WOWL_ADD_PTRN 1
294#define WE_WOWL_DEL_PTRN 2
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295#define WE_NEIGHBOR_REPORT_REQUEST 3
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296#define WE_SET_AP_WPS_IE 4 /* This is called in station mode to set probe rsp ie. */
297#define WE_SET_CONFIG 5
298
299/* Private ioctls and their sub-ioctls */
300#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
301#define WE_SET_WLAN_DBG 1
302#define WE_SET_DP_TRACE 2
303#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +0530304#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305
306/* Private ioctls and their sub-ioctls */
307#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
308#define WE_WLAN_VERSION 1
309#define WE_GET_STATS 2
310#define WE_GET_CFG 3
311#define WE_GET_WMM_STATUS 4
312#define WE_GET_CHANNEL_LIST 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313#define WE_GET_RSSI 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314#ifdef FEATURE_WLAN_TDLS
315#define WE_GET_TDLS_PEERS 8
316#endif
317#ifdef WLAN_FEATURE_11W
318#define WE_GET_11W_INFO 9
319#endif
320#define WE_GET_STATES 10
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800321#define WE_GET_IBSS_STA_INFO 11
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322#define WE_GET_PHYMODE 12
323#ifdef FEATURE_OEM_DATA_SUPPORT
324#define WE_GET_OEM_DATA_CAP 13
325#endif
326#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +0530327#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800328
329/* Private ioctls and their sub-ioctls */
330#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
331#define WE_SET_REASSOC_TRIGGER 8
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800332#define WE_IBSS_GET_PEER_INFO_ALL 10
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333#define WE_DUMP_AGC_START 11
334#define WE_DUMP_AGC 12
335#define WE_DUMP_CHANINFO_START 13
336#define WE_DUMP_CHANINFO 14
337#define WE_DUMP_WATCHDOG 15
338#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
339#define WE_DUMP_PCIE_LOG 16
340#endif
341#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -0800342#define WE_GET_FW_PROFILE_DATA 18
343#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344
345/* Private ioctls and their sub-ioctls */
346#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
347
348#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +0530349/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350
Manjeet Singhf82ed072016-07-08 11:40:00 +0530351#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352
353#ifdef FEATURE_WLAN_TDLS
354#define WE_TDLS_CONFIG_PARAMS 5
355#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800356#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357#define WE_UNIT_TEST_CMD 7
358
359#define WE_MTRACE_DUMP_CMD 8
360#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
361
362
363#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
364#define WE_LED_FLASHING_PARAM 10
365#endif
366
367#define WE_POLICY_MANAGER_CLIST_CMD 11
368#define WE_POLICY_MANAGER_DLIST_CMD 12
369#define WE_POLICY_MANAGER_DBS_CMD 13
370#define WE_POLICY_MANAGER_PCL_CMD 14
371#define WE_POLICY_MANAGER_CINFO_CMD 15
372#define WE_POLICY_MANAGER_ULIST_CMD 16
373#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
374#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
375#define WE_POLICY_MANAGER_SCENARIO_CMD 19
376#define WE_POLICY_SET_HW_MODE_CMD 20
377
378#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
379#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -0700380#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381
382#ifdef FEATURE_WLAN_TDLS
383#undef MAX_VAR_ARGS
384#define MAX_VAR_ARGS 11
385#else
386#undef MAX_VAR_ARGS
387#define MAX_VAR_ARGS 9
388#endif
389
390/* Private ioctls (with no sub-ioctls) */
391/* note that they must be odd so that they have "get" semantics */
392#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
393#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
394#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
395
396/* (SIOCIWFIRSTPRIV + 8) is currently unused */
397/* (SIOCIWFIRSTPRIV + 10) is currently unused */
398/* (SIOCIWFIRSTPRIV + 12) is currently unused */
399/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700400#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
401#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402/* (SIOCIWFIRSTPRIV + 16) is currently unused */
403/* (SIOCIWFIRSTPRIV + 17) is currently unused */
404/* (SIOCIWFIRSTPRIV + 19) is currently unused */
405
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800407
408/* Private ioctl for setting the host offload feature */
409#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
410
411/* Private ioctl to get the statistics */
412#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
413
414/* Private ioctl to set the Keep Alive Params */
415#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
416
417#ifdef WLAN_FEATURE_PACKET_FILTERING
418/* Private ioctl to set the packet filtering params */
419#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
420#endif
421
422
423#ifdef FEATURE_WLAN_SCAN_PNO
424/* Private ioctl to get the statistics */
425#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
426#endif
427
428#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
429
430/* (SIOCIWFIRSTPRIV + 26) is currently unused */
431/* (SIOCIWFIRSTPRIV + 27) is currently unused */
432
433/* Private ioctls and their sub-ioctls */
434#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
435#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -0700436#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437#define WE_SET_FW_CRASH_INJECT 2
438#endif
439#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +0530440/* Private sub ioctl for enabling and setting histogram interval of profiling */
441#define WE_ENABLE_FW_PROFILE 4
442#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443
Rajeev Kumar9bb2e852016-09-24 12:29:25 -0700444/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -0700445#define WE_SET_WLAN_SUSPEND 6
446#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -0700447
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448/* (SIOCIWFIRSTPRIV + 29) is currently unused */
449
450/* 802.11p IOCTL */
451#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
452
453#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
454
455#define WLAN_STATS_INVALID 0
456#define WLAN_STATS_RETRY_CNT 1
457#define WLAN_STATS_MUL_RETRY_CNT 2
458#define WLAN_STATS_TX_FRM_CNT 3
459#define WLAN_STATS_RX_FRM_CNT 4
460#define WLAN_STATS_FRM_DUP_CNT 5
461#define WLAN_STATS_FAIL_CNT 6
462#define WLAN_STATS_RTS_FAIL_CNT 7
463#define WLAN_STATS_ACK_FAIL_CNT 8
464#define WLAN_STATS_RTS_SUC_CNT 9
465#define WLAN_STATS_RX_DISCARD_CNT 10
466#define WLAN_STATS_RX_ERROR_CNT 11
467#define WLAN_STATS_TX_BYTE_CNT 12
468
469#define WLAN_STATS_RX_BYTE_CNT 13
470#define WLAN_STATS_RX_RATE 14
471#define WLAN_STATS_TX_RATE 15
472
473#define WLAN_STATS_RX_UC_BYTE_CNT 16
474#define WLAN_STATS_RX_MC_BYTE_CNT 17
475#define WLAN_STATS_RX_BC_BYTE_CNT 18
476#define WLAN_STATS_TX_UC_BYTE_CNT 19
477#define WLAN_STATS_TX_MC_BYTE_CNT 20
478#define WLAN_STATS_TX_BC_BYTE_CNT 21
479
480#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
481 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
482 *__p++ = __type; \
483 *__p++ = __size; \
484 memcpy(__p, __val, __size); \
485 __p += __size; \
486 __tlen += __size + 2; \
487 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -0700488 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800489 } \
490 } while (0)
491
492#define VERSION_VALUE_MAX_LEN 32
493
494#define TX_PER_TRACKING_DEFAULT_RATIO 5
495#define TX_PER_TRACKING_MAX_RATIO 10
496#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
497
498#define WLAN_ADAPTER 0
499#define P2P_ADAPTER 1
500
501/**
502 * mem_alloc_copy_from_user_helper - copy from user helper
503 * @wrqu_data: wireless extensions request data
504 * @len: length of @wrqu_data
505 *
506 * Helper function to allocate buffer and copy user data.
507 *
508 * Return: On success return a pointer to a kernel buffer containing a
509 * copy of the userspace data (with an additional NUL character
510 * appended for safety). On failure return %NULL.
511 */
512void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
513{
514 u8 *ptr = NULL;
515
516 /* in order to protect the code, an extra byte is post
517 * appended to the buffer and the null termination is added.
518 * However, when allocating (len+1) byte of memory, we need to
519 * make sure that there is no uint overflow when doing
520 * addition. In theory check len < UINT_MAX protects the uint
521 * overflow. For wlan private ioctl, the buffer size is much
522 * less than UINT_MAX, as a good guess, now, it is assumed
523 * that the private command buffer size is no greater than 4K
524 * (4096 bytes). So we use 4096 as the upper boundary for now.
525 */
526 if (len > MAX_USER_COMMAND_SIZE) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700527 hdd_err("Invalid length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800528 return NULL;
529 }
530
531 ptr = kmalloc(len + 1, GFP_KERNEL);
532 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700533 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800534 return NULL;
535 }
536
537 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700538 hdd_err("failed to copy data to user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800539 kfree(ptr);
540 return NULL;
541 }
542 ptr[len] = '\0';
543 return ptr;
544}
545
546/**
547 * hdd_priv_get_data() - Get pointer to ioctl private data
548 * @p_priv_data: pointer to iw_point struct to be filled
549 * @wrqu: Pointer to IOCTL Data received from userspace
550 *
551 * Helper function to get compatible struct iw_point passed to ioctl
552 *
553 * Return - 0 if p_priv_data successfully filled, error otherwise
554 */
555int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
556{
557 if ((NULL == p_priv_data) || (NULL == wrqu)) {
558 return -EINVAL;
559 }
560#ifdef CONFIG_COMPAT
561 if (is_compat_task()) {
562 struct compat_iw_point *p_compat_priv_data;
563
564 /* Compat task:
565 * typecast to compat structure and copy the members.
566 */
567 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
568
569 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
570 p_priv_data->length = p_compat_priv_data->length;
571 p_priv_data->flags = p_compat_priv_data->flags;
572 } else {
573#endif /* #ifdef CONFIG_COMPAT */
574
575 /* Non compat task: directly copy the structure. */
576 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
577
578#ifdef CONFIG_COMPAT
579 }
580#endif /* #ifdef CONFIG_COMPAT */
581
582 return 0;
583}
584
585
586/**
587 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
588 * @pAdapter: Pointer to the hdd adapter.
589 * @length: Size of the data copied
590 * @buffer: Pointer to char buffer.
591 * @buf_len: Length of the char buffer.
592 *
593 * This function called when the "iwpriv wlan0 get_stats" command is given.
594 * It used to collect the txrx stats when the device is configured in SAP mode.
595 *
596 * Return - none
597 */
598void hdd_wlan_get_stats(hdd_adapter_t *pAdapter, uint16_t *length,
599 char *buffer, uint16_t buf_len)
600{
601 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
602 uint32_t len = 0;
603 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
604 uint32_t total_rx_delv = 0, total_rx_refused = 0;
605 int i = 0;
606
607 for (; i < NUM_CPUS; i++) {
608 total_rx_pkt += pStats->rxPackets[i];
609 total_rx_dropped += pStats->rxDropped[i];
610 total_rx_delv += pStats->rxDelivered[i];
611 total_rx_refused += pStats->rxRefused[i];
612 }
613
614 len = scnprintf(buffer, buf_len,
615 "\nTransmit"
616 "\ncalled %u, dropped %u,"
617 "\n dropped BK %u, BE %u, VI %u, VO %u"
618 "\n classified BK %u, BE %u, VI %u, VO %u"
619 "\ncompleted %u,"
620 "\n\nReceive Total"
621 "\n packets %u, dropped %u, delivered %u, refused %u"
622 "\n",
623 pStats->txXmitCalled,
624 pStats->txXmitDropped,
625
626 pStats->txXmitDroppedAC[SME_AC_BK],
627 pStats->txXmitDroppedAC[SME_AC_BE],
628 pStats->txXmitDroppedAC[SME_AC_VI],
629 pStats->txXmitDroppedAC[SME_AC_VO],
630
631 pStats->txXmitClassifiedAC[SME_AC_BK],
632 pStats->txXmitClassifiedAC[SME_AC_BE],
633 pStats->txXmitClassifiedAC[SME_AC_VI],
634 pStats->txXmitClassifiedAC[SME_AC_VO],
635
636 pStats->txCompleted,
637 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
638 );
639
640 for (i = 0; i < NUM_CPUS; i++) {
641 len += scnprintf(buffer + len, buf_len - len,
642 "\nReceive CPU: %d"
643 "\n packets %u, dropped %u, delivered %u, refused %u",
644 i, pStats->rxPackets[i], pStats->rxDropped[i],
645 pStats->rxDelivered[i], pStats->rxRefused[i]);
646 }
647
648 len += scnprintf(buffer + len, buf_len - len,
649 "\n\nTX_FLOW"
650 "\nCurrent status: %s"
651 "\ntx-flow timer start count %u"
652 "\npause count %u, unpause count %u",
653 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
654 pStats->txflow_timer_cnt,
655 pStats->txflow_pause_cnt,
656 pStats->txflow_unpause_cnt);
657
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{
Houston Hoffman59c097f2016-11-09 15:50:25 -08001225 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226 hdd_context_t *pHddCtx;
1227 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301228 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 unsigned long rc;
1230
1231 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001232 hdd_warn("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301233 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08001235 if (cds_is_driver_recovering()) {
1236 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
1237 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 /* return a cached value */
1239 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301240 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 }
1242
1243 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1244 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1245
1246 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
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{
Houston Hoffman59c097f2016-11-09 15:50:25 -08001311 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 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;
Houston Hoffman59c097f2016-11-09 15:50:25 -08001458 static struct linkspeedContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459 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{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001628 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07001629
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001630 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001631
1632 /* clear WPA/RSN/WSC IE information in the profile */
1633 pWextState->roamProfile.nWPAReqIELength = 0;
1634 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
1635 pWextState->roamProfile.nRSNReqIELength = 0;
1636 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
1637
1638#ifdef FEATURE_WLAN_WAPI
1639 pWextState->roamProfile.nWAPIReqIELength = 0;
1640 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
1641#endif
1642
1643 pWextState->roamProfile.bWPSAssociation = false;
1644 pWextState->roamProfile.bOSENAssociation = false;
1645 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
1646 pWextState->roamProfile.nAddIEScanLength = 0;
1647 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
1648 pWextState->roamProfile.nAddIEAssocLength = 0;
1649
1650 pWextState->roamProfile.EncryptionType.numEntries = 1;
1651 pWextState->roamProfile.EncryptionType.encryptionType[0]
1652 = eCSR_ENCRYPT_TYPE_NONE;
1653
1654 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1655 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1656 = eCSR_ENCRYPT_TYPE_NONE;
1657
1658 pWextState->roamProfile.AuthType.numEntries = 1;
1659 pWextState->roamProfile.AuthType.authType[0] =
1660 eCSR_AUTH_TYPE_OPEN_SYSTEM;
1661
1662#ifdef WLAN_FEATURE_11W
1663 pWextState->roamProfile.MFPEnabled = false;
1664 pWextState->roamProfile.MFPRequired = 0;
1665 pWextState->roamProfile.MFPCapable = 0;
1666#endif
1667
1668 pWextState->authKeyMgmt = 0;
1669
Yingying Tang3cc6b792016-10-20 17:00:37 +08001670 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
1671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672#ifdef FEATURE_WLAN_WAPI
1673 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1674 pAdapter->wapi_info.nWapiMode = 0;
1675#endif
1676
Anurag Chouhanc5548422016-02-24 18:33:27 +05301677 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001678 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679}
1680
1681/**
1682 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
1683 * @oui: The OUI that is being searched for
1684 * @oui_size: The length of @oui
1685 * @ie: The set of IEs within which we're trying to find @oui
1686 * @ie_len: The length of @ie
1687 *
1688 * This function will scan the IEs contained within @ie looking for @oui.
1689 *
1690 * Return: Pointer to @oui embedded within @ie if it is present, NULL
1691 * if @oui is not present within @ie.
1692 */
1693uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
1694 uint8_t *ie, int ie_len)
1695{
1696 int left = ie_len;
1697 uint8_t *ptr = ie;
1698 uint8_t elem_id, elem_len;
1699 uint8_t eid = 0xDD;
1700
1701 if (NULL == ie || 0 == ie_len)
1702 return NULL;
1703
1704 while (left >= 2) {
1705 elem_id = ptr[0];
1706 elem_len = ptr[1];
1707 left -= 2;
1708 if (elem_len > left) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001709 hdd_alert("****Invalid IEs eid = %d elem_len=%d left=%d*****",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 eid, elem_len, left);
1711 return NULL;
1712 }
1713 if (elem_id == eid) {
1714 if (memcmp(&ptr[2], oui, oui_size) == 0)
1715 return ptr;
1716 }
1717
1718 left -= elem_len;
1719 ptr += (elem_len + 2);
1720 }
1721 return NULL;
1722}
1723
1724/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05301725 * hdd_get_ldpc() - Get adapter LDPC
1726 * @adapter: adapter being queried
1727 * @value: where to store the value
1728 *
1729 * Return: 0 on success, negative errno on failure
1730 */
1731int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
1732{
1733 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1734 int ret;
1735
1736 ENTER();
1737 ret = sme_get_ht_config(hal, adapter->sessionId,
1738 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
1739 if (ret < 0) {
1740 hdd_alert("Failed to get LDPC value");
1741 } else {
1742 *value = ret;
1743 ret = 0;
1744 }
1745 return ret;
1746}
1747
1748/**
1749 * hdd_set_ldpc() - Set adapter LDPC
1750 * @adapter: adapter being modified
1751 * @value: new LDPC value
1752 *
1753 * Return: 0 on success, negative errno on failure
1754 */
1755int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
1756{
1757 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1758 int ret;
1759
1760 hdd_alert("%d", value);
1761 if (value) {
1762 /* make sure HT capabilities allow this */
1763 QDF_STATUS status;
1764 uint32_t cfg_value;
1765 union {
1766 uint16_t cfg_value16;
1767 tSirMacHTCapabilityInfo ht_cap_info;
1768 } u;
1769
1770 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1771 if (QDF_STATUS_SUCCESS != status) {
1772 hdd_alert("Failed to get HT capability info");
1773 return -EIO;
1774 }
1775 u.cfg_value16 = cfg_value & 0xFFFF;
1776 if (!u.ht_cap_info.advCodingCap) {
1777 hdd_alert("LDCP not supported");
1778 return -EINVAL;
1779 }
1780 }
1781
1782 ret = sme_update_ht_config(hal, adapter->sessionId,
1783 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
1784 value);
1785 if (ret)
1786 hdd_alert("Failed to set LDPC value");
1787
1788 return ret;
1789}
1790
1791/**
1792 * hdd_get_tx_stbc() - Get adapter TX STBC
1793 * @adapter: adapter being queried
1794 * @value: where to store the value
1795 *
1796 * Return: 0 on success, negative errno on failure
1797 */
1798int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
1799{
1800 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1801 int ret;
1802
1803 ENTER();
1804 ret = sme_get_ht_config(hal, adapter->sessionId,
1805 WNI_CFG_HT_CAP_INFO_TX_STBC);
1806 if (ret < 0) {
1807 hdd_alert("Failed to get TX STBC value");
1808 } else {
1809 *value = ret;
1810 ret = 0;
1811 }
1812
1813 return ret;
1814}
1815
1816/**
1817 * hdd_set_tx_stbc() - Set adapter TX STBC
1818 * @adapter: adapter being modified
1819 * @value: new TX STBC value
1820 *
1821 * Return: 0 on success, negative errno on failure
1822 */
1823int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
1824{
1825 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1826 int ret;
1827
1828 hdd_alert("%d", value);
1829 if (value) {
1830 /* make sure HT capabilities allow this */
1831 QDF_STATUS status;
1832 uint32_t cfg_value;
1833 union {
1834 uint16_t cfg_value16;
1835 tSirMacHTCapabilityInfo ht_cap_info;
1836 } u;
1837
1838 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1839 if (QDF_STATUS_SUCCESS != status) {
1840 hdd_alert("Failed to get HT capability info");
1841 return -EIO;
1842 }
1843 u.cfg_value16 = cfg_value & 0xFFFF;
1844 if (!u.ht_cap_info.txSTBC) {
1845 hdd_alert("TX STBC not supported");
1846 return -EINVAL;
1847 }
1848 }
1849 ret = sme_update_ht_config(hal, adapter->sessionId,
1850 WNI_CFG_HT_CAP_INFO_TX_STBC,
1851 value);
1852 if (ret)
1853 hdd_alert("Failed to set TX STBC value");
1854
1855 return ret;
1856}
1857
1858/**
1859 * hdd_get_rx_stbc() - Get adapter RX STBC
1860 * @adapter: adapter being queried
1861 * @value: where to store the value
1862 *
1863 * Return: 0 on success, negative errno on failure
1864 */
1865int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
1866{
1867 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1868 int ret;
1869
1870 ENTER();
1871 ret = sme_get_ht_config(hal, adapter->sessionId,
1872 WNI_CFG_HT_CAP_INFO_RX_STBC);
1873 if (ret < 0) {
1874 hdd_alert("Failed to get RX STBC value");
1875 } else {
1876 *value = ret;
1877 ret = 0;
1878 }
1879
1880 return ret;
1881}
1882
1883/**
1884 * hdd_set_rx_stbc() - Set adapter RX STBC
1885 * @adapter: adapter being modified
1886 * @value: new RX STBC value
1887 *
1888 * Return: 0 on success, negative errno on failure
1889 */
1890int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
1891{
1892 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1893 int ret;
1894
1895 hdd_alert("%d", value);
1896 if (value) {
1897 /* make sure HT capabilities allow this */
1898 QDF_STATUS status;
1899 uint32_t cfg_value;
1900 union {
1901 uint16_t cfg_value16;
1902 tSirMacHTCapabilityInfo ht_cap_info;
1903 } u;
1904
1905 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1906 if (QDF_STATUS_SUCCESS != status) {
1907 hdd_alert("Failed to get HT capability info");
1908 return -EIO;
1909 }
1910 u.cfg_value16 = cfg_value & 0xFFFF;
1911 if (!u.ht_cap_info.rxSTBC) {
1912 hdd_alert("RX STBC not supported");
1913 return -EINVAL;
1914 }
1915 }
1916 ret = sme_update_ht_config(hal, adapter->sessionId,
1917 WNI_CFG_HT_CAP_INFO_RX_STBC,
1918 value);
1919 if (ret)
1920 hdd_alert("Failed to set RX STBC value");
1921
1922 return ret;
1923}
1924
1925/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
1927 * @dev: device upon which the ioctl was received
1928 * @info: ioctl request information
1929 * @wrqu: ioctl request data
1930 * @extra: ioctl extra data
1931 *
1932 * Return: 0 on success, non-zero on error
1933 */
1934static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1935 union iwreq_data *wrqu, char *extra)
1936{
1937 hdd_adapter_t *adapter;
1938 hdd_context_t *hdd_ctx;
1939 int ret;
1940
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08001941 ENTER_DEV(dev);
1942
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001943 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1944 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
1945 ret = wlan_hdd_validate_context(hdd_ctx);
1946 if (0 != ret)
1947 return ret;
1948
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 /* Do nothing for now */
1950 return 0;
1951}
1952
1953/**
1954 * iw_set_commit() - SSR wrapper function for __iw_set_commit
1955 * @dev: pointer to net_device
1956 * @info: pointer to iw_request_info
1957 * @wrqu: pointer to iwreq_data
1958 * @extra: extra
1959 *
1960 * Return: 0 on success, error number otherwise
1961 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07001962static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963 union iwreq_data *wrqu, char *extra)
1964{
1965 int ret;
1966
1967 cds_ssr_protect(__func__);
1968 ret = __iw_set_commit(dev, info, wrqu, extra);
1969 cds_ssr_unprotect(__func__);
1970
1971 return ret;
1972}
1973
1974/**
1975 * __iw_get_name() - SIOCGIWNAME ioctl handler
1976 * @dev: device upon which the ioctl was received
1977 * @info: ioctl request information
1978 * @wrqu: ioctl request data
1979 * @extra: ioctl extra data
1980 *
1981 * Return: 0 on success, non-zero on error
1982 */
1983static int __iw_get_name(struct net_device *dev,
1984 struct iw_request_info *info, char *wrqu, char *extra)
1985{
1986 hdd_adapter_t *adapter;
1987 hdd_context_t *hdd_ctx;
1988 int ret;
1989
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08001990 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991
1992 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1993 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
1994 ret = wlan_hdd_validate_context(hdd_ctx);
1995 if (0 != ret)
1996 return ret;
1997
1998 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1999 EXIT();
2000 return 0;
2001}
2002
2003/**
2004 * __iw_get_name() - SSR wrapper for __iw_get_name
2005 * @dev: pointer to net_device
2006 * @info: pointer to iw_request_info
2007 * @wrqu: pointer to iwreq_data
2008 * @extra: extra
2009 *
2010 * Return: 0 on success, error number otherwise
2011 */
2012static int iw_get_name(struct net_device *dev,
2013 struct iw_request_info *info,
2014 char *wrqu, char *extra)
2015{
2016 int ret;
2017
2018 cds_ssr_protect(__func__);
2019 ret = __iw_get_name(dev, info, wrqu, extra);
2020 cds_ssr_unprotect(__func__);
2021
2022 return ret;
2023}
2024
2025/**
2026 * __iw_set_mode() - ioctl handler
2027 * @dev: device upon which the ioctl was received
2028 * @info: ioctl request information
2029 * @wrqu: ioctl request data
2030 * @extra: ioctl extra data
2031 *
2032 * Return: 0 on success, non-zero on error
2033 */
2034static int __iw_set_mode(struct net_device *dev,
2035 struct iw_request_info *info,
2036 union iwreq_data *wrqu, char *extra)
2037{
2038 hdd_wext_state_t *pWextState;
2039 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2040 hdd_context_t *hdd_ctx;
2041 tCsrRoamProfile *pRoamProfile;
2042 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 struct hdd_config *pConfig;
2044 struct wireless_dev *wdev;
2045 int ret;
2046
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002047 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048
2049 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2050 ret = wlan_hdd_validate_context(hdd_ctx);
2051 if (0 != ret)
2052 return ret;
2053
2054 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2055 wdev = dev->ieee80211_ptr;
2056 pRoamProfile = &pWextState->roamProfile;
2057 LastBSSType = pRoamProfile->BSSType;
2058
Jeff Johnson99bac312016-06-28 10:38:18 -07002059 hdd_notice("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060
2061 switch (wrqu->mode) {
2062 case IW_MODE_ADHOC:
Jeff Johnson99bac312016-06-28 10:38:18 -07002063 hdd_notice("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2065 /* Set the phymode correctly for IBSS. */
2066 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
2067 pWextState->roamProfile.phyMode =
2068 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08002069 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002070 wdev->iftype = NL80211_IFTYPE_ADHOC;
2071 break;
2072 case IW_MODE_INFRA:
Jeff Johnson99bac312016-06-28 10:38:18 -07002073 hdd_notice("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
2075 wdev->iftype = NL80211_IFTYPE_STATION;
2076 break;
2077 case IW_MODE_AUTO:
Jeff Johnson99bac312016-06-28 10:38:18 -07002078 hdd_notice("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
2080 break;
2081 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002082 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 return -EOPNOTSUPP;
2084 }
2085
2086 if (LastBSSType != pRoamProfile->BSSType) {
2087 /* the BSS mode changed. We need to issue disconnect
2088 * if connected or in IBSS disconnect state
2089 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07002090 if (hdd_conn_is_connected
2091 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302093 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 /* need to issue a disconnect to CSR. */
2095 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302096 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
2098 pAdapter->sessionId,
2099 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302100 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 unsigned long rc;
2102 rc = wait_for_completion_timeout(&pAdapter->
2103 disconnect_comp_var,
2104 msecs_to_jiffies
2105 (WLAN_WAIT_TIME_DISCONNECT));
2106 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07002107 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 }
2109 }
2110 }
2111
2112 EXIT();
2113 return 0;
2114}
2115
2116/**
2117 * iw_set_mode() - SSR wrapper for __iw_set_mode()
2118 * @dev: pointer to net_device
2119 * @info: pointer to iw_request_info
2120 * @wrqu: pointer to iwreq_data
2121 * @extra: pointer to extra ioctl payload
2122 *
2123 * Return: 0 on success, error number otherwise
2124 */
2125static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
2126 union iwreq_data *wrqu, char *extra)
2127{
2128 int ret;
2129
2130 cds_ssr_protect(__func__);
2131 ret = __iw_set_mode(dev, info, wrqu, extra);
2132 cds_ssr_unprotect(__func__);
2133
2134 return ret;
2135}
2136
2137/**
2138 * __iw_get_mode() - SIOCGIWMODE ioctl handler
2139 * @dev: device upon which the ioctl was received
2140 * @info: ioctl request information
2141 * @wrqu: ioctl request data
2142 * @extra: ioctl extra data
2143 *
2144 * Return: 0 on success, non-zero on error
2145 */
2146static int
2147__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2148 union iwreq_data *wrqu, char *extra)
2149{
2150 hdd_wext_state_t *pWextState;
2151 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2152 hdd_context_t *hdd_ctx;
2153 int ret;
2154
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002155 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156
2157 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2158 ret = wlan_hdd_validate_context(hdd_ctx);
2159 if (0 != ret)
2160 return ret;
2161
2162 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2163
2164 switch (pWextState->roamProfile.BSSType) {
2165 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Jeff Johnson99bac312016-06-28 10:38:18 -07002166 hdd_notice("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167 wrqu->mode = IW_MODE_INFRA;
2168 break;
2169 case eCSR_BSS_TYPE_IBSS:
2170 case eCSR_BSS_TYPE_START_IBSS:
Jeff Johnson99bac312016-06-28 10:38:18 -07002171 hdd_notice("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 wrqu->mode = IW_MODE_ADHOC;
2173 break;
2174 case eCSR_BSS_TYPE_ANY:
2175 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002176 hdd_notice("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 wrqu->mode = IW_MODE_AUTO;
2178 break;
2179 }
2180
2181 EXIT();
2182 return 0;
2183}
2184
2185/**
2186 * iw_get_mode() - SSR wrapper for __iw_get_mode()
2187 * @dev: pointer to net_device
2188 * @info: pointer to iw_request_info
2189 * @wrqu: pointer to iwreq_data
2190 * @extra: pointer to extra ioctl payload
2191 *
2192 * Return: 0 on success, error number otherwise
2193 */
2194static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2195 union iwreq_data *wrqu, char *extra)
2196{
2197 int ret;
2198
2199 cds_ssr_protect(__func__);
2200 ret = __iw_get_mode(dev, info, wrqu, extra);
2201 cds_ssr_unprotect(__func__);
2202
2203 return ret;
2204}
2205
2206/**
2207 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
2208 * @dev: device upon which the ioctl was received
2209 * @info: ioctl request information
2210 * @wrqu: ioctl request data
2211 * @extra: ioctl extra data
2212 *
2213 * Return: 0 on success, non-zero on error
2214 */
2215static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2216 union iwreq_data *wrqu, char *extra)
2217{
2218 uint32_t numChans = 0;
2219 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2220 uint32_t indx = 0;
2221 int ret;
2222 hdd_wext_state_t *pWextState;
2223 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2224 hdd_context_t *hdd_ctx;
2225 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2226 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2227 tCsrRoamProfile *pRoamProfile;
2228
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002229 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230
2231 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2232 ret = wlan_hdd_validate_context(hdd_ctx);
2233 if (0 != ret)
2234 return ret;
2235
2236 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2237
2238 pRoamProfile = &pWextState->roamProfile;
2239
Jeff Johnson99bac312016-06-28 10:38:18 -07002240 hdd_notice("setCHANNEL ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241
2242 /* Link is up then return cant set channel */
2243 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
2244 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002245 hdd_err("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246 return -EOPNOTSUPP;
2247 }
2248
2249 /* Settings by Frequency as input */
2250 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
2251 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
2252 uint32_t freq = wrqu->freq.m / 100000;
2253
2254 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
2255 && (freq != freq_chan_map[indx].freq))
2256 indx++;
2257 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) {
2258 return -EINVAL;
2259 }
2260 wrqu->freq.e = 0;
2261 wrqu->freq.m = freq_chan_map[indx].chan;
2262
2263 }
2264
2265 if (wrqu->freq.e == 0) {
2266 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
2267 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002268 hdd_notice("Channel %d is outside valid range from %d to %d",
2269 wrqu->freq.m,
2270 WNI_CFG_CURRENT_CHANNEL_STAMIN,
2271 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272 return -EINVAL;
2273 }
2274
2275 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2276
2277 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2278 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302279 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002280 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281 return -EIO;
2282 }
2283
2284 for (indx = 0; indx < numChans; indx++) {
2285 if (wrqu->freq.m == validChan[indx]) {
2286 break;
2287 }
2288 }
2289 } else {
2290
2291 return -EINVAL;
2292 }
2293
2294 if (indx >= numChans) {
2295 return -EINVAL;
2296 }
2297
2298 /* Set the Operational Channel */
2299 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2300 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2301 pRoamProfile->ChannelInfo.ChannelList =
2302 &pHddStaCtx->conn_info.operationChannel;
2303
Jeff Johnson99bac312016-06-28 10:38:18 -07002304 hdd_notice("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002305
2306 EXIT();
2307
2308 return ret;
2309}
2310
2311/**
2312 * iw_set_freq() - SSR wrapper for __iw_set_freq()
2313 * @dev: pointer to net_device
2314 * @info: pointer to iw_request_info
2315 * @wrqu: pointer to iwreq_data
2316 * @extra: pointer to extra ioctl payload
2317 *
2318 * Return: 0 on success, error number otherwise
2319 */
2320static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2321 union iwreq_data *wrqu, char *extra)
2322{
2323 int ret;
2324
2325 cds_ssr_protect(__func__);
2326 ret = __iw_set_freq(dev, info, wrqu, extra);
2327 cds_ssr_unprotect(__func__);
2328
2329 return ret;
2330}
2331
2332/**
2333 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
2334 * @dev: device upon which the ioctl was received
2335 * @info: ioctl request information
2336 * @wrqu: ioctl request data
2337 * @extra: ioctl extra data
2338 *
2339 * Return: 0 on success, non-zero on error
2340 */
2341static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2342 struct iw_freq *fwrq, char *extra)
2343{
2344 uint32_t status = false, channel = 0, freq = 0;
2345 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2346 tHalHandle hHal;
2347 hdd_wext_state_t *pWextState;
2348 tCsrRoamProfile *pRoamProfile;
2349 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2350 hdd_context_t *hdd_ctx;
2351 int ret;
2352
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002353 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354
2355 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2356 ret = wlan_hdd_validate_context(hdd_ctx);
2357 if (0 != ret)
2358 return ret;
2359
2360 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2361 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2362
2363 pRoamProfile = &pWextState->roamProfile;
2364
2365 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
2366 if (sme_get_operation_channel(hHal, &channel, pAdapter->sessionId)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302367 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002368 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369 pAdapter->sessionId);
2370 return -EIO;
2371 } else {
2372 status = hdd_wlan_get_freq(channel, &freq);
2373 if (true == status) {
2374 /* Set Exponent parameter as 6 (MHZ)
2375 * in struct iw_freq iwlist & iwconfig
2376 * command shows frequency into proper
2377 * format (2.412 GHz instead of 246.2
2378 * MHz)
2379 */
2380 fwrq->m = freq;
2381 fwrq->e = MHZ;
2382 }
2383 }
2384 } else {
2385 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2386 * iwlist & iwconfig command shows frequency into proper
2387 * format (2.412 GHz instead of 246.2 MHz)
2388 */
2389 fwrq->m = 0;
2390 fwrq->e = MHZ;
2391 }
2392 return 0;
2393}
2394
2395/**
2396 * iw_get_freq() - SSR wrapper for __iw_get_freq()
2397 * @dev: pointer to net_device
2398 * @info: pointer to iw_request_info
2399 * @fwrq: pointer to frequency data
2400 * @extra: pointer to extra ioctl payload
2401 *
2402 * Return: 0 on success, error number otherwise
2403 */
2404static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2405 struct iw_freq *fwrq, char *extra)
2406{
2407 int ret;
2408
2409 cds_ssr_protect(__func__);
2410 ret = __iw_get_freq(dev, info, fwrq, extra);
2411 cds_ssr_unprotect(__func__);
2412
2413 return ret;
2414}
2415
2416/**
2417 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
2418 * @dev: device upon which the ioctl was received
2419 * @info: ioctl request information
2420 * @wrqu: ioctl request data
2421 * @extra: ioctl extra data
2422 *
2423 * Return: 0 on success, non-zero on error
2424 */
2425static int __iw_get_tx_power(struct net_device *dev,
2426 struct iw_request_info *info,
2427 union iwreq_data *wrqu, char *extra)
2428{
2429
2430 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2431 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2432 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2433 int ret;
2434
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002435 ENTER_DEV(dev);
2436
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 ret = wlan_hdd_validate_context(hdd_ctx);
2438 if (0 != ret)
2439 return ret;
2440
2441 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2442 wrqu->txpower.value = 0;
2443 return 0;
2444 }
2445 wlan_hdd_get_class_astats(pAdapter);
2446 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2447
2448 return 0;
2449}
2450
2451/**
2452 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
2453 * @dev: pointer to net_device
2454 * @info: pointer to iw_request_info
2455 * @wrqu: pointer to iwreq_data
2456 * @extra: pointer to extra ioctl payload
2457 *
2458 * Return: 0 on success, error number otherwise
2459 */
2460static int iw_get_tx_power(struct net_device *dev,
2461 struct iw_request_info *info,
2462 union iwreq_data *wrqu, char *extra)
2463{
2464 int ret;
2465
2466 cds_ssr_protect(__func__);
2467 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2468 cds_ssr_unprotect(__func__);
2469
2470 return ret;
2471}
2472
2473/**
2474 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
2475 * @dev: device upon which the ioctl was received
2476 * @info: ioctl request information
2477 * @wrqu: ioctl request data
2478 * @extra: ioctl extra data
2479 *
2480 * Return: 0 on success, non-zero on error
2481 */
2482static int __iw_set_tx_power(struct net_device *dev,
2483 struct iw_request_info *info,
2484 union iwreq_data *wrqu, char *extra)
2485{
2486 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2487 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2488 hdd_context_t *hdd_ctx;
2489 int ret;
2490
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002491 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492
2493 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2494 ret = wlan_hdd_validate_context(hdd_ctx);
2495 if (0 != ret)
2496 return ret;
2497
2498 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302499 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002500 hdd_err("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501 return -EIO;
2502 }
2503
2504 EXIT();
2505
2506 return 0;
2507}
2508
2509/**
2510 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
2511 * @dev: pointer to net_device
2512 * @info: pointer to iw_request_info
2513 * @wrqu: pointer to iwreq_data
2514 * @extra: pointer to extra ioctl payload
2515 *
2516 * Return: 0 on success, error number otherwise
2517 */
2518static int iw_set_tx_power(struct net_device *dev,
2519 struct iw_request_info *info,
2520 union iwreq_data *wrqu, char *extra)
2521{
2522 int ret;
2523
2524 cds_ssr_protect(__func__);
2525 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2526 cds_ssr_unprotect(__func__);
2527
2528 return ret;
2529}
2530
2531/**
2532 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
2533 * @dev: device upon which the ioctl was received
2534 * @info: ioctl request information
2535 * @wrqu: ioctl request data
2536 * @extra: ioctl extra data
2537 *
2538 * Return: 0 on success, non-zero on error
2539 */
2540static int __iw_get_bitrate(struct net_device *dev,
2541 struct iw_request_info *info,
2542 union iwreq_data *wrqu, char *extra)
2543{
Anurag Chouhance0dc992016-02-16 18:18:03 +05302544 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302545 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546 hdd_wext_state_t *pWextState;
2547 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2548 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2549 hdd_context_t *hdd_ctx;
2550 int ret;
2551
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002552 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002553
2554 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2555 ret = wlan_hdd_validate_context(hdd_ctx);
2556 if (0 != ret)
2557 return ret;
2558
Prashanth Bhatta9e143052015-12-04 11:56:47 -08002559 if (cds_is_driver_recovering()) {
2560 hdd_alert("Recovery in Progress. State: 0x%x Ignore!!!",
2561 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002562 return status;
2563 }
2564
2565 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2566 wrqu->bitrate.value = 0;
2567 } else {
2568 status =
2569 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2570 eCSR_HDD,
2571 SME_SUMMARY_STATS |
2572 SME_GLOBAL_CLASSA_STATS |
2573 SME_GLOBAL_CLASSB_STATS |
2574 SME_GLOBAL_CLASSC_STATS |
2575 SME_GLOBAL_CLASSD_STATS |
2576 SME_PER_STA_STATS,
2577 hdd_statistics_cb, 0,
2578 false,
2579 pHddStaCtx->conn_info.staId[0],
2580 pAdapter, pAdapter->sessionId);
2581
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302582 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002583 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 return status;
2585 }
2586
2587 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2588
Anurag Chouhance0dc992016-02-16 18:18:03 +05302589 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302590 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 WLAN_WAIT_TIME_STATS);
2592
Anurag Chouhance0dc992016-02-16 18:18:03 +05302593 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002594 hdd_err("SME timeout while retrieving statistics");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302595 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 }
2597
2598 wrqu->bitrate.value =
2599 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
2600 }
2601
2602 EXIT();
2603
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302604 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605}
2606
2607/**
2608 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
2609 * @dev: pointer to net_device
2610 * @info: pointer to iw_request_info
2611 * @wrqu: pointer to iwreq_data
2612 * @extra: pointer to extra ioctl payload
2613 *
2614 * Return: 0 on success, error number otherwise
2615 */
2616static int iw_get_bitrate(struct net_device *dev,
2617 struct iw_request_info *info,
2618 union iwreq_data *wrqu, char *extra)
2619{
2620 int ret;
2621
2622 cds_ssr_protect(__func__);
2623 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2624 cds_ssr_unprotect(__func__);
2625
2626 return ret;
2627}
2628
2629/**
2630 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
2631 * @dev: device upon which the ioctl was received
2632 * @info: ioctl request information
2633 * @wrqu: ioctl request data
2634 * @extra: ioctl extra data
2635 *
2636 * Return: 0 on success, non-zero on error
2637 */
2638static int __iw_set_bitrate(struct net_device *dev,
2639 struct iw_request_info *info,
2640 union iwreq_data *wrqu, char *extra)
2641{
2642 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2643 hdd_wext_state_t *pWextState;
2644 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2645 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2646 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2647 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2648 uint32_t i, rate;
2649 uint32_t valid_rate = false, active_phy_mode = 0;
2650 hdd_context_t *hdd_ctx;
2651 int ret;
2652
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002653 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654
2655 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2656 ret = wlan_hdd_validate_context(hdd_ctx);
2657 if (0 != ret)
2658 return ret;
2659
2660 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2661
2662 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2663 return -ENXIO;
2664 }
2665
2666 rate = wrqu->bitrate.value;
2667
2668 if (rate == -1) {
2669 rate = WNI_CFG_FIXED_RATE_AUTO;
2670 valid_rate = true;
2671 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
2672 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302673 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
2675 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2676 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
2677 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
2678 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302679 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 &&
2681 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
2682 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302683 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 for (i = 0; i < (b_len + a_len); ++i) {
2685 /* supported rates returned is double
2686 * the actual rate so we divide it by 2
2687 */
2688 if ((supp_rates[i] & 0x7F) / 2 ==
2689 rate) {
2690 valid_rate = true;
2691 rate = i +
2692 WNI_CFG_FIXED_RATE_1MBPS;
2693 break;
2694 }
2695 }
2696 }
2697 }
2698 }
2699 if (valid_rate != true) {
2700 return -EINVAL;
2701 }
2702 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302703 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002704 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705 return -EIO;
2706 }
2707 return 0;
2708}
2709
2710/**
2711 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
2712 * @dev: pointer to net_device
2713 * @info: pointer to iw_request_info
2714 * @wrqu: pointer to iwreq_data
2715 * @extra: pointer to extra ioctl payload
2716 *
2717 * Return: 0 on success, error number otherwise
2718 */
2719static int iw_set_bitrate(struct net_device *dev,
2720 struct iw_request_info *info,
2721 union iwreq_data *wrqu, char *extra)
2722{
2723 int ret;
2724
2725 cds_ssr_protect(__func__);
2726 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2727 cds_ssr_unprotect(__func__);
2728
2729 return ret;
2730}
2731
2732/**
2733 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
2734 * @dev: device upon which the ioctl was received
2735 * @info: ioctl request information
2736 * @wrqu: ioctl request data
2737 * @extra: ioctl extra data
2738 *
2739 * Return: 0 on success, non-zero on error
2740 */
2741static int __iw_set_genie(struct net_device *dev,
2742 struct iw_request_info *info,
2743 union iwreq_data *wrqu, char *extra)
2744{
2745 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2746 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2747 uint8_t *genie = NULL;
2748 uint8_t *base_genie = NULL;
2749 uint16_t remLen;
2750 hdd_context_t *hdd_ctx;
2751 int ret;
2752
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002753 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754
2755 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2756 ret = wlan_hdd_validate_context(hdd_ctx);
2757 if (0 != ret)
2758 return ret;
2759
2760 if (!wrqu->data.length) {
2761 hdd_clear_roam_profile_ie(pAdapter);
2762 EXIT();
2763 return 0;
2764 }
2765
2766 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2767 wrqu->data.length);
2768 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002769 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 return -ENOMEM;
2771 }
2772
2773 genie = base_genie;
2774
2775 remLen = wrqu->data.length;
2776
Jeff Johnson99bac312016-06-28 10:38:18 -07002777 hdd_notice("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778 genie[1]);
2779
2780 /* clear any previous genIE before this call */
2781 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
2782
2783 while (remLen >= 2) {
2784 uint16_t eLen = 0;
2785 uint8_t elementId;
2786 elementId = *genie++;
2787 eLen = *genie++;
2788 remLen -= 2;
2789
Jeff Johnson99bac312016-06-28 10:38:18 -07002790 hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791
2792 switch (elementId) {
2793 case IE_EID_VENDOR:
2794 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 +05302795 ret = -EINVAL;
2796 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002797 }
2798
2799 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
2800 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07002801 hdd_notice("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2802 genie[0], genie[1], genie[2],
2803 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804
2805 if (SIR_MAC_MAX_IE_LENGTH <
2806 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002807 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302808 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302809 ret = -ENOMEM;
2810 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811 }
2812 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
2813 memcpy(pWextState->genIE.addIEdata +
2814 curGenIELen, genie - 2, eLen + 2);
2815 pWextState->genIE.length += eLen + 2;
2816 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002817 hdd_notice("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302818 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
2819 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
2820 ret = -EINVAL;
2821 QDF_ASSERT(0);
2822 goto exit;
2823 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 memset(pWextState->WPARSNIE, 0,
2825 MAX_WPA_RSN_IE_LEN);
2826 memcpy(pWextState->WPARSNIE, genie - 2,
2827 (eLen + 2));
2828 pWextState->roamProfile.pWPAReqIE =
2829 pWextState->WPARSNIE;
2830 pWextState->roamProfile.nWPAReqIELength =
2831 eLen + 2;
2832 } else { /* any vendorId except WPA IE should be accumulated to genIE */
2833
2834 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07002835 hdd_notice("Set OUI(%02x %02x %02x %02x) IE(len %d)",
2836 genie[0], genie[1], genie[2],
2837 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002838
2839 if (SIR_MAC_MAX_IE_LENGTH <
2840 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002841 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302842 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302843 ret = -ENOMEM;
2844 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 }
2846 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
2847 memcpy(pWextState->genIE.addIEdata +
2848 curGenIELen, genie - 2, eLen + 2);
2849 pWextState->genIE.length += eLen + 2;
2850 }
2851 break;
2852 case DOT11F_EID_RSN:
Jeff Johnson99bac312016-06-28 10:38:18 -07002853 hdd_notice("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302854 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
2855 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
2856 ret = -EINVAL;
2857 QDF_ASSERT(0);
2858 goto exit;
2859 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
2861 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
2862 pWextState->roamProfile.pRSNReqIE =
2863 pWextState->WPARSNIE;
2864 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2865 break;
2866
2867 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002868 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302869 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002870 }
2871 genie += eLen;
2872 remLen -= eLen;
2873 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302874exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 EXIT();
2876 kfree(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302877 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878}
2879
2880/**
2881 * iw_set_genie() - SSR wrapper for __iw_set_genie()
2882 * @dev: pointer to net_device
2883 * @info: pointer to iw_request_info
2884 * @wrqu: pointer to iwreq_data
2885 * @extra: pointer to extra ioctl payload
2886 *
2887 * Return: 0 on success, error number otherwise
2888 */
2889static int iw_set_genie(struct net_device *dev,
2890 struct iw_request_info *info,
2891 union iwreq_data *wrqu, char *extra)
2892{
2893 int ret;
2894
2895 cds_ssr_protect(__func__);
2896 ret = __iw_set_genie(dev, info, wrqu, extra);
2897 cds_ssr_unprotect(__func__);
2898
2899 return ret;
2900}
2901
2902/**
2903 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
2904 * @dev: device upon which the ioctl was received
2905 * @info: ioctl request information
2906 * @wrqu: ioctl request data
2907 * @extra: ioctl extra data
2908 *
2909 * Return: 0 on success, non-zero on error
2910 */
2911static int __iw_get_genie(struct net_device *dev,
2912 struct iw_request_info *info,
2913 union iwreq_data *wrqu, char *extra)
2914{
2915 hdd_wext_state_t *pWextState;
2916 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2917 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302918 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
2920 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2921 hdd_context_t *hdd_ctx;
2922 int ret;
2923
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002924 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925
2926 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2927 ret = wlan_hdd_validate_context(hdd_ctx);
2928 if (0 != ret)
2929 return ret;
2930
Jeff Johnson99bac312016-06-28 10:38:18 -07002931 hdd_notice("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932
2933 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2934
2935 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
2936 return -ENXIO;
2937 }
2938
2939 /* Return something ONLY if we are associated with an RSN or
2940 * WPA network
2941 */
2942 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
2943 return -ENXIO;
2944 }
2945
2946 /* Actually retrieve the RSN IE from CSR. (We previously sent
2947 * it down in the CSR Roam Profile.)
2948 */
2949 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
2950 pAdapter->sessionId,
2951 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05302952 if (QDF_STATUS_SUCCESS != status) {
2953 hdd_notice("failed to get WPA-RSN IE data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954 return -EFAULT;
2955 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05302957 if (length > DOT11F_IE_RSN_MAX_LEN) {
2958 hdd_notice("invalid buffer length length:%d", length);
2959 return -E2BIG;
2960 }
2961 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962
Jeff Johnson99bac312016-06-28 10:38:18 -07002963 hdd_notice("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964 wrqu->data.length);
2965
2966 EXIT();
2967
2968 return 0;
2969}
2970
2971/**
2972 * iw_get_genie() - SSR wrapper for __iw_get_genie()
2973 * @dev: pointer to net_device
2974 * @info: pointer to iw_request_info
2975 * @wrqu: pointer to iwreq_data
2976 * @extra: pointer to extra ioctl payload
2977 *
2978 * Return: 0 on success, error number otherwise
2979 */
2980static int iw_get_genie(struct net_device *dev,
2981 struct iw_request_info *info,
2982 union iwreq_data *wrqu, char *extra)
2983{
2984 int ret;
2985
2986 cds_ssr_protect(__func__);
2987 ret = __iw_get_genie(dev, info, wrqu, extra);
2988 cds_ssr_unprotect(__func__);
2989
2990 return ret;
2991}
2992
2993/**
2994 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
2995 * @dev: device upon which the ioctl was received
2996 * @info: ioctl request information
2997 * @wrqu: ioctl request data
2998 * @extra: ioctl extra data
2999 *
3000 * Return: 0 on success, non-zero on error
3001 */
3002static int __iw_get_encode(struct net_device *dev,
3003 struct iw_request_info *info,
3004 struct iw_point *dwrq, char *extra)
3005{
3006 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3007 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3008 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3009 int keyId;
3010 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3011 int i;
3012 hdd_context_t *hdd_ctx;
3013 int ret;
3014
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003015 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016
3017 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3018 ret = wlan_hdd_validate_context(hdd_ctx);
3019 if (0 != ret)
3020 return ret;
3021
3022 keyId = pRoamProfile->Keys.defaultIndex;
3023
3024 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003025 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026 return -EINVAL;
3027 }
3028
3029 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
3030 dwrq->flags |= IW_ENCODE_ENABLED;
3031 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303032 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 pRoamProfile->Keys.KeyLength[keyId]);
3034
3035 dwrq->flags |= (keyId + 1);
3036
3037 } else {
3038 dwrq->flags |= IW_ENCODE_DISABLED;
3039 }
3040
3041 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08003042 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043 continue;
3044 } else {
3045 break;
3046 }
3047 }
3048
3049 if (MAX_WEP_KEYS == i) {
3050 dwrq->flags |= IW_ENCODE_NOKEY;
3051 }
3052
3053 authType =
3054 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
3055 conn_info.authType;
3056
3057 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
3058 dwrq->flags |= IW_ENCODE_OPEN;
3059 } else {
3060 dwrq->flags |= IW_ENCODE_RESTRICTED;
3061 }
3062 EXIT();
3063 return 0;
3064}
3065
3066/**
3067 * iw_get_encode() - SSR wrapper for __iw_get_encode()
3068 * @dev: pointer to net_device
3069 * @info: pointer to iw_request_info
3070 * @dwrq: pointer to encoding information
3071 * @extra: pointer to extra ioctl payload
3072 *
3073 * Return: 0 on success, error number otherwise
3074 */
3075static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
3076 struct iw_point *dwrq, char *extra)
3077{
3078 int ret;
3079
3080 cds_ssr_protect(__func__);
3081 ret = __iw_get_encode(dev, info, dwrq, extra);
3082 cds_ssr_unprotect(__func__);
3083
3084 return ret;
3085}
3086
3087/**
3088 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
3089 * @dev: device upon which the ioctl was received
3090 * @info: ioctl request information
3091 * @wrqu: ioctl request data
3092 * @extra: ioctl extra data
3093 *
3094 * Return: 0 on success, non-zero on error
3095 */
3096static int __iw_get_rts_threshold(struct net_device *dev,
3097 struct iw_request_info *info,
3098 union iwreq_data *wrqu, char *extra)
3099{
3100 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3101 uint32_t status = 0;
3102
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003103 ENTER_DEV(dev);
3104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003105 status = hdd_wlan_get_rts_threshold(pAdapter, wrqu);
3106
3107 return status;
3108}
3109
3110/**
3111 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
3112 * @dev: device upon which the ioctl was received
3113 * @info: ioctl request information
3114 * @wrqu: ioctl request data
3115 * @extra: ioctl extra data
3116 *
3117 * Return: 0 on success, non-zero on error
3118 */
3119static int __iw_set_rts_threshold(struct net_device *dev,
3120 struct iw_request_info *info,
3121 union iwreq_data *wrqu, char *extra)
3122{
3123 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3124 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3125 hdd_context_t *hdd_ctx;
3126 int ret;
3127
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003128 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129
3130 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3131 ret = wlan_hdd_validate_context(hdd_ctx);
3132 if (0 != ret)
3133 return ret;
3134
3135 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
3136 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
3137 return -EINVAL;
3138 }
3139
3140 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303141 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003142 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 return -EIO;
3144 }
3145
3146 EXIT();
3147
3148 return 0;
3149}
3150
3151/**
3152 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
3153 * @dev: pointer to net_device
3154 * @info: pointer to iw_request_info
3155 * @wrqu: pointer to iwreq_data
3156 * @extra: pointer to extra ioctl payload
3157 *
3158 * Return: 0 on success, error number otherwise
3159 */
3160static int iw_get_rts_threshold(struct net_device *dev,
3161 struct iw_request_info *info,
3162 union iwreq_data *wrqu, char *extra)
3163{
3164 int ret;
3165
3166 cds_ssr_protect(__func__);
3167 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
3168 cds_ssr_unprotect(__func__);
3169
3170 return ret;
3171}
3172
3173/**
3174 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
3175 * @dev: pointer to net_device
3176 * @info: pointer to iw_request_info
3177 * @wrqu: pointer to iwreq_data
3178 * @extra: pointer to extra ioctl payload
3179 *
3180 * Return: 0 on success, error number otherwise
3181 */
3182static int iw_set_rts_threshold(struct net_device *dev,
3183 struct iw_request_info *info,
3184 union iwreq_data *wrqu, char *extra)
3185{
3186 int ret;
3187
3188 cds_ssr_protect(__func__);
3189 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
3190 cds_ssr_unprotect(__func__);
3191
3192 return ret;
3193}
3194
3195/**
3196 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
3197 * @dev: device upon which the ioctl was received
3198 * @info: ioctl request information
3199 * @wrqu: ioctl request data
3200 * @extra: ioctl extra data
3201 *
3202 * Return: 0 on success, non-zero on error
3203 */
3204static int __iw_get_frag_threshold(struct net_device *dev,
3205 struct iw_request_info *info,
3206 union iwreq_data *wrqu, char *extra)
3207{
3208 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3209 uint32_t status = 0;
3210
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003211 ENTER_DEV(dev);
3212
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 status = hdd_wlan_get_frag_threshold(pAdapter, wrqu);
3214
3215 return status;
3216}
3217
3218/**
3219 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
3220 * @dev: pointer to net_device
3221 * @info: pointer to iw_request_info
3222 * @wrqu: pointer to iwreq_data
3223 * @extra: pointer to extra ioctl payload
3224 *
3225 * Return: 0 on success, error number otherwise
3226 */
3227static int iw_get_frag_threshold(struct net_device *dev,
3228 struct iw_request_info *info,
3229 union iwreq_data *wrqu, char *extra)
3230{
3231 int ret;
3232
3233 cds_ssr_protect(__func__);
3234 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
3235 cds_ssr_unprotect(__func__);
3236
3237 return ret;
3238}
3239
3240/**
3241 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
3242 * @dev: device upon which the ioctl was received
3243 * @info: ioctl request information
3244 * @wrqu: ioctl request data
3245 * @extra: ioctl extra data
3246 *
3247 * Return: 0 on success, non-zero on error
3248 */
3249static int __iw_set_frag_threshold(struct net_device *dev,
3250 struct iw_request_info *info,
3251 union iwreq_data *wrqu, char *extra)
3252{
3253 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3254 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3255 hdd_context_t *hdd_ctx;
3256 int ret;
3257
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003258 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259
3260 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3261 ret = wlan_hdd_validate_context(hdd_ctx);
3262 if (0 != ret)
3263 return ret;
3264
3265 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
3266 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
3267 return -EINVAL;
3268 }
3269
3270 if (sme_cfg_set_int
3271 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303272 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003273 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 return -EIO;
3275 }
3276
3277 EXIT();
3278
3279 return 0;
3280}
3281
3282/**
3283 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
3284 * @dev: pointer to net_device
3285 * @info: pointer to iw_request_info
3286 * @wrqu: pointer to iwreq_data
3287 * @extra: pointer to extra ioctl payload
3288 *
3289 * Return: 0 on success, error number otherwise
3290 */
3291static int iw_set_frag_threshold(struct net_device *dev,
3292 struct iw_request_info *info,
3293 union iwreq_data *wrqu, char *extra)
3294{
3295 int ret;
3296
3297 cds_ssr_protect(__func__);
3298 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3299 cds_ssr_unprotect(__func__);
3300
3301 return ret;
3302}
3303
3304/**
3305 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
3306 * @dev: device upon which the ioctl was received
3307 * @info: ioctl request information
3308 * @wrqu: ioctl request data
3309 * @extra: ioctl extra data
3310 *
3311 * Return: 0 on success, non-zero on error
3312 */
3313static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003314 struct iw_request_info *info,
3315 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316{
3317 hdd_adapter_t *adapter;
3318 hdd_context_t *hdd_ctx;
3319 int ret;
3320
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003321 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322
3323 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3324 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3325 ret = wlan_hdd_validate_context(hdd_ctx);
3326 if (0 != ret)
3327 return ret;
3328
3329 return -EOPNOTSUPP;
3330}
3331
3332/**
3333 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
3334 * @dev: pointer to net_device
3335 * @info: pointer to iw_request_info
3336 * @wrqu: pointer to iwreq_data
3337 * @extra: extra
3338 *
3339 * Return: 0 on success, error number otherwise
3340 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003341static int iw_get_power_mode(struct net_device *dev,
3342 struct iw_request_info *info,
3343 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344{
3345 int ret;
3346
3347 cds_ssr_protect(__func__);
3348 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3349 cds_ssr_unprotect(__func__);
3350
3351 return ret;
3352}
3353
3354/**
3355 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
3356 * @dev: device upon which the ioctl was received
3357 * @info: ioctl request information
3358 * @wrqu: ioctl request data
3359 * @extra: ioctl extra data
3360 *
3361 * Return: 0 on success, non-zero on error
3362 */
3363static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003364 struct iw_request_info *info,
3365 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366{
3367 hdd_adapter_t *adapter;
3368 hdd_context_t *hdd_ctx;
3369 int ret;
3370
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003371 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372
3373 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3374 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3375 ret = wlan_hdd_validate_context(hdd_ctx);
3376 if (0 != ret)
3377 return ret;
3378
3379 return -EOPNOTSUPP;
3380}
3381
3382/**
3383 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
3384 * @dev: pointer to net_device
3385 * @info: pointer to iw_request_info
3386 * @wrqu: pointer to iwreq_data
3387 * @extra: extra
3388 *
3389 * Return: 0 on success, error number otherwise
3390 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003391static int iw_set_power_mode(struct net_device *dev,
3392 struct iw_request_info *info,
3393 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394{
3395 int ret;
3396
3397 cds_ssr_protect(__func__);
3398 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3399 cds_ssr_unprotect(__func__);
3400
3401 return ret;
3402}
3403
3404/**
3405 * __iw_get_range() - SIOCGIWRANGE ioctl handler
3406 * @dev: device upon which the ioctl was received
3407 * @info: ioctl request information
3408 * @wrqu: ioctl request data
3409 * @extra: ioctl extra data
3410 *
3411 * Return: 0 on success, non-zero on error
3412 */
3413static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
3414 union iwreq_data *wrqu, char *extra)
3415{
3416 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3417 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3418 struct iw_range *range = (struct iw_range *)extra;
3419
3420 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3421
3422 uint32_t num_channels = sizeof(channels);
3423 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3424 uint32_t a_len;
3425 uint32_t b_len;
3426 uint32_t active_phy_mode = 0;
3427 uint8_t index = 0, i;
3428 hdd_context_t *hdd_ctx;
3429 int ret;
3430
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003431 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432
3433 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3434 ret = wlan_hdd_validate_context(hdd_ctx);
3435 if (0 != ret)
3436 return ret;
3437
3438 wrqu->data.length = sizeof(struct iw_range);
3439 memset(range, 0, sizeof(struct iw_range));
3440
3441
3442 /*Get the phy mode */
3443 if (sme_cfg_get_int(hHal,
3444 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303445 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003446 hdd_notice("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447
3448 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
3449 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
3450 /*Get the supported rates for 11G band */
3451 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3452 if (sme_cfg_get_str(hHal,
3453 WNI_CFG_SUPPORTED_RATES_11A,
3454 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303455 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
3457 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3458 }
3459 for (i = 0; i < a_len; i++) {
3460 range->bitrate[i] =
3461 ((supp_rates[i] & 0x7F) / 2) *
3462 1000000;
3463 }
3464 range->num_bitrates = a_len;
3465 } else {
3466 return -EIO;
3467 }
3468 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
3469 /*Get the supported rates for 11B band */
3470 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3471 if (sme_cfg_get_str(hHal,
3472 WNI_CFG_SUPPORTED_RATES_11B,
3473 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303474 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
3476 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3477 }
3478 for (i = 0; i < b_len; i++) {
3479 range->bitrate[i] =
3480 ((supp_rates[i] & 0x7F) / 2) *
3481 1000000;
3482 }
3483 range->num_bitrates = b_len;
3484 } else {
3485 return -EIO;
3486 }
3487 }
3488 }
3489
3490 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3491 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3492 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3493
3494 range->encoding_size[0] = 5;
3495 range->encoding_size[1] = 13;
3496 range->num_encoding_sizes = 2;
3497 range->max_encoding_tokens = MAX_WEP_KEYS;
3498
3499 /* we support through Wireless Extensions 22 */
3500 range->we_version_compiled = WIRELESS_EXT;
3501 range->we_version_source = 22;
3502
3503 /*Supported Channels and Frequencies */
3504 if (sme_cfg_get_str
3505 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303506 &num_channels) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003507 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 return -EIO;
3509 }
3510 if (num_channels > IW_MAX_FREQUENCIES) {
3511 num_channels = IW_MAX_FREQUENCIES;
3512 }
3513
3514 range->num_channels = num_channels;
3515 range->num_frequency = num_channels;
3516
3517 for (index = 0; index < num_channels; index++) {
3518 uint32_t frq_indx = 0;
3519
3520 range->freq[index].i = channels[index];
3521 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
3522 if (channels[index] == freq_chan_map[frq_indx].chan) {
3523 range->freq[index].m =
3524 freq_chan_map[frq_indx].freq * 100000;
3525 range->freq[index].e = 1;
3526 break;
3527 }
3528 frq_indx++;
3529 }
3530 }
3531
3532 /* Event capability (kernel + driver) */
3533 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3534 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3535 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3536 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3537
3538 /*Encryption capability */
3539 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3540 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3541
3542 /* Txpower capability */
3543 range->txpower_capa = IW_TXPOW_MWATT;
3544
3545 /*Scanning capability */
3546#if WIRELESS_EXT >= 22
3547 range->scan_capa =
3548 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3549#endif
3550
3551 EXIT();
3552 return 0;
3553}
3554
3555/**
3556 * iw_get_range() - SSR wrapper for __iw_get_range()
3557 * @dev: pointer to net_device
3558 * @info: pointer to iw_request_info
3559 * @wrqu: pointer to iwreq_data
3560 * @extra: pointer to extra ioctl payload
3561 *
3562 * Return: 0 on success, error number otherwise
3563 */
3564static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
3565 union iwreq_data *wrqu, char *extra)
3566{
3567 int ret;
3568
3569 cds_ssr_protect(__func__);
3570 ret = __iw_get_range(dev, info, wrqu, extra);
3571 cds_ssr_unprotect(__func__);
3572
3573 return ret;
3574}
3575
3576/**
3577 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
3578 * @pStats: pointer to Class A stats
3579 * @pContext: user context originally registered with SME
3580 *
3581 * Return: None
3582 */
3583static void hdd_get_class_a_statistics_cb(void *pStats, void *pContext)
3584{
3585 struct statsContext *pStatsContext;
3586 tCsrGlobalClassAStatsInfo *pClassAStats;
3587 hdd_adapter_t *pAdapter;
3588
3589 if (ioctl_debug) {
3590 pr_info("%s: pStats [%p] pContext [%p]\n",
3591 __func__, pStats, pContext);
3592 }
3593
3594 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003595 hdd_err("Bad param, pStats [%p] pContext [%p]",
3596 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597 return;
3598 }
3599
3600 pClassAStats = pStats;
3601 pStatsContext = pContext;
3602 pAdapter = pStatsContext->pAdapter;
3603
3604 /* there is a race condition that exists between this callback
3605 * function and the caller since the caller could time out
3606 * either before or while this code is executing. we use a
3607 * spinlock to serialize these actions
3608 */
3609 spin_lock(&hdd_context_lock);
3610
3611 if ((NULL == pAdapter) ||
3612 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
3613 /* the caller presumably timed out so there is nothing
3614 * we can do
3615 */
3616 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07003617 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
3618 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003619 if (ioctl_debug) {
3620 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
3621 __func__, pAdapter, pStatsContext->magic);
3622 }
3623 return;
3624 }
3625
3626 /* context is valid so caller is still waiting */
3627
3628 /* paranoia: invalidate the magic */
3629 pStatsContext->magic = 0;
3630
3631 /* copy over the stats. do so as a struct copy */
3632 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3633
3634 /* notify the caller */
3635 complete(&pStatsContext->completion);
3636
3637 /* serialization is complete */
3638 spin_unlock(&hdd_context_lock);
3639}
3640
3641/**
3642 * wlan_hdd_get_class_astats() - Get Class A statistics
3643 * @pAdapter: adapter for which statistics are desired
3644 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303645 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003646 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303647QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648{
3649 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303650 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 unsigned long rc;
Houston Hoffman59c097f2016-11-09 15:50:25 -08003652 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653
3654 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003655 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303656 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003658 if (cds_is_driver_recovering()) {
3659 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3660 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303661 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662 }
3663
3664 /* we are connected so prepare our callback context */
3665 init_completion(&context.completion);
3666 context.pAdapter = pAdapter;
3667 context.magic = STATS_CONTEXT_MAGIC;
3668 /* query only for Class A statistics (which include link speed) */
3669 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3670 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
3671 hdd_get_class_a_statistics_cb,
3672 0, /* not periodic */
3673 false, /* non-cached results */
3674 pHddStaCtx->conn_info.staId[0],
3675 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303676 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07003677 hdd_warn("Unable to retrieve Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003678 /* we'll returned a cached value below */
3679 } else {
3680 /* request was sent -- wait for the response */
3681 rc = wait_for_completion_timeout
3682 (&context.completion,
3683 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3684 if (!rc) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07003685 hdd_warn("SME timed out while retrieving Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003686 }
3687 }
3688
3689 /* either we never sent a request, we sent a request and
3690 * received a response or we sent a request and timed out. if
3691 * we never sent a request or if we sent a request and got a
3692 * response, we want to clear the magic out of paranoia. if
3693 * we timed out there is a race condition such that the
3694 * callback function could be executing at the same time we
3695 * are. of primary concern is if the callback function had
3696 * already verified the "magic" but had not yet set the
3697 * completion variable when a timeout occurred. we serialize
3698 * these activities by invalidating the magic while holding a
3699 * shared spinlock which will cause us to block if the
3700 * callback is currently executing
3701 */
3702 spin_lock(&hdd_context_lock);
3703 context.magic = 0;
3704 spin_unlock(&hdd_context_lock);
3705
3706 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303707 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708}
3709
3710/**
3711 * hdd_get_station_statistics_cb() - Get stats callback function
3712 * @pStats: pointer to Class A stats
3713 * @pContext: user context originally registered with SME
3714 *
3715 * Return: None
3716 */
3717static void hdd_get_station_statistics_cb(void *pStats, void *pContext)
3718{
3719 struct statsContext *pStatsContext;
3720 tCsrSummaryStatsInfo *pSummaryStats;
3721 tCsrGlobalClassAStatsInfo *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303722 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723 hdd_adapter_t *pAdapter;
3724
3725 if (ioctl_debug) {
3726 pr_info("%s: pStats [%p] pContext [%p]\n",
3727 __func__, pStats, pContext);
3728 }
3729
3730 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003731 hdd_err("Bad param, pStats [%p] pContext [%p]",
3732 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733 return;
3734 }
3735
3736 /* there is a race condition that exists between this callback
3737 * function and the caller since the caller could time out
3738 * either before or while this code is executing. we use a
3739 * spinlock to serialize these actions
3740 */
3741 spin_lock(&hdd_context_lock);
3742
3743 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
3744 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303745 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
3746 (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003747 pStatsContext = pContext;
3748 pAdapter = pStatsContext->pAdapter;
3749 if ((NULL == pAdapter) ||
3750 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
3751 /* the caller presumably timed out so there is nothing
3752 * we can do
3753 */
3754 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07003755 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
3756 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003757 if (ioctl_debug) {
3758 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
3759 __func__, pAdapter, pStatsContext->magic);
3760 }
3761 return;
3762 }
3763
3764 /* context is valid so caller is still waiting */
3765
3766 /* paranoia: invalidate the magic */
3767 pStatsContext->magic = 0;
3768
3769 /* copy over the stats. do so as a struct copy */
3770 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3771 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303772 pAdapter->hdd_stats.per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003773
3774 /* notify the caller */
3775 complete(&pStatsContext->completion);
3776
3777 /* serialization is complete */
3778 spin_unlock(&hdd_context_lock);
3779}
3780
3781/**
3782 * wlan_hdd_get_station_stats() - Get station statistics
3783 * @pAdapter: adapter for which statistics are desired
3784 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303785 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303787QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788{
3789 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303790 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003791 unsigned long rc;
Jeff Johnson5aacdf92016-11-04 18:08:11 -07003792 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793
3794 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003795 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303796 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797 }
3798
3799 /* we are connected so prepare our callback context */
3800 init_completion(&context.completion);
3801 context.pAdapter = pAdapter;
3802 context.magic = STATS_CONTEXT_MAGIC;
3803
3804 /* query only for Summary & Class A statistics */
3805 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3806 eCSR_HDD,
3807 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303808 SME_GLOBAL_CLASSA_STATS |
3809 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810 hdd_get_station_statistics_cb,
3811 0, /* not periodic */
3812 false, /* non-cached results */
3813 pHddStaCtx->conn_info.staId[0],
3814 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303815 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003816 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 /* we'll return with cached values */
3818 } else {
3819 /* request was sent -- wait for the response */
3820 rc = wait_for_completion_timeout
3821 (&context.completion,
3822 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3823
3824 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003825 hdd_err("SME timed out while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 }
3827 }
3828
3829 /* either we never sent a request, we sent a request and
3830 * received a response or we sent a request and timed out. if
3831 * we never sent a request or if we sent a request and got a
3832 * response, we want to clear the magic out of paranoia. if
3833 * we timed out there is a race condition such that the
3834 * callback function could be executing at the same time we
3835 * are. of primary concern is if the callback function had
3836 * already verified the "magic" but had not yet set the
3837 * completion variable when a timeout occurred. we serialize
3838 * these activities by invalidating the magic while holding a
3839 * shared spinlock which will cause us to block if the
3840 * callback is currently executing
3841 */
3842 spin_lock(&hdd_context_lock);
3843 context.magic = 0;
3844 spin_unlock(&hdd_context_lock);
3845
3846 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303847 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848}
3849
3850/**
3851 * iw_get_linkspeed() - Get current link speed ioctl
3852 * @dev: device upon which the ioctl was received
3853 * @info: ioctl request information
3854 * @wrqu: ioctl request data
3855 * @extra: extra ioctl buffer
3856 *
3857 * Return: 0 on success, non-zero on error
3858 */
3859static int __iw_get_linkspeed(struct net_device *dev,
3860 struct iw_request_info *info,
3861 union iwreq_data *wrqu, char *extra)
3862{
3863 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3864 char *pLinkSpeed = (char *)extra;
3865 int len = sizeof(uint32_t) + 1;
3866 uint32_t link_speed = 0;
3867 hdd_context_t *hdd_ctx;
3868 int rc, valid;
3869
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08003870 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303871
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3873 valid = wlan_hdd_validate_context(hdd_ctx);
3874 if (0 != valid)
3875 return valid;
3876
3877 rc = wlan_hdd_get_link_speed(pAdapter, &link_speed);
3878 if (0 != rc) {
3879 return rc;
3880 }
3881
3882 wrqu->data.length = len;
3883 /* return the linkspeed as a string */
3884 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
3885 if ((rc < 0) || (rc >= len)) {
3886 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07003887 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 return -EIO;
3889 }
3890
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303891 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 /* a value is being successfully returned */
3893 return 0;
3894}
3895
3896static int iw_get_linkspeed(struct net_device *dev,
3897 struct iw_request_info *info,
3898 union iwreq_data *wrqu, char *extra)
3899{
3900 int ret;
3901
3902 cds_ssr_protect(__func__);
3903 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
3904 cds_ssr_unprotect(__func__);
3905
3906 return ret;
3907}
3908
3909/**
3910 * wlan_hdd_change_country_code_callback() - Change country code callback
3911 * @context: opaque context originally passed to SME. All functions
3912 * which use this callback pass the adapter upon which the country
3913 * code change is active
3914 *
3915 * This function is registered as the callback function when
3916 * sme_change_country_code() is invoked. Callers of
3917 * sme_change_country_code() subsequently wait for the adapter's
3918 * @change_country_code completion variable, so all this function
3919 * needs to do is set that completion variable so that execution can
3920 * continue.
3921 *
3922 * Return: none
3923 */
3924void wlan_hdd_change_country_code_callback(void *context)
3925{
3926
3927 hdd_adapter_t *adapter = context;
3928
3929 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
3930 complete(&adapter->change_country_code);
3931
3932 return;
3933}
3934
3935/**
3936 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
3937 * @dev: device upon which the ioctl was received
3938 * @info: ioctl request information
3939 * @wrqu: ioctl request data
3940 * @extra: ioctl extra data
3941 *
3942 * Return: 0 on success, non-zero on error
3943 */
3944static int __iw_set_nick(struct net_device *dev,
3945 struct iw_request_info *info,
3946 union iwreq_data *wrqu, char *extra)
3947{
3948 hdd_adapter_t *adapter;
3949 hdd_context_t *hdd_ctx;
3950 int ret;
3951
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003952 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003953
3954 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3955 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3956 ret = wlan_hdd_validate_context(hdd_ctx);
3957 if (0 != ret)
3958 return ret;
3959
3960 return 0;
3961}
3962
3963/**
3964 * iw_set_nick() - SSR wrapper for __iw_set_nick
3965 * @dev: pointer to net_device
3966 * @info: pointer to iw_request_info
3967 * @wrqu: pointer to iwreq_data
3968 * @extra: extra
3969 *
3970 * Return: 0 on success, error number otherwise
3971 */
3972static int iw_set_nick(struct net_device *dev,
3973 struct iw_request_info *info,
3974 union iwreq_data *wrqu, char *extra)
3975{
3976 int ret;
3977
3978 cds_ssr_protect(__func__);
3979 ret = __iw_set_nick(dev, info, wrqu, extra);
3980 cds_ssr_unprotect(__func__);
3981
3982 return ret;
3983}
3984
3985/**
3986 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
3987 * @dev: device upon which the ioctl was received
3988 * @info: ioctl request information
3989 * @wrqu: ioctl request data
3990 * @extra: ioctl extra data
3991 *
3992 * Return: 0 on success, non-zero on error
3993 */
3994static int __iw_get_nick(struct net_device *dev,
3995 struct iw_request_info *info,
3996 union iwreq_data *wrqu, char *extra)
3997{
3998 hdd_adapter_t *adapter;
3999 hdd_context_t *hdd_ctx;
4000 int ret;
4001
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004002 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003
4004 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4005 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4006 ret = wlan_hdd_validate_context(hdd_ctx);
4007 if (0 != ret)
4008 return ret;
4009
4010 return 0;
4011}
4012
4013/**
4014 * iw_get_nick() - SSR wrapper for __iw_get_nick
4015 * @dev: pointer to net_device
4016 * @info: pointer to iw_request_info
4017 * @wrqu: pointer to iwreq_data
4018 * @extra: extra
4019 *
4020 * Return: 0 on success, error number otherwise
4021 */
4022static int iw_get_nick(struct net_device *dev,
4023 struct iw_request_info *info,
4024 union iwreq_data *wrqu, char *extra)
4025{
4026 int ret;
4027
4028 cds_ssr_protect(__func__);
4029 ret = __iw_get_nick(dev, info, wrqu, extra);
4030 cds_ssr_unprotect(__func__);
4031
4032 return ret;
4033}
4034
4035/**
4036 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
4037 * @dev: device upon which the ioctl was received
4038 * @info: ioctl request information
4039 * @wrqu: ioctl request data
4040 * @extra: ioctl extra data
4041 *
4042 * Return: 0 on success, non-zero on error
4043 */
4044static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4045 union iwreq_data *wrqu, char *extra)
4046{
4047 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4048 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4049 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4050 hdd_context_t *hdd_ctx;
4051 struct iw_point *encoderq = &(wrqu->encoding);
4052 uint32_t keyId;
4053 uint8_t key_length;
4054 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4055 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304056 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057 int ret;
4058
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004059 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060
4061 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4062 ret = wlan_hdd_validate_context(hdd_ctx);
4063 if (0 != ret)
4064 return ret;
4065
4066 keyId = encoderq->flags & IW_ENCODE_INDEX;
4067
4068 if (keyId) {
4069 if (keyId > MAX_WEP_KEYS) {
4070 return -EINVAL;
4071 }
4072
4073 fKeyPresent = 1;
4074 keyId--;
4075 } else {
4076 fKeyPresent = 0;
4077 }
4078
4079 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004080 hdd_notice("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08004082 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
4083 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 }
4085 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4086 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4087 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4088 eCSR_ENCRYPT_TYPE_NONE;
4089 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4090 eCSR_ENCRYPT_TYPE_NONE;
4091
4092 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4093 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4094
4095 if (eConnectionState_Associated ==
4096 pHddStaCtx->conn_info.connState) {
4097 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4098 status =
4099 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4100 pAdapter->sessionId,
4101 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304102 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004103 unsigned long rc;
4104 rc = wait_for_completion_timeout(&pAdapter->
4105 disconnect_comp_var,
4106 msecs_to_jiffies
4107 (WLAN_WAIT_TIME_DISCONNECT));
4108 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004109 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 }
4111 }
4112
4113 return status;
4114
4115 }
4116
4117 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004118 hdd_notice("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004119
4120 pHddStaCtx->conn_info.authType =
4121 (encoderq->
4122 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
4123 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4124
4125 }
4126
4127 if (wrqu->data.length > 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004128 hdd_notice("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129
4130 key_length = wrqu->data.length;
4131
4132 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
4133
4134 if (5 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004135 hdd_notice("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 key_length);
4137
4138 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4139 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4140 pHddStaCtx->conn_info.authType)) {
4141 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4142 } else {
4143 encryptionType =
4144 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4145 }
4146 } else if (13 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004147 hdd_notice("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 key_length);
4149
4150 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4151 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4152 pHddStaCtx->conn_info.authType)) {
4153 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4154 } else {
4155 encryptionType =
4156 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4157 }
4158 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004159 hdd_warn("Invalid WEP key length :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 key_length);
4161 return -EINVAL;
4162 }
4163
4164 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4165 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4166 pWextState->roamProfile.EncryptionType.numEntries = 1;
4167 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4168 encryptionType;
4169 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4170 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4171 encryptionType;
4172
4173 if ((eConnectionState_NotConnected ==
4174 pHddStaCtx->conn_info.connState)
4175 &&
4176 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4177 pHddStaCtx->conn_info.authType)
4178 || (eCSR_AUTH_TYPE_SHARED_KEY ==
4179 pHddStaCtx->conn_info.authType))) {
4180
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304181 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 KeyMaterial[keyId][0], extra, key_length);
4183
4184 pWextState->roamProfile.Keys.KeyLength[keyId] =
4185 (uint8_t) key_length;
4186 pWextState->roamProfile.Keys.defaultIndex =
4187 (uint8_t) keyId;
4188
4189 return status;
4190 }
4191 }
4192
4193 return 0;
4194}
4195
4196/**
4197 * iw_set_encode() - SSR wrapper for __iw_set_encode()
4198 * @dev: pointer to net_device
4199 * @info: pointer to iw_request_info
4200 * @wrqu: pointer to iwreq_data
4201 * @extra: pointer to extra ioctl payload
4202 *
4203 * Return: 0 on success, error number otherwise
4204 */
4205static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4206 union iwreq_data *wrqu, char *extra)
4207{
4208 int ret;
4209
4210 cds_ssr_protect(__func__);
4211 ret = __iw_set_encode(dev, info, wrqu, extra);
4212 cds_ssr_unprotect(__func__);
4213
4214 return ret;
4215}
4216
4217/**
4218 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
4219 * @dev: device upon which the ioctl was received
4220 * @info: ioctl request information
4221 * @wrqu: ioctl request data
4222 * @extra: ioctl extra data
4223 *
4224 * Return: 0 on success, non-zero on error
4225 */
4226static int __iw_get_encodeext(struct net_device *dev,
4227 struct iw_request_info *info,
4228 struct iw_point *dwrq, char *extra)
4229{
4230 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4231 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4232 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4233 int keyId;
4234 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4235 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
4236 int i, ret;
4237 hdd_context_t *hdd_ctx;
4238
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004239 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004240
4241 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4242 ret = wlan_hdd_validate_context(hdd_ctx);
4243 if (0 != ret)
4244 return ret;
4245
4246 keyId = pRoamProfile->Keys.defaultIndex;
4247
4248 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004249 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004250 return -EINVAL;
4251 }
4252
4253 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
4254 dwrq->flags |= IW_ENCODE_ENABLED;
4255 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304256 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004257 pRoamProfile->Keys.KeyLength[keyId]);
4258 } else {
4259 dwrq->flags |= IW_ENCODE_DISABLED;
4260 }
4261
4262 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08004263 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 continue;
4265 } else {
4266 break;
4267 }
4268 }
4269
4270 if (MAX_WEP_KEYS == i) {
4271 dwrq->flags |= IW_ENCODE_NOKEY;
4272 } else {
4273 dwrq->flags |= IW_ENCODE_ENABLED;
4274 }
4275
4276 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4277
4278 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
4279 dwrq->flags |= IW_ENCODE_DISABLED;
4280 }
4281
4282 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4283
4284 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
4285 dwrq->flags |= IW_ENCODE_OPEN;
4286 } else {
4287 dwrq->flags |= IW_ENCODE_RESTRICTED;
4288 }
4289 EXIT();
4290 return 0;
4291
4292}
4293
4294/**
4295 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
4296 * @dev: pointer to net_device
4297 * @info: pointer to iw_request_info
4298 * @dwrq: pointer to encoding information
4299 * @extra: pointer to extra ioctl payload
4300 *
4301 * Return: 0 on success, error number otherwise
4302 */
4303static int iw_get_encodeext(struct net_device *dev,
4304 struct iw_request_info *info,
4305 struct iw_point *dwrq, char *extra)
4306{
4307 int ret;
4308
4309 cds_ssr_protect(__func__);
4310 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4311 cds_ssr_unprotect(__func__);
4312
4313 return ret;
4314}
4315
4316/**
4317 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
4318 * @dev: device upon which the ioctl was received
4319 * @info: ioctl request information
4320 * @wrqu: ioctl request data
4321 * @extra: ioctl extra data
4322 *
4323 * Return: 0 on success, non-zero on error
4324 */
4325static int __iw_set_encodeext(struct net_device *dev,
4326 struct iw_request_info *info,
4327 union iwreq_data *wrqu, char *extra)
4328{
4329 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4330 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4331 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4332 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304333 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004334 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4335 int ret;
4336 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
4337 int key_index;
4338 struct iw_point *encoding = &wrqu->encoding;
4339 tCsrRoamSetKey setKey;
4340 uint32_t roamId = 0xFF;
4341
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004342 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004343
4344 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4345 ret = wlan_hdd_validate_context(hdd_ctx);
4346 if (0 != ret)
4347 return ret;
4348
4349 key_index = encoding->flags & IW_ENCODE_INDEX;
4350
4351 if (key_index > 0) {
4352
4353 /*Convert from 1-based to 0-based keying */
4354 key_index--;
4355 }
4356 if (!ext->key_len) {
4357
4358 /*Set the encrytion type to NONE */
4359 pRoamProfile->EncryptionType.encryptionType[0] =
4360 eCSR_ENCRYPT_TYPE_NONE;
4361 return ret;
4362 }
4363
4364 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4365 (IW_ENCODE_ALG_WEP == ext->alg)) {
4366 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4367
Jeff Johnson99bac312016-06-28 10:38:18 -07004368 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004369 return -EINVAL;
4370 } else {
4371 /*Static wep, update the roam profile with the keys */
Yingying Tang3cc6b792016-10-20 17:00:37 +08004372 if (ext->key_len
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004373 && (ext->key_len <=
4374 eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES)
4375 && key_index < CSR_MAX_NUM_KEY) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304376 qdf_mem_copy(&pRoamProfile->Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377 KeyMaterial[key_index][0],
4378 ext->key, ext->key_len);
4379 pRoamProfile->Keys.KeyLength[key_index] =
4380 (uint8_t) ext->key_len;
4381
4382 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4383 pRoamProfile->Keys.defaultIndex =
4384 (uint8_t) key_index;
4385
4386 }
4387 }
4388 return ret;
4389 }
4390
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304391 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004392
4393 setKey.keyId = key_index;
4394 setKey.keyLength = ext->key_len;
4395
4396 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304397 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004398 }
4399
4400 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4401 /*Key direction for group is RX only */
4402 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05304403 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404 } else {
4405
4406 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304407 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304408 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004409 }
4410
4411 /*For supplicant pae role is zero */
4412 setKey.paeRole = 0;
4413
4414 switch (ext->alg) {
4415 case IW_ENCODE_ALG_NONE:
4416 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4417 break;
4418
4419 case IW_ENCODE_ALG_WEP:
4420 setKey.encType =
4421 (ext->key_len ==
4422 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
4423 break;
4424
4425 case IW_ENCODE_ALG_TKIP:
4426 {
4427 uint8_t *pKey = &setKey.Key[0];
4428
4429 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4430
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304431 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432
4433 /* Supplicant sends the 32bytes key in this order
4434 * |--------------|----------|----------|
4435 * | Tk1 | TX MIC | RX MIC |
4436 * |--------------|----------|----------|
4437 * <---16bytes---><--8bytes--><--8bytes-->
4438 *
4439 *
4440 * Sme expects the 32 bytes key to be in the below order
4441 * |--------------|----------|----------|
4442 * | Tk1 | RX MIC | TX MIC |
4443 * |--------------|----------|----------|
4444 * <---16bytes---><--8bytes--><--8bytes-->
4445 */
4446
4447 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304448 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449
4450 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304451 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452
4453 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304454 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455
4456 }
4457 break;
4458
4459 case IW_ENCODE_ALG_CCMP:
4460 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4461 break;
4462
4463#ifdef FEATURE_WLAN_ESE
4464#define IW_ENCODE_ALG_KRK 6
4465 case IW_ENCODE_ALG_KRK:
4466 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4467 break;
4468#endif /* FEATURE_WLAN_ESE */
4469
4470 default:
4471 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4472 break;
4473 }
4474
Jeff Johnson99bac312016-06-28 10:38:18 -07004475 hdd_notice("cipher_alg:%d key_len:%d EncryptionType:%d",
4476 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 /* The supplicant may attempt to set the PTK once
4479 * pre-authentication is done. Save the key in the UMAC and
4480 * include it in the ADD BSS request
4481 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304482 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304484 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004485 hdd_info("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304487 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004488 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004489 return -EINVAL;
4490 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491
4492 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4493
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304494 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495 pAdapter->sessionId,
4496 &setKey, &roamId);
4497
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304498 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004499 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304500 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501
4502 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4503 }
4504
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304505 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004506}
4507
4508/**
4509 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
4510 * @dev: pointer to net_device
4511 * @info: pointer to iw_request_info
4512 * @wrqu: pointer to iwreq_data
4513 * @extra: pointer to extra ioctl payload
4514 *
4515 * Return: 0 on success, error number otherwise
4516 */
4517static int iw_set_encodeext(struct net_device *dev,
4518 struct iw_request_info *info,
4519 union iwreq_data *wrqu, char *extra)
4520{
4521 int ret;
4522
4523 cds_ssr_protect(__func__);
4524 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4525 cds_ssr_unprotect(__func__);
4526
4527 return ret;
4528}
4529
4530/**
4531 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
4532 * @dev: device upon which the ioctl was received
4533 * @info: ioctl request information
4534 * @wrqu: ioctl request data
4535 * @extra: ioctl extra data
4536 *
4537 * Return: 0 on success, non-zero on error
4538 */
4539static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
4540 union iwreq_data *wrqu, char *extra)
4541{
4542 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4543 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4544 hdd_context_t *hdd_ctx;
4545 int ret;
4546
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004547 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548
4549 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4550 ret = wlan_hdd_validate_context(hdd_ctx);
4551 if (0 != ret)
4552 return ret;
4553
4554 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4555 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4556
Jeff Johnson99bac312016-06-28 10:38:18 -07004557 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558
4559 return -EINVAL;
4560 }
4561
4562 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
4563
4564 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
4565 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
4566 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304567 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004568 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569 return -EIO;
4570 }
4571 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
4572 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
4573 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304574 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05304575 hdd_err("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576 return -EIO;
4577 }
4578 }
4579 } else {
4580 return -EOPNOTSUPP;
4581 }
4582
Jeff Johnson99bac312016-06-28 10:38:18 -07004583 hdd_notice("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584
4585 EXIT();
4586
4587 return 0;
4588
4589}
4590
4591/**
4592 * iw_set_retry() - SSR wrapper for __iw_set_retry()
4593 * @dev: pointer to net_device
4594 * @info: pointer to iw_request_info
4595 * @wrqu: pointer to iwreq_data
4596 * @extra: pointer to extra ioctl payload
4597 *
4598 * Return: 0 on success, error number otherwise
4599 */
4600static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
4601 union iwreq_data *wrqu, char *extra)
4602{
4603 int ret;
4604
4605 cds_ssr_protect(__func__);
4606 ret = __iw_set_retry(dev, info, wrqu, extra);
4607 cds_ssr_unprotect(__func__);
4608
4609 return ret;
4610}
4611
4612/**
4613 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
4614 * @dev: device upon which the ioctl was received
4615 * @info: ioctl request information
4616 * @wrqu: ioctl request data
4617 * @extra: ioctl extra data
4618 *
4619 * Return: 0 on success, non-zero on error
4620 */
4621static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
4622 union iwreq_data *wrqu, char *extra)
4623{
4624 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4625 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4626 uint32_t retry = 0;
4627 hdd_context_t *hdd_ctx;
4628 int ret;
4629
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004630 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631
4632 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4633 ret = wlan_hdd_validate_context(hdd_ctx);
4634 if (0 != ret)
4635 return ret;
4636
4637 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
4638 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
4639
4640 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304641 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004642 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 return -EIO;
4644 }
4645
4646 wrqu->retry.value = retry;
4647 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
4648 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
4649
4650 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304651 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05304652 hdd_warn("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 return -EIO;
4654 }
4655
4656 wrqu->retry.value = retry;
4657 } else {
4658 return -EOPNOTSUPP;
4659 }
4660
Jeff Johnson99bac312016-06-28 10:38:18 -07004661 hdd_notice("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004662
4663 EXIT();
4664
4665 return 0;
4666}
4667
4668/**
4669 * iw_get_retry() - SSR wrapper for __iw_get_retry()
4670 * @dev: pointer to net_device
4671 * @info: pointer to iw_request_info
4672 * @wrqu: pointer to iwreq_data
4673 * @extra: pointer to extra ioctl payload
4674 *
4675 * Return: 0 on success, error number otherwise
4676 */
4677static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
4678 union iwreq_data *wrqu, char *extra)
4679{
4680 int ret;
4681
4682 cds_ssr_protect(__func__);
4683 ret = __iw_get_retry(dev, info, wrqu, extra);
4684 cds_ssr_unprotect(__func__);
4685
4686 return ret;
4687}
4688
4689/**
4690 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
4691 * @dev: device upon which the ioctl was received
4692 * @info: ioctl request information
4693 * @wrqu: ioctl request data
4694 * @extra: ioctl extra data
4695 *
4696 * Return: 0 on success, non-zero on error
4697 */
4698static int __iw_set_mlme(struct net_device *dev,
4699 struct iw_request_info *info,
4700 union iwreq_data *wrqu, char *extra)
4701{
4702 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4703 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4704 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304705 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004706 hdd_context_t *hdd_ctx;
4707 int ret;
4708
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004709 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710
4711 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4712 ret = wlan_hdd_validate_context(hdd_ctx);
4713 if (0 != ret)
4714 return ret;
4715
4716 /* reason_code is unused. By default it is set to
4717 * eCSR_DISCONNECT_REASON_UNSPECIFIED
4718 */
4719 switch (mlme->cmd) {
4720 case IW_MLME_DISASSOC:
4721 case IW_MLME_DEAUTH:
4722
4723 if (pHddStaCtx->conn_info.connState ==
4724 eConnectionState_Associated) {
4725 eCsrRoamDisconnectReason reason =
4726 eCSR_DISCONNECT_REASON_UNSPECIFIED;
4727
4728 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
4729 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4730
4731 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4732 status =
4733 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4734 pAdapter->sessionId, reason);
4735
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304736 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004737 unsigned long rc;
4738 rc = wait_for_completion_timeout(&pAdapter->
4739 disconnect_comp_var,
4740 msecs_to_jiffies
4741 (WLAN_WAIT_TIME_DISCONNECT));
4742 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004743 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004744 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07004745 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
4746 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747
4748 /* Resetting authKeyMgmt */
4749 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
4750 0;
4751
Jeff Johnson99bac312016-06-28 10:38:18 -07004752 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753 wlan_hdd_netif_queue_control(pAdapter,
4754 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4755 WLAN_CONTROL_PATH);
4756
4757 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004758 hdd_err("%d Command Disassociate/Deauthenticate called but station is not in associated state",
4759 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 }
4761 break;
4762 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004763 hdd_err("%d Command should be Disassociate/Deauthenticate",
4764 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004765 return -EINVAL;
4766 } /* end of switch */
4767
4768 EXIT();
4769
4770 return status;
4771
4772}
4773
4774/**
4775 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
4776 * @dev: pointer to net_device
4777 * @info: pointer to iw_request_info
4778 * @wrqu: pointer to iwreq_data
4779 * @extra: pointer to extra ioctl payload
4780 *
4781 * Return: 0 on success, error number otherwise
4782 */
4783static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
4784 union iwreq_data *wrqu, char *extra)
4785{
4786 int ret;
4787
4788 cds_ssr_protect(__func__);
4789 ret = __iw_set_mlme(dev, info, wrqu, extra);
4790 cds_ssr_unprotect(__func__);
4791
4792 return ret;
4793}
4794
4795/**
4796 * wlan_hdd_update_phymode() - handle change in PHY mode
4797 * @net: device upon which PHY mode change was received
4798 * @hal: umac handle for the driver
4799 * @new_phymode: new PHY mode for the device
4800 * @phddctx: pointer to the HDD context
4801 *
4802 * This function is called when the device is set to a new PHY mode.
4803 * It takes a holistic look at the desired PHY mode along with the
4804 * configured capabilities of the driver and the reported capabilities
4805 * of the hardware in order to correctly configure all PHY-related
4806 * parameters.
4807 *
4808 * Return: 0 on success, negative errno value on error
4809 */
4810int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
4811 int new_phymode, hdd_context_t *phddctx)
4812{
4813#ifdef QCA_HT_2040_COEX
4814 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304815 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004816#endif
4817 bool band_24 = false, band_5g = false;
4818 bool ch_bond24 = false, ch_bond5g = false;
4819 tSmeConfigParams smeconfig;
4820 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004821 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 eCsrPhyMode phymode = -EIO, old_phymode;
4823 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
4824 eCsrBand curr_band = eCSR_BAND_ALL;
4825
4826 old_phymode = sme_get_phy_mode(hal);
4827
4828 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
4829 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
4830 nChannelBondingMode24GHz))
4831 ch_bond24 = true;
4832
4833 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
4834 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
4835 nChannelBondingMode5GHz))
4836 ch_bond5g = true;
4837
4838 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
4839 band_24 = band_5g = true;
4840 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
4841 band_24 = true;
4842 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
4843 band_5g = true;
4844 }
4845
4846 vhtchanwidth = phddctx->config->vhtChannelWidth;
Jeff Johnson99bac312016-06-28 10:38:18 -07004847 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 -08004848 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
4849
4850 switch (new_phymode) {
4851 case IEEE80211_MODE_AUTO:
4852 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4853 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
4854 phymode = eCSR_DOT11_MODE_AUTO;
4855 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4856 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4857 curr_band = eCSR_BAND_ALL;
4858 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
4859 } else {
4860 sme_set_phy_mode(hal, old_phymode);
4861 return -EIO;
4862 }
4863 break;
4864 case IEEE80211_MODE_11A:
4865 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
4866 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4867 phymode = eCSR_DOT11_MODE_11a;
4868 hdd_dot11mode = eHDD_DOT11_MODE_11a;
4869 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4870 curr_band = eCSR_BAND_5G;
4871 } else {
4872 sme_set_phy_mode(hal, old_phymode);
4873 return -EIO;
4874 }
4875 break;
4876 case IEEE80211_MODE_11B:
4877 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
4878 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4879 phymode = eCSR_DOT11_MODE_11b;
4880 hdd_dot11mode = eHDD_DOT11_MODE_11b;
4881 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4882 curr_band = eCSR_BAND_24;
4883 } else {
4884 sme_set_phy_mode(hal, old_phymode);
4885 return -EIO;
4886 }
4887 break;
4888 case IEEE80211_MODE_11G:
4889 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
4890 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4891 phymode = eCSR_DOT11_MODE_11g;
4892 hdd_dot11mode = eHDD_DOT11_MODE_11g;
4893 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4894 curr_band = eCSR_BAND_24;
4895 } else {
4896 sme_set_phy_mode(hal, old_phymode);
4897 return -EIO;
4898 }
4899 break;
4900 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
4901 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
4902 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
4903 */
4904 case IEEE80211_MODE_11NA_HT20:
4905 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4906 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4907 phymode = eCSR_DOT11_MODE_11n;
4908 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4909 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4910 curr_band = eCSR_BAND_5G;
4911 } else {
4912 sme_set_phy_mode(hal, old_phymode);
4913 return -EIO;
4914 }
4915 break;
4916 case IEEE80211_MODE_11NA_HT40:
4917 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4918 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4919 phymode = eCSR_DOT11_MODE_11n;
4920 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4921 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4922 curr_band = eCSR_BAND_5G;
4923 } else {
4924 sme_set_phy_mode(hal, old_phymode);
4925 return -EIO;
4926 }
4927 break;
4928 case IEEE80211_MODE_11NG_HT20:
4929 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4930 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4931 phymode = eCSR_DOT11_MODE_11n;
4932 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4933 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4934 curr_band = eCSR_BAND_24;
4935 } else {
4936 sme_set_phy_mode(hal, old_phymode);
4937 return -EIO;
4938 }
4939 break;
4940 case IEEE80211_MODE_11NG_HT40:
4941 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4942 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4943 phymode = eCSR_DOT11_MODE_11n;
4944 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4945 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4946 curr_band = eCSR_BAND_24;
4947 } else {
4948 sme_set_phy_mode(hal, old_phymode);
4949 return -EIO;
4950 }
4951 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004952 case IEEE80211_MODE_11AC_VHT20:
4953 case IEEE80211_MODE_11AC_VHT40:
4954 case IEEE80211_MODE_11AC_VHT80:
4955 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
4956 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4957 phymode = eCSR_DOT11_MODE_11ac;
4958 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
4959 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4960 curr_band = eCSR_BAND_5G;
4961 } else {
4962 sme_set_phy_mode(hal, old_phymode);
4963 return -EIO;
4964 }
4965 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004966 case IEEE80211_MODE_2G_AUTO:
4967 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4968 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4969 phymode = eCSR_DOT11_MODE_AUTO;
4970 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4971 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4972 curr_band = eCSR_BAND_24;
4973 } else {
4974 sme_set_phy_mode(hal, old_phymode);
4975 return -EIO;
4976 }
4977 break;
4978 case IEEE80211_MODE_5G_AUTO:
4979 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4980 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4981 phymode = eCSR_DOT11_MODE_AUTO;
4982 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4983 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4984 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
4985 curr_band = eCSR_BAND_5G;
4986 } else {
4987 sme_set_phy_mode(hal, old_phymode);
4988 return -EIO;
4989 }
4990 break;
4991 case IEEE80211_MODE_11AGN:
4992 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4993 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
4994 phymode = eCSR_DOT11_MODE_11n;
4995 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4996 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4997 curr_band = eCSR_BAND_ALL;
4998 } else {
4999 sme_set_phy_mode(hal, old_phymode);
5000 return -EIO;
5001 }
5002 break;
5003 default:
5004 return -EIO;
5005 }
5006
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005007 switch (new_phymode) {
5008 case IEEE80211_MODE_11AC_VHT20:
5009 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5010 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
5011 break;
5012 case IEEE80211_MODE_11AC_VHT40:
5013 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
5014 break;
5015 case IEEE80211_MODE_11AC_VHT80:
5016 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5017 break;
5018 default:
5019 vhtchanwidth = phddctx->config->vhtChannelWidth;
5020 break;
5021 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022
5023 if (phymode != -EIO) {
5024 sme_get_config_param(hal, &smeconfig);
5025 smeconfig.csrConfig.phyMode = phymode;
5026#ifdef QCA_HT_2040_COEX
5027 if (phymode == eCSR_DOT11_MODE_11n &&
5028 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
5029 smeconfig.csrConfig.obssEnabled = false;
5030 halStatus = sme_set_ht2040_mode(hal,
5031 pAdapter->sessionId,
5032 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305033 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005034 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005035 return -EIO;
5036 }
5037 } else if (phymode == eCSR_DOT11_MODE_11n &&
5038 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
5039 smeconfig.csrConfig.obssEnabled = true;
5040 halStatus = sme_set_ht2040_mode(hal,
5041 pAdapter->sessionId,
5042 eHT_CHAN_HT20, true);
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 enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005045 return -EIO;
5046 }
5047 }
5048#endif
5049 smeconfig.csrConfig.eBand = curr_band;
5050 smeconfig.csrConfig.bandCapability = curr_band;
5051 if (curr_band == eCSR_BAND_24)
5052 smeconfig.csrConfig.Is11hSupportEnabled = 0;
5053 else
5054 smeconfig.csrConfig.Is11hSupportEnabled =
5055 phddctx->config->Is11hSupportEnabled;
5056 if (curr_band == eCSR_BAND_24)
5057 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5058 else if (curr_band == eCSR_BAND_24)
5059 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5060 else {
5061 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5062 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5063 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005064 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005065 sme_update_config(hal, &smeconfig);
5066
5067 phddctx->config->dot11Mode = hdd_dot11mode;
5068 phddctx->config->nBandCapability = curr_band;
5069 phddctx->config->nChannelBondingMode24GHz =
5070 smeconfig.csrConfig.channelBondingMode24GHz;
5071 phddctx->config->nChannelBondingMode5GHz =
5072 smeconfig.csrConfig.channelBondingMode5GHz;
5073 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07005074 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005075 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005076 return -EIO;
5077 }
5078 if (phddctx->config->nChannelBondingMode5GHz)
Dustin Browna30892e2016-10-12 17:28:36 -07005079 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005080 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5081 else
Dustin Browna30892e2016-10-12 17:28:36 -07005082 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005083 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5084
Jeff Johnson99bac312016-06-28 10:38:18 -07005085 hdd_warn("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005086 phymode, chwidth, curr_band, vhtchanwidth);
5087 }
5088
5089 return 0;
5090}
5091
5092/**
5093 * hdd_get_temperature_cb() - "Get Temperature" callback function
5094 * @temperature: measured temperature
5095 * @pContext: callback context
5096 *
5097 * This function is passed to sme_get_temperature() as the callback
5098 * function to be invoked when the temperature measurement is
5099 * available.
5100 *
5101 * Return: None
5102 */
5103static void hdd_get_temperature_cb(int temperature, void *pContext)
5104{
5105 struct statsContext *pTempContext;
5106 hdd_adapter_t *pAdapter;
5107 ENTER();
5108 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005109 hdd_err("pContext is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005110 return;
5111 }
5112 pTempContext = pContext;
5113 pAdapter = pTempContext->pAdapter;
5114 spin_lock(&hdd_context_lock);
5115 if ((NULL == pAdapter) || (TEMP_CONTEXT_MAGIC != pTempContext->magic)) {
5116 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07005117 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005118 pAdapter, pTempContext->magic);
5119 return;
5120 }
5121 if (temperature != 0) {
5122 pAdapter->temperature = temperature;
5123 }
5124 complete(&pTempContext->completion);
5125 spin_unlock(&hdd_context_lock);
5126 EXIT();
5127}
5128
5129/**
5130 * wlan_hdd_get_temperature() - get current device temperature
5131 * @pAdapter: device upon which the request was made
5132 * @temperature: pointer to where the temperature is to be returned
5133 *
5134 * Return: 0 if a temperature value (either current or cached) was
5135 * returned, otherwise a negative errno is returned.
5136 *
5137 */
5138int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
5139{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305140 QDF_STATUS status;
Houston Hoffman59c097f2016-11-09 15:50:25 -08005141 static struct statsContext tempContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005142 unsigned long rc;
5143
5144 ENTER();
5145 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005146 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 return -EPERM;
5148 }
5149 init_completion(&tempContext.completion);
5150 tempContext.pAdapter = pAdapter;
5151 tempContext.magic = TEMP_CONTEXT_MAGIC;
5152 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
5153 &tempContext, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305154 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005155 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 } else {
5157 rc = wait_for_completion_timeout(&tempContext.completion,
5158 msecs_to_jiffies
5159 (WLAN_WAIT_TIME_STATS));
5160 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005161 hdd_err("SME timed out while retrieving temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162 }
5163 }
5164 spin_lock(&hdd_context_lock);
5165 tempContext.magic = 0;
5166 spin_unlock(&hdd_context_lock);
5167 *temperature = pAdapter->temperature;
5168 EXIT();
5169 return 0;
5170}
5171
5172/**
5173 * iw_setint_getnone() - Generic "set integer" private ioctl handler
5174 * @dev: device upon which the ioctl was received
5175 * @info: ioctl request information
5176 * @wrqu: ioctl request data
5177 * @extra: ioctl extra data
5178 *
5179 * Return: 0 on success, non-zero on error
5180 */
5181static int __iw_setint_getnone(struct net_device *dev,
5182 struct iw_request_info *info,
5183 union iwreq_data *wrqu, char *extra)
5184{
5185 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5186 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5187 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5188 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5189 hdd_context_t *hdd_ctx;
5190 tSmeConfigParams smeConfig;
5191 int *value = (int *)extra;
5192 int sub_cmd = value[0];
5193 int set_value = value[1];
5194 int ret;
5195 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305196 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005198 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305199
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 INIT_COMPLETION(pWextState->completion_var);
Mukul Sharma81661ae2015-10-30 20:26:02 +05305201 memset(&smeConfig, 0x00, sizeof(smeConfig));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005202
5203 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5204 ret = wlan_hdd_validate_context(hdd_ctx);
5205 if (0 != ret)
5206 return ret;
5207
5208 switch (sub_cmd) {
5209 case WE_SET_11D_STATE:
5210 {
5211 if ((ENABLE_11D == set_value)
5212 || (DISABLE_11D == set_value)) {
5213
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005214 sme_get_config_param(hHal, &smeConfig);
5215 smeConfig.csrConfig.Is11dSupportEnabled =
5216 (bool) set_value;
5217
Jeff Johnson99bac312016-06-28 10:38:18 -07005218 hdd_notice("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005219 smeConfig.csrConfig.
5220 Is11dSupportEnabled);
5221
5222 sme_update_config(hHal, &smeConfig);
5223 } else {
5224 return -EINVAL;
5225 }
5226 break;
5227 }
5228
5229 case WE_WOWL:
5230 {
5231 switch (set_value) {
5232 case 0x00:
5233 hdd_exit_wowl(pAdapter);
5234 break;
5235 case 0x01:
5236 case 0x02:
5237 case 0x03:
5238 enable_mp = (set_value & 0x01) ? 1 : 0;
5239 enable_pbm = (set_value & 0x02) ? 1 : 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005240 hdd_err("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005241 (enable_mp ? "YES" : "NO"),
5242 (enable_pbm ? "YES" : "NO"));
5243 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5244 break;
5245 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005246 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247 set_value);
5248 ret = -EINVAL;
5249 break;
5250 }
5251
5252 break;
5253 }
5254 case WE_SET_POWER:
5255 {
5256 switch (set_value) {
5257 case 1:
5258 /* Enable PowerSave */
5259 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5260 SME_PS_ENABLE);
5261 break;
5262 case 2:
5263 /* Disable PowerSave */
5264 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5265 SME_PS_DISABLE);
5266 break;
5267 case 3: /* Enable UASPD */
5268 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
5269 break;
5270 case 4: /* Disable UASPD */
5271 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
5272 break;
5273 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005274 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275 set_value);
5276 ret = -EINVAL;
5277 break;
5278 }
5279 break;
5280 }
5281
5282 case WE_SET_MAX_ASSOC:
5283 {
5284 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5285 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
5286 ret = -EINVAL;
5287 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5288 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305289 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005290 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005291 ret = -EIO;
5292 }
5293 break;
5294 }
5295
5296 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5297 if (set_value == 0 || set_value == 1)
5298 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
5299 set_value;
5300 else
5301 ret = -EINVAL;
5302 break;
5303
5304 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005305 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5306 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5307 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5308 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305309 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005310 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005311 ret = -EINVAL;
5312 }
5313 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314 case WE_SET_MC_RATE:
5315 {
5316 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
5317 break;
5318 }
5319 case WE_SET_TX_POWER:
5320 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305321 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322
Anurag Chouhanc5548422016-02-24 18:33:27 +05305323 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324 if (sme_set_tx_power
5325 (hHal, pAdapter->sessionId, bssid,
5326 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305327 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005328 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005329 return -EIO;
5330 }
5331 break;
5332 }
5333 case WE_SET_MAX_TX_POWER:
5334 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305335 struct qdf_mac_addr bssid;
5336 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337
Jeff Johnson99bac312016-06-28 10:38:18 -07005338 hdd_notice("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005339 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05305340 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
5341 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005342
5343 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305344 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005345 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005346 return -EIO;
5347 }
5348
5349 break;
5350 }
5351 case WE_SET_MAX_TX_POWER_2_4:
5352 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005353 hdd_notice("Setting maximum tx power %d dBm for 2.4 GHz band",
5354 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005355 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305356 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005357 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005358 return -EIO;
5359 }
5360
5361 break;
5362 }
5363 case WE_SET_MAX_TX_POWER_5_0:
5364 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005365 hdd_notice("Setting maximum tx power %d dBm for 5.0 GHz band",
5366 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005367 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305368 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005369 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005370 return -EIO;
5371 }
5372
5373 break;
5374 }
5375 case WE_SET_HIGHER_DTIM_TRANSITION:
5376 {
5377 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005378 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379 set_value);
5380 ret = -EINVAL;
5381 } else {
5382 if (pAdapter->higherDtimTransition != set_value) {
5383 pAdapter->higherDtimTransition =
5384 set_value;
Jeff Johnson99bac312016-06-28 10:38:18 -07005385 hdd_notice("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005386 pAdapter->higherDtimTransition);
5387 }
5388 }
5389
5390 break;
5391 }
5392
5393 case WE_SET_TM_LEVEL:
5394 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005395 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005396 (void)sme_set_thermal_level(hHal, set_value);
5397 break;
5398 }
5399
5400 case WE_SET_PHYMODE:
5401 {
5402 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5403
5404 ret =
5405 wlan_hdd_update_phymode(dev, hHal, set_value,
5406 phddctx);
5407 break;
5408 }
5409
5410 case WE_SET_NSS:
5411 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005412 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005413 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005414 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005415 ret = -EINVAL;
5416 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305417 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
5419 set_value))
5420 ret = -EINVAL;
5421 }
5422 break;
5423 }
5424
5425 case WE_SET_GTX_HT_MCS:
5426 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005427 hdd_notice("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 ret = wma_cli_set_command(pAdapter->sessionId,
5429 WMI_VDEV_PARAM_GTX_HT_MCS,
5430 set_value, GTX_CMD);
5431 break;
5432 }
5433
5434 case WE_SET_GTX_VHT_MCS:
5435 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005436 hdd_notice("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005437 set_value);
5438 ret = wma_cli_set_command(pAdapter->sessionId,
5439 WMI_VDEV_PARAM_GTX_VHT_MCS,
5440 set_value, GTX_CMD);
5441 break;
5442 }
5443
5444 case WE_SET_GTX_USRCFG:
5445 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005446 hdd_notice("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 set_value);
5448 ret = wma_cli_set_command(pAdapter->sessionId,
5449 WMI_VDEV_PARAM_GTX_USR_CFG,
5450 set_value, GTX_CMD);
5451 break;
5452 }
5453
5454 case WE_SET_GTX_THRE:
5455 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005456 hdd_notice("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457 ret = wma_cli_set_command(pAdapter->sessionId,
5458 WMI_VDEV_PARAM_GTX_THRE,
5459 set_value, GTX_CMD);
5460 break;
5461 }
5462
5463 case WE_SET_GTX_MARGIN:
5464 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005465 hdd_notice("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 ret = wma_cli_set_command(pAdapter->sessionId,
5467 WMI_VDEV_PARAM_GTX_MARGIN,
5468 set_value, GTX_CMD);
5469 break;
5470 }
5471
5472 case WE_SET_GTX_STEP:
5473 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005474 hdd_notice("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005475 ret = wma_cli_set_command(pAdapter->sessionId,
5476 WMI_VDEV_PARAM_GTX_STEP,
5477 set_value, GTX_CMD);
5478 break;
5479 }
5480
5481 case WE_SET_GTX_MINTPC:
5482 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005483 hdd_notice("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005484 ret = wma_cli_set_command(pAdapter->sessionId,
5485 WMI_VDEV_PARAM_GTX_MINTPC,
5486 set_value, GTX_CMD);
5487 break;
5488 }
5489
5490 case WE_SET_GTX_BWMASK:
5491 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005492 hdd_notice("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005493 ret = wma_cli_set_command(pAdapter->sessionId,
5494 WMI_VDEV_PARAM_GTX_BW_MASK,
5495 set_value, GTX_CMD);
5496 break;
5497 }
5498
5499 case WE_SET_LDPC:
5500 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305501 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502 break;
5503 }
5504
5505 case WE_SET_TX_STBC:
5506 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305507 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508 break;
5509 }
5510
5511 case WE_SET_RX_STBC:
5512 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305513 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514 break;
5515 }
5516
5517 case WE_SET_SHORT_GI:
5518 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005519 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
5521 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
5522 set_value);
5523 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07005524 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005525 break;
5526 }
5527
5528 case WE_SET_RTSCTS:
5529 {
5530 uint32_t value;
5531
Jeff Johnson99bac312016-06-28 10:38:18 -07005532 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005533 set_value);
5534
5535 if ((set_value & HDD_RTSCTS_EN_MASK) ==
5536 HDD_RTSCTS_ENABLE)
5537 value =
5538 (WLAN_HDD_GET_CTX(pAdapter))->config->
5539 RTSThreshold;
5540 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
5541 || ((set_value & HDD_RTSCTS_EN_MASK) ==
5542 HDD_CTS_ENABLE))
5543 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
5544 else
5545 return -EIO;
5546
5547 ret = wma_cli_set_command(pAdapter->sessionId,
5548 WMI_VDEV_PARAM_ENABLE_RTSCTS,
5549 set_value, VDEV_CMD);
5550 if (!ret) {
5551 if (sme_cfg_set_int
5552 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305553 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005554 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005555 return -EIO;
5556 }
5557 }
5558
5559 break;
5560 }
5561
5562 case WE_SET_CHWIDTH:
5563 {
5564 bool chwidth = false;
5565 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5566 /*updating channel bonding only on 5Ghz */
Jeff Johnson99bac312016-06-28 10:38:18 -07005567 hdd_notice("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568 set_value);
5569 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005570 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005571 return -EINVAL;
5572 }
5573
5574 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5575 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
5576 nChannelBondingMode5GHz)))
5577 chwidth = true;
5578
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005579 sme_get_config_param(hHal, &smeConfig);
5580 switch (set_value) {
5581 case eHT_CHANNEL_WIDTH_20MHZ:
5582 smeConfig.csrConfig.channelBondingMode5GHz =
5583 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5584 break;
5585 case eHT_CHANNEL_WIDTH_40MHZ:
5586 if (chwidth)
5587 smeConfig.csrConfig.
5588 channelBondingMode5GHz =
5589 phddctx->config->
5590 nChannelBondingMode5GHz;
5591 else
5592 return -EINVAL;
5593
5594 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595 case eHT_CHANNEL_WIDTH_80MHZ:
5596 if (chwidth)
5597 smeConfig.csrConfig.
5598 channelBondingMode5GHz =
5599 phddctx->config->
5600 nChannelBondingMode5GHz;
5601 else
5602 return -EINVAL;
5603
5604 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605
5606 default:
5607 return -EINVAL;
5608 }
5609
5610 ret = wma_cli_set_command(pAdapter->sessionId,
5611 WMI_VDEV_PARAM_CHWIDTH,
5612 set_value, VDEV_CMD);
5613 if (!ret)
5614 sme_update_config(hHal, &smeConfig);
5615
5616 break;
5617 }
5618
5619 case WE_SET_ANI_EN_DIS:
5620 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005621 hdd_notice("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005622 set_value);
5623 ret = wma_cli_set_command(pAdapter->sessionId,
5624 WMI_PDEV_PARAM_ANI_ENABLE,
5625 set_value, PDEV_CMD);
5626 break;
5627 }
5628
5629 case WE_SET_ANI_POLL_PERIOD:
5630 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005631 hdd_notice("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632 set_value);
5633 ret = wma_cli_set_command(pAdapter->sessionId,
5634 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
5635 set_value, PDEV_CMD);
5636 break;
5637 }
5638
5639 case WE_SET_ANI_LISTEN_PERIOD:
5640 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005641 hdd_notice("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642 set_value);
5643 ret = wma_cli_set_command(pAdapter->sessionId,
5644 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
5645 set_value, PDEV_CMD);
5646 break;
5647 }
5648
5649 case WE_SET_ANI_OFDM_LEVEL:
5650 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005651 hdd_notice("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005652 set_value);
5653 ret = wma_cli_set_command(pAdapter->sessionId,
5654 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
5655 set_value, PDEV_CMD);
5656 break;
5657 }
5658
5659 case WE_SET_ANI_CCK_LEVEL:
5660 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005661 hdd_notice("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005662 set_value);
5663 ret = wma_cli_set_command(pAdapter->sessionId,
5664 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
5665 set_value, PDEV_CMD);
5666 break;
5667 }
5668
5669 case WE_SET_DYNAMIC_BW:
5670 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005671 hdd_notice("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005672 set_value);
5673 ret = wma_cli_set_command(pAdapter->sessionId,
5674 WMI_PDEV_PARAM_DYNAMIC_BW,
5675 set_value, PDEV_CMD);
5676 break;
5677 }
5678
5679 case WE_SET_CTS_CBW:
5680 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005681 hdd_notice("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005682 ret = wma_cli_set_command(pAdapter->sessionId,
5683 WMI_PDEV_PARAM_CTS_CBW,
5684 set_value, PDEV_CMD);
5685 break;
5686 }
5687
5688 case WE_SET_11N_RATE:
5689 {
5690 uint8_t preamble = 0, nss = 0, rix = 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005691 hdd_notice("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 set_value);
5693
5694 if (set_value != 0xff) {
5695 rix = RC_2_RATE_IDX(set_value);
5696 if (set_value & 0x80) {
5697 preamble = WMI_RATE_PREAMBLE_HT;
5698 nss = HT_RC_2_STREAMS(set_value) - 1;
5699 } else {
5700 nss = 0;
5701 rix = RC_2_RATE_IDX(set_value);
5702 if (set_value & 0x10) {
5703 preamble =
5704 WMI_RATE_PREAMBLE_CCK;
5705 if (rix != 0x3)
5706 /* Enable Short
5707 * preamble always for
5708 * CCK except 1mbps
5709 */
5710 rix |= 0x4;
5711 } else {
5712 preamble =
5713 WMI_RATE_PREAMBLE_OFDM;
5714 }
5715 }
5716 set_value = (preamble << 6) | (nss << 4) | rix;
5717 }
5718 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
5719 set_value, rix, preamble, nss);
5720
5721 ret = wma_cli_set_command(pAdapter->sessionId,
5722 WMI_VDEV_PARAM_FIXED_RATE,
5723 set_value, VDEV_CMD);
5724 break;
5725 }
5726
5727 case WE_SET_VHT_RATE:
5728 {
5729 uint8_t preamble = 0, nss = 0, rix = 0;
5730
5731 if (set_value != 0xff) {
5732 rix = RC_2_RATE_IDX_11AC(set_value);
5733 preamble = WMI_RATE_PREAMBLE_VHT;
5734 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
5735
5736 set_value = (preamble << 6) | (nss << 4) | rix;
5737 }
5738 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
5739 set_value, rix, preamble, nss);
5740 ret = wma_cli_set_command(pAdapter->sessionId,
5741 WMI_VDEV_PARAM_FIXED_RATE,
5742 set_value, VDEV_CMD);
5743 break;
5744 }
5745
5746 case WE_SET_AMPDU:
5747 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005748 hdd_notice("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005749 ret = wma_cli_set_command(pAdapter->sessionId,
5750 GEN_VDEV_PARAM_AMPDU,
5751 set_value, GEN_CMD);
5752 break;
5753 }
5754
5755 case WE_SET_AMSDU:
5756 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005757 hdd_notice("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 ret = wma_cli_set_command(pAdapter->sessionId,
5759 GEN_VDEV_PARAM_AMSDU,
5760 set_value, GEN_CMD);
5761 break;
5762 }
5763
5764 case WE_SET_BURST_ENABLE:
5765 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005766 hdd_notice("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005767 if ((set_value == 0) || (set_value == 1)) {
5768 ret = wma_cli_set_command(pAdapter->sessionId,
5769 WMI_PDEV_PARAM_BURST_ENABLE,
5770 set_value, PDEV_CMD);
5771 } else
5772 ret = -EINVAL;
5773 break;
5774 }
5775 case WE_SET_BURST_DUR:
5776 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005777 hdd_notice("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07005778 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005779 ret = wma_cli_set_command(pAdapter->sessionId,
5780 WMI_PDEV_PARAM_BURST_DUR,
5781 set_value, PDEV_CMD);
5782 else
5783 ret = -EINVAL;
5784 break;
5785 }
5786
5787 case WE_SET_TX_CHAINMASK:
5788 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005789 hdd_notice("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790 set_value);
5791 ret = wma_cli_set_command(pAdapter->sessionId,
5792 WMI_PDEV_PARAM_TX_CHAIN_MASK,
5793 set_value, PDEV_CMD);
5794 break;
5795 }
5796
5797 case WE_SET_RX_CHAINMASK:
5798 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005799 hdd_notice("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005800 set_value);
5801 ret = wma_cli_set_command(pAdapter->sessionId,
5802 WMI_PDEV_PARAM_RX_CHAIN_MASK,
5803 set_value, PDEV_CMD);
5804 break;
5805 }
5806
5807 case WE_SET_TXPOW_2G:
5808 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005809 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005810 set_value);
5811 ret = wma_cli_set_command(pAdapter->sessionId,
5812 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
5813 set_value, PDEV_CMD);
5814 break;
5815 }
5816
5817 case WE_SET_TXPOW_5G:
5818 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005819 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005820 set_value);
5821 ret = wma_cli_set_command(pAdapter->sessionId,
5822 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
5823 set_value, PDEV_CMD);
5824 break;
5825 }
5826
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005827 /* Firmware debug log */
5828 case WE_DBGLOG_LOG_LEVEL:
5829 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005830 hdd_notice("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005831 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
5832 ret = wma_cli_set_command(pAdapter->sessionId,
5833 WMI_DBGLOG_LOG_LEVEL,
5834 set_value, DBG_CMD);
5835 break;
5836 }
5837
5838 case WE_DBGLOG_VAP_ENABLE:
5839 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005840 hdd_notice("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 ret = wma_cli_set_command(pAdapter->sessionId,
5842 WMI_DBGLOG_VAP_ENABLE,
5843 set_value, DBG_CMD);
5844 break;
5845 }
5846
5847 case WE_DBGLOG_VAP_DISABLE:
5848 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005849 hdd_notice("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 ret = wma_cli_set_command(pAdapter->sessionId,
5851 WMI_DBGLOG_VAP_DISABLE,
5852 set_value, DBG_CMD);
5853 break;
5854 }
5855
5856 case WE_DBGLOG_MODULE_ENABLE:
5857 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005858 hdd_notice("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005859 set_value);
5860 hdd_ctx->fw_log_settings.enable = set_value;
5861 ret = wma_cli_set_command(pAdapter->sessionId,
5862 WMI_DBGLOG_MODULE_ENABLE,
5863 set_value, DBG_CMD);
5864 break;
5865 }
5866
5867 case WE_DBGLOG_MODULE_DISABLE:
5868 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005869 hdd_notice("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005870 set_value);
5871 hdd_ctx->fw_log_settings.enable = set_value;
5872 ret = wma_cli_set_command(pAdapter->sessionId,
5873 WMI_DBGLOG_MODULE_DISABLE,
5874 set_value, DBG_CMD);
5875 break;
5876 }
5877 case WE_DBGLOG_MOD_LOG_LEVEL:
5878 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005879 hdd_notice("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005880 set_value);
5881
5882 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
5883 hdd_ctx->fw_log_settings.index = 0;
5884
5885 hdd_ctx->fw_log_settings.
5886 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
5887 set_value;
5888 hdd_ctx->fw_log_settings.index++;
5889
5890 ret = wma_cli_set_command(pAdapter->sessionId,
5891 WMI_DBGLOG_MOD_LOG_LEVEL,
5892 set_value, DBG_CMD);
5893 break;
5894 }
5895
5896 case WE_DBGLOG_TYPE:
5897 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005898 hdd_notice("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005899 hdd_ctx->fw_log_settings.dl_type = set_value;
5900 ret = wma_cli_set_command(pAdapter->sessionId,
5901 WMI_DBGLOG_TYPE,
5902 set_value, DBG_CMD);
5903 break;
5904 }
5905 case WE_DBGLOG_REPORT_ENABLE:
5906 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005907 hdd_notice("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005908 set_value);
5909 hdd_ctx->fw_log_settings.dl_report = set_value;
5910 ret = wma_cli_set_command(pAdapter->sessionId,
5911 WMI_DBGLOG_REPORT_ENABLE,
5912 set_value, DBG_CMD);
5913 break;
5914 }
5915
5916 case WE_SET_TXRX_FWSTATS:
5917 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005918 hdd_notice("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005919 ret = wma_cli_set_command(pAdapter->sessionId,
5920 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
5921 set_value, VDEV_CMD);
5922 break;
5923 }
5924
5925 case WE_TXRX_FWSTATS_RESET:
5926 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005927 hdd_notice("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005928 ret = wma_cli_set_command(pAdapter->sessionId,
5929 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
5930 set_value, VDEV_CMD);
5931 break;
5932 }
5933
5934 case WE_DUMP_STATS:
5935 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005936 hdd_notice("WE_DUMP_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005937 hdd_wlan_dump_stats(pAdapter, set_value);
5938 break;
5939 }
5940
5941 case WE_CLEAR_STATS:
5942 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005943 hdd_notice("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005944 switch (set_value) {
5945 case WLAN_HDD_STATS:
5946 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5947 memset(&pAdapter->hdd_stats, 0,
5948 sizeof(pAdapter->hdd_stats));
5949 break;
5950 case WLAN_TXRX_HIST_STATS:
5951 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
5952 break;
5953 case WLAN_HDD_NETIF_OPER_HISTORY:
5954 wlan_hdd_clear_netif_queue_history(hdd_ctx);
5955 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05305956 case WLAN_HIF_STATS:
5957 hdd_clear_hif_stats();
5958 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005959 default:
5960 ol_txrx_clear_stats(set_value);
5961 }
5962 break;
5963 }
5964
5965 case WE_PPS_PAID_MATCH:
5966 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005967 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005968 return EINVAL;
5969
Jeff Johnson99bac312016-06-28 10:38:18 -07005970 hdd_notice("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005971 set_value);
5972 ret = wma_cli_set_command(pAdapter->sessionId,
5973 WMI_VDEV_PPS_PAID_MATCH,
5974 set_value, PPS_CMD);
5975 break;
5976 }
5977
5978 case WE_PPS_GID_MATCH:
5979 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005980 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005981 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07005982 hdd_notice("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005983 set_value);
5984 ret = wma_cli_set_command(pAdapter->sessionId,
5985 WMI_VDEV_PPS_GID_MATCH,
5986 set_value, PPS_CMD);
5987 break;
5988 }
5989
5990 case WE_PPS_EARLY_TIM_CLEAR:
5991 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005992 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005993 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07005994 hdd_notice(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 set_value);
5996 ret = wma_cli_set_command(pAdapter->sessionId,
5997 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
5998 set_value, PPS_CMD);
5999 break;
6000 }
6001
6002 case WE_PPS_EARLY_DTIM_CLEAR:
6003 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006004 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006005 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006006 hdd_notice("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 set_value);
6008 ret = wma_cli_set_command(pAdapter->sessionId,
6009 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6010 set_value, PPS_CMD);
6011 break;
6012 }
6013
6014 case WE_PPS_EOF_PAD_DELIM:
6015 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006016 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006018 hdd_notice("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006019 set_value);
6020 ret = wma_cli_set_command(pAdapter->sessionId,
6021 WMI_VDEV_PPS_EOF_PAD_DELIM,
6022 set_value, PPS_CMD);
6023 break;
6024 }
6025
6026 case WE_PPS_MACADDR_MISMATCH:
6027 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006028 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006029 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006030 hdd_notice("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006031 set_value);
6032 ret = wma_cli_set_command(pAdapter->sessionId,
6033 WMI_VDEV_PPS_MACADDR_MISMATCH,
6034 set_value, PPS_CMD);
6035 break;
6036 }
6037
6038 case WE_PPS_DELIM_CRC_FAIL:
6039 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006040 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006041 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006042 hdd_notice("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006043 set_value);
6044 ret = wma_cli_set_command(pAdapter->sessionId,
6045 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6046 set_value, PPS_CMD);
6047 break;
6048 }
6049
6050 case WE_PPS_GID_NSTS_ZERO:
6051 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006052 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006053 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006054 hdd_notice("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006055 set_value);
6056 ret = wma_cli_set_command(pAdapter->sessionId,
6057 WMI_VDEV_PPS_GID_NSTS_ZERO,
6058 set_value, PPS_CMD);
6059 break;
6060 }
6061
6062 case WE_PPS_RSSI_CHECK:
6063 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006064 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006065 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006066 hdd_notice("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006067 set_value);
6068 ret = wma_cli_set_command(pAdapter->sessionId,
6069 WMI_VDEV_PPS_RSSI_CHECK,
6070 set_value, PPS_CMD);
6071 break;
6072 }
6073
6074 case WE_PPS_5G_EBT:
6075 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006076 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006077 return -EINVAL;
6078
Jeff Johnson99bac312016-06-28 10:38:18 -07006079 hdd_notice("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006080 ret = wma_cli_set_command(pAdapter->sessionId,
6081 WMI_VDEV_PPS_5G_EBT,
6082 set_value, PPS_CMD);
6083 break;
6084 }
6085
6086 case WE_SET_HTSMPS:
6087 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006088 hdd_notice("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006089 ret = wma_cli_set_command(pAdapter->sessionId,
6090 WMI_STA_SMPS_FORCE_MODE_CMDID,
6091 set_value, VDEV_CMD);
6092 break;
6093 }
6094
6095 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
6096 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006097 hdd_notice("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006098 set_value);
6099 ret = wma_cli_set_command(pAdapter->sessionId,
6100 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6101 set_value, QPOWER_CMD);
6102 break;
6103 }
6104
6105 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
6106 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006107 hdd_notice("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006108 set_value);
6109 ret = wma_cli_set_command(
6110 pAdapter->sessionId,
6111 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6112 set_value, QPOWER_CMD);
6113 break;
6114 }
6115
6116 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6117 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006118 hdd_notice("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006119 set_value);
6120 ret = wma_cli_set_command(
6121 pAdapter->sessionId,
6122 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6123 set_value, QPOWER_CMD);
6124 break;
6125 }
6126
6127 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6128 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006129 hdd_notice("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006130 set_value);
6131 ret = wma_cli_set_command(
6132 pAdapter->sessionId,
6133 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6134 set_value, QPOWER_CMD);
6135 break;
6136 }
6137
6138 case WE_MCC_CONFIG_LATENCY:
6139 {
6140 cds_set_mcc_latency(pAdapter, set_value);
6141 break;
6142 }
6143
6144 case WE_MCC_CONFIG_QUOTA:
6145 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006146 hdd_notice("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006147 set_value);
6148 ret = cds_set_mcc_p2p_quota(pAdapter, set_value);
6149 break;
6150 }
6151 case WE_SET_DEBUG_LOG:
6152 {
6153 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05306154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006155 hdd_ctx->config->gEnableDebugLog = set_value;
6156 sme_update_connect_debug(hdd_ctx->hHal, set_value);
6157 break;
6158 }
6159 case WE_SET_EARLY_RX_ADJUST_ENABLE:
6160 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006161 hdd_notice("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006162 if ((set_value == 0) || (set_value == 1))
6163 ret = wma_cli_set_command(
6164 pAdapter->sessionId,
6165 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
6166 set_value, VDEV_CMD);
6167 else
6168 ret = -EINVAL;
6169 break;
6170 }
6171 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
6172 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006173 hdd_notice("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006174 ret = wma_cli_set_command(pAdapter->sessionId,
6175 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
6176 set_value, VDEV_CMD);
6177 break;
6178 }
6179 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
6180 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006181 hdd_notice("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006182 set_value);
6183 ret = wma_cli_set_command(
6184 pAdapter->sessionId,
6185 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
6186 set_value, VDEV_CMD);
6187 break;
6188 }
6189 case WE_SET_EARLY_RX_SLOP_STEP:
6190 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006191 hdd_notice("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006192 set_value);
6193 ret = wma_cli_set_command(pAdapter->sessionId,
6194 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
6195 set_value, VDEV_CMD);
6196 break;
6197 }
6198 case WE_SET_EARLY_RX_INIT_SLOP:
6199 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006200 hdd_notice("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006201 set_value);
6202 ret = wma_cli_set_command(pAdapter->sessionId,
6203 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
6204 set_value, VDEV_CMD);
6205 break;
6206 }
6207 case WE_SET_EARLY_RX_ADJUST_PAUSE:
6208 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006209 hdd_notice("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006210 if ((set_value == 0) || (set_value == 1))
6211 ret = wma_cli_set_command(
6212 pAdapter->sessionId,
6213 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
6214 set_value, VDEV_CMD);
6215 else
6216 ret = -EINVAL;
6217 break;
6218 }
6219 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
6220 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006221 hdd_notice("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006222 ret = wma_cli_set_command(pAdapter->sessionId,
6223 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
6224 set_value, VDEV_CMD);
6225 break;
6226 }
6227 case WE_SET_SCAN_DISABLE:
6228 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006229 hdd_notice("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006230 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
6231 break;
6232 }
Govind Singha471e5e2015-10-12 17:11:14 +05306233 case WE_START_FW_PROFILE:
6234 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006235 hdd_notice("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05306236 ret = wma_cli_set_command(pAdapter->sessionId,
6237 WMI_WLAN_PROFILE_TRIGGER_CMDID,
6238 set_value, DBG_CMD);
6239 break;
6240 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306241 case WE_SET_CHANNEL:
6242 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006243 hdd_notice("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306244 pAdapter->sessionId, pAdapter->device_mode);
6245
Krunal Sonif07bb382016-03-10 13:02:11 -08006246 if ((QDF_STA_MODE == pAdapter->device_mode) ||
6247 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306248
6249 status = sme_ext_change_channel(hHal,
6250 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306251 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006252 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306253 status);
6254 ret = -EINVAL;
6255 }
6256 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006257 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306258 pAdapter->device_mode);
6259 ret = -EINVAL;
6260 }
6261 break;
6262 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306263 case WE_SET_CONC_SYSTEM_PREF:
6264 {
6265 hdd_info("New preference: %d", set_value);
6266 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
6267 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
6268 hdd_err("Invalid system preference %d", set_value);
6269 return -EINVAL;
6270 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306271
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306272 /* hdd_ctx, hdd_ctx->config are already checked for null */
6273 hdd_ctx->config->conc_system_pref = set_value;
6274 break;
6275 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006276 default:
6277 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006278 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006279 sub_cmd);
6280 ret = -EINVAL;
6281 break;
6282 }
6283 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306284 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006285 return ret;
6286}
6287
6288static int iw_setint_getnone(struct net_device *dev,
6289 struct iw_request_info *info,
6290 union iwreq_data *wrqu,
6291 char *extra)
6292{
6293 int ret;
6294
6295 cds_ssr_protect(__func__);
6296 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6297 cds_ssr_unprotect(__func__);
6298
6299 return ret;
6300}
6301
6302/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006303 * __iw_setnone_get_threeint() - return three value to up layer.
6304 *
6305 * @dev: pointer of net_device of this wireless card
6306 * @info: meta data about Request sent
6307 * @wrqu: include request info
6308 * @extra: buf used for in/Output
6309 *
6310 * Return: execute result
6311 */
6312static int __iw_setnone_get_threeint(struct net_device *dev,
6313 struct iw_request_info *info,
6314 union iwreq_data *wrqu, char *extra)
6315{
6316 int ret = 0; /* success */
6317 uint32_t *value = (int *)extra;
6318 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6319 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6320
6321 ENTER_DEV(dev);
6322 ret = wlan_hdd_validate_context(hdd_ctx);
6323 if (0 != ret)
6324 return ret;
6325
Jeff Johnson99bac312016-06-28 10:38:18 -07006326 hdd_info("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006327 switch (value[0]) {
6328 case WE_GET_TSF:
6329 ret = hdd_indicate_tsf(adapter, value, 3);
6330 break;
6331 default:
6332 hdd_err("Invalid IOCTL get_value command %d", value[0]);
6333 break;
6334 }
6335 return ret;
6336}
6337
6338/**
6339 * iw_setnone_get_threeint() - return three value to up layer.
6340 *
6341 * @dev: pointer of net_device of this wireless card
6342 * @info: meta data about Request sent
6343 * @wrqu: include request info
6344 * @extra: buf used for in/Output
6345 *
6346 * Return: execute result
6347 */
6348static int iw_setnone_get_threeint(struct net_device *dev,
6349 struct iw_request_info *info,
6350 union iwreq_data *wrqu, char *extra)
6351{
6352 int ret;
6353
6354 cds_ssr_protect(__func__);
6355 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
6356 cds_ssr_unprotect(__func__);
6357
6358 return ret;
6359}
6360
6361/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006362 * iw_setchar_getnone() - Generic "set string" private ioctl handler
6363 * @dev: device upon which the ioctl was received
6364 * @info: ioctl request information
6365 * @wrqu: ioctl request data
6366 * @extra: ioctl extra data
6367 *
6368 * Return: 0 on success, non-zero on error
6369 */
6370static int __iw_setchar_getnone(struct net_device *dev,
6371 struct iw_request_info *info,
6372 union iwreq_data *wrqu, char *extra)
6373{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306374 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006375 int sub_cmd;
6376 int ret;
6377 char *pBuffer = NULL;
6378 hdd_adapter_t *pAdapter = (netdev_priv(dev));
6379 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006380 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006381 struct iw_point s_priv_data;
6382
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006383 ENTER_DEV(dev);
6384
Mukul Sharma34777c62015-11-02 20:22:30 +05306385 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006386 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05306387 return -EPERM;
6388 }
6389
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006390 ret = wlan_hdd_validate_context(hdd_ctx);
6391 if (0 != ret)
6392 return ret;
6393
6394 /* helper function to get iwreq_data with compat handling. */
6395 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
6396 return -EINVAL;
6397 }
6398
6399 /* make sure all params are correctly passed to function */
6400 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
6401 return -EINVAL;
6402 }
6403
6404 sub_cmd = s_priv_data.flags;
6405
6406 /* ODD number is used for set, copy data using copy_from_user */
6407 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6408 s_priv_data.length);
6409 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006410 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006411 return -ENOMEM;
6412 }
6413
Jeff Johnson99bac312016-06-28 10:38:18 -07006414 hdd_notice("Received length %d", s_priv_data.length);
6415 hdd_notice("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006416
6417 switch (sub_cmd) {
6418 case WE_WOWL_ADD_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006419 hdd_notice("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006420 hdd_add_wowl_ptrn(pAdapter, pBuffer);
6421 break;
6422 case WE_WOWL_DEL_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006423 hdd_notice("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006424 hdd_del_wowl_ptrn(pAdapter, pBuffer);
6425 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006426 case WE_NEIGHBOR_REPORT_REQUEST:
6427 {
6428 tRrmNeighborReq neighborReq;
6429 tRrmNeighborRspCallbackInfo callbackInfo;
6430
6431 if (pConfig->fRrmEnable) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006432 hdd_notice("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006433 neighborReq.no_ssid =
6434 (s_priv_data.length - 1) ? false : true;
6435 if (!neighborReq.no_ssid) {
6436 neighborReq.ssid.length =
6437 (s_priv_data.length - 1) >
6438 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306439 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006440 pBuffer,
6441 neighborReq.ssid.length);
6442 }
6443
6444 callbackInfo.neighborRspCallback = NULL;
6445 callbackInfo.neighborRspCallbackContext = NULL;
6446 callbackInfo.timeout = 5000; /* 5 seconds */
6447 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
6448 (pAdapter),
6449 pAdapter->sessionId,
6450 &neighborReq,
6451 &callbackInfo);
6452 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006453 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006454 ret = -EINVAL;
6455 }
6456 }
6457 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006458 case WE_SET_AP_WPS_IE:
Jeff Johnson99bac312016-06-28 10:38:18 -07006459 hdd_err("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006460 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
6461 s_priv_data.length);
6462 break;
6463 case WE_SET_CONFIG:
6464 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306465 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006466 ret = -EINVAL;
6467 }
6468 break;
6469 default:
6470 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006471 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006472 sub_cmd);
6473 ret = -EINVAL;
6474 break;
6475 }
6476 }
6477 kfree(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306478 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006479 return ret;
6480}
6481
6482static int iw_setchar_getnone(struct net_device *dev,
6483 struct iw_request_info *info,
6484 union iwreq_data *wrqu, char *extra)
6485{
6486 int ret;
6487
6488 cds_ssr_protect(__func__);
6489 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6490 cds_ssr_unprotect(__func__);
6491
6492 return ret;
6493}
6494
6495/**
6496 * iw_setnone_getint() - Generic "get integer" private ioctl handler
6497 * @dev: device upon which the ioctl was received
6498 * @info: ioctl request information
6499 * @wrqu: ioctl request data
6500 * @extra: ioctl extra data
6501 *
6502 * Return: 0 on success, non-zero on error
6503 */
6504static int __iw_setnone_getint(struct net_device *dev,
6505 struct iw_request_info *info,
6506 union iwreq_data *wrqu, char *extra)
6507{
6508 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6509 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6510 int *value = (int *)extra;
6511 int ret;
6512 tSmeConfigParams smeConfig;
6513 hdd_context_t *hdd_ctx;
6514
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006515 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306516
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006517 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6518 ret = wlan_hdd_validate_context(hdd_ctx);
6519 if (0 != ret)
6520 return ret;
6521
6522 switch (value[0]) {
6523 case WE_GET_11D_STATE:
6524 {
6525 sme_get_config_param(hHal, &smeConfig);
6526
6527 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6528
Jeff Johnson99bac312016-06-28 10:38:18 -07006529 hdd_notice("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006530
6531 break;
6532 }
6533
6534 case WE_IBSS_STATUS:
Jeff Johnson99bac312016-06-28 10:38:18 -07006535 hdd_notice("****Return IBSS Status*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006536 break;
6537
6538 case WE_GET_WLAN_DBG:
6539 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306540 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006541 *value = 0;
6542 break;
6543 }
6544 case WE_GET_MAX_ASSOC:
6545 {
6546 if (sme_cfg_get_int
6547 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306548 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006549 hdd_warn("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006550 ret = -EIO;
6551 }
6552 break;
6553 }
6554 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6555 *value = (WLAN_HDD_GET_CTX(
6556 pAdapter))->config->force_sap_acs;
6557 break;
6558
6559 case WE_GET_CONCURRENCY_MODE:
6560 {
6561 *value = cds_get_concurrency_mode();
6562
Jeff Johnson99bac312016-06-28 10:38:18 -07006563 hdd_notice("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006564 break;
6565 }
6566
6567 case WE_GET_NSS:
6568 {
6569 sme_get_config_param(hHal, &smeConfig);
6570 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Jeff Johnson99bac312016-06-28 10:38:18 -07006571 hdd_notice("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006572 break;
6573 }
6574
6575 case WE_GET_GTX_HT_MCS:
6576 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006577 hdd_notice("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006578 *value = wma_cli_get_command(pAdapter->sessionId,
6579 WMI_VDEV_PARAM_GTX_HT_MCS,
6580 GTX_CMD);
6581 break;
6582 }
6583
6584 case WE_GET_GTX_VHT_MCS:
6585 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006586 hdd_notice("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006587 *value = wma_cli_get_command(pAdapter->sessionId,
6588 WMI_VDEV_PARAM_GTX_VHT_MCS,
6589 GTX_CMD);
6590 break;
6591 }
6592
6593 case WE_GET_GTX_USRCFG:
6594 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006595 hdd_notice("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006596 *value = wma_cli_get_command(pAdapter->sessionId,
6597 WMI_VDEV_PARAM_GTX_USR_CFG,
6598 GTX_CMD);
6599 break;
6600 }
6601
6602 case WE_GET_GTX_THRE:
6603 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006604 hdd_notice("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006605 *value = wma_cli_get_command(pAdapter->sessionId,
6606 WMI_VDEV_PARAM_GTX_THRE,
6607 GTX_CMD);
6608 break;
6609 }
6610
6611 case WE_GET_GTX_MARGIN:
6612 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006613 hdd_notice("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006614 *value = wma_cli_get_command(pAdapter->sessionId,
6615 WMI_VDEV_PARAM_GTX_MARGIN,
6616 GTX_CMD);
6617 break;
6618 }
6619
6620 case WE_GET_GTX_STEP:
6621 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006622 hdd_notice("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006623 *value = wma_cli_get_command(pAdapter->sessionId,
6624 WMI_VDEV_PARAM_GTX_STEP,
6625 GTX_CMD);
6626 break;
6627 }
6628
6629 case WE_GET_GTX_MINTPC:
6630 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006631 hdd_notice("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006632 *value = wma_cli_get_command(pAdapter->sessionId,
6633 WMI_VDEV_PARAM_GTX_MINTPC,
6634 GTX_CMD);
6635 break;
6636 }
6637
6638 case WE_GET_GTX_BWMASK:
6639 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006640 hdd_notice("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006641 *value = wma_cli_get_command(pAdapter->sessionId,
6642 WMI_VDEV_PARAM_GTX_BW_MASK,
6643 GTX_CMD);
6644 break;
6645 }
6646
6647 case WE_GET_LDPC:
6648 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306649 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006650 break;
6651 }
6652
6653 case WE_GET_TX_STBC:
6654 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306655 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006656 break;
6657 }
6658
6659 case WE_GET_RX_STBC:
6660 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306661 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006662 break;
6663 }
6664
6665 case WE_GET_SHORT_GI:
6666 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006667 hdd_notice("GET WMI_VDEV_PARAM_SGI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006668 *value = sme_get_ht_config(hHal, pAdapter->sessionId,
6669 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ);
6670 break;
6671 }
6672
6673 case WE_GET_RTSCTS:
6674 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006675 hdd_notice("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006676 *value = wma_cli_get_command(pAdapter->sessionId,
6677 WMI_VDEV_PARAM_ENABLE_RTSCTS,
6678 VDEV_CMD);
6679 break;
6680 }
6681
6682 case WE_GET_CHWIDTH:
6683 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006684 hdd_notice("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006685 *value = wma_cli_get_command(pAdapter->sessionId,
6686 WMI_VDEV_PARAM_CHWIDTH,
6687 VDEV_CMD);
6688 break;
6689 }
6690
6691 case WE_GET_ANI_EN_DIS:
6692 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006693 hdd_notice("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006694 *value = wma_cli_get_command(pAdapter->sessionId,
6695 WMI_PDEV_PARAM_ANI_ENABLE,
6696 PDEV_CMD);
6697 break;
6698 }
6699
6700 case WE_GET_ANI_POLL_PERIOD:
6701 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006702 hdd_notice("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006703 *value = wma_cli_get_command(pAdapter->sessionId,
6704 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
6705 PDEV_CMD);
6706 break;
6707 }
6708
6709 case WE_GET_ANI_LISTEN_PERIOD:
6710 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006711 hdd_notice("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006712 *value = wma_cli_get_command(pAdapter->sessionId,
6713 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
6714 PDEV_CMD);
6715 break;
6716 }
6717
6718 case WE_GET_ANI_OFDM_LEVEL:
6719 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006720 hdd_notice("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006721 *value = wma_cli_get_command(pAdapter->sessionId,
6722 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
6723 PDEV_CMD);
6724 break;
6725 }
6726
6727 case WE_GET_ANI_CCK_LEVEL:
6728 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006729 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006730 *value = wma_cli_get_command(pAdapter->sessionId,
6731 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
6732 PDEV_CMD);
6733 break;
6734 }
6735
6736 case WE_GET_DYNAMIC_BW:
6737 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006738 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006739 *value = wma_cli_get_command(pAdapter->sessionId,
6740 WMI_PDEV_PARAM_DYNAMIC_BW,
6741 PDEV_CMD);
6742 break;
6743 }
6744
6745 case WE_GET_11N_RATE:
6746 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006747 hdd_notice("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006748 *value = wma_cli_get_command(pAdapter->sessionId,
6749 WMI_VDEV_PARAM_FIXED_RATE,
6750 VDEV_CMD);
6751 break;
6752 }
6753
6754 case WE_GET_AMPDU:
6755 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006756 hdd_notice("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006757 *value = wma_cli_get_command(pAdapter->sessionId,
6758 GEN_VDEV_PARAM_AMPDU,
6759 GEN_CMD);
6760 break;
6761 }
6762
6763 case WE_GET_AMSDU:
6764 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006765 hdd_notice("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006766 *value = wma_cli_get_command(pAdapter->sessionId,
6767 GEN_VDEV_PARAM_AMSDU,
6768 GEN_CMD);
6769 break;
6770 }
6771
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07006772 case WE_GET_ROAM_SYNCH_DELAY:
6773 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006774 hdd_notice("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07006775 *value = wma_cli_get_command(pAdapter->sessionId,
6776 GEN_VDEV_ROAM_SYNCH_DELAY,
6777 GEN_CMD);
6778 break;
6779 }
6780
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006781 case WE_GET_BURST_ENABLE:
6782 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006783 hdd_notice("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006784 *value = wma_cli_get_command(pAdapter->sessionId,
6785 WMI_PDEV_PARAM_BURST_ENABLE,
6786 PDEV_CMD);
6787 break;
6788 }
6789 case WE_GET_BURST_DUR:
6790 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006791 hdd_notice("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006792 *value = wma_cli_get_command(pAdapter->sessionId,
6793 WMI_PDEV_PARAM_BURST_DUR,
6794 PDEV_CMD);
6795 break;
6796 }
6797
6798 case WE_GET_TX_CHAINMASK:
6799 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006800 hdd_notice("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006801 *value = wma_cli_get_command(pAdapter->sessionId,
6802 WMI_PDEV_PARAM_TX_CHAIN_MASK,
6803 PDEV_CMD);
6804 break;
6805 }
6806
6807 case WE_GET_RX_CHAINMASK:
6808 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006809 hdd_notice("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006810 *value = wma_cli_get_command(pAdapter->sessionId,
6811 WMI_PDEV_PARAM_RX_CHAIN_MASK,
6812 PDEV_CMD);
6813 break;
6814 }
6815
6816 case WE_GET_TXPOW_2G:
6817 {
6818 uint32_t txpow2g = 0;
6819 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07006820 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006821 *value = wma_cli_get_command(pAdapter->sessionId,
6822 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
6823 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306824 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006825 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6826 &txpow2g)) {
6827 return -EIO;
6828 }
Jeff Johnson99bac312016-06-28 10:38:18 -07006829 hdd_notice("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006830 break;
6831 }
6832
6833 case WE_GET_TXPOW_5G:
6834 {
6835 uint32_t txpow5g = 0;
6836 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07006837 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006838 *value = wma_cli_get_command(pAdapter->sessionId,
6839 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
6840 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306841 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006842 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6843 &txpow5g)) {
6844 return -EIO;
6845 }
Jeff Johnson99bac312016-06-28 10:38:18 -07006846 hdd_notice("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006847 break;
6848 }
6849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006850 case WE_GET_PPS_PAID_MATCH:
6851 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006852 hdd_notice("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006853 *value = wma_cli_get_command(pAdapter->sessionId,
6854 WMI_VDEV_PPS_PAID_MATCH,
6855 PPS_CMD);
6856 break;
6857 }
6858
6859 case WE_GET_PPS_GID_MATCH:
6860 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006861 hdd_notice("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006862 *value = wma_cli_get_command(pAdapter->sessionId,
6863 WMI_VDEV_PPS_GID_MATCH,
6864 PPS_CMD);
6865 break;
6866 }
6867
6868 case WE_GET_PPS_EARLY_TIM_CLEAR:
6869 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006870 hdd_notice("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006871 *value = wma_cli_get_command(pAdapter->sessionId,
6872 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6873 PPS_CMD);
6874 break;
6875 }
6876
6877 case WE_GET_PPS_EARLY_DTIM_CLEAR:
6878 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006879 hdd_notice("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006880 *value = wma_cli_get_command(pAdapter->sessionId,
6881 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6882 PPS_CMD);
6883 break;
6884 }
6885
6886 case WE_GET_PPS_EOF_PAD_DELIM:
6887 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006888 hdd_notice("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006889 *value = wma_cli_get_command(pAdapter->sessionId,
6890 WMI_VDEV_PPS_EOF_PAD_DELIM,
6891 PPS_CMD);
6892 break;
6893 }
6894
6895 case WE_GET_PPS_MACADDR_MISMATCH:
6896 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006897 hdd_notice("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006898 *value = wma_cli_get_command(pAdapter->sessionId,
6899 WMI_VDEV_PPS_MACADDR_MISMATCH,
6900 PPS_CMD);
6901 break;
6902 }
6903
6904 case WE_GET_PPS_DELIM_CRC_FAIL:
6905 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006906 hdd_notice("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006907 *value = wma_cli_get_command(pAdapter->sessionId,
6908 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6909 PPS_CMD);
6910 break;
6911 }
6912
6913 case WE_GET_PPS_GID_NSTS_ZERO:
6914 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006915 hdd_notice("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006916 *value = wma_cli_get_command(pAdapter->sessionId,
6917 WMI_VDEV_PPS_GID_NSTS_ZERO,
6918 PPS_CMD);
6919 break;
6920 }
6921
6922 case WE_GET_PPS_RSSI_CHECK:
6923 {
6924
Jeff Johnson99bac312016-06-28 10:38:18 -07006925 hdd_notice("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006926 *value = wma_cli_get_command(pAdapter->sessionId,
6927 WMI_VDEV_PPS_RSSI_CHECK,
6928 PPS_CMD);
6929 break;
6930 }
6931
6932 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
6933 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006934 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006935 *value = wma_cli_get_command(pAdapter->sessionId,
6936 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6937 QPOWER_CMD);
6938 break;
6939 }
6940
6941 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
6942 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006943 hdd_notice("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006944 *value = wma_cli_get_command(pAdapter->sessionId,
6945 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6946 QPOWER_CMD);
6947 break;
6948 }
6949
6950 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6951 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006952 hdd_notice("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006953 *value = wma_cli_get_command(pAdapter->sessionId,
6954 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6955 QPOWER_CMD);
6956 break;
6957 }
6958
6959 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6960 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006961 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006962 *value = wma_cli_get_command(pAdapter->sessionId,
6963 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6964 QPOWER_CMD);
6965 break;
6966 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006967 case WE_CAP_TSF:
6968 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
6969 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006970 case WE_GET_TEMPERATURE:
6971 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006972 hdd_notice("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006973 ret = wlan_hdd_get_temperature(pAdapter, value);
6974 break;
6975 }
6976 default:
6977 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006978 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006979 value[0]);
6980 break;
6981 }
6982 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306983 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006984 return ret;
6985}
6986
6987static int iw_setnone_getint(struct net_device *dev,
6988 struct iw_request_info *info,
6989 union iwreq_data *wrqu, char *extra)
6990{
6991 int ret;
6992
6993 cds_ssr_protect(__func__);
6994 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6995 cds_ssr_unprotect(__func__);
6996
6997 return ret;
6998}
6999
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307000static int hdd_set_fwtest(int argc, int cmd, int value)
7001{
7002 struct set_fwtest_params *fw_test;
7003
7004 /* check for max number of arguments */
7005 if (argc > (WMA_MAX_NUM_ARGS) ||
7006 argc != HDD_FWTEST_PARAMS) {
7007 hdd_err("Too Many args %d", argc);
7008 return -EINVAL;
7009 }
7010 /*
7011 * check if number of arguments are 3 then, check
7012 * then set the default value for sounding interval.
7013 */
7014 if (HDD_FWTEST_PARAMS == argc) {
7015 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
7016 value = HDD_FWTEST_SU_DEFAULT_VALUE;
7017 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
7018 value = HDD_FWTEST_MU_DEFAULT_VALUE;
7019 }
7020 /* check sounding interval value should not exceed to max */
7021 if (value > HDD_FWTEST_MAX_VALUE) {
7022 hdd_err("Invalid arguments value should not exceed max: %d",
7023 value);
7024 return -EINVAL;
7025 }
7026 fw_test = qdf_mem_malloc(sizeof(*fw_test));
7027 if (NULL == fw_test) {
7028 hdd_err("qdf_mem_malloc failed for fw_test");
7029 return -ENOMEM;
7030 }
7031 fw_test->arg = cmd;
7032 fw_test->value = value;
7033 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
7034 qdf_mem_free(fw_test);
7035 hdd_err("Not able to post FW_TEST_CMD message to WMA");
7036 return -EINVAL;
7037 }
7038 return 0;
7039}
7040
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007041/**
7042 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
7043 * @dev: device upon which the ioctl was received
7044 * @info: ioctl request information
7045 * @wrqu: ioctl request data
7046 * @extra: ioctl extra data
7047 *
7048 * Return: 0 on success, non-zero on error
7049 */
7050static int __iw_set_three_ints_getnone(struct net_device *dev,
7051 struct iw_request_info *info,
7052 union iwreq_data *wrqu, char *extra)
7053{
7054 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7055 int *value = (int *)extra;
7056 int sub_cmd = value[0];
7057 int ret;
7058 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7059
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007060 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307061
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007062 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007063 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007064 return -EPERM;
7065 }
7066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007067 ret = wlan_hdd_validate_context(hdd_ctx);
7068 if (0 != ret)
7069 return ret;
7070
7071 switch (sub_cmd) {
7072
7073 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307074 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007075 break;
7076 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307077 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007078 break;
7079
7080 /* value[3] the acs band is not required as start and end channels are
7081 * enough but this cmd is maintained under set three ints for historic
7082 * reasons.
7083 */
7084 case WE_SET_SAP_CHANNELS:
7085 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307086 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007087 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307088 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007089 ret = -EINVAL;
7090 } else {
7091 hdd_ctx->config->force_sap_acs_st_ch = value[1];
7092 hdd_ctx->config->force_sap_acs_end_ch = value[2];
7093 }
7094 break;
7095 case WE_SET_DUAL_MAC_SCAN_CONFIG:
7096 hdd_debug("Ioctl to set dual mac scan config");
7097 if (hdd_ctx->config->dual_mac_feature_disable) {
7098 hdd_err("Dual mac feature is disabled from INI");
7099 return -EPERM;
7100 }
7101 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08007102 cds_set_dual_mac_scan_config(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007103 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307104 case WE_SET_FW_TEST:
7105 {
7106 ret = hdd_set_fwtest(value[1], value[2], value[3]);
7107 if (ret) {
7108 hdd_err("Not able to set fwtest %d", ret);
7109 return ret;
7110 }
7111 }
7112 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007113 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007114 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007115 break;
7116
7117 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307118 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007119 return ret;
7120}
7121
7122int iw_set_three_ints_getnone(struct net_device *dev,
7123 struct iw_request_info *info,
7124 union iwreq_data *wrqu, char *extra)
7125{
7126 int ret;
7127
7128 cds_ssr_protect(__func__);
7129 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7130 cds_ssr_unprotect(__func__);
7131
7132 return ret;
7133}
7134
7135/**
7136 * hdd_connection_state_string() - Get connection state string
7137 * @connection_state: enum to be converted to a string
7138 *
7139 * Return: the string equivalent of @connection_state
7140 */
7141static const char *
7142hdd_connection_state_string(eConnectionState connection_state)
7143{
7144 switch (connection_state) {
7145 CASE_RETURN_STRING(eConnectionState_NotConnected);
7146 CASE_RETURN_STRING(eConnectionState_Connecting);
7147 CASE_RETURN_STRING(eConnectionState_Associated);
7148 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
7149 CASE_RETURN_STRING(eConnectionState_IbssConnected);
7150 CASE_RETURN_STRING(eConnectionState_Disconnecting);
7151 default:
7152 return "UNKNOWN";
7153 }
7154}
7155
7156/**
7157 * iw_get_char_setnone() - Generic "get string" private ioctl handler
7158 * @dev: device upon which the ioctl was received
7159 * @info: ioctl request information
7160 * @wrqu: ioctl request data
7161 * @extra: ioctl extra data
7162 *
7163 * Return: 0 on success, non-zero on error
7164 */
7165static int __iw_get_char_setnone(struct net_device *dev,
7166 struct iw_request_info *info,
7167 union iwreq_data *wrqu, char *extra)
7168{
7169 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7170 int sub_cmd = wrqu->data.flags;
7171 hdd_context_t *hdd_ctx;
7172 int ret;
7173#ifdef WLAN_FEATURE_11W
7174 hdd_wext_state_t *pWextState;
7175#endif
7176
7177#ifdef WLAN_FEATURE_11W
7178 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7179#endif
7180
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007181 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307182
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007183 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7184 ret = wlan_hdd_validate_context(hdd_ctx);
7185 if (0 != ret)
7186 return ret;
7187
7188 switch (sub_cmd) {
7189 case WE_WLAN_VERSION:
7190 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05307191 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007192 break;
7193 }
7194
7195 case WE_GET_STATS:
7196 {
7197 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
7198 extra, WE_MAX_STR_LEN);
7199 break;
7200 }
7201
Govind Singha471e5e2015-10-12 17:11:14 +05307202 case WE_LIST_FW_PROFILE:
7203 hdd_wlan_list_fw_profile(&(wrqu->data.length),
7204 extra, WE_MAX_STR_LEN);
7205 break;
7206
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007207 /* The case prints the current state of the HDD, SME, CSR, PE,
7208 * TL it can be extended for WDI Global State as well. And
7209 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
7210 * and P2P_GO have not been added as of now.
7211 */
7212 case WE_GET_STATES:
7213 {
7214 int buf = 0, len = 0;
7215 int adapter_num = 0;
7216 int count = 0, check = 1;
7217
7218 tHalHandle hHal = NULL;
7219 tpAniSirGlobal pMac = NULL;
7220 hdd_station_ctx_t *pHddStaCtx = NULL;
7221
7222 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7223 hdd_adapter_t *useAdapter = NULL;
7224
7225 /* Print wlan0 or p2p0 states based on the adapter_num
7226 * by using the correct adapter
7227 */
7228 while (adapter_num < 2) {
7229 if (WLAN_ADAPTER == adapter_num) {
7230 useAdapter = pAdapter;
7231 buf =
7232 scnprintf(extra + len,
7233 WE_MAX_STR_LEN - len,
7234 "\n\n wlan0 States:-");
7235 len += buf;
7236 } else if (P2P_ADAPTER == adapter_num) {
7237 buf =
7238 scnprintf(extra + len,
7239 WE_MAX_STR_LEN - len,
7240 "\n\n p2p0 States:-");
7241 len += buf;
7242
7243 if (!pHddCtx) {
7244 buf =
7245 scnprintf(extra + len,
7246 WE_MAX_STR_LEN -
7247 len,
7248 "\n pHddCtx is NULL");
7249 len += buf;
7250 break;
7251 }
7252
7253 /* Printing p2p0 states only in the
7254 * case when the device is configured
7255 * as a p2p_client
7256 */
7257 useAdapter =
7258 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08007259 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007260 if (!useAdapter) {
7261 buf =
7262 scnprintf(extra + len,
7263 WE_MAX_STR_LEN -
7264 len,
7265 "\n Device not configured as P2P_CLIENT.");
7266 len += buf;
7267 break;
7268 }
7269 }
7270
7271 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
7272 if (!hHal) {
7273 buf =
7274 scnprintf(extra + len,
7275 WE_MAX_STR_LEN - len,
7276 "\n pMac is NULL");
7277 len += buf;
7278 break;
7279 }
7280 pMac = PMAC_STRUCT(hHal);
7281 if (!pMac) {
7282 buf =
7283 scnprintf(extra + len,
7284 WE_MAX_STR_LEN - len,
7285 "\n pMac is NULL");
7286 len += buf;
7287 break;
7288 }
7289 pHddStaCtx =
7290 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
7291
7292
7293 buf =
7294 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7295 "\n HDD Conn State - %s "
7296 "\n \n SME State:"
7297 "\n Neighbour Roam State - %s"
7298 "\n CSR State - %s"
7299 "\n CSR Substate - %s",
7300 hdd_connection_state_string
7301 (pHddStaCtx->conn_info.connState),
7302 mac_trace_get_neighbour_roam_state
7303 (sme_get_neighbor_roam_state
7304 (hHal, useAdapter->sessionId)),
7305 mac_trace_getcsr_roam_state
7306 (sme_get_current_roam_state
7307 (hHal, useAdapter->sessionId)),
7308 mac_trace_getcsr_roam_sub_state
7309 (sme_get_current_roam_sub_state
7310 (hHal, useAdapter->sessionId))
7311 );
7312 len += buf;
7313 adapter_num++;
7314 }
7315
Mukul Sharma81661ae2015-10-30 20:26:02 +05307316 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007317 /* Printing Lim State starting with global lim states */
7318 buf =
7319 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7320 "\n \n LIM STATES:-"
7321 "\n Global Sme State - %s "
7322 "\n Global mlm State - %s " "\n",
7323 mac_trace_get_lim_sme_state
7324 (sme_get_lim_sme_state(hHal)),
7325 mac_trace_get_lim_mlm_state
7326 (sme_get_lim_sme_state(hHal))
7327 );
7328 len += buf;
7329
7330 /* Printing the PE Sme and Mlm states for valid lim sessions */
7331 while (check < 3 && count < 255) {
7332 if (sme_is_lim_session_valid(hHal, count)) {
7333 buf =
7334 scnprintf(extra + len,
7335 WE_MAX_STR_LEN -
7336 len,
7337 "\n Lim Valid Session %d:-"
7338 "\n PE Sme State - %s "
7339 "\n PE Mlm State - %s "
7340 "\n", check,
7341 mac_trace_get_lim_sme_state
7342 (sme_get_lim_sme_session_state
7343 (hHal, count)),
7344 mac_trace_get_lim_mlm_state
7345 (sme_get_lim_mlm_session_state
7346 (hHal, count))
7347 );
7348
7349 len += buf;
7350 check++;
7351 }
7352 count++;
7353 }
7354 }
7355
7356 wrqu->data.length = strlen(extra) + 1;
7357 break;
7358 }
7359
7360 case WE_GET_CFG:
7361 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007362 hdd_notice("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007363 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
7364 extra,
7365 QCSAP_IOCTL_MAX_STR_LEN);
7366 wrqu->data.length = strlen(extra) + 1;
7367 break;
7368 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007369 case WE_GET_RSSI:
7370 {
7371 int8_t s7Rssi = 0;
7372 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7373 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7374 wrqu->data.length = strlen(extra) + 1;
7375 break;
7376 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007377
7378 case WE_GET_WMM_STATUS:
7379 {
7380 snprintf(extra, WE_MAX_STR_LEN,
7381 "\nDir: 0=up, 1=down, 3=both\n"
7382 "|------------------------|\n"
7383 "|AC | ACM |Admitted| Dir |\n"
7384 "|------------------------|\n"
7385 "|VO | %d | %3s | %d |\n"
7386 "|VI | %d | %3s | %d |\n"
7387 "|BE | %d | %3s | %d |\n"
7388 "|BK | %d | %3s | %d |\n"
7389 "|------------------------|\n",
7390 pAdapter->hddWmmStatus.
7391 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
7392 pAdapter->hddWmmStatus.
7393 wmmAcStatus[SME_AC_VO].
7394 wmmAcAccessAllowed ? "YES" : "NO",
7395 pAdapter->hddWmmStatus.
7396 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
7397 ts_info.direction,
7398 pAdapter->hddWmmStatus.
7399 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
7400 pAdapter->hddWmmStatus.
7401 wmmAcStatus[SME_AC_VI].
7402 wmmAcAccessAllowed ? "YES" : "NO",
7403 pAdapter->hddWmmStatus.
7404 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
7405 ts_info.direction,
7406 pAdapter->hddWmmStatus.
7407 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
7408 pAdapter->hddWmmStatus.
7409 wmmAcStatus[SME_AC_BE].
7410 wmmAcAccessAllowed ? "YES" : "NO",
7411 pAdapter->hddWmmStatus.
7412 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
7413 ts_info.direction,
7414 pAdapter->hddWmmStatus.
7415 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
7416 pAdapter->hddWmmStatus.
7417 wmmAcStatus[SME_AC_BK].
7418 wmmAcAccessAllowed ? "YES" : "NO",
7419 pAdapter->hddWmmStatus.
7420 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
7421 ts_info.direction);
7422
7423 wrqu->data.length = strlen(extra) + 1;
7424 break;
7425 }
7426 case WE_GET_CHANNEL_LIST:
7427 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307428 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007429 uint8_t i, len;
7430 char *buf;
7431 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
7432 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
7433 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7434
7435 tChannelListInfo channel_list;
7436
7437 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05307438 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007439 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307440 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007441 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007442 return -EINVAL;
7443 }
7444 buf = extra;
7445 /*
7446 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
7447 * Maximum buffer needed = 5 * number of channels.
7448 * Check ifsufficient buffer is available and then
7449 * proceed to fill the buffer.
7450 */
7451 if (WE_MAX_STR_LEN <
7452 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007453 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007454 return -EINVAL;
7455 }
7456 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7457 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307458 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007459 ubuf, &ubuf_len)) {
7460 /* Printing Country code in getChannelList */
7461 for (i = 0; i < (ubuf_len - 1); i++)
7462 len += scnprintf(buf + len,
7463 WE_MAX_STR_LEN - len,
7464 "%c", ubuf[i]);
7465 }
7466 for (i = 0; i < channel_list.num_channels; i++) {
7467 len +=
7468 scnprintf(buf + len, WE_MAX_STR_LEN - len,
7469 " %u", channel_list.channels[i]);
7470 }
7471 wrqu->data.length = strlen(extra) + 1;
7472
7473 break;
7474 }
7475#ifdef FEATURE_WLAN_TDLS
7476 case WE_GET_TDLS_PEERS:
7477 {
7478 wrqu->data.length =
7479 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
7480 WE_MAX_STR_LEN) + 1;
7481 break;
7482 }
7483#endif
7484#ifdef WLAN_FEATURE_11W
7485 case WE_GET_11W_INFO:
7486 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007487 hdd_err("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007488 pWextState->roamProfile.MFPEnabled);
7489
7490 snprintf(extra, WE_MAX_STR_LEN,
7491 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7492 "\n Number of Unprotected Disassocs %d"
7493 "\n Number of Unprotected Deauths %d",
7494 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
7495 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
7496 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
7497 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
7498 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
7499 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
7500 pWextState->roamProfile.MFPEnabled,
7501 pAdapter->hdd_stats.hddPmfStats.
7502 numUnprotDisassocRx,
7503 pAdapter->hdd_stats.hddPmfStats.
7504 numUnprotDeauthRx);
7505
7506 wrqu->data.length = strlen(extra) + 1;
7507 break;
7508 }
7509#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007510 case WE_GET_IBSS_STA_INFO:
7511 {
7512 hdd_station_ctx_t *pHddStaCtx =
7513 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7514 int idx = 0;
7515 int length = 0, buf = 0;
7516
Naveen Rawatc45d1622016-07-05 12:20:09 -07007517 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007518 if (0 != pHddStaCtx->conn_info.staId[idx]) {
7519 buf = snprintf
7520 ((extra + length),
7521 WE_MAX_STR_LEN - length,
7522 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7523 pHddStaCtx->conn_info.staId[idx],
7524 pHddStaCtx->conn_info.
7525 peerMacAddress[idx].bytes[0],
7526 pHddStaCtx->conn_info.
7527 peerMacAddress[idx].bytes[1],
7528 pHddStaCtx->conn_info.
7529 peerMacAddress[idx].bytes[2],
7530 pHddStaCtx->conn_info.
7531 peerMacAddress[idx].bytes[3],
7532 pHddStaCtx->conn_info.
7533 peerMacAddress[idx].bytes[4],
7534 pHddStaCtx->conn_info.
7535 peerMacAddress[idx].bytes[5]
7536 );
7537 length += buf;
7538 }
7539 }
7540 wrqu->data.length = strlen(extra) + 1;
7541 break;
7542 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007543 case WE_GET_PHYMODE:
7544 {
7545 bool ch_bond24 = false, ch_bond5g = false;
7546 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
7547 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7548 eCsrPhyMode phymode;
7549 eCsrBand currBand;
7550 tSmeConfigParams smeconfig;
7551
7552 sme_get_config_param(hal, &smeconfig);
7553 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7554 smeconfig.csrConfig.channelBondingMode24GHz)
7555 ch_bond24 = true;
7556
7557 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7558 smeconfig.csrConfig.channelBondingMode5GHz)
7559 ch_bond5g = true;
7560
7561 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307562 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007563 sme_get_freq_band(hal, &currBand))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007564 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007565 return -EIO;
7566 }
7567
7568 switch (phymode) {
7569 case eCSR_DOT11_MODE_AUTO:
7570 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
7571 break;
7572 case eCSR_DOT11_MODE_11n:
7573 case eCSR_DOT11_MODE_11n_ONLY:
7574 if (currBand == eCSR_BAND_24) {
7575 if (ch_bond24)
7576 snprintf(extra, WE_MAX_STR_LEN,
7577 "11NGHT40");
7578 else
7579 snprintf(extra, WE_MAX_STR_LEN,
7580 "11NGHT20");
7581 } else if (currBand == eCSR_BAND_5G) {
7582 if (ch_bond5g)
7583 snprintf(extra, WE_MAX_STR_LEN,
7584 "11NAHT40");
7585 else
7586 snprintf(extra, WE_MAX_STR_LEN,
7587 "11NAHT20");
7588 } else {
7589 snprintf(extra, WE_MAX_STR_LEN, "11N");
7590 }
7591 break;
7592 case eCSR_DOT11_MODE_abg:
7593 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
7594 break;
7595 case eCSR_DOT11_MODE_11a:
7596 snprintf(extra, WE_MAX_STR_LEN, "11A");
7597 break;
7598 case eCSR_DOT11_MODE_11b:
7599 case eCSR_DOT11_MODE_11b_ONLY:
7600 snprintf(extra, WE_MAX_STR_LEN, "11B");
7601 break;
7602 case eCSR_DOT11_MODE_11g:
7603 case eCSR_DOT11_MODE_11g_ONLY:
7604 snprintf(extra, WE_MAX_STR_LEN, "11G");
7605 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007606 case eCSR_DOT11_MODE_11ac:
7607 case eCSR_DOT11_MODE_11ac_ONLY:
7608 if (hddctx->config->vhtChannelWidth ==
7609 eHT_CHANNEL_WIDTH_20MHZ)
7610 snprintf(extra, WE_MAX_STR_LEN,
7611 "11ACVHT20");
7612 else if (hddctx->config->vhtChannelWidth ==
7613 eHT_CHANNEL_WIDTH_40MHZ)
7614 snprintf(extra, WE_MAX_STR_LEN,
7615 "11ACVHT40");
7616 else if (hddctx->config->vhtChannelWidth ==
7617 eHT_CHANNEL_WIDTH_80MHZ)
7618 snprintf(extra, WE_MAX_STR_LEN,
7619 "11ACVHT80");
7620 else if (hddctx->config->vhtChannelWidth ==
7621 eHT_CHANNEL_WIDTH_160MHZ)
7622 snprintf(extra, WE_MAX_STR_LEN,
7623 "11ACVHT160");
7624 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007625 }
7626
7627 wrqu->data.length = strlen(extra) + 1;
7628 break;
7629 }
7630
7631#ifdef FEATURE_OEM_DATA_SUPPORT
7632 case WE_GET_OEM_DATA_CAP:
7633 {
7634 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7635 }
7636#endif /* FEATURE_OEM_DATA_SUPPORT */
7637 case WE_GET_SNR:
7638 {
7639 int8_t s7snr = 0;
7640 int status = 0;
7641 hdd_context_t *pHddCtx;
7642 hdd_station_ctx_t *pHddStaCtx;
7643 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7644 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05307645 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007646 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05307647
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007648 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7649 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
7650 eConnectionState_Associated !=
7651 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007652 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007653 pHddCtx->config->fEnableSNRMonitoring,
7654 pHddStaCtx->conn_info.connState);
7655 return -ENONET;
7656 }
7657 wlan_hdd_get_snr(pAdapter, &s7snr);
7658 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
7659 wrqu->data.length = strlen(extra) + 1;
7660 break;
7661 }
7662 default:
7663 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007664 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007665 sub_cmd);
7666 break;
7667 }
7668 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307669 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007670 return 0;
7671}
7672
7673static int iw_get_char_setnone(struct net_device *dev,
7674 struct iw_request_info *info,
7675 union iwreq_data *wrqu, char *extra)
7676{
7677 int ret;
7678
7679 cds_ssr_protect(__func__);
7680 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7681 cds_ssr_unprotect(__func__);
7682
7683 return ret;
7684}
7685
7686/**
7687 * iw_setnone_getnone() - Generic "action" private ioctl handler
7688 * @dev: device upon which the ioctl was received
7689 * @info: ioctl request information
7690 * @wrqu: ioctl request data
7691 * @extra: ioctl extra data
7692 *
7693 * Return: 0 on success, non-zero on error
7694 */
7695static int __iw_setnone_getnone(struct net_device *dev,
7696 struct iw_request_info *info,
7697 union iwreq_data *wrqu, char *extra)
7698{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007699 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007700 hdd_context_t *hdd_ctx;
7701 int ret;
7702 int sub_cmd;
7703
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007704 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307705
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007706 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007707 ret = wlan_hdd_validate_context(hdd_ctx);
7708 if (0 != ret)
7709 return ret;
7710
7711#ifdef CONFIG_COMPAT
7712 /* this ioctl is a special case where a sub-ioctl is used and both
7713 * the number of get and set args is 0. in this specific case the
7714 * logic in iwpriv places the sub_cmd in the data.flags portion of
7715 * the iwreq. unfortunately the location of this field will be
7716 * different between 32-bit and 64-bit userspace, and the standard
7717 * compat support in the kernel does not handle this case. so we
7718 * need to explicitly handle it here.
7719 */
7720 if (is_compat_task()) {
7721 struct compat_iw_point *compat_iw_point =
7722 (struct compat_iw_point *)&wrqu->data;
7723 sub_cmd = compat_iw_point->flags;
7724 } else {
7725 sub_cmd = wrqu->data.flags;
7726 }
7727#else
7728 sub_cmd = wrqu->data.flags;
7729#endif
7730
7731 switch (sub_cmd) {
7732 case WE_GET_RECOVERY_STAT:
7733 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007734 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007735 sme_get_recovery_stats(hal);
7736 break;
7737 }
7738
Govind Singha471e5e2015-10-12 17:11:14 +05307739 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007740 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +05307741 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
7742 0, DBG_CMD);
7743 break;
7744
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007745 case WE_IBSS_GET_PEER_INFO_ALL:
7746 {
7747 hdd_wlan_get_ibss_peer_info_all(adapter);
7748 break;
7749 }
7750
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007751 case WE_SET_REASSOC_TRIGGER:
7752 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007753 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7754 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307755 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007756 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307757 uint8_t operating_ch =
7758 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007759 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007760
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007761 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007762 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307763 if (roaming_offload_enabled(hdd_ctx)) {
7764 qdf_mem_copy(bssid,
7765 &adapter->sessionCtx.station.conn_info.bssId,
7766 sizeof(bssid));
7767 hdd_wma_send_fastreassoc_cmd((int)adapter->sessionId,
7768 bssid, operating_ch);
7769 } else {
7770 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
7771 NULL, modProfileFields, &roamId, 1);
7772 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007773 return 0;
7774 }
7775
7776 case WE_DUMP_AGC_START:
7777 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007778 hdd_notice("WE_DUMP_AGC_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007779 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007780 GEN_PARAM_DUMP_AGC_START,
7781 0, GEN_CMD);
7782 break;
7783 }
7784 case WE_DUMP_AGC:
7785 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007786 hdd_notice("WE_DUMP_AGC");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007787 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007788 GEN_PARAM_DUMP_AGC,
7789 0, GEN_CMD);
7790 break;
7791 }
7792
7793 case WE_DUMP_CHANINFO_START:
7794 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007795 hdd_notice("WE_DUMP_CHANINFO_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007796 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007797 GEN_PARAM_DUMP_CHANINFO_START,
7798 0, GEN_CMD);
7799 break;
7800 }
7801 case WE_DUMP_CHANINFO:
7802 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007803 hdd_notice("WE_DUMP_CHANINFO_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007804 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007805 GEN_PARAM_DUMP_CHANINFO,
7806 0, GEN_CMD);
7807 break;
7808 }
7809 case WE_DUMP_WATCHDOG:
7810 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007811 hdd_notice("WE_DUMP_WATCHDOG");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007812 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007813 GEN_PARAM_DUMP_WATCHDOG,
7814 0, GEN_CMD);
7815 break;
7816 }
7817#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
7818 case WE_DUMP_PCIE_LOG:
7819 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007820 hdd_err("WE_DUMP_PCIE_LOG");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007821 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007822 GEN_PARAM_DUMP_PCIE_ACCESS_LOG,
7823 0, GEN_CMD);
7824 break;
7825 }
7826#endif
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007827 case WE_STOP_OBSS_SCAN:
7828 {
7829 /*
7830 * 1.OBSS Scan is mandatory while operating in 2.4GHz
7831 * 2.OBSS scan is stopped by Firmware during the disassociation
7832 * 3.OBSS stop comamnd is added for debugging purpose
7833 */
7834 tHalHandle hal;
7835
7836 hal = WLAN_HDD_GET_HAL_CTX(adapter);
7837 if (hal == NULL) {
7838 hdd_err("hal context is NULL");
7839 return -EINVAL;
7840 }
7841 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
7842 }
7843 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007844 default:
7845 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007846 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007847 break;
7848 }
7849 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307850 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007851 return ret;
7852}
7853
7854static int iw_setnone_getnone(struct net_device *dev,
7855 struct iw_request_info *info,
7856 union iwreq_data *wrqu, char *extra)
7857{
7858 int ret;
7859
7860 cds_ssr_protect(__func__);
7861 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7862 cds_ssr_unprotect(__func__);
7863
7864 return ret;
7865}
7866
7867/**
7868 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
7869 * @dev: device upon which the ioctl was received
7870 * @info: ioctl request information
7871 * @wrqu: ioctl request data
7872 * @extra: ioctl extra data
7873 *
7874 * This is an SSR-protected generic handler for private ioctls which
7875 * take multiple arguments. Note that this implementation is also
7876 * somewhat unique in that it is shared by both STA-mode and SAP-mode
7877 * interfaces.
7878 *
7879 * Return: 0 on success, non-zero on error
7880 */
7881static int __iw_set_var_ints_getnone(struct net_device *dev,
7882 struct iw_request_info *info,
7883 union iwreq_data *wrqu, char *extra)
7884{
7885 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7886 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7887 int sub_cmd;
7888 int *apps_args = (int *) extra;
7889 hdd_context_t *hdd_ctx;
7890 int ret, num_args;
7891
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007892 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307893
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007894 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7895 ret = wlan_hdd_validate_context(hdd_ctx);
7896 if (0 != ret)
7897 return ret;
7898
7899 if (extra == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007900 hdd_err("NULL extra buffer pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007901 return -EINVAL;
7902 }
7903
7904 sub_cmd = wrqu->data.flags;
7905 num_args = wrqu->data.length;
7906
Jeff Johnson99bac312016-06-28 10:38:18 -07007907 hdd_notice("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007908
7909 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007910 case WE_IBSS_GET_PEER_INFO:
7911 {
7912 pr_info("Station ID = %d\n", apps_args[0]);
7913 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7914 }
7915 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007916
7917 case WE_P2P_NOA_CMD:
7918 {
7919 p2p_app_setP2pPs_t p2pNoA;
7920
Krunal Sonif07bb382016-03-10 13:02:11 -08007921 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -08007922 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
7923 hdd_device_mode_to_string(
7924 pAdapter->device_mode),
7925 pAdapter->device_mode);
7926 return -EINVAL;
7927 }
7928
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007929 p2pNoA.opp_ps = apps_args[0];
7930 p2pNoA.ctWindow = apps_args[1];
7931 p2pNoA.duration = apps_args[2];
7932 p2pNoA.interval = apps_args[3];
7933 p2pNoA.count = apps_args[4];
7934 p2pNoA.single_noa_duration = apps_args[5];
7935 p2pNoA.psSelection = apps_args[6];
7936
Jeff Johnson99bac312016-06-28 10:38:18 -07007937 hdd_notice("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
7938 apps_args[0], apps_args[1], apps_args[2],
7939 apps_args[3], apps_args[4],
7940 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007941
7942 hdd_set_p2p_ps(dev, &p2pNoA);
7943
7944 }
7945 break;
7946
7947 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7948 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007949 hdd_notice("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7950 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307951 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007952 }
7953 break;
7954
7955 case WE_MTRACE_DUMP_CMD:
7956 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007957 hdd_notice("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
7958 apps_args[0], apps_args[1],
7959 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307960 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007961 apps_args[1], apps_args[2],
7962 apps_args[3]);
7963
7964 }
7965 break;
7966
7967 case WE_POLICY_MANAGER_CLIST_CMD:
7968 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007969 hdd_err("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007970 cds_incr_connection_count_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007971 apps_args[1], apps_args[2], apps_args[3],
7972 apps_args[4], apps_args[5], apps_args[6],
7973 apps_args[7]);
7974 }
7975 break;
7976
7977 case WE_POLICY_MANAGER_DLIST_CMD:
7978 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007979 hdd_err("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007980 cds_decr_connection_count_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007981 apps_args[1]);
7982 }
7983 break;
7984
7985 case WE_POLICY_MANAGER_ULIST_CMD:
7986 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007987 hdd_err("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007988 cds_update_connection_info_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007989 apps_args[1], apps_args[2], apps_args[3],
7990 apps_args[4], apps_args[5], apps_args[6],
7991 apps_args[7]);
7992 }
7993 break;
7994
7995 case WE_POLICY_MANAGER_DBS_CMD:
7996 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007997 hdd_err("<iwpriv wlan0 pm_dbs> is called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007998 if (apps_args[0] == 0)
7999 wma_set_dbs_capability_ut(0);
8000 else
8001 wma_set_dbs_capability_ut(1);
8002
8003 if (apps_args[1] >= CDS_THROUGHPUT &&
8004 apps_args[1] <= CDS_LATENCY) {
8005 pr_info("setting system pref to [%d]\n", apps_args[1]);
8006 hdd_ctx->config->conc_system_pref = apps_args[1];
8007 }
8008 }
8009 break;
8010
8011 case WE_POLICY_MANAGER_PCL_CMD:
8012 {
Manishekar Chandrasekaran1db3abe2016-06-24 03:27:07 +05308013 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
8014 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008015 uint32_t pcl_len = 0, i = 0;
8016
Jeff Johnson99bac312016-06-28 10:38:18 -07008017 hdd_err("<iwpriv wlan0 pm_pcl> is called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008018
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008019 cds_get_pcl(apps_args[0],
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308020 pcl, &pcl_len,
8021 weight_list, QDF_ARRAY_SIZE(weight_list));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008022 pr_info("PCL list for role[%d] is {", apps_args[0]);
8023 for (i = 0 ; i < pcl_len; i++)
8024 pr_info(" %d, ", pcl[i]);
8025 pr_info("}--------->\n");
8026 }
8027 break;
8028
8029 case WE_POLICY_MANAGER_CINFO_CMD:
8030 {
8031 struct cds_conc_connection_info *conn_info;
8032 uint32_t i = 0, len = 0;
8033
Jeff Johnson99bac312016-06-28 10:38:18 -07008034 hdd_err("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008035 conn_info = cds_get_conn_info(&len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008036 pr_info("+-----------------------------+\n");
8037 for (i = 0; i < len; i++) {
8038 pr_info("|table_index[%d]\t\t|\n", i);
8039 pr_info("|\t|vdev_id - %d\t\t|\n", conn_info->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008040 pr_info("|\t|chan - %d\t\t|\n", conn_info->chan);
Tushnim Bhattacharyya7624a182016-03-30 13:30:46 -07008041 pr_info("|\t|bw - %d\t\t|\n", conn_info->bw);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008042 pr_info("|\t|mode - %d\t\t|\n", conn_info->mode);
8043 pr_info("|\t|mac - %d\t\t|\n", conn_info->mac);
8044 pr_info("|\t|in_use - %d\t\t|\n", conn_info->in_use);
8045 pr_info("+-----------------------------+\n");
8046 conn_info++;
8047 }
8048 }
8049 break;
8050
8051 case WE_POLICY_SET_HW_MODE_CMD:
8052 {
8053 if (apps_args[0] == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008054 hdd_err("set hw mode for single mac");
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308055 cds_pdev_set_hw_mode(
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308056 pAdapter->sessionId,
8057 HW_MODE_SS_2x2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008058 HW_MODE_80_MHZ,
8059 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
8060 HW_MODE_DBS_NONE,
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308061 HW_MODE_AGILE_DFS_NONE,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05308062 HW_MODE_SBS_NONE,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308063 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008064 } else if (apps_args[0] == 1) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008065 hdd_err("set hw mode for dual mac");
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308066 cds_pdev_set_hw_mode(
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308067 pAdapter->sessionId,
8068 HW_MODE_SS_1x1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008069 HW_MODE_80_MHZ,
8070 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
8071 HW_MODE_DBS,
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308072 HW_MODE_AGILE_DFS_NONE,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05308073 HW_MODE_SBS_NONE,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308074 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008075 }
8076 }
8077 break;
8078
8079 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8080 {
8081 enum cds_conc_next_action action;
Jeff Johnson99bac312016-06-28 10:38:18 -07008082 hdd_err("<iwpriv wlan0 pm_query_action> is called");
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308083 action = cds_current_connections_update(pAdapter->sessionId,
8084 apps_args[0],
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308085 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008086 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
8087 }
8088 break;
8089 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8090 {
8091 bool allow;
Jeff Johnson99bac312016-06-28 10:38:18 -07008092 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008093 allow = cds_allow_concurrency(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008094 apps_args[0], apps_args[1], apps_args[2]);
8095 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
8096 }
8097 break;
8098
8099 case WE_POLICY_MANAGER_SCENARIO_CMD:
8100 {
8101 clean_report(hdd_ctx);
8102 if (apps_args[0] == 1) {
8103 wlan_hdd_one_connection_scenario(hdd_ctx);
8104 } else if (apps_args[0] == 2) {
8105 wlan_hdd_two_connections_scenario(hdd_ctx,
8106 6, CDS_TWO_TWO);
8107 wlan_hdd_two_connections_scenario(hdd_ctx,
8108 36, CDS_TWO_TWO);
8109 wlan_hdd_two_connections_scenario(hdd_ctx,
8110 6, CDS_ONE_ONE);
8111 wlan_hdd_two_connections_scenario(hdd_ctx,
8112 36, CDS_ONE_ONE);
8113 } else if (apps_args[0] == 3) {
8114 /* MCC on same band with 2x2 same mac*/
8115 wlan_hdd_three_connections_scenario(hdd_ctx,
8116 6, 11, CDS_TWO_TWO, 0);
8117 /* MCC on diff band with 2x2 same mac*/
8118 wlan_hdd_three_connections_scenario(hdd_ctx,
8119 6, 36, CDS_TWO_TWO, 0);
8120 /* MCC on diff band with 1x1 diff mac */
8121 wlan_hdd_three_connections_scenario(hdd_ctx,
8122 36, 6, CDS_ONE_ONE, 0);
8123 /* MCC on diff band with 1x1 same mac */
8124 wlan_hdd_three_connections_scenario(hdd_ctx,
8125 36, 6, CDS_ONE_ONE, 1);
8126 /* SCC on same band with 2x2 same mac */
8127 wlan_hdd_three_connections_scenario(hdd_ctx,
8128 36, 36, CDS_TWO_TWO, 0);
8129 /* SCC on same band with 1x1 same mac */
8130 wlan_hdd_three_connections_scenario(hdd_ctx,
8131 36, 36, CDS_ONE_ONE, 1);
8132 /* MCC on same band with 2x2 same mac */
8133 wlan_hdd_three_connections_scenario(hdd_ctx,
8134 36, 149, CDS_TWO_TWO, 0);
8135 /* MCC on same band with 1x1 same mac */
8136 wlan_hdd_three_connections_scenario(hdd_ctx,
8137 36, 149, CDS_ONE_ONE, 1);
8138 }
8139 print_report(hdd_ctx);
8140 }
8141 break;
8142
8143#ifdef FEATURE_WLAN_TDLS
8144 case WE_TDLS_CONFIG_PARAMS:
8145 {
8146 tdls_config_params_t tdlsParams;
8147
8148 tdlsParams.tdls = apps_args[0];
8149 tdlsParams.tx_period_t = apps_args[1];
8150 tdlsParams.tx_packet_n = apps_args[2];
8151 /* ignore args[3] as discovery_period is not used anymore */
8152 tdlsParams.discovery_tries_n = apps_args[4];
8153 /* ignore args[5] as idle_timeout is not used anymore */
8154 tdlsParams.idle_packet_n = apps_args[6];
8155 /* ignore args[7] as rssi_hysteresis is not used anymore */
8156 tdlsParams.rssi_trigger_threshold = apps_args[8];
8157 tdlsParams.rssi_teardown_threshold = apps_args[9];
8158 tdlsParams.rssi_delta = apps_args[10];
8159
8160 wlan_hdd_tdls_set_params(dev, &tdlsParams);
8161 }
8162 break;
8163#endif
8164 case WE_UNIT_TEST_CMD:
8165 {
8166 t_wma_unit_test_cmd *unitTestArgs;
8167 cds_msg_t msg = { 0 };
8168 int i, j;
8169 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
8170 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008171 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008172 apps_args[0]);
8173 return -EINVAL;
8174 }
Anurag Chouhan77564182016-09-03 16:38:01 +05308175 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
8176 (apps_args[1] < 0)) {
8177 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008178 apps_args[1]);
8179 return -EINVAL;
8180 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308181 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008182 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008183 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008184 return -ENOMEM;
8185 }
8186 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
8187 unitTestArgs->module_id = apps_args[0];
8188 unitTestArgs->num_args = apps_args[1];
8189 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
8190 unitTestArgs->args[i] = apps_args[j];
8191 }
8192 msg.type = SIR_HAL_UNIT_TEST_CMD;
8193 msg.reserved = 0;
8194 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308195 if (QDF_STATUS_SUCCESS !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05308196 cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308197 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -07008198 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008199 return -EINVAL;
8200 }
8201 }
8202 break;
8203#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8204 case WE_LED_FLASHING_PARAM:
8205 {
8206 int i;
8207 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008208 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008209 return -EINVAL;
8210 }
8211 for (i = 0; i < num_args; i++) {
8212 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008213 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008214 return -EINVAL;
8215 }
8216 }
8217 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8218 0, apps_args[0], apps_args[1]);
8219 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8220 1, apps_args[2], apps_args[3]);
8221 }
8222 break;
8223#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05308224 case WE_SET_PKTLOG:
8225 {
8226 int ret;
8227
8228 if (num_args < 1 || num_args > 2) {
8229 hdd_err("pktlog: either 1 or 2 parameters are required");
8230 return -EINVAL;
8231 }
8232
8233 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
8234 apps_args[1]);
8235 if (ret)
8236 return ret;
8237 break;
8238 }
8239
Manjeet Singhf82ed072016-07-08 11:40:00 +05308240 case WE_MAC_PWR_DEBUG_CMD:
8241 {
8242 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
8243 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8244 int i, j;
8245
8246 if (num_args < 3) {
8247 hdd_err("number of arguments can't be null %d",
8248 num_args);
8249 return -EINVAL;
8250 }
8251 if (num_args - 3 != apps_args[2]) {
8252 hdd_err("arg list of size %d doesn't match num_args %d",
8253 num_args-3, apps_args[2]);
8254 return -EINVAL;
8255 }
8256 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
8257 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
8258 hdd_err("Invalid MODULE ID %d", apps_args[1]);
8259 return -EINVAL;
8260 }
8261 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
8262 hdd_err("Too Many args %d", apps_args[2]);
8263 return -EINVAL;
8264 }
8265 mac_pwr_dbg_args.pdev_id = apps_args[0];
8266 mac_pwr_dbg_args.module_id = apps_args[1];
8267 mac_pwr_dbg_args.num_args = apps_args[2];
8268
8269 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
8270 mac_pwr_dbg_args.args[i] = apps_args[j];
8271
8272 if (QDF_STATUS_SUCCESS !=
8273 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
8274 &mac_pwr_dbg_args)) {
8275 return -EINVAL;
8276 }
8277 }
8278 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008279 default:
8280 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008281 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008282 }
8283 break;
8284 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308285 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008286 return 0;
8287}
8288
8289/**
8290 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
8291 * @dev: pointer to net_device structure
8292 * @info: pointer to iw_request_info structure
8293 * @wrqu: pointer to iwreq_data
8294 * @extra; extra
8295 *
8296 * Return: 0 on success, error number otherwise
8297 *
8298 */
8299static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8300 struct iw_request_info *info,
8301 union iwreq_data *wrqu, char *extra)
8302{
8303 union iwreq_data u_priv_wrqu;
8304 int apps_args[MAX_VAR_ARGS] = {0};
8305 int ret, num_args;
8306
Mukul Sharma64a70e82015-11-02 20:05:09 +05308307 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008308 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +05308309 return -EPERM;
8310 }
8311
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008312 /* Helper function to get iwreq_data with compat handling. */
8313 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8314 return -EINVAL;
8315
8316 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008317 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008318 return -EINVAL;
8319 }
8320
8321 num_args = u_priv_wrqu.data.length;
8322 if (num_args > MAX_VAR_ARGS)
8323 num_args = MAX_VAR_ARGS;
8324
8325 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8326 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008327 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008328 return -EFAULT;
8329 }
8330
8331 cds_ssr_protect(__func__);
8332 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8333 (char *)&apps_args);
8334 cds_ssr_unprotect(__func__);
8335 return ret;
8336}
8337
8338/**
8339 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8340 * @dev: device upon which the ioctl was received
8341 * @info: ioctl request information
8342 * @wrqu: ioctl request data
8343 * @extra: ioctl extra data
8344 *
8345 * This is a generic handler for private ioctls which take multiple
8346 * arguments. Note that this implementation is also somewhat unique
8347 * in that it is shared by both STA-mode and SAP-mode interfaces.
8348 *
8349 * Return: 0 on success, non-zero on error
8350 */
8351int iw_set_var_ints_getnone(struct net_device *dev,
8352 struct iw_request_info *info,
8353 union iwreq_data *wrqu, char *extra)
8354{
8355 int ret;
8356
8357 cds_ssr_protect(__func__);
8358 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8359 cds_ssr_unprotect(__func__);
8360 return ret;
8361}
8362
8363/**
8364 * iw_add_tspec - Add TSpec private ioctl handler
8365 * @dev: device upon which the ioctl was received
8366 * @info: ioctl request information
8367 * @wrqu: ioctl request data
8368 * @extra: ioctl extra data
8369 *
8370 * Return: 0 on success, non-zero on error
8371 */
8372static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
8373 union iwreq_data *wrqu, char *extra)
8374{
8375 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8376 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8377 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8378 int params[HDD_WLAN_WMM_PARAM_COUNT];
8379 sme_QosWmmTspecInfo tSpec;
8380 uint32_t handle;
8381 struct iw_point s_priv_data;
8382 hdd_context_t *hdd_ctx;
8383 int ret;
8384
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008385 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308386
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008387 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8388 ret = wlan_hdd_validate_context(hdd_ctx);
8389 if (0 != ret)
8390 return ret;
8391
8392 /* make sure the application is sufficiently priviledged */
8393 /* note that the kernel will do this for "set" ioctls, but since */
8394 /* this ioctl wants to return status to user space it must be */
8395 /* defined as a "get" ioctl */
8396 if (!capable(CAP_NET_ADMIN)) {
8397 return -EPERM;
8398 }
8399
8400 /* we must be associated in order to add a tspec */
8401 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
8402 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8403 return 0;
8404 }
8405 /* since we are defined to be a "get" ioctl, and since the number */
8406 /* of params exceeds the number of params that wireless extensions */
8407 /* will pass down in the iwreq_data, we must copy the "set" params. */
8408 /* We must handle the compat for iwreq_data in 32U/64K environment. */
8409
8410 /* helper function to get iwreq_data with compat handling. */
8411 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8412 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8413 return 0;
8414 }
8415 /* make sure all params are correctly passed to function */
8416 if ((NULL == s_priv_data.pointer) ||
8417 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
8418 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8419 return 0;
8420 }
8421 /* from user space ourselves */
8422 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
8423 /* hmmm, can't get them */
8424 return -EIO;
8425 }
8426 /* clear the tspec */
8427 memset(&tSpec, 0, sizeof(tSpec));
8428
8429 /* validate the handle */
8430 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8431 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8432 /* that one is reserved */
8433 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8434 return 0;
8435 }
8436 /* validate the TID */
8437 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
8438 /* out of range */
8439 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8440 return 0;
8441 }
8442 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8443
8444 /* validate the direction */
8445 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
8446 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8447 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8448 break;
8449
8450 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8451 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8452 break;
8453
8454 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8455 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8456 break;
8457
8458 default:
8459 /* unknown */
8460 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8461 return 0;
8462 }
8463
8464 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8465
8466 /* validate the user priority */
8467 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
8468 /* out of range */
8469 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8470 return 0;
8471 }
8472 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
8473 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008474 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008475 return 0;
8476 }
8477
Jeff Johnson99bac312016-06-28 10:38:18 -07008478 hdd_info("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008479 tSpec.ts_info.psb, tSpec.ts_info.up);
8480
8481 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8482 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8483 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8484 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8485 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8486 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8487 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8488 tSpec.surplus_bw_allowance =
8489 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8490 tSpec.min_service_interval =
8491 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8492 tSpec.max_service_interval =
8493 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8494 tSpec.suspension_interval =
8495 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8496 tSpec.inactivity_interval =
8497 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8498
8499 tSpec.ts_info.burst_size_defn =
8500 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8501
8502 /* validate the ts info ack policy */
8503 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
8504 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8505 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8506 break;
8507
8508 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8509 tSpec.ts_info.ack_policy =
8510 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8511 break;
8512
8513 default:
8514 /* unknown */
8515 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8516 return 0;
8517 }
8518
8519 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308520 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008521 return 0;
8522}
8523
8524static int iw_add_tspec(struct net_device *dev,
8525 struct iw_request_info *info,
8526 union iwreq_data *wrqu, char *extra)
8527{
8528 int ret;
8529
8530 cds_ssr_protect(__func__);
8531 ret = __iw_add_tspec(dev, info, wrqu, extra);
8532 cds_ssr_unprotect(__func__);
8533
8534 return ret;
8535}
8536
8537/**
8538 * iw_del_tspec - Delete TSpec private ioctl handler
8539 * @dev: device upon which the ioctl was received
8540 * @info: ioctl request information
8541 * @wrqu: ioctl request data
8542 * @extra: ioctl extra data
8543 *
8544 * Return: 0 on success, non-zero on error
8545 */
8546static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
8547 union iwreq_data *wrqu, char *extra)
8548{
8549 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8550 hdd_context_t *hdd_ctx;
8551 int *params = (int *)extra;
8552 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8553 uint32_t handle;
8554 int ret;
8555
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008556 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308557
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008558 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8559 ret = wlan_hdd_validate_context(hdd_ctx);
8560 if (0 != ret)
8561 return ret;
8562
8563 /* make sure the application is sufficiently priviledged */
8564 /* note that the kernel will do this for "set" ioctls, but since */
8565 /* this ioctl wants to return status to user space it must be */
8566 /* defined as a "get" ioctl */
8567 if (!capable(CAP_NET_ADMIN)) {
8568 return -EPERM;
8569 }
8570
8571 /* although we are defined to be a "get" ioctl, the params we require */
8572 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
8573 /* is no need to copy the params from user space */
8574
8575 /* validate the handle */
8576 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8577 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8578 /* that one is reserved */
8579 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8580 return 0;
8581 }
8582
8583 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308584 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008585 return 0;
8586}
8587
8588static int iw_del_tspec(struct net_device *dev,
8589 struct iw_request_info *info,
8590 union iwreq_data *wrqu, char *extra)
8591{
8592 int ret;
8593
8594 cds_ssr_protect(__func__);
8595 ret = __iw_del_tspec(dev, info, wrqu, extra);
8596 cds_ssr_unprotect(__func__);
8597
8598 return ret;
8599}
8600
8601/**
8602 * iw_get_tspec - Get TSpec private ioctl handler
8603 * @dev: device upon which the ioctl was received
8604 * @info: ioctl request information
8605 * @wrqu: ioctl request data
8606 * @extra: ioctl extra data
8607 *
8608 * Return: 0 on success, non-zero on error
8609 */
8610static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
8611 union iwreq_data *wrqu, char *extra)
8612{
8613 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8614 hdd_context_t *hdd_ctx;
8615 int *params = (int *)extra;
8616 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8617 uint32_t handle;
8618 int ret;
8619
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008620 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308621
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008622 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8623 ret = wlan_hdd_validate_context(hdd_ctx);
8624 if (0 != ret)
8625 return ret;
8626
8627 /* although we are defined to be a "get" ioctl, the params we require */
8628 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
8629 /* is no need to copy the params from user space */
8630
8631 /* validate the handle */
8632 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8633 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8634 /* that one is reserved */
8635 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8636 return 0;
8637 }
8638
8639 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308640 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008641 return 0;
8642}
8643
8644static int iw_get_tspec(struct net_device *dev,
8645 struct iw_request_info *info,
8646 union iwreq_data *wrqu, char *extra)
8647{
8648 int ret;
8649
8650 cds_ssr_protect(__func__);
8651 ret = __iw_get_tspec(dev, info, wrqu, extra);
8652 cds_ssr_unprotect(__func__);
8653
8654 return ret;
8655}
8656
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008657/**
8658 * iw_set_fties - Set FT IEs private ioctl handler
8659 * @dev: device upon which the ioctl was received
8660 * @info: ioctl request information
8661 * @wrqu: ioctl request data
8662 * @extra: ioctl extra data
8663 *
8664 * Each time the supplicant has the auth_request or reassoc request
8665 * IEs ready they are pushed to the driver. The driver will in turn
8666 * use it to send out the auth req and reassoc req for 11r FT Assoc.
8667 *
8668 * Return: 0 on success, non-zero on error
8669 */
8670static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
8671 union iwreq_data *wrqu, char *extra)
8672{
8673 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8674 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8675 hdd_context_t *hdd_ctx;
8676 int ret;
8677
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008678 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008680 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8681 ret = wlan_hdd_validate_context(hdd_ctx);
8682 if (0 != ret)
8683 return ret;
8684
8685 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008686 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008687 return -EINVAL;
8688 }
8689 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008690 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008691 return -EINVAL;
8692 }
8693 /* Added for debug on reception of Re-assoc Req. */
8694 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008695 hdd_err("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008696 wrqu->data.length);
Jeff Johnson99bac312016-06-28 10:38:18 -07008697 hdd_err("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008698 }
Jeff Johnson99bac312016-06-28 10:38:18 -07008699 hdd_notice("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008700
8701 /* Pass the received FT IEs to SME */
8702 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
8703 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308704 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008705 return 0;
8706}
8707
8708static int iw_set_fties(struct net_device *dev,
8709 struct iw_request_info *info,
8710 union iwreq_data *wrqu, char *extra)
8711{
8712 int ret;
8713
8714 cds_ssr_protect(__func__);
8715 ret = __iw_set_fties(dev, info, wrqu, extra);
8716 cds_ssr_unprotect(__func__);
8717
8718 return ret;
8719}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008720
8721/**
8722 * iw_set_host_offload - Set host offload ioctl handler
8723 * @dev: device upon which the ioctl was received
8724 * @info: ioctl request information
8725 * @wrqu: ioctl request data
8726 * @extra: ioctl extra data
8727 *
8728 * Return: 0 on success, non-zero on error
8729 */
8730static int __iw_set_host_offload(struct net_device *dev,
8731 struct iw_request_info *info,
8732 union iwreq_data *wrqu, char *extra)
8733{
8734 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8735 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
8736 tSirHostOffloadReq offloadRequest;
8737 hdd_context_t *hdd_ctx;
8738 int ret;
8739
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008740 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308741
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008742 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8743 ret = wlan_hdd_validate_context(hdd_ctx);
8744 if (0 != ret)
8745 return ret;
8746
8747 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008748 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008749 return -EINVAL;
8750 }
8751
8752 /* Debug display of request components. */
8753 switch (pRequest->offloadType) {
8754 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07008755 hdd_warn("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008756 switch (pRequest->enableOrDisable) {
8757 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008758 hdd_warn(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008759 break;
8760 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008761 hdd_warn(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008762 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008763 hdd_warn(" ARP offload enable");
8764 hdd_warn(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008765 pRequest->params.hostIpv4Addr[0],
8766 pRequest->params.hostIpv4Addr[1],
8767 pRequest->params.hostIpv4Addr[2],
8768 pRequest->params.hostIpv4Addr[3]);
8769 }
8770 break;
8771
8772 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07008773 hdd_info("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008774 switch (pRequest->enableOrDisable) {
8775 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008776 hdd_info(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008777 break;
8778 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008779 hdd_info(" enable");
8780 hdd_info(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008781 *(uint16_t *) (pRequest->params.hostIpv6Addr),
8782 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8783 2),
8784 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8785 4),
8786 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8787 6),
8788 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8789 8),
8790 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8791 10),
8792 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8793 12),
8794 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8795 14));
8796 }
8797 }
8798
8799 /* Execute offload request. The reason that we can copy the
8800 * request information from the ioctl structure to the SME
8801 * structure is that they are laid out exactly the same.
8802 * Otherwise, each piece of information would have to be
8803 * copied individually.
8804 */
8805 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308806 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008807 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8808 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008809 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008810 return -EINVAL;
8811 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308812 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008813 return 0;
8814}
8815
8816static int iw_set_host_offload(struct net_device *dev,
8817 struct iw_request_info *info,
8818 union iwreq_data *wrqu, char *extra)
8819{
8820 int ret;
8821
8822 cds_ssr_protect(__func__);
8823 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8824 cds_ssr_unprotect(__func__);
8825
8826 return ret;
8827}
8828
8829/**
8830 * iw_set_keepalive_params - Set keepalive params ioctl handler
8831 * @dev: device upon which the ioctl was received
8832 * @info: ioctl request information
8833 * @wrqu: ioctl request data
8834 * @extra: ioctl extra data
8835 *
8836 * Return: 0 on success, non-zero on error
8837 */
8838static int __iw_set_keepalive_params(struct net_device *dev,
8839 struct iw_request_info *info,
8840 union iwreq_data *wrqu, char *extra)
8841{
8842 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008843 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008844 hdd_context_t *hdd_ctx;
8845 int ret;
8846
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008847 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308848
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008849 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8850 ret = wlan_hdd_validate_context(hdd_ctx);
8851 if (0 != ret)
8852 return ret;
8853
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008854 if (wrqu->data.length != sizeof(*request)) {
8855 hdd_err("Invalid length %d", wrqu->data.length);
8856 return -EINVAL;
8857 }
8858
8859 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
8860 hdd_err("Value of timePeriod %d exceed Max limit %d",
8861 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008862 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
8863 return -EINVAL;
8864 }
8865
8866 /* Debug display of request components. */
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008867 hdd_info("Set Keep Alive Request : TimePeriod %d size %zu",
8868 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008869
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008870 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008871 case WLAN_KEEP_ALIVE_NULL_PKT:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008872 hdd_info("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008873 break;
8874
8875 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008876 hdd_info("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008877
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008878 hdd_info("Host IP address: %d.%d.%d.%d",
8879 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
8880 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008881
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008882 hdd_info("Dest IP address: %d.%d.%d.%d",
8883 request->destIpv4Addr[0], request->destIpv4Addr[1],
8884 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008885
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08008886 hdd_info("Dest MAC address: "MAC_ADDRESS_STR,
8887 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008888 break;
8889 }
8890
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008891 hdd_info("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008892
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308893 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008894 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008895 pAdapter->sessionId, request)) {
8896 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008897 return -EINVAL;
8898 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308899 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008900 return 0;
8901}
8902
8903static int iw_set_keepalive_params(struct net_device *dev,
8904 struct iw_request_info *info,
8905 union iwreq_data *wrqu,
8906 char *extra)
8907{
8908 int ret;
8909
8910 cds_ssr_protect(__func__);
8911 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8912 cds_ssr_unprotect(__func__);
8913
8914 return ret;
8915}
8916
8917#ifdef WLAN_FEATURE_PACKET_FILTERING
8918/**
8919 * wlan_hdd_set_filter() - Set packet filter
8920 * @hdd_ctx: Global HDD context
8921 * @request: Packet filter request struct
8922 * @sessionId: Target session for the request
8923 *
8924 * Return: 0 on success, non-zero on error
8925 */
8926static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
8927 struct pkt_filter_cfg *request,
8928 uint8_t sessionId)
8929{
8930 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8931 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8932 int i = 0;
8933
8934 if (hdd_ctx->config->disablePacketFilter) {
8935 hdd_err("packet filtering disabled in ini returning");
8936 return 0;
8937 }
8938
8939 /* Debug display of request components. */
8940 hdd_info("Packet Filter Request : FA %d params %d",
8941 request->filter_action, request->num_params);
8942
8943 switch (request->filter_action) {
8944 case HDD_RCV_FILTER_SET:
8945 hdd_info("Set Packet Filter Request for Id: %d",
8946 request->filter_id);
8947
8948 packetFilterSetReq.filterId = request->filter_id;
8949 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
8950 hdd_err("Number of Params exceed Max limit %d",
8951 request->num_params);
8952 return -EINVAL;
8953 }
8954 packetFilterSetReq.numFieldParams = request->num_params;
8955 packetFilterSetReq.coalesceTime = 0;
8956 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8957 for (i = 0; i < request->num_params; i++) {
8958 packetFilterSetReq.paramsData[i].protocolLayer =
8959 request->params_data[i].protocol_layer;
8960 packetFilterSetReq.paramsData[i].cmpFlag =
8961 request->params_data[i].compare_flag;
8962 packetFilterSetReq.paramsData[i].dataOffset =
8963 request->params_data[i].data_offset;
8964 packetFilterSetReq.paramsData[i].dataLength =
8965 request->params_data[i].data_length;
8966 packetFilterSetReq.paramsData[i].reserved = 0;
8967
8968 if (request->params_data[i].data_length >
8969 SIR_MAX_FILTER_TEST_DATA_LEN) {
8970 hdd_err("Error invalid data length %d",
8971 request->params_data[i].data_length);
8972 return -EINVAL;
8973 }
8974
8975 hdd_info("Proto %d Comp Flag %d Filter Type %d",
8976 request->params_data[i].protocol_layer,
8977 request->params_data[i].compare_flag,
8978 packetFilterSetReq.filterType);
8979
8980 hdd_info("Data Offset %d Data Len %d",
8981 request->params_data[i].data_offset,
8982 request->params_data[i].data_length);
8983
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07008984 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
8985 < (request->params_data[i].data_length)) {
8986 hdd_err("Error invalid data length %d",
8987 request->params_data[i].data_length);
8988 return -EINVAL;
8989 }
8990
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008991 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8992 request->params_data[i].compare_data,
8993 request->params_data[i].data_length);
8994 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8995 request->params_data[i].data_mask,
8996 request->params_data[i].data_length);
8997
8998 hdd_info("CData %d CData %d CData %d CData %d CData %d CData %d",
8999 request->params_data[i].compare_data[0],
9000 request->params_data[i].compare_data[1],
9001 request->params_data[i].compare_data[2],
9002 request->params_data[i].compare_data[3],
9003 request->params_data[i].compare_data[4],
9004 request->params_data[i].compare_data[5]);
9005
9006 hdd_info("MData %d MData %d MData %d MData %d MData %d MData %d",
9007 request->params_data[i].data_mask[0],
9008 request->params_data[i].data_mask[1],
9009 request->params_data[i].data_mask[2],
9010 request->params_data[i].data_mask[3],
9011 request->params_data[i].data_mask[4],
9012 request->params_data[i].data_mask[5]);
9013 }
9014
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309015 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009016 sme_receive_filter_set_filter(hdd_ctx->hHal,
9017 &packetFilterSetReq,
9018 sessionId)) {
9019 hdd_err("Failure to execute Set Filter");
9020 return -EINVAL;
9021 }
9022
9023 break;
9024
9025 case HDD_RCV_FILTER_CLEAR:
9026
9027 hdd_info("Clear Packet Filter Request for Id: %d",
9028 request->filter_id);
9029 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309030 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009031 sme_receive_filter_clear_filter(hdd_ctx->hHal,
9032 &packetFilterClrReq,
9033 sessionId)) {
9034 hdd_err("Failure to execute Clear Filter");
9035 return -EINVAL;
9036 }
9037 break;
9038
9039 default:
9040 hdd_err("Packet Filter Request: Invalid %d",
9041 request->filter_action);
9042 return -EINVAL;
9043 }
9044 return 0;
9045}
9046
9047/**
9048 * __iw_set_packet_filter_params() - set packet filter parameters in target
9049 * @dev: Pointer to netdev
9050 * @info: Pointer to iw request info
9051 * @wrqu: Pointer to data
9052 * @extra: Pointer to extra data
9053 *
9054 * Return: 0 on success, non-zero on error
9055 */
9056static int __iw_set_packet_filter_params(struct net_device *dev,
9057 struct iw_request_info *info,
9058 union iwreq_data *wrqu, char *extra)
9059{
9060 int ret;
9061 hdd_context_t *hdd_ctx;
9062 struct iw_point priv_data;
9063 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9064 struct pkt_filter_cfg *request = NULL;
9065
Mukul Sharma472382f2015-11-02 20:16:31 +05309066 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009067 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +05309068 return -EPERM;
9069 }
9070
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009071 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309072
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009073 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9074 ret = wlan_hdd_validate_context(hdd_ctx);
9075 if (0 != ret)
9076 return ret;
9077
9078 if (hdd_priv_get_data(&priv_data, wrqu)) {
9079 hdd_err("failed to get priv data");
9080 return -EINVAL;
9081 }
9082
9083 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
9084 hdd_err("invalid priv data %p or invalid priv data length %d",
9085 priv_data.pointer, priv_data.length);
9086 return -EINVAL;
9087 }
9088
9089 /* copy data using copy_from_user */
9090 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
9091 priv_data.length);
9092 if (NULL == request) {
9093 hdd_err("mem_alloc_copy_from_user_helper fail");
9094 return -ENOMEM;
9095 }
9096
9097 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
9098
9099 kfree(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309100 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009101 return ret;
9102}
9103
9104/**
9105 * iw_set_packet_filter_params() - set packet filter parameters in target
9106 * @dev: Pointer to netdev
9107 * @info: Pointer to iw request info
9108 * @wrqu: Pointer to data
9109 * @extra: Pointer to extra data
9110 *
9111 * Return: 0 on success, non-zero on error
9112 */
9113static int iw_set_packet_filter_params(struct net_device *dev,
9114 struct iw_request_info *info,
9115 union iwreq_data *wrqu, char *extra)
9116{
9117 int ret;
9118
9119 cds_ssr_protect(__func__);
9120 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9121 cds_ssr_unprotect(__func__);
9122
9123 return ret;
9124}
9125#endif
9126
9127
9128static int __iw_get_statistics(struct net_device *dev,
9129 struct iw_request_info *info,
9130 union iwreq_data *wrqu, char *extra)
9131{
9132
Anurag Chouhance0dc992016-02-16 18:18:03 +05309133 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309134 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009135 hdd_wext_state_t *pWextState;
9136 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9137 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9138 char *p = extra;
9139 int tlen = 0;
9140 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
9141 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
9142 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
9143 int ret;
9144
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009145 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009146
9147 ret = wlan_hdd_validate_context(hdd_ctx);
9148 if (0 != ret)
9149 return ret;
9150
9151 if (eConnectionState_Associated !=
9152 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9153
9154 wrqu->txpower.value = 0;
9155 } else {
9156 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9157 SME_SUMMARY_STATS |
9158 SME_GLOBAL_CLASSA_STATS |
9159 SME_GLOBAL_CLASSB_STATS |
9160 SME_GLOBAL_CLASSC_STATS |
9161 SME_GLOBAL_CLASSD_STATS |
9162 SME_PER_STA_STATS,
9163 hdd_statistics_cb, 0, false,
9164 (WLAN_HDD_GET_STATION_CTX_PTR
9165 (pAdapter))->conn_info.staId[0],
9166 pAdapter, pAdapter->sessionId);
9167
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309168 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009169 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009170 return -EINVAL;
9171 }
9172
9173 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9174
Anurag Chouhance0dc992016-02-16 18:18:03 +05309175 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05309176 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009177 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +05309178 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009179 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009180 /*Remove the SME statistics list by passing NULL in callback argument */
9181 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9182 SME_SUMMARY_STATS |
9183 SME_GLOBAL_CLASSA_STATS |
9184 SME_GLOBAL_CLASSB_STATS |
9185 SME_GLOBAL_CLASSC_STATS |
9186 SME_GLOBAL_CLASSD_STATS |
9187 SME_PER_STA_STATS,
9188 NULL, 0, false,
9189 (WLAN_HDD_GET_STATION_CTX_PTR
9190 (pAdapter))->conn_info.
9191 staId[0], pAdapter,
9192 pAdapter->sessionId);
9193
9194 return -EINVAL;
9195 }
9196 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
9197 (uint8_t) sizeof(pStats->retry_cnt),
9198 (char *)&(pStats->retry_cnt[0]), tlen);
9199
9200 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
9201 (uint8_t) sizeof(pStats->multiple_retry_cnt),
9202 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
9203
9204 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
9205 (uint8_t) sizeof(pStats->tx_frm_cnt),
9206 (char *)&(pStats->tx_frm_cnt[0]), tlen);
9207
9208 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
9209 (uint8_t) sizeof(pStats->rx_frm_cnt),
9210 (char *)&(pStats->rx_frm_cnt), tlen);
9211
9212 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
9213 (uint8_t) sizeof(pStats->frm_dup_cnt),
9214 (char *)&(pStats->frm_dup_cnt), tlen);
9215
9216 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
9217 (uint8_t) sizeof(pStats->fail_cnt),
9218 (char *)&(pStats->fail_cnt[0]), tlen);
9219
9220 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
9221 (uint8_t) sizeof(pStats->rts_fail_cnt),
9222 (char *)&(pStats->rts_fail_cnt), tlen);
9223
9224 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
9225 (uint8_t) sizeof(pStats->ack_fail_cnt),
9226 (char *)&(pStats->ack_fail_cnt), tlen);
9227
9228 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
9229 (uint8_t) sizeof(pStats->rts_succ_cnt),
9230 (char *)&(pStats->rts_succ_cnt), tlen);
9231
9232 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
9233 (uint8_t) sizeof(pStats->rx_discard_cnt),
9234 (char *)&(pStats->rx_discard_cnt), tlen);
9235
9236 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
9237 (uint8_t) sizeof(pStats->rx_error_cnt),
9238 (char *)&(pStats->rx_error_cnt), tlen);
9239
9240 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
9241 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9242 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9243
9244 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
9245 (uint8_t) sizeof(dStats->rx_byte_cnt),
9246 (char *)&(dStats->rx_byte_cnt), tlen);
9247
9248 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
9249 (uint8_t) sizeof(dStats->rx_rate),
9250 (char *)&(dStats->rx_rate), tlen);
9251
9252 /* Transmit rate, in units of 500 kbit/sec */
9253 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
9254 (uint8_t) sizeof(aStats->tx_rate),
9255 (char *)&(aStats->tx_rate), tlen);
9256
9257 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
9258 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
9259 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
9260 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
9261 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
9262 (char *)&(dStats->rx_mc_byte_cnt), tlen);
9263 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
9264 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
9265 (char *)&(dStats->rx_bc_byte_cnt), tlen);
9266 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
9267 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9268 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9269 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
9270 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
9271 (char *)&(dStats->tx_mc_byte_cnt), tlen);
9272 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
9273 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
9274 (char *)&(dStats->tx_bc_byte_cnt), tlen);
9275
9276 wrqu->data.length = tlen;
9277
9278 }
9279
9280 EXIT();
9281
9282 return 0;
9283}
9284
9285static int iw_get_statistics(struct net_device *dev,
9286 struct iw_request_info *info,
9287 union iwreq_data *wrqu, char *extra)
9288{
9289 int ret;
9290
9291 cds_ssr_protect(__func__);
9292 ret = __iw_get_statistics(dev, info, wrqu, extra);
9293 cds_ssr_unprotect(__func__);
9294
9295 return ret;
9296}
9297
9298#ifdef FEATURE_WLAN_SCAN_PNO
9299
9300/*Max Len for PNO notification*/
9301#define MAX_PNO_NOTIFY_LEN 100
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07009302static void found_pref_network_cb(void *callbackContext,
9303 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009304{
9305 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
9306 union iwreq_data wrqu;
9307 char buf[MAX_PNO_NOTIFY_LEN + 1];
9308
Jeff Johnson99bac312016-06-28 10:38:18 -07009309 hdd_warn("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009310 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9311
9312 /* create the event */
9313 memset(&wrqu, 0, sizeof(wrqu));
9314 memset(buf, 0, sizeof(buf));
9315
9316 snprintf(buf, MAX_PNO_NOTIFY_LEN,
9317 "QCOM: Found preferred network: %s with RSSI of -%u",
9318 pPrefNetworkFoundInd->ssId.ssId,
9319 (unsigned int)pPrefNetworkFoundInd->rssi);
9320
9321 wrqu.data.pointer = buf;
9322 wrqu.data.length = strlen(buf);
9323
9324 /* send the event */
9325
9326 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9327
9328}
9329
9330/**
9331 * __iw_set_pno() - Preferred Network Offload ioctl handler
9332 * @dev: device upon which the ioctl was received
9333 * @info: ioctl request information
9334 * @wrqu: ioctl request data
9335 * @extra: ioctl extra data
9336 *
9337 * This function parses a Preferred Network Offload command
9338 * Input is string based and expected to be of the form:
9339 *
9340 * <enable(1) | disable(0)>
9341 * when enabling:
9342 * <number of networks>
9343 * for each network:
9344 * <ssid_len> <ssid> <authentication> <encryption>
9345 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -07009346 * <scan_time (seconds)>
9347 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009348 * <suspend mode>
9349 *
9350 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -07009351 * 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 -08009352 *
9353 * this translates into:
9354 * -----------------------------
9355 * enable PNO
9356 * 2 networks
9357 * Network 1:
9358 * test - with authentication type 0 and encryption type 0,
9359 * search on 3 channels: 1 6 and 11,
9360 * SSID bcast type is unknown (directed probe will be sent if
9361 * AP not found) and must meet -40dBm RSSI
9362 * Network 2:
9363 * test2 - with authentication type 4 and encryption type 4,
9364 * search on 6 channels 1, 2, 3, 4, 5 and 6
9365 * bcast type is non-bcast (directed probe will be sent)
9366 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009367 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -07009368 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009369 */
9370static int __iw_set_pno(struct net_device *dev,
9371 struct iw_request_info *info,
9372 union iwreq_data *wrqu, char *extra)
9373{
9374 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9375 hdd_context_t *hdd_ctx;
9376 int ret;
9377 int offset;
9378 char *ptr;
9379 uint8_t i, j, params, mode;
9380
9381 /* request is a large struct, so we make it static to avoid
9382 * stack overflow. This API is only invoked via ioctl, so it
9383 * is serialized by the kernel rtnl_lock and hence does not
9384 * need to be reentrant
9385 */
9386 static tSirPNOScanReq request;
9387
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009388 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009389
9390 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9391 ret = wlan_hdd_validate_context(hdd_ctx);
9392 if (ret)
9393 return ret;
9394
9395 hdd_notice("PNO data len %d data %s", wrqu->data.length, extra);
9396
9397 request.enable = 0;
9398 request.ucNetworksCount = 0;
9399
9400 ptr = extra;
9401
9402 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
9403 hdd_err("PNO enable input is not valid %s", ptr);
9404 return -EINVAL;
9405 }
9406
9407 if (0 == request.enable) {
9408 /* Disable PNO, ignore any other params */
9409 memset(&request, 0, sizeof(request));
9410 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
9411 &request, adapter->sessionId,
9412 found_pref_network_cb, adapter);
9413 return 0;
9414 }
9415
9416 ptr += offset;
9417
9418 if (1 !=
9419 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
9420 hdd_err("PNO count input not valid %s", ptr);
9421 return -EINVAL;
9422
9423 }
9424
9425 hdd_info("PNO enable %d networks count %d offset %d",
9426 request.enable, request.ucNetworksCount, offset);
9427
9428 if ((0 == request.ucNetworksCount) ||
9429 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
9430 hdd_err("Network count %d invalid",
9431 request.ucNetworksCount);
9432 return -EINVAL;
9433 }
9434
9435 ptr += offset;
9436
9437 for (i = 0; i < request.ucNetworksCount; i++) {
9438
9439 request.aNetworks[i].ssId.length = 0;
9440
9441 params = sscanf(ptr, "%hhu %n",
9442 &(request.aNetworks[i].ssId.length),
9443 &offset);
9444
9445 if (1 != params) {
9446 hdd_err("PNO ssid length input is not valid %s", ptr);
9447 return -EINVAL;
9448 }
9449
9450 if ((0 == request.aNetworks[i].ssId.length) ||
9451 (request.aNetworks[i].ssId.length > 32)) {
9452 hdd_err("SSID Len %d is not correct for network %d",
9453 request.aNetworks[i].ssId.length, i);
9454 return -EINVAL;
9455 }
9456
9457 /* Advance to SSID */
9458 ptr += offset;
9459
9460 memcpy(request.aNetworks[i].ssId.ssId, ptr,
9461 request.aNetworks[i].ssId.length);
9462 ptr += request.aNetworks[i].ssId.length;
9463
9464 params = sscanf(ptr, "%u %u %hhu %n",
9465 &(request.aNetworks[i].authentication),
9466 &(request.aNetworks[i].encryption),
9467 &(request.aNetworks[i].ucChannelCount),
9468 &offset);
9469
9470 if (3 != params) {
9471 hdd_warn("Incorrect cmd %s", ptr);
9472 return -EINVAL;
9473 }
9474
9475 hdd_notice("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
9476 request.aNetworks[i].ssId.length,
9477 request.aNetworks[i].ssId.length,
9478 request.aNetworks[i].ssId.ssId,
9479 request.aNetworks[i].authentication,
9480 request.aNetworks[i].encryption,
9481 request.aNetworks[i].ucChannelCount, offset);
9482
9483 /* Advance to channel list */
9484 ptr += offset;
9485
9486 if (SIR_PNO_MAX_NETW_CHANNELS <
9487 request.aNetworks[i].ucChannelCount) {
9488 hdd_warn("Incorrect number of channels");
9489 return -EINVAL;
9490 }
9491
9492 if (0 != request.aNetworks[i].ucChannelCount) {
9493 for (j = 0; j < request.aNetworks[i].ucChannelCount;
9494 j++) {
9495 if (1 !=
9496 sscanf(ptr, "%hhu %n",
9497 &(request.aNetworks[i].
9498 aChannels[j]), &offset)) {
9499 hdd_err("PNO network channel input is not valid %s",
9500 ptr);
9501 return -EINVAL;
9502 }
9503 /* Advance to next channel number */
9504 ptr += offset;
9505 }
9506 }
9507
9508 if (1 != sscanf(ptr, "%u %n",
9509 &(request.aNetworks[i].bcastNetwType),
9510 &offset)) {
9511 hdd_err("PNO broadcast network type input is not valid %s",
9512 ptr);
9513 return -EINVAL;
9514 }
9515
9516 hdd_notice("PNO bcastNetwType %d offset %d",
9517 request.aNetworks[i].bcastNetwType, offset);
9518
9519 /* Advance to rssi Threshold */
9520 ptr += offset;
9521 if (1 != sscanf(ptr, "%d %n",
9522 &(request.aNetworks[i].rssiThreshold),
9523 &offset)) {
9524 hdd_err("PNO rssi threshold input is not valid %s",
9525 ptr);
9526 return -EINVAL;
9527 }
9528 hdd_notice("PNO rssi %d offset %d",
9529 request.aNetworks[i].rssiThreshold, offset);
9530 /* Advance to next network */
9531 ptr += offset;
9532 } /* For ucNetworkCount */
9533
Dustin Brown43e87292016-10-10 10:38:25 -07009534 request.fast_scan_period = 0;
9535 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
9536 request.fast_scan_period *= MSEC_PER_SEC;
9537 ptr += offset;
9538 }
9539
9540 request.fast_scan_max_cycles = 0;
9541 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
9542 &offset) > 0)
9543 ptr += offset;
9544
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009545 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
9546
9547 request.modePNO = mode;
9548 /* for LA we just expose suspend option */
9549 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
9550 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9551 }
9552
9553 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
9554 &request,
9555 adapter->sessionId,
9556 found_pref_network_cb, adapter);
9557
9558 return 0;
9559}
9560
9561static int iw_set_pno(struct net_device *dev,
9562 struct iw_request_info *info,
9563 union iwreq_data *wrqu, char *extra)
9564{
9565 int ret;
9566
9567 cds_ssr_protect(__func__);
9568 ret = __iw_set_pno(dev, info, wrqu, extra);
9569 cds_ssr_unprotect(__func__);
9570
9571 return ret;
9572}
9573#endif /* FEATURE_WLAN_SCAN_PNO */
9574
9575/* Common function to SetBand */
9576int hdd_set_band(struct net_device *dev, u8 ui_band)
9577{
9578 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9579 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9580 eCsrBand band;
9581
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309582 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009583 hdd_context_t *pHddCtx;
9584 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9585 eCsrBand currBand = eCSR_BAND_MAX;
9586 eCsrBand connectedBand;
9587
9588 pAdapterNode = NULL;
9589 pNext = NULL;
9590 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9591
9592 switch (ui_band) {
9593 case WLAN_HDD_UI_BAND_AUTO:
9594 band = eCSR_BAND_ALL;
9595 break;
9596 case WLAN_HDD_UI_BAND_5_GHZ:
9597 band = eCSR_BAND_5G;
9598 break;
9599 case WLAN_HDD_UI_BAND_2_4_GHZ:
9600 band = eCSR_BAND_24;
9601 break;
9602 default:
9603 band = eCSR_BAND_MAX;
9604 }
9605
Jeff Johnson99bac312016-06-28 10:38:18 -07009606 hdd_notice("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009607
9608 if (band == eCSR_BAND_MAX) {
9609 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -07009610 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009611 return -EINVAL;
9612 }
9613
9614 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
9615 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009616 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009617 band, pHddCtx->config->nBandCapability);
9618 return -EIO;
9619 }
9620
9621 if (band == eCSR_BAND_ALL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009622 hdd_notice("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009623 pHddCtx->config->nBandCapability);
9624 band = pHddCtx->config->nBandCapability;
9625 }
9626
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309627 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009628 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009629 return -EIO;
9630 }
9631
9632 if (currBand != band) {
9633 /* Change band request received.
9634 * Abort pending scan requests, flush the existing scan results,
9635 * and change the band capability
9636 */
Jeff Johnson99bac312016-06-28 10:38:18 -07009637 hdd_notice("Current band value = %u, new setting %u ",
9638 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009639
9640 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309641 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009642 pAdapter = pAdapterNode->pAdapter;
9643 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9644 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
9645 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9646 connectedBand =
9647 hdd_conn_get_connected_band
9648 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
9649
9650 /* Handling is done only for STA and P2P */
9651 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -08009652 ((pAdapter->device_mode == QDF_STA_MODE)
9653 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009654 &&
9655 (hdd_conn_is_connected
9656 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
9657 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309658 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009659 long lrc;
9660
9661 /* STA already connected on current band, So issue disconnect
9662 * first, then change the band*/
9663
Jeff Johnson99bac312016-06-28 10:38:18 -07009664 hdd_notice("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009665 hdd_device_mode_to_string(pAdapter->device_mode),
9666 pAdapter->device_mode, currBand, band);
9667 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9668
9669 status =
9670 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
9671 (pAdapter),
9672 pAdapter->sessionId,
9673 eCSR_DISCONNECT_REASON_UNSPECIFIED);
9674
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309675 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009676 hdd_err("csr_roam_disconnect failure, returned %d",
9677 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009678 return -EINVAL;
9679 }
9680
9681 lrc =
9682 wait_for_completion_timeout(&pAdapter->
9683 disconnect_comp_var,
9684 msecs_to_jiffies
9685 (WLAN_WAIT_TIME_DISCONNECT));
9686
9687 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009688 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009689 return -ETIMEDOUT;
9690 }
9691 }
9692
9693 sme_scan_flush_result(hHal);
9694
9695 status =
9696 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
9697 pAdapterNode = pNext;
9698 }
9699
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309700 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009701 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009702 hdd_alert("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009703 band);
9704 return -EINVAL;
9705 }
9706 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
9707 }
9708 return 0;
9709}
9710
9711int hdd_set_band_helper(struct net_device *dev, const char *command)
9712{
9713 uint8_t band;
9714 int ret;
9715
9716 /* Convert the band value from ascii to integer */
9717 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
9718 ret = kstrtou8(command, 10, &band);
9719 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009720 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009721 return -EINVAL;
9722 }
9723
9724 return hdd_set_band(dev, band);
9725}
9726
9727static int __iw_set_band_config(struct net_device *dev,
9728 struct iw_request_info *info,
9729 union iwreq_data *wrqu, char *extra)
9730{
9731 int *value = (int *)extra;
9732
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009733 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009734
Mukul Sharmaa5fe1982015-11-02 19:28:14 +05309735 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009736 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +05309737 return -EPERM;
9738 }
9739
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009740 return hdd_set_band(dev, value[0]);
9741}
9742
9743static int iw_set_band_config(struct net_device *dev,
9744 struct iw_request_info *info,
9745 union iwreq_data *wrqu, char *extra)
9746{
9747 int ret;
9748
9749 cds_ssr_protect(__func__);
9750 ret = __iw_set_band_config(dev, info, wrqu, extra);
9751 cds_ssr_unprotect(__func__);
9752
9753 return ret;
9754}
9755
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009756/**
9757 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
9758 * @adapter: Handle to adapter
9759 * @chan: Monitor mode channel
9760 * @bandwidth: Capture channel bandwidth
9761 *
9762 * Return: 0 on success else error code.
9763 */
9764static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
9765 uint32_t bandwidth)
9766{
9767 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9768 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
9769 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
9770 QDF_STATUS status;
9771 tHalHandle hal_hdl = hdd_ctx->hHal;
9772 struct qdf_mac_addr bssid;
9773 tCsrRoamProfile roam_profile;
9774 struct ch_params_s ch_params;
9775
9776 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
9777 hdd_err("Not supported, device is not in monitor mode");
9778 return -EINVAL;
9779 }
9780
9781 hdd_info("Set monitor mode Channel %d", chan);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009782 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
9783 roam_profile.ChannelInfo.numOfChannels = 1;
9784 roam_profile.phyMode = ch_info->phy_mode;
9785 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -07009786 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009787
9788 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
9789 QDF_MAC_ADDR_SIZE);
9790
9791 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07009792 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009793 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
9794 &roam_profile);
9795 if (status) {
9796 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
9797 status);
9798 }
9799
9800 return qdf_status_to_os_return(status);
9801}
9802
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009803static int __iw_set_two_ints_getnone(struct net_device *dev,
9804 struct iw_request_info *info,
9805 union iwreq_data *wrqu, char *extra)
9806{
9807 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9808 int *value = (int *)extra;
9809 int sub_cmd = value[0];
9810 int ret;
9811 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9812
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009813 ENTER_DEV(dev);
9814
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009815 ret = wlan_hdd_validate_context(hdd_ctx);
9816 if (0 != ret)
9817 return ret;
9818
9819 switch (sub_cmd) {
9820 case WE_SET_SMPS_PARAM:
Jeff Johnson99bac312016-06-28 10:38:18 -07009821 hdd_notice("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009822 ret = wma_cli_set_command(pAdapter->sessionId,
9823 WMI_STA_SMPS_PARAM_CMDID,
9824 value[1] << WMA_SMPS_PARAM_VALUE_S
9825 | value[2],
9826 VDEV_CMD);
9827 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -07009828#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009829 case WE_SET_FW_CRASH_INJECT:
Jeff Johnson99bac312016-06-28 10:38:18 -07009830 hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009831 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +05309832 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
9833 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009834 ret = wma_cli_set2_command(pAdapter->sessionId,
9835 GEN_PARAM_CRASH_INJECT,
9836 value[1], value[2], GEN_CMD);
9837 break;
9838#endif
Govind Singha471e5e2015-10-12 17:11:14 +05309839 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009840 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +05309841 value[1], value[2]);
9842 ret = wma_cli_set2_command(pAdapter->sessionId,
9843 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
9844 value[1], value[2], DBG_CMD);
9845 break;
9846 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -07009847 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +05309848 value[1], value[2]);
9849 ret = wma_cli_set2_command(pAdapter->sessionId,
9850 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
9851 value[1], value[2], DBG_CMD);
9852 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009853 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
9854 hdd_debug("Ioctl to set dual fw mode config");
9855 if (hdd_ctx->config->dual_mac_feature_disable) {
9856 hdd_err("Dual mac feature is disabled from INI");
9857 return -EPERM;
9858 }
9859 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08009860 cds_set_dual_mac_fw_mode_config(value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009861 break;
9862 case WE_DUMP_DP_TRACE_LEVEL:
9863 hdd_info("WE_DUMP_DP_TRACE_LEVEL: %d %d",
9864 value[1], value[2]);
9865 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309866 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +05309867 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
9868 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +05309869 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
9870 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009871 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009872 case WE_SET_MON_MODE_CHAN:
9873 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
9874 break;
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009875 case WE_SET_WLAN_SUSPEND:
Dustin Brownbc81a472016-10-26 16:56:59 -07009876 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009877 break;
9878 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -07009879 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009880 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009881 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07009882 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009883 break;
9884 }
9885
9886 return ret;
9887}
9888
9889static int iw_set_two_ints_getnone(struct net_device *dev,
9890 struct iw_request_info *info,
9891 union iwreq_data *wrqu, char *extra)
9892{
9893 int ret;
9894
9895 cds_ssr_protect(__func__);
9896 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
9897 cds_ssr_unprotect(__func__);
9898
9899 return ret;
9900}
9901
9902/* Define the Wireless Extensions to the Linux Network Device structure */
9903/* A number of these routines are NULL (meaning they are not implemented.) */
9904
9905static const iw_handler we_handler[] = {
9906 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9907 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9908 (iw_handler) NULL, /* SIOCSIWNWID */
9909 (iw_handler) NULL, /* SIOCGIWNWID */
9910 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9911 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9912 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9913 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9914 (iw_handler) NULL, /* SIOCSIWSENS */
9915 (iw_handler) NULL, /* SIOCGIWSENS */
9916 (iw_handler) NULL, /* SIOCSIWRANGE */
9917 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9918 (iw_handler) NULL, /* SIOCSIWPRIV */
9919 (iw_handler) NULL, /* SIOCGIWPRIV */
9920 (iw_handler) NULL, /* SIOCSIWSTATS */
9921 (iw_handler) NULL, /* SIOCGIWSTATS */
9922 (iw_handler) NULL, /* SIOCSIWSPY */
9923 (iw_handler) NULL, /* SIOCGIWSPY */
9924 (iw_handler) NULL, /* SIOCSIWTHRSPY */
9925 (iw_handler) NULL, /* SIOCGIWTHRSPY */
9926 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9927 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9928 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9929 (iw_handler) NULL, /* SIOCGIWAPLIST */
9930 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9931 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9932 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9933 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9934 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9935 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9936 (iw_handler) NULL, /* -- hole -- */
9937 (iw_handler) NULL, /* -- hole -- */
9938 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9939 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9940 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
9941 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
9942 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9943 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9944 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9945 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9946 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9947 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9948 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9949 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9950 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9951 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9952 (iw_handler) NULL, /* -- hole -- */
9953 (iw_handler) NULL, /* -- hole -- */
9954 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9955 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9956 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9957 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9958 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9959 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9960 (iw_handler) NULL, /* SIOCSIWPMKSA */
9961};
9962
9963static const iw_handler we_private[] = {
9964
9965 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, /* set priv ioctl */
9966 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, /* get priv ioctl */
9967 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, /* get priv ioctl */
9968 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9969 iw_set_three_ints_getnone,
9970 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9971 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, /* action priv ioctl */
9972 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9973 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009974 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
9975 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009976 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9977 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9978 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009979 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009980 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9981 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9982 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
9983 iw_set_keepalive_params,
9984#ifdef WLAN_FEATURE_PACKET_FILTERING
9985 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
9986 iw_set_packet_filter_params,
9987#endif
9988#ifdef FEATURE_WLAN_SCAN_PNO
9989 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
9990#endif
9991 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
9992 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
9993 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9994 iw_set_two_ints_getnone,
9995 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
9996 iw_set_dot11p_channel_sched,
9997};
9998
9999/*Maximum command length can be only 15 */
10000static const struct iw_priv_args we_private_args[] = {
10001
10002 /* handlers for main ioctl */
10003 {WLAN_PRIV_SET_INT_GET_NONE,
10004 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10005 0,
10006 ""},
10007
10008 /* handlers for sub-ioctl */
10009 {WE_SET_11D_STATE,
10010 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10011 0,
10012 "set11Dstate"},
10013
10014 {WE_WOWL,
10015 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10016 0,
10017 "wowl"},
10018
10019 {WE_SET_POWER,
10020 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10021 0,
10022 "setPower"},
10023
10024 {WE_SET_MAX_ASSOC,
10025 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10026 0,
10027 "setMaxAssoc"},
10028
10029 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10030 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
10031 "setAutoChannel" },
10032
10033 {WE_SET_SCAN_DISABLE,
10034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10035 0,
10036 "scan_disable"},
10037
10038 {WE_SET_DATA_INACTIVITY_TO,
10039 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10040 0,
10041 "inactivityTO"},
10042
10043 {WE_SET_MAX_TX_POWER,
10044 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10045 0,
10046 "setMaxTxPower"},
10047
10048 {WE_SET_TX_POWER,
10049 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10050 0,
10051 "setTxPower"},
10052
10053 {WE_SET_MC_RATE,
10054 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10055 0,
10056 "setMcRate"},
10057
10058 {WE_SET_MAX_TX_POWER_2_4,
10059 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10060 0,
10061 "setTxMaxPower2G"},
10062
10063 {WE_SET_MAX_TX_POWER_5_0,
10064 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10065 0,
10066 "setTxMaxPower5G"},
10067
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010068 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010069 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010070 0,
10071 "pktlog"},
10072
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010073 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10074 * as well to keep same syntax as in SAP. Now onwards, STA
10075 * will support both */
10076 {WE_SET_MAX_TX_POWER,
10077 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10078 0,
10079 "setTxMaxPower"},
10080
10081 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10082 * 1 = enable and 0 = disable */
10083 {
10084 WE_SET_HIGHER_DTIM_TRANSITION,
10085 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10086 0,
10087 "setHDtimTransn"
10088 },
10089
10090 {WE_SET_TM_LEVEL,
10091 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10092 0,
10093 "setTmLevel"},
10094
10095 {WE_SET_PHYMODE,
10096 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10097 0,
10098 "setphymode"},
10099
10100 {WE_SET_NSS,
10101 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10102 0,
10103 "nss"},
10104
10105 {WE_SET_LDPC,
10106 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10107 0,
10108 "ldpc"},
10109
10110 {WE_SET_TX_STBC,
10111 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10112 0,
10113 "tx_stbc"},
10114
10115 {WE_SET_RX_STBC,
10116 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10117 0,
10118 "rx_stbc"},
10119
10120 {WE_SET_SHORT_GI,
10121 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10122 0,
10123 "shortgi"},
10124
10125 {WE_SET_RTSCTS,
10126 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10127 0,
10128 "enablertscts"},
10129
10130 {WE_SET_CHWIDTH,
10131 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10132 0,
10133 "chwidth"},
10134
10135 {WE_SET_ANI_EN_DIS,
10136 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10137 0,
10138 "anienable"},
10139
10140 {WE_SET_ANI_POLL_PERIOD,
10141 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10142 0,
10143 "aniplen"},
10144
10145 {WE_SET_ANI_LISTEN_PERIOD,
10146 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10147 0,
10148 "anilislen"},
10149
10150 {WE_SET_ANI_OFDM_LEVEL,
10151 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10152 0,
10153 "aniofdmlvl"},
10154
10155 {WE_SET_ANI_CCK_LEVEL,
10156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10157 0,
10158 "aniccklvl"},
10159
10160 {WE_SET_DYNAMIC_BW,
10161 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10162 0,
10163 "cwmenable"},
10164
10165 {WE_SET_CTS_CBW,
10166 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10167 0,
10168 "cts_cbw" },
10169
10170 {WE_SET_GTX_HT_MCS,
10171 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10172 0,
10173 "gtxHTMcs"},
10174
10175 {WE_SET_GTX_VHT_MCS,
10176 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10177 0,
10178 "gtxVHTMcs"},
10179
10180 {WE_SET_GTX_USRCFG,
10181 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10182 0,
10183 "gtxUsrCfg"},
10184
10185 {WE_SET_GTX_THRE,
10186 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10187 0,
10188 "gtxThre"},
10189
10190 {WE_SET_GTX_MARGIN,
10191 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10192 0,
10193 "gtxMargin"},
10194
10195 {WE_SET_GTX_STEP,
10196 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10197 0,
10198 "gtxStep"},
10199
10200 {WE_SET_GTX_MINTPC,
10201 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10202 0,
10203 "gtxMinTpc"},
10204
10205 {WE_SET_GTX_BWMASK,
10206 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10207 0,
10208 "gtxBWMask"},
10209
10210 {WE_SET_TX_CHAINMASK,
10211 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10212 0,
10213 "txchainmask"},
10214
10215 {WE_SET_RX_CHAINMASK,
10216 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10217 0,
10218 "rxchainmask"},
10219
10220 {WE_SET_11N_RATE,
10221 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10222 0,
10223 "set11NRates"},
10224
10225 {WE_SET_VHT_RATE,
10226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10227 0,
10228 "set11ACRates"},
10229
10230 {WE_SET_AMPDU,
10231 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10232 0,
10233 "ampdu"},
10234
10235 {WE_SET_AMSDU,
10236 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10237 0,
10238 "amsdu"},
10239
10240 {WE_SET_BURST_ENABLE,
10241 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10242 0,
10243 "burst_enable"},
10244
10245 {WE_SET_BURST_DUR,
10246 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10247 0,
10248 "burst_dur"},
10249
10250 {WE_SET_TXPOW_2G,
10251 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10252 0,
10253 "txpow2g"},
10254
10255 {WE_SET_TXPOW_5G,
10256 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10257 0,
10258 "txpow5g"},
10259
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010260 /* Sub-cmds DBGLOG specific commands */
10261 {WE_DBGLOG_LOG_LEVEL,
10262 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10263 0,
10264 "dl_loglevel"},
10265
10266 {WE_DBGLOG_VAP_ENABLE,
10267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10268 0,
10269 "dl_vapon"},
10270
10271 {WE_DBGLOG_VAP_DISABLE,
10272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10273 0,
10274 "dl_vapoff"},
10275
10276 {WE_DBGLOG_MODULE_ENABLE,
10277 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10278 0,
10279 "dl_modon"},
10280
10281 {WE_DBGLOG_MODULE_DISABLE,
10282 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10283 0,
10284 "dl_modoff"},
10285
10286 {WE_DBGLOG_MOD_LOG_LEVEL,
10287 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10288 0,
10289 "dl_mod_loglevel"},
10290
10291 {WE_DBGLOG_TYPE,
10292 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10293 0,
10294 "dl_type"},
10295 {WE_DBGLOG_REPORT_ENABLE,
10296 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10297 0,
10298 "dl_report"},
10299
10300 {WE_SET_TXRX_FWSTATS,
10301 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10302 0,
10303 "txrx_fw_stats"},
10304
10305 {WE_TXRX_FWSTATS_RESET,
10306 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10307 0,
10308 "txrx_fw_st_rst"},
10309
10310 {WE_PPS_PAID_MATCH,
10311 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10312 0, "paid_match"},
10313
10314 {WE_PPS_GID_MATCH,
10315 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10316 0, "gid_match"},
10317
10318 {WE_PPS_EARLY_TIM_CLEAR,
10319 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10320 0, "tim_clear"},
10321
10322 {WE_PPS_EARLY_DTIM_CLEAR,
10323 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10324 0, "dtim_clear"},
10325
10326 {WE_PPS_EOF_PAD_DELIM,
10327 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10328 0, "eof_delim"},
10329
10330 {WE_PPS_MACADDR_MISMATCH,
10331 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10332 0, "mac_match"},
10333
10334 {WE_PPS_DELIM_CRC_FAIL,
10335 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10336 0, "delim_fail"},
10337
10338 {WE_PPS_GID_NSTS_ZERO,
10339 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10340 0, "nsts_zero"},
10341
10342 {WE_PPS_RSSI_CHECK,
10343 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10344 0, "rssi_chk"},
10345
10346 {WE_PPS_5G_EBT,
10347 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10348 0, "5g_ebt"},
10349
10350 {WE_SET_HTSMPS,
10351 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10352 0, "htsmps"},
10353
10354 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
10355 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10356 0, "set_qpspollcnt"},
10357
10358 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
10359 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10360 0, "set_qtxwake"},
10361
10362 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
10363 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10364 0, "set_qwakeintv"},
10365
10366 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
10367 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10368 0, "set_qnodatapoll"},
10369
10370 /* handlers for MCC time quota and latency sub ioctls */
10371 {WE_MCC_CONFIG_LATENCY,
10372 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10373 0, "setMccLatency"},
10374
10375 {WE_MCC_CONFIG_QUOTA,
10376 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10377 0, "setMccQuota"},
10378
10379 {WE_SET_DEBUG_LOG,
10380 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10381 0, "setDbgLvl"},
10382
10383 /* handlers for early_rx power save */
10384 {WE_SET_EARLY_RX_ADJUST_ENABLE,
10385 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10386 0, "erx_enable"},
10387
10388 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
10389 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10390 0, "erx_bmiss_val"},
10391
10392 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
10393 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10394 0, "erx_bmiss_smpl"},
10395
10396 {WE_SET_EARLY_RX_SLOP_STEP,
10397 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10398 0, "erx_slop_step"},
10399
10400 {WE_SET_EARLY_RX_INIT_SLOP,
10401 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10402 0, "erx_init_slop"},
10403
10404 {WE_SET_EARLY_RX_ADJUST_PAUSE,
10405 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10406 0, "erx_adj_pause"},
10407
10408 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
10409 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10410 0, "erx_dri_sample"},
10411
10412 {WE_DUMP_STATS,
10413 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10414 0, "dumpStats"},
10415
10416 {WE_CLEAR_STATS,
10417 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10418 0, "clearStats"},
10419
Govind Singha471e5e2015-10-12 17:11:14 +053010420 {WE_START_FW_PROFILE,
10421 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10422 0, "startProfile"},
10423
Abhishek Singh1bdb1572015-10-16 16:24:19 +053010424 {WE_SET_CHANNEL,
10425 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10426 0, "setChanChange" },
10427
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053010428 {WE_SET_CONC_SYSTEM_PREF,
10429 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10430 0, "setConcSysPref" },
10431
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010432 {WLAN_PRIV_SET_NONE_GET_INT,
10433 0,
10434 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10435 ""},
10436
10437 /* handlers for sub-ioctl */
10438 {WE_GET_11D_STATE,
10439 0,
10440 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10441 "get11Dstate"},
10442
10443 {WE_IBSS_STATUS,
10444 0,
10445 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10446 "getAdhocStatus"},
10447
10448 {WE_GET_WLAN_DBG,
10449 0,
10450 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10451 "getwlandbg"},
10452
10453 {WE_GET_MAX_ASSOC,
10454 0,
10455 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10456 "getMaxAssoc"},
10457
10458 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10459 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10460 "getAutoChannel" },
10461
10462 {WE_GET_CONCURRENCY_MODE,
10463 0,
10464 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10465 "getconcurrency"},
10466
10467 {WE_GET_NSS,
10468 0,
10469 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10470 "get_nss"},
10471
10472 {WE_GET_LDPC,
10473 0,
10474 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10475 "get_ldpc"},
10476
10477 {WE_GET_TX_STBC,
10478 0,
10479 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10480 "get_tx_stbc"},
10481
10482 {WE_GET_RX_STBC,
10483 0,
10484 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10485 "get_rx_stbc"},
10486
10487 {WE_GET_SHORT_GI,
10488 0,
10489 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10490 "get_shortgi"},
10491
10492 {WE_GET_RTSCTS,
10493 0,
10494 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10495 "get_rtscts"},
10496
10497 {WE_GET_CHWIDTH,
10498 0,
10499 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10500 "get_chwidth"},
10501
10502 {WE_GET_ANI_EN_DIS,
10503 0,
10504 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10505 "get_anienable"},
10506
10507 {WE_GET_ANI_POLL_PERIOD,
10508 0,
10509 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10510 "get_aniplen"},
10511
10512 {WE_GET_ANI_LISTEN_PERIOD,
10513 0,
10514 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10515 "get_anilislen"},
10516
10517 {WE_GET_ANI_OFDM_LEVEL,
10518 0,
10519 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10520 "get_aniofdmlvl"},
10521
10522 {WE_GET_ANI_CCK_LEVEL,
10523 0,
10524 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10525 "get_aniccklvl"},
10526
10527 {WE_GET_DYNAMIC_BW,
10528 0,
10529 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10530 "get_cwmenable"},
10531
10532 {WE_GET_GTX_HT_MCS,
10533 0,
10534 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10535 "get_gtxHTMcs"},
10536
10537 {WE_GET_GTX_VHT_MCS,
10538 0,
10539 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10540 "get_gtxVHTMcs"},
10541
10542 {WE_GET_GTX_USRCFG,
10543 0,
10544 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10545 "get_gtxUsrCfg"},
10546
10547 {WE_GET_GTX_THRE,
10548 0,
10549 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10550 "get_gtxThre"},
10551
10552 {WE_GET_GTX_MARGIN,
10553 0,
10554 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10555 "get_gtxMargin"},
10556
10557 {WE_GET_GTX_STEP,
10558 0,
10559 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10560 "get_gtxStep"},
10561
10562 {WE_GET_GTX_MINTPC,
10563 0,
10564 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10565 "get_gtxMinTpc"},
10566
10567 {WE_GET_GTX_BWMASK,
10568 0,
10569 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10570 "get_gtxBWMask"},
10571
10572 {WE_GET_TX_CHAINMASK,
10573 0,
10574 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10575 "get_txchainmask"},
10576
10577 {WE_GET_RX_CHAINMASK,
10578 0,
10579 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10580 "get_rxchainmask"},
10581
10582 {WE_GET_11N_RATE,
10583 0,
10584 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10585 "get_11nrate"},
10586
10587 {WE_GET_AMPDU,
10588 0,
10589 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10590 "get_ampdu"},
10591
10592 {WE_GET_AMSDU,
10593 0,
10594 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10595 "get_amsdu"},
10596
10597 {WE_GET_BURST_ENABLE,
10598 0,
10599 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10600 "get_burst_en"},
10601
10602 {WE_GET_BURST_DUR,
10603 0,
10604 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10605 "get_burst_dur"},
10606
10607 {WE_GET_TXPOW_2G,
10608 0,
10609 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10610 "get_txpow2g"},
10611
10612 {WE_GET_TXPOW_5G,
10613 0,
10614 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10615 "get_txpow5g"},
10616
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010617 {WE_GET_PPS_PAID_MATCH,
10618 0,
10619 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10620 "get_paid_match"},
10621
10622 {WE_GET_PPS_GID_MATCH,
10623 0,
10624 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10625 "get_gid_match"},
10626
10627 {WE_GET_PPS_EARLY_TIM_CLEAR,
10628 0,
10629 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10630 "get_tim_clear"},
10631
10632 {WE_GET_PPS_EARLY_DTIM_CLEAR,
10633 0,
10634 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10635 "get_dtim_clear"},
10636
10637 {WE_GET_PPS_EOF_PAD_DELIM,
10638 0,
10639 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10640 "get_eof_delim"},
10641
10642 {WE_GET_PPS_MACADDR_MISMATCH,
10643 0,
10644 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10645 "get_mac_match"},
10646
10647 {WE_GET_PPS_DELIM_CRC_FAIL,
10648 0,
10649 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10650 "get_delim_fail"},
10651
10652 {WE_GET_PPS_GID_NSTS_ZERO,
10653 0,
10654 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10655 "get_nsts_zero"},
10656
10657 {WE_GET_PPS_RSSI_CHECK,
10658 0,
10659 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10660 "get_rssi_chk"},
10661
10662 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
10663 0,
10664 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10665 "get_qpspollcnt"},
10666
10667 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
10668 0,
10669 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10670 "get_qtxwake"},
10671
10672 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
10673 0,
10674 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10675 "get_qwakeintv"},
10676
10677 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
10678 0,
10679 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10680 "get_qnodatapoll"},
10681
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010682 {WE_CAP_TSF,
10683 0,
10684 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10685 "cap_tsf"},
10686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010687 {WE_GET_TEMPERATURE,
10688 0,
10689 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10690 "get_temp"},
10691 /* handlers for main ioctl */
10692 {WLAN_PRIV_SET_CHAR_GET_NONE,
10693 IW_PRIV_TYPE_CHAR | 512,
10694 0,
10695 ""},
10696
10697 /* handlers for sub-ioctl */
10698 {WE_WOWL_ADD_PTRN,
10699 IW_PRIV_TYPE_CHAR | 512,
10700 0,
10701 "wowlAddPtrn"},
10702
10703 {WE_WOWL_DEL_PTRN,
10704 IW_PRIV_TYPE_CHAR | 512,
10705 0,
10706 "wowlDelPtrn"},
10707
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010708 /* handlers for sub-ioctl */
10709 {WE_NEIGHBOR_REPORT_REQUEST,
10710 IW_PRIV_TYPE_CHAR | 512,
10711 0,
10712 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080010713
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010714 {WE_SET_AP_WPS_IE,
10715 IW_PRIV_TYPE_CHAR | 512,
10716 0,
10717 "set_ap_wps_ie"},
10718
10719 {WE_SET_CONFIG,
10720 IW_PRIV_TYPE_CHAR | 512,
10721 0,
10722 "setConfig"},
10723
10724 /* handlers for main ioctl */
10725 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
10726 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10727 0,
10728 ""},
10729
10730 /* handlers for sub-ioctl */
10731 {WE_SET_WLAN_DBG,
10732 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10733 0,
10734 "setwlandbg"},
10735
10736 /* handlers for sub-ioctl */
10737 {WE_SET_DP_TRACE,
10738 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10739 0,
10740 "set_dp_trace"},
10741
10742 {WE_SET_SAP_CHANNELS,
10743 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10744 0,
10745 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053010746
10747 {WE_SET_FW_TEST,
10748 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10749 0, "fw_test"},
10750
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010751 /* handlers for main ioctl */
10752 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
10753 0,
10754 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10755 "" },
10756 {WE_GET_TSF,
10757 0,
10758 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10759 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010760
10761 {WE_SET_DUAL_MAC_SCAN_CONFIG,
10762 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10763 0,
10764 "set_scan_cfg"},
10765
10766 /* handlers for main ioctl */
10767 {WLAN_PRIV_GET_CHAR_SET_NONE,
10768 0,
10769 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10770 ""},
10771
10772 /* handlers for sub-ioctl */
10773 {WE_WLAN_VERSION,
10774 0,
10775 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10776 "version"},
10777 {WE_GET_STATS,
10778 0,
10779 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10780 "getStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053010781 {WE_LIST_FW_PROFILE,
10782 0,
10783 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10784 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010785 {WE_GET_STATES,
10786 0,
10787 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10788 "getHostStates"},
10789 {WE_GET_CFG,
10790 0,
10791 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10792 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010793 {WE_GET_RSSI,
10794 0,
10795 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10796 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010797 {WE_GET_WMM_STATUS,
10798 0,
10799 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10800 "getWmmStatus"},
10801 {
10802 WE_GET_CHANNEL_LIST,
10803 0,
10804 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10805 "getChannelList"
10806 },
10807#ifdef FEATURE_WLAN_TDLS
10808 {
10809 WE_GET_TDLS_PEERS,
10810 0,
10811 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10812 "getTdlsPeers"
10813 },
10814#endif
10815#ifdef WLAN_FEATURE_11W
10816 {
10817 WE_GET_11W_INFO,
10818 0,
10819 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10820 "getPMFInfo"
10821 },
10822#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010823 {
10824 WE_GET_IBSS_STA_INFO,
10825 0,
10826 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10827 "getIbssSTAs"
10828 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010829 {WE_GET_PHYMODE,
10830 0,
10831 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10832 "getphymode"},
10833#ifdef FEATURE_OEM_DATA_SUPPORT
10834 {WE_GET_OEM_DATA_CAP,
10835 0,
10836 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10837 "getOemDataCap"},
10838#endif /* FEATURE_OEM_DATA_SUPPORT */
10839 {WE_GET_SNR,
10840 0,
10841 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10842 "getSNR"},
10843
10844 /* handlers for main ioctl */
10845 {WLAN_PRIV_SET_NONE_GET_NONE,
10846 0,
10847 0,
10848 ""},
10849
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010850 /* handlers for sub-ioctl */
10851 {
10852 WE_IBSS_GET_PEER_INFO_ALL,
10853 0,
10854 0,
10855 "ibssPeerInfoAll"
10856 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010857 {WE_GET_RECOVERY_STAT,
10858 0,
10859 0,
10860 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053010861
10862 {WE_GET_FW_PROFILE_DATA,
10863 0,
10864 0,
10865 "getProfileData"},
10866
10867 {WE_SET_REASSOC_TRIGGER,
10868 0,
10869 0,
10870 "reassoc"},
10871
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010872 {WE_DUMP_AGC_START,
10873 0,
10874 0,
10875 "dump_agc_start"},
10876
10877 {WE_DUMP_AGC,
10878 0,
10879 0,
10880 "dump_agc"},
10881
10882 {WE_DUMP_CHANINFO_START,
10883 0,
10884 0,
10885 "dump_chninfo_en"},
10886
10887 {WE_DUMP_CHANINFO,
10888 0,
10889 0,
10890 "dump_chninfo"},
10891
10892 {WE_DUMP_WATCHDOG,
10893 0,
10894 0,
10895 "dump_watchdog"},
10896#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
10897 {WE_DUMP_PCIE_LOG,
10898 0,
10899 0,
10900 "dump_pcie_log"},
10901#endif
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010902 {WE_STOP_OBSS_SCAN,
10903 0,
10904 0,
10905 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010906 /* handlers for main ioctl */
10907 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
10908 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10909 0,
10910 ""},
10911
10912 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010913 {WE_IBSS_GET_PEER_INFO,
10914 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10915 0,
10916 "ibssPeerInfo"},
10917
10918 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010919 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10920 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10921 0,
10922 "setdumplog"},
10923
10924 {WE_MTRACE_DUMP_CMD,
10925 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10926 0,
10927 "dumplog"},
10928#ifdef MPC_UT_FRAMEWORK
10929 {WE_POLICY_MANAGER_CLIST_CMD,
10930 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10931 0,
10932 "pm_clist"},
10933
10934 {WE_POLICY_MANAGER_DLIST_CMD,
10935 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10936 0,
10937 "pm_dlist"},
10938
10939 {WE_POLICY_MANAGER_DBS_CMD,
10940 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10941 0,
10942 "pm_dbs"},
10943
10944 {WE_POLICY_MANAGER_PCL_CMD,
10945 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10946 0,
10947 "pm_pcl"},
10948
10949 {WE_POLICY_MANAGER_CINFO_CMD,
10950 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10951 0,
10952 "pm_cinfo"},
10953
10954 {WE_POLICY_MANAGER_ULIST_CMD,
10955 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10956 0,
10957 "pm_ulist"},
10958
10959 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
10960 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10961 0,
10962 "pm_query_action"},
10963
10964 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
10965 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10966 0,
10967 "pm_query_allow"},
10968
10969 {WE_POLICY_MANAGER_SCENARIO_CMD,
10970 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10971 0,
10972 "pm_run_scenario"},
10973
10974 {WE_POLICY_SET_HW_MODE_CMD,
10975 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10976 0,
10977 "pm_set_hw_mode"},
10978#endif
10979#ifdef FEATURE_WLAN_TDLS
10980 /* handlers for sub ioctl */
10981 {
10982 WE_TDLS_CONFIG_PARAMS,
10983 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10984 0,
10985 "setTdlsConfig"
10986 },
10987#endif
10988 {
10989 WE_UNIT_TEST_CMD,
10990 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10991 0,
10992 "setUnitTestCmd"
10993 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053010994 {
10995 WE_MAC_PWR_DEBUG_CMD,
10996 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10997 0,
10998 "halPwrDebug"
10999 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011000
11001#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
11002 {WE_LED_FLASHING_PARAM,
11003 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11004 0,
11005 "gpio_control"},
11006#endif
11007 /* handlers for main ioctl */
11008 {WLAN_PRIV_ADD_TSPEC,
11009 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11010 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11011 "addTspec"},
11012
11013 /* handlers for main ioctl */
11014 {WLAN_PRIV_DEL_TSPEC,
11015 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11016 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11017 "delTspec"},
11018
11019 /* handlers for main ioctl */
11020 {WLAN_PRIV_GET_TSPEC,
11021 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11022 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11023 "getTspec"},
11024
11025 /* handlers for main ioctl - host offload */
11026 {
11027 WLAN_PRIV_SET_HOST_OFFLOAD,
11028 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11029 0,
11030 "setHostOffload"
11031 }
11032 ,
11033
11034 {
11035 WLAN_GET_WLAN_STATISTICS,
11036 0,
11037 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11038 "getWlanStats"
11039 }
11040 ,
11041
11042 {
11043 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053011044 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
11045 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011046 0,
11047 "setKeepAlive"
11048 }
11049 ,
11050#ifdef WLAN_FEATURE_PACKET_FILTERING
11051 {
11052 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053011053 IW_PRIV_TYPE_BYTE |
11054 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011055 0,
11056 "setPktFilter"
11057 }
11058 ,
11059#endif
11060#ifdef FEATURE_WLAN_SCAN_PNO
11061 {
11062 WLAN_SET_PNO,
11063 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11064 0,
11065 "setpno"
11066 }
11067 ,
11068#endif
11069 {
11070 WLAN_SET_BAND_CONFIG,
11071 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11072 0,
11073 "SETBAND"
11074 }
11075 ,
11076 {
11077 WLAN_GET_LINK_SPEED,
11078 IW_PRIV_TYPE_CHAR | 18,
11079 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
11080 }
11081 ,
11082
11083 /* handlers for main ioctl */
11084 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
11085 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11086 0,
11087 ""}
11088 ,
11089 {WE_SET_SMPS_PARAM,
11090 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11091 0, "set_smps_param"}
11092 ,
11093 {WLAN_SET_DOT11P_CHANNEL_SCHED,
11094 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
11095 0, "set_dot11p" }
11096 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070011097#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011098 {WE_SET_FW_CRASH_INJECT,
11099 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11100 0, "crash_inject"}
11101 ,
11102#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070011103#ifdef WLAN_SUSPEND_RESUME_TEST
11104 {WE_SET_WLAN_SUSPEND,
11105 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11106 0, "wlan_suspend"}
11107 ,
11108 {WE_SET_WLAN_RESUME,
11109 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11110 0, "wlan_resume"}
11111 ,
11112#endif
Govind Singha471e5e2015-10-12 17:11:14 +053011113 {WE_ENABLE_FW_PROFILE,
11114 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11115 0, "enableProfile"}
11116 ,
11117 {WE_SET_FW_PROFILE_HIST_INTVL,
11118 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11119 0, "set_hist_intvl"}
11120 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011121 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
11122 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11123 0, "set_fw_mode_cfg"}
11124 ,
11125 {WE_DUMP_DP_TRACE_LEVEL,
11126 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11127 0, "dump_dp_trace"}
11128 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070011129 {WE_SET_MON_MODE_CHAN,
11130 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11131 0, "setMonChan"}
11132 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070011133
11134 {WE_GET_ROAM_SYNCH_DELAY,
11135 0,
11136 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11137 "hostroamdelay"}
11138 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011139};
11140
11141const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053011142 .num_standard = QDF_ARRAY_SIZE(we_handler),
11143 .num_private = QDF_ARRAY_SIZE(we_private),
11144 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011145
11146 .standard = (iw_handler *) we_handler,
11147 .private = (iw_handler *) we_private,
11148 .private_args = we_private_args,
11149 .get_wireless_stats = NULL,
11150};
11151
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011152/* hdd_set_wext() - configures bss parameters
11153 * @pAdapter: handle to adapter context
11154 *
11155 * Returns: none
11156 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070011157static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011158{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011159 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11160 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011161
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011162 ENTER();
11163
11164 if (!pwextBuf) {
11165 hdd_err("ERROR: pwextBuf is NULL");
11166 return QDF_STATUS_E_FAILURE;
11167 }
11168
11169 if (!pHddStaCtx) {
11170 hdd_err("ERROR: pHddStaCtx is NULL");
11171 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011172 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011173
11174 /* Now configure the roaming profile links. To SSID and bssid. */
11175 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011176 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011177
11178 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011179 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011180
11181 /*Set the numOfChannels to zero to scan all the channels */
11182 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11183 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11184
11185 /* Default is no encryption */
11186 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11187 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
11188 eCSR_ENCRYPT_TYPE_NONE;
11189
11190 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11191 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
11192 eCSR_ENCRYPT_TYPE_NONE;
11193
11194 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11195
11196 /* Default is no authentication */
11197 pwextBuf->roamProfile.AuthType.numEntries = 1;
11198 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11199
11200 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
11201 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11202
11203 /*Set the default scan mode */
11204 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
11205
11206 hdd_clear_roam_profile_ie(pAdapter);
11207
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011208 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011209 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011210
11211}
11212
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011213/**
11214 * hdd_register_wext() - register wext context
11215 * @dev: net device handle
11216 *
11217 * Registers wext interface context for a given net device
11218 *
11219 * Returns: 0 on success, errno on failure
11220 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011221int hdd_register_wext(struct net_device *dev)
11222{
11223 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011224 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011225 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011226
11227 ENTER();
11228
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011229 if (!pwextBuf) {
11230 hdd_err(FL("ERROR: pwextBuf is NULL"));
11231 return QDF_STATUS_E_FAILURE;
11232 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011233
11234 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011235 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
11236
11237 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->
11238 completion_var);
11239
11240 status = hdd_set_wext(pAdapter);
11241
Anurag Chouhance0dc992016-02-16 18:18:03 +053011242 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011243
Jeff Johnson99bac312016-06-28 10:38:18 -070011244 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011245 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011246 }
11247
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011248 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->hdd_qdf_event))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011249 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011250 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011251 }
11252
Anurag Chouhance0dc992016-02-16 18:18:03 +053011253 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->scanevent))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011254 hdd_err("ERROR: HDD scan event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011255 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011256 }
11257 /* Register as a wireless device */
11258 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11259
11260 EXIT();
11261 return 0;
11262}
11263
11264int hdd_unregister_wext(struct net_device *dev)
11265{
Jeff Johnson99bac312016-06-28 10:38:18 -070011266 hdd_notice("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011267
11268 if (dev != NULL) {
11269 rtnl_lock();
11270 dev->wireless_handlers = NULL;
11271 rtnl_unlock();
11272 }
11273
11274 return 0;
11275}